cdpuk / ha-bestway

Home Assistant integration for Bestway / Lay-Z-Spa hot tubs
MIT License
72 stars 19 forks source link

Cant turn off heater from Thermostat Card heat icon #2

Closed townsmcp closed 2 years ago

townsmcp commented 2 years ago

You can click the heat icon on the thermostat card to turn on the heater, however when you click again to turn the heating element off, I hear a beep on the spa but the heater stays on. Workaround - click the 3 dots at top right of the thermostat card, in 'Operation' change the option to 'Off' and the heater goes off

townsmcp commented 2 years ago

Ignore the above report - it works if I click the power button on the card. However, if I turn the heater off in the app, HA does not get updated. Vice versa, turning the heater on in the app does not update HA even after terminating the app and reloading and making the changes

cdpuk commented 2 years ago

What you might be seeing is a bit of a shortcoming of the API that the integration uses. When HA sends a command to change the state of the spa, it takes effect immediately, but takes some amount of time for that change to be reflected in subsequent polls for the spa state. It's normally <30s, but can sometimes be minutes.

Fortunately, responses from the API contain a timestamp so we can tell when those timestamps are older than HA's last requested state change. In such cases, the integration ignores what the API says, and uses a best guess of the current state.

Bottom line is: if you change anything via the spa controls or the Bestway app, those changes can take a few minutes to be reflected in HA. If you only control the spa via HA, you probably won't notice anything strange going on at all.

As per the README, it'd be nice to work out what the app is doing in more detail, as clearly it's able to react very quickly to changes from physical button presses on the spa. This isn't something I plan on doing in the near future, but of course I welcome contributions from anyone else!

Does the change from the app get reflected in HA after waiting that short period? If so, I'll probably close this but may update the README to explain the behaviour.

townsmcp commented 2 years ago

@cdpuk thanks for your explanation. I ran a test today and the first test took 10 seconds to reflect in HA when changing from the app. Second test took about one and half minutes to reflect back in HA - important thing though is it did reflect back to HA :)