robertklep / name.klep.homekitty

HomeyKit 3.0
15 stars 5 forks source link

fix(thermostat): Use Auto mode if capability thermostat_mode is not uā€¦ #95

Closed bursacmilan closed 5 months ago

bursacmilan commented 5 months ago

Problem

When the thermostat_mode capability is not utilized, the TargetHeatingCoolingState is currently being determined based on the current temperature and target temperature. This approach involves unnecessary calculations and assumptions, which can lead to incorrect state settings.

Fix

To simplify the implementation and avoid unnecessary calculations, I removed the dynamic determination of TargetHeatingCoolingState. Now, if the thermostat_mode capability is not used, the TargetHeatingCoolingState is set to AUTO by default. This ensures a consistent and predictable behavior without the need for additional calculations or guesses.

Result

IMG_C685EB135CC4-1

robertklep commented 5 months ago

Thanks šŸ˜Š Just for my understanding, can you explain the "incorrect state settings" that can occur with the old code?

bursacmilan commented 5 months ago

@robertklep If a device only supports changing the target temperature and does not support any HeatingCoolingState, the current logic will switch the HeatingCoolingState to "Off" if the current temperature exceeds the target temperature. As a result, the UI in HomeKit will turn off the thermostat control, requiring you to manually switch the mode back to HEAT, COOL, or AUTO. This is annoying because if you accidentally set the target temperature lower than the current temperature, you will first need to change the mode before you can adjust the temperature again.

I hope it is clear :)

robertklep commented 5 months ago

@bursacmilan ah, thanks for the explanation! Sounds like a good solution šŸ‘šŸ»

robertklep commented 5 months ago

Published as v2.2.14 (test).