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    537 suites   0s ⏱️
3 190 tests 3 190 ✅ 0 💤 0 ❌
5 191 runs  5 191 ✅ 0 💤 0 ❌

Results for commit 2376ac9.

♻️ 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/wallhero/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/aqara/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/init.lua 97%
/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/zenwithin/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/vimar/init.lua 89%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/sinope/init.lua 97%
/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/popp/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-thermostat/src/stelpro/init.lua 87%
/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/lux-konoz/can_handle.lua 83%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 2376ac9

@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 2 times, most recently 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?

@aleclorimer aleclorimer force-pushed the zb-thermostat-zenwithin-overflow-fix branch from 4254ba3 to 55f504a Compare July 14, 2026 16:22
@aleclorimer aleclorimer force-pushed the zb-thermostat-zenwithin-overflow-fix branch from 55f504a to 2376ac9 Compare July 14, 2026 18:06
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