Discontinued - The Following method is not updated and doesn’t work with recent version of Home Assistant. Suggestion for that device is to move to a different thermostat firmware GitHub - klausahrenberg/WThermostatBeca: Replaces original Tuya firmware on Beca thermostat with ESP8266 wifi module and use that via mqtt (as discussed in this thread). All mentioned below has to be intended as a start-point for who wants to continue developing-maintaining this
Modified tuya doesn’t work anymore but a local interface is provided (It works but must be intended for Testing Purpose Only, without any warrantly or responsability)
I have configured that Thermostat (BHT-6000) following that steps:
- Registered the device in “TuyaSmart” app instead of the “My Smart Thermostat” app (the one of the instruction qr code)
- Added tuya support in home assistant:
tuya:
username: YOUR_TUYA_USERNAME
password: YOUR_TUYA_PASSWORD
country_code: YOUR_ACCOUNT_COUNTRYCODE
Notes and Issues:
-
Ambient temperature is doubled, roughly solved: Smart Life (tuya) show wrong temperature
-
On/off states reports device screen on/off instead of device status.
workaround to show what the unit is doing is by adding a binary sensor
- platform: template
like this:
binary_sensor:
- platform: template
sensors:
- termostato:
friendly_name: "Stato Termostato Camera"
value_template: "{{ (state_attr('climate.<climate_id>','current_temperature')) < (state_attr('<climate_id>','temperature')) }}
- Local key and device id can be obtained by tuyapi (tuyapi/docs/SETUP.md at master · codetheweb/tuyapi · GitHub)
- Local communication does not work with custom_components: wifithermostat, broadlink, broadlinkhysen
Bigger problem (for me):
- Google Assistant does not work with tuya (google home integration, the tuya app works fine) or by exposing hass device. In both mode the device appears but no data is displayed, problem probably related at this Unable To Change Mode On Zwave Thermostat Via Google Assistant · Issue #13158 · home-assistant/core · GitHub
UPDATE 1 – No Longer working
Modified tuya.py to get correct temperature (not doubled) and full google home integration (voice and dashboard)
That’s a rough workaround for testing purpouse, not a stable solution
Only work when thermostat is in manual mode:
- rename the attached ‘tuya.yaml’ in ‘tuya.py’ (can’t apload .py as github attachment)
- create a folder named ‘climate’ in ‘custom_components’ folder
- copy tuya.py in previous ‘climate’ folder
tuya.yaml (5.6 KB)
Notes on modified tuya.py:
-
Temperature formula correction:
@property def current_temperature(self): """Return the current temperature.""" full = round((float(self.tuya.current_temperature())/ float(2)),2) return full
-
Google Home Workaround details:
@property def current_operation(self): """Return current operation ie. heat, cool, idle.""" #mode = self.tuya.current_operation() #if mode is None: #return None #TUYA_STATE_TO_HA.get("idle") #return TUYA_STATE_TO_HA.get(mode) if self.current_temperature < self.target_temperature: return TUYA_STATE_TO_HA.get('hot') else: return TUYA_STATE_TO_HA.get('off')
-
Operation Mode are disabled (actually working on this)
def set_operation_mode(self, operation_mode): """Set new target operation mode.""" return self.tuya.set_operation_mode(HA_STATE_TO_TUYA.get(operation_mode))
-
In Google home correction, if the target temperature is < room temperature the device is reported off without the ability to set temperature (there is no ‘idle’ feature on google home trait schema)
to get target temperature also when idle (but loosing the ability to see if the device is on or off), change this:
return TUYA_STATE_TO_HA.get('off')
to this:
return TUYA_STATE_TO_HA.get('hot')
Know issues of that tuya.py:
- Can’t get float value for current temperature value
- Operation Mode disabled (set them does nothing)
Reference post: Smart Life (tuya) show wrong temperature
That mod overrides Official Tuya Climate Support, it’s not applicable if there are other Tuya Climate Dev
To Revert Back to Official Tuya Support Remove that tuya.py from /custom_components/climate/
- After any change to python files an hass restart is needed
- That Mod is for testing purpouse and not for stable use, in future a separate components must be made
LAN Control
The device can be controlled locally, refer to GitHub - TuyaAPI/cli: 🔧 A CLI for Tuya devices and tuyapi/docs/SETUP.md at master · codetheweb/tuyapi · GitHub for full steps
The device has the following dps:
1 - Device Screen: “false” off - “true” on
2 - Doubled set temperature ( 40 is 20°)
3 - Doubled ambient temperature
4 - Work Mode - 0 auto - 1 manual
5 - Unknown - Actual value “false”
6 - Unknown - Actual value “false”
102 - Unknown - Actual value “0”
103 - Unknown - Actual value “1”
104 - Unknown - Actual value “true”
That custom_component provides local readings, with some limit (polling less than 30 sec causes instability)
localtuya.yaml (9.1 KB)
– Updated version for hass 89.1 climate.yaml (9.0 KB) → rename to climate.py and follow :
It’s for testing purpouse, it works but needs more tests
-
Copy the file in custom_components/climate and then rename from localtuya.yaml to localtuya.py
-
Add that to configuration.yaml
climate: - platform: localtuya host: deviceIp local_key: 'localKey' device_id: 'deviceId' name: 'name' scan_interval: 20
-
It works with google home integration (just expose)
-
Away Mode is the Eco Mode → Echo mode can be turned on both via “Eco” and “Away” but can be deactivated only with away mode
Other Things
As seems, manufacturer is not interested on correct the way the target temperature is reported when in automatic mode.
So meanwhile i’m exploring GitHub - xoseperez/espurna: Home automation firmware for ESP8266-based devices for a custom firmware
Known issues of the device:
If the device is in schedule mode, the app, and also the local reading does not report correctly the temperature set
UPDATE 2 - Deprecated
Side Notes:
changing in localtuya.py, from
def status(self):
"""Get state of Tuya switch and cache the results."""
self._lock.acquire()
try:
now = time()
_LOGGER.debug("UPDATING status")
if not self._cached_status or now - self._cached_status_time > 30:
self._cached_status = self.__get_status()
self._cached_status_time = time()
return self._cached_status
finally:
self._lock.release()
to:
def status(self): """Get state of Tuya switch and cache the results.""" self._lock.acquire() try: now = time() _LOGGER.debug("UPDATING status") #if not self._cached_status or now - self._cached_status_time > 30: self._cached_status = self.__get_status() self._cached_status_time = time() return self._cached_status finally: self._lock.release()
allows to set a lower scan_interval: now i’m at 5 sec and there’s no issues till now
UPDATE 3:
with scan interval at 5 device does not responds to commands (set_temperature, mode, etc),
If this happen increase to 10
(rapid readings makes set to be rejected, as the readings are issued by command)
UPDATE 4:
climate:
- platform: localtuya
host: deviceIp
local_key: 'localKey'
device_id: 'deviceId'
name: 'name'
scan_interval: 5
min_temp: 5
max_temp: 35
Allows to get full temperature range (by default is 7-21 degree) in combination with this new localtuya.py file localtuya.yaml (8.9 KB) → See above for updated file
The code was also modified to try to resolve the 5 second update interval. At this time it seems to work, but more tests are needed (didn’t know exactly how python lock works)
Remember that using the official app (tuya, ecc…) will cause connection rejection to local readings, so there are’t update unless the app is open
ANY HELP IS APRECIATED