cdpuk / ha-bestway

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

Thermostat cannot be adjusted in fahrenheit #4

Closed cdpuk closed 1 year ago

cdpuk commented 1 year ago

The current min/max limits are hard-coded to valid celsius values. This makes it impossible to set the temperature when the spa is switched to fahrenheit.

TheOneOgre commented 1 year ago

This is still an issue. Is the repo still being maintained? Seems like this should be an easy fix. I will try to see if I can figure out a way to set the temperature setting based on your HA's default setting.

As a current workaround for anyone, setting the temperature to a specific number via an automation will call the correct number in fahrenheit, only the UI controls are messed up.

cdpuk commented 1 year ago

Yes, this is still maintained, however I'm reluctant to make changes when I'm unable to test them against a real Spa. There are a few unknowns around what the valid values are, and how to ensure HA correctly updates the UI when the device is switched between temperature units. Given I'm in the UK, this will be at the earliest April, perhaps May 2023.

jak119 commented 1 year ago

It's been a while since @TheOneOgre opened this, but my spa is reporting (and taking adjustments in) fahrenheit via the UI

image

TheOneOgre commented 1 year ago

So I haven't messed with this since my automation has been setting temperature correctly, but since @jak119 reported his was working, I tested mine again. As @cdpuk stated, if the hot tub is switched to Fahrenheit, then the manual control does not work, but if the hot tub is in Celsius mode, the number reports and changes properly in the UI. Very odd behavior.

Since the numbers are hard coded, maybe a translation layer so that when the tub is switched to Fahrenheit but the API is sending and receiving Celsius, it can translate the temperature via a function to show and send back the proper values? I'm not sure how it works just throwing ideas.

dRuEFFECT commented 1 year ago

I opened up my spa for the season and had to update the app in HACS to get it working again, as such I came back around to this problem again. For anyone that uses Fahrenheit on the both the spa unit and in Home Assistant, you can manually fix this, you just need to edit lines 47 and 48 in the climate.py file and restart Home Assistant.

_attr_max_temp = 104
_attr_min_temp = 68

@cdpuk these are max/min values for Fahrenheit available in the Bestway app. Changing these values in the file requires a restart of Home Assistant. If the pump is left in Celsius mode and the Home Assistant is set to Fahrenheit, then by default with the Celsius values in this file work fine, it's only when changing the pump itself to Fahrenheit that Home Assistant is no longer converting Celsius to Fahrenheit and so it's taking the hardcoded values of 40 and 20 as literal numeric limits.

We just need to have the above settings be dynamic based on the pump temperature settings.

Related, there is an inherent issue with the pump in that it does not remember the previous temperature settings when turning back on from a power outage. This means that if you had changed the pump to display F instead of C, when you lose and restore power to the pump, it will return to C. After doing my "fix" above for hardcoding F temps in the file, when the pump is in C then Home Assistant is once again trying to convert these values to F, so the gauge and limits in HA are showing as 219 and 154 in this scenario. Having the limits be updated in HA dynamically means that after power failure is restored, HA will convert the C temps appropriately and always show F limits in HA as desired.

A really nice add-on to this would be if you can add a device entity to the integration for controlling the pump's temperature settings of Fahrenheit vs Celsius, this way we can add a step to HA scenes/routines to set this to Fahrenheit and not have to manually do this after the pump reconnects to power. Certainly not necessary, as with just dynamic limits means that HA will always operate correctly with whatever combination of C vs F settings there are at the pump and in HA, but it would be nice to never have to think about it again.