Skip to content

Aligned handlers and fields in value magnitude and added tests#3111

Open
aleclorimer wants to merge 2 commits into
mainfrom
zb-thermostat-zenwithin-overflow-fix
Open

Aligned handlers and fields in value magnitude and added tests#3111
aleclorimer wants to merge 2 commits into
mainfrom
zb-thermostat-zenwithin-overflow-fix

Conversation

@aleclorimer

Copy link
Copy Markdown
Contributor

Fixed a bug where (min|max)(Heat|Cool)SetPoint was being set in centidegrees and then being used to clamp a value in degrees causing the clamped value to have an Int16 overflow error when then tried to scale to centidegrees.

Mutant testing: Failing without the / 100.0 fix/update.

@aleclorimer aleclorimer requested review from tpmanley and varzac July 9, 2026 16:16
@aleclorimer aleclorimer added the CGAI Contains code that was generated by AI label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Test Results

   73 files  ±0    537 suites  ±0   0s ⏱️ ±0s
3 176 tests +9  3 176 ✅ +12  0 💤 ±0  0 ❌  - 3 
5 177 runs  +9  5 177 ✅ +12  0 💤 ±0  0 ❌  - 3 

Results for commit 4254ba3. ± Comparison against base commit 4dcfe01.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

File Coverage
All files 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/stelpro-ki-zigbee-thermostat/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/sinope/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/lux-konoz/can_handle.lua 83%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/stelpro/init.lua 87%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/aqara/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/zenwithin/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/resideo_korea/init.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/popp/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/wallhero/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/vimar/init.lua 89%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 4254ba3

@aleclorimer aleclorimer force-pushed the zb-thermostat-zenwithin-overflow-fix branch from e2b0384 to 08a32b8 Compare July 9, 2026 16:34
local setpoint_limit_handler = function(limit_type)
return function(driver, device, limit)
device:set_field(limit_type, limit.value, {persist = true})
device:set_field(limit_type, limit.value / 100.0, {persist = true})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this will fix it for future devices, this value is already persisted on existing devices, so even though I think this change makes more sense in a vacuum, for this fix, I think we need to keep persisting in centidegrees (and comment that we are doing such) and then do this division on the checks. We'll have to update the DEFAULT values as well

@aleclorimer aleclorimer force-pushed the zb-thermostat-zenwithin-overflow-fix branch from 1264792 to aeac47a Compare July 9, 2026 20:21
@aleclorimer aleclorimer force-pushed the zb-thermostat-zenwithin-overflow-fix branch from aeac47a to 4254ba3 Compare July 9, 2026 20:22
device:get_field(MAX_HEAT_LIMIT) or DEFAULT_MAX_SETPOINT)
device:get_field(MIN_COOL_LIMIT) or DEFAULT_MIN_SETPOINT,
device:get_field(MAX_COOL_LIMIT) or DEFAULT_MAX_SETPOINT)
device:set_field(COOLING_SETPOINT, value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to set the value in centidegrees, and then correspondingly the update_device_setpoint call will emit an invalid event?

cooling_setpoint = nil
elseif (current_mode == ModeAttribute.cool.NAME) and heating_setpoint ~= nil then
heating_setpoint = device:get_latest_state("main", ThermostatHeatingSetpoint.ID, ThermostatHeatingSetpoint.heatingSetpoint.NAME)
device:emit_event(ThermostatHeatingSetpoint.heatingSetpoint({value = heating_setpoint, unit = "C"}))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this be multiplied by 100 now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CGAI Contains code that was generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants