seydx / homebridge-tado-platform

Homebridge plugin for controlling Tado devices
MIT License
127 stars 69 forks source link

Schedule Switch does not turn off #118

Open DarkStarDS9 opened 2 years ago

DarkStarDS9 commented 2 years ago

I take it the schedule-switch should act as a toggle? When I tested it, it just stayed on. From reading the code, my guess is that this return here...

https://github.com/seydx/homebridge-tado-platform/blob/610be01db5d72b67d39ba846926151595cdd67cc/src/helper/handler.js#L317

... shouldn't be there?!

I'm not a JS guy, but from a general clean-code-perspective, I think that the whole setStates-function would benefit from braking it up into smaller functions. Especially the case 'extra-cntrlswitch' could be put in something like handleExtraCntrlSwitch() and use a switch instead of the ifs to switch on Central, Shedule, Boost and Off, or at the very least use "else if" there - this would make the intention of the code more clear ("it's either this or that..."). With the existing "if (target !== 'Central')" at the end, it would be more clear that the intention is to run this on all the cases EXCEPT when target is Central. Maybe it would be even more readable to have a resetSwitchState() and call this explicitly in all the relevant cases...

r33ce15 commented 1 year ago

Yes I have noticed this too it would be great if this switch reacted as should so once a manual override has been do this switch should be turned off automatically allowing you to know it's been changed