BHT-6000 Thermostat (tuya) support

No I have solved all and I update every 5 second without changing nothing… I hope only that tuya will update for climate as other thermostat with Google home.

With default tuya support google home works only for voice commands. Exposing the hass entitty to google (I’ve tried without cloud) enables also the Google Home App. Remember that the workaround for tuya.py are also applicable to localtuya.py (expecially the way a status off/heat is reported).

If Your previous issues are related at uncomprensible explanation on first post or difficulty you have found, please add some details, that can be usefull at all

temperature set doesn’t work

2019-01-27 17:50:29 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 289, in _handle_service_platform_call await func(entity, data) File "/usr/local/lib/python3.6/site-packages/homeassistant/components/climate/__init__.py", line 574, in async_service_temperature_set await entity.async_set_temperature(**kwargs) File "/config/custom_components/climate/localtuya.py", line 204, in async_set_temperature self._device.set_status(temperature, '2') File "/config/custom_components/climate/localtuya.py", line 111, in set_status return self._device.set_status(state, switchid) File "/config/deps/lib/python3.6/site-packages/pytuya/__init__.py", line 302, in set_status data = self._send_receive(payload) File "/config/deps/lib/python3.6/site-packages/pytuya/__init__.py", line 171, in _send_receive data = s.recv(1024) socket.timeout: timed out

Actually I’m using the latest uploaded localtuya.py without any issues (for now).

As seen in another post, yout thermostat is a BHT-002-GBLW and not a BHT-6000.
Probably the device dps are different and the code must be modified accordingly.
(If the set_temperature dps is different probably you can’t also see the set_temperature value in hass)

To get the list of all available dps make this simple script

import pytuya

d = pytuya.OutletDevice('<dev-id>','<dev-ip>', '<local-key>')
data = d.status()  # NOTE this does NOT require a valid key
print('Dictionary %r' % data)

Then modify the localtuya.py accordingly:

In the code all is done by interfacing directly with the dps:
so all the set command have that pattern: self._device.set_status( '1' , '4') where ‘1’ is the value to be set and ‘4’ the corresponding dps

The readings (all in status) are managed like this:

self._target_temperature = float(status['dps']['2']) /2
self._current_temperature = float(status['dps']['3']) /2
self._state = status['dps']['1']

Explanation: [‘dps’] is the dps data from the status matrix (pytuya handles the same data you get with the previous script), [‘1’] or ['2] or [‘3’] are the single dps from data. /2 is a correction because my device transmits temperature doubled (so can handle .5 resolution with integer data)

As seen till now all data is handled as number or true/false,
Example: temperature at ‘30’ in my device is 15°, Mode Auto is ‘1’ and Manual ‘0’, screen on/off is true/false

Hi where can I find the switch that command the start and stop of my boiler in home assistant? I think that I put 20© on thermostat. It read temperature if it is more of 20 stop boiler with a switch. If it is minus of 20 start boiler. Where I can find that switch, in home assistant?

@itmax86
Encountered same error, it happens (rarely, one time till now) when set-temperature is triggered when the read-status is already running. Now I’m trying this workaround:

async def async_set_temperature(self, **kwargs):
    while True:
       try:
           self._lock.acquire()
           temperature = int(float(kwargs[ATTR_TEMPERATURE])*2)
           _LOGGER.debug("Set Temperature: " + str(temperature))
           if ATTR_TEMPERATURE in kwargs:
               self._device.set_status(temperature, '2')
               sleep(1)
           self._lock.release()
       except:
           _LOGGER.warning("Set Temperature Retry")
           continue
       break

@hdjweb1
There is no way to control directly the relay, it’s done by the thermostat and not by homeassistant. If you want to trigger the device as on/off use home assistant automation or appdaemon. to turn on, set any temp over the ambient temp, and to turn off any temperature below.

Someone have migrated localtuya custom component to home assistant 0.88???

I’m on 0.86.4, by 0.88 changelog I didn’t see anything that can be related on how localtuya works, but i have to try it. What doesn’t work or what error do you get?

i have not tryed but i see thaht i must put in a folder but i don’t know what change

In 0.88 still works without modification, only a warning message is displayed. Anyway referring to https://developers.home-assistant.io/blog/
the localtuya.py must be renamed to climate.py
and placed in /custom_components/localtuya/ folder (that folder must be created)
then an empty files named __init__.py must be placed in the same above folder

In 0.88 the custom component is not working anymore, the temperature is doubled again…
I’ve tried to create the localtuya dir and rename the old file in climate.py, but the temperature is still wrong

Wait… Which component? I refer to the localtuya (the one with local readings) and not to the modified tuya.py. The localtuya works with the modification in folder structure, see previous post (I have two devices correctly working in hass 0.88.1). I’m not using anymore the modified tuya.py so I didn’t watch if it still works or what is needed to get it work.
The localtuya is a custom_components, the tuya.py is an overlay to the existing hass support. Maybe is sufficient to follow the previous post (naming the directory tuya) or maybe a complete climate overlay is needed (refer to https://developers.home-assistant.io/blog/2019/02/19/the-great-migration.html). Probably hass is not loading the modified tuya and uses the official one, take a look to the logs

Thank you Fraschi, I’m not using the local component… sorry

I was using your component in home assistant 0.88. 2 with the new configuration folder all is good but now platform not found in home assistant 0.89.1

1 Like

try this climate.yaml (9.0 KB) (rename to climate.py)
It’s not fully tested but seems to work in 89.1
The problem was on the imports, some homeassistant climate const where moved in recent updates.

As already told, when issues happens provide hass version and relevant log output, and at least a thanks is apreciated, when the problem gets solved as in past. Helping in that way is unpleasant.

1 Like

I try now wait 5 minute and I will give you a response

All is good thank you @Fraschi

1 Like

Thank you! I’m very appreciate that. It’s working again for me as well! :wink:

1 Like

No news about tuya component update no localtuya for read temperature in good way in Google???

Have you see https://github.com/klausahrenberg/ThermostatBecaWifi

Bye

Tiziano

1 Like