Aligned handlers and fields in value magnitude and added tests#3111
Aligned handlers and fields in value magnitude and added tests#3111aleclorimer wants to merge 2 commits into
Conversation
|
Invitation URL: |
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against 4254ba3 |
e2b0384 to
08a32b8
Compare
| 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}) |
There was a problem hiding this comment.
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
1264792 to
aeac47a
Compare
aeac47a to
4254ba3
Compare
| 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) |
There was a problem hiding this comment.
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"})) |
There was a problem hiding this comment.
Won't this be multiplied by 100 now?
Fixed a bug where
(min|max)(Heat|Cool)SetPointwas 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.0fix/update.