Smart Life (tuya) show wrong temperature

When will Tuya v2 be available for installation from within HA as a official integration or HACS download?

Tuya and HA core team is working togheter to integrate new API in Tuya official integration. I think it will be available maximum by the end of this year, also because Tuya is going to dismiss old API on that period, but this is only my supposition.

1 Like

You have to add the repository in HACS, and then you can install through HACS.

https://github.com/tuya/tuya-home-assistant

1 Like

Faster then that, in 2021.10. It is in the beta release notes.

Hi All, Now with the update to 2021.10.2 we have Tuya v2 as an integration. I have updated my dashboard with the new entity details and notice some issues with the Thermostat status not showing as “Auto” when the thermostat is in the Auto or on mode. Does anyone have any suggestions for the following setup?

To get these to work I had to edit the dashboard grid card entry using yaml and add “hvac_mode: auto” like this:

type: thermostat
name: Guest toilet
entity: climate.guest_toilet
hvac_mode: auto

Although I see this warning when in the card editing mode:
image

However the thermostat always shows “off” even when the thermostat is set to auto (on mode).

If the thermostat is actually off then they appear like this:

When I tap the three dots at the top right corner of any of the thermostats then there is no available “operation” to select. With the old integration I could select Auto or off modes.
image

My thermostats are ProWarm model (Underfloor Heating Thermostats & Controls | ProWarm™):

Also does anyone know if it is possible to get the Tuya Zigbee Hub and its entities (PIR Sensors) to show up in HomeAssistant?

I have similar effect:
I have 5 of Beca BHT 6000 thermostats, acctualy made integration of Tuya (with Tuya IOT developer ID as old stopped working), all my thermostats are set as manual with 21C-24C,
I can see all of them in HA, but the’re show as OFF and temps are 5x lower:
eg. bathroom set to 24C, current temp. 24C but HA shows 4,8C

BECA SMART BHT-002

with the new integration, the temp value should be multiplied by 10 and then divided by 2 to get the right value, but there’s no update on the status of the thermostat if it starts heating, in home assistant still to be “off”

image

I have the same. Temperatures shown as 4.4 instead 22 (divided by 10 but should be divided by 2) and no change on the mode. So is it possible to switch back to old tuya v1 that worked instead this v2 that doesn’t? Could we have both for some time?

Hi @luka6000

I believe that is an option and you can install and operate both v1 and v2 integrations together. But for me, neither v1 or v2 showed the status of my brand of thermostats.

well, actually you can’t have both. At least not with official support.
You can use HACS with this repos
https://github.com/fuatakgun/tuya_v1 this one is replacing new v2 totally
https://github.com/andrey-yantsen/home-assistant-tuya-old and this one is adding v1 as “tuya old” so yes, you can have both with this.
I’m using this tuya old and it works as expected. But Tuya will disable this API sooner than later.

1 Like

This issue is back again in tuya v2, however you can just use it by patching it.

This is a test repo that works with current HA stable: GitHub - 3v1n0/tuya-ha-hacks

Main dirty changes needed are:

commit b85573b19849e4f2c3d0d50e0291b9585aa71784
Author: Marco Trevisan (Treviño) <[email protected]>
Date:   Mon Nov 1 19:06:23 2021 +0100

    climate: Also use Upper temp as current temperature

diff --git a/climate.py b/climate.py
index bd3afd8..e6aaf7b 100644
--- a/climate.py
+++ b/climate.py
@@ -144,9 +144,9 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
         # use whatever the device is set to, with a fallback to celsius.
         if all(
             dpcode in device.status
-            for dpcode in (DPCode.TEMP_CURRENT, DPCode.TEMP_CURRENT_F)
+            for dpcode in (DPCode.TEMP_CURRENT, DPCode.TEMP_CURRENT_F, DPCode.UPPER_TEMP)
         ) or all(
-            dpcode in device.status for dpcode in (DPCode.TEMP_SET, DPCode.TEMP_SET_F)
+            dpcode in device.status for dpcode in (DPCode.TEMP_SET, DPCode.TEMP_SET_F, DPCode.UPPER_TEMP)
         ):
             self._attr_temperature_unit = TEMP_CELSIUS
             if any(
@@ -198,7 +198,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
         # Determine dpcode to use for getting the current temperature
         if all(
             dpcode in device.status
-            for dpcode in (DPCode.TEMP_CURRENT, DPCode.TEMP_CURRENT_F)
+            for dpcode in (DPCode.TEMP_CURRENT, DPCode.TEMP_CURRENT_F, DPCode.UPPER_TEMP)
         ):
             self._current_temperature_dpcode = DPCode.TEMP_CURRENT
             if self._attr_temperature_unit == TEMP_FAHRENHEIT:
@@ -207,6 +207,8 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
             self._current_temperature_dpcode = DPCode.TEMP_CURRENT
         elif DPCode.TEMP_CURRENT_F in device.status:
             self._current_temperature_dpcode = DPCode.TEMP_CURRENT_F
+        elif DPCode.UPPER_TEMP in device.status:
+            self._current_temperature_dpcode = DPCode.UPPER_TEMP
 
         # If we have a current temperature dpcode, get the integer type data
         if (
diff --git a/const.py b/const.py
index a9f7afb..f0f1ecd 100644
--- a/const.py
+++ b/const.py
@@ -298,6 +298,7 @@ class DPCode(str, Enum):
     TEMP_VALUE = "temp_value"  # Color temperature
     TEMP_VALUE_V2 = "temp_value_v2"
     TEMPER_ALARM = "temper_alarm"  # Tamper alarm
+    UPPER_TEMP = "upper_temp"
     UV = "uv"  # UV sterilization
     VA_BATTERY = "va_battery"
     VA_HUMIDITY = "va_humidity"

And

commit e46a5922b9e5630eb2e5702557ccc9803c1289e1
Author: Marco Trevisan (Treviño) <[email protected]>
Date:   Mon Nov 1 19:11:53 2021 +0100

    climate: Adjust temperature dividers to support my setup

diff --git a/climate.py b/climate.py
index e6aaf7b..e0943ac 100644
--- a/climate.py
+++ b/climate.py
@@ -191,8 +191,8 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
             )
             self._attr_supported_features |= SUPPORT_TARGET_TEMPERATURE
             self._set_temperature_type = type_data
-            self._attr_max_temp = type_data.max_scaled
-            self._attr_min_temp = type_data.min_scaled
+            self._attr_max_temp = type_data.max_scaled * 10.0 / 2.0
+            self._attr_min_temp = type_data.min_scaled * 10.0 / 2.0
             self._attr_target_temperature_step = type_data.step_scaled
 
         # Determine dpcode to use for getting the current temperature
@@ -367,9 +367,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
             [
                 {
                     "code": self._set_temperature_dpcode,
-                    "value": round(
-                        self._set_temperature_type.scale_value(kwargs["temperature"])
-                    ),
+                    "value": round(float(kwargs["temperature"]) * 2.0),
                 }
             ]
         )
@@ -387,7 +385,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
         if temperature is None:
             return None
 
-        return self._current_temperature_type.scale_value(temperature)
+        return self._current_temperature_type.scale_value(temperature) / 2.0
 
     @property
     def current_humidity(self) -> int | None:
@@ -411,7 +409,7 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity):
         if temperature is None:
             return None
 
-        return self._set_temperature_type.scale_value(temperature)
+        return self._set_temperature_type.scale_value(temperature) * 10 / 2.0
 
     @property
     def target_humidity(self) -> int | None:
2 Likes

Hi!
That´s great news, please could you gave us short guide how to change it in config?
I have the same problem:


Together with no current temp. state.

There’s no extra config (other than the default one).

Just clone https://github.com/3v1n0/tuya-ha-hacks in your custom_components folder so that it’s called tuya (to override the default one):

git clone https://github.com/3v1n0/tuya-ha-hacks.git tuya

And on reboot, the custom component will be used instead of default one. Adjust the hardcoded multiplier (TUYA_TEMPERATURE_MULTIPLIER) in case yours doesn’t use values multiplied by 2.

10 Likes

@3v1n0 Thank you! Did you submit fixes to mainstream repo?

1 Like

All my Tuya devices disappeared (disconnected) from HA yesterday after I updated to core 2021.11.1 did anyone else have this problem for the TuyaV2 integration? Once I rolled back to the previous day’s HA back up everything as working again.

I did mention that it would be the way (even though my code is just a quick hack, not something merge-able), but it requires custom codepaths for devices with product_id that is IAYz2WK1th0cMLmL (please check if yours match).

So, I can imagine that upstream is reluctant in doing that just for one specific kind (that tuya explicitly didn’t support), even though that’s probably the most sold tuya thermostat ever…

I’ve updated the branch to make it look only like an heater given that this is something true for this, and the scheduler card didn’t support properly the heater/cooler mode.


BTW, I think that another way to use it without the custom integration above would be to just define a custom heater via:

template:
  - sensor:
      - name: "Tuya thermostat fixed temperature"
        unique_id: tuya_thermostat_temperature_fixed
        unit_of_measurement: "°C"
        state: '{ (states('sensor.original_tuya_temperature_sensor_name')) | float) / 2.0 }' # use your multiplier here

climate:
  - platform: generic_thermostat
    name: Tuya Heater
    heater: climate.your_tuya_thermostat_id
    target_sensor: sensor.tuya_thermostat_temperature_fixed
    min_temp: 5
    max_temp: 35
    ac_mode: false
    target_temp: 17
    min_cycle_duration:
      seconds: 5
    initial_hvac_mode: "off"
    away_temp: 12
    precision: 0.5

Then, set the actual thermostat temperature value to an high value, and just use this manual thermostat to handle it. Sad but should work (check the syntax, as I didn’t test it fully).

This worked great, thanks!

I have a MOES BHT-002 thermostat which uses the SmartLife app. It used to work with the old TUYA integration but I now have several problems:

  • Temperatures (readings and settings) are out by a factor of a fifth
  • Temperatures never update. When I add the TUYA 2 integration (I’ve added and removed it several times to see if I can sort it out at all to no avail), the temperature seems to be read but then no more.
  • I can’t send any commands to the thermostat - I can’t set a temperature, switch it off, etc.
    Some of the suggestions above may help (I’ve already set up a sensor to multiply the temperature by 5) but not everything. Appreciate any suggestions.

Old Tuya
It will work, I don’t know how long
Edit:
Tuya pushed back the timeline for sunsetting the old API with 6 months; but it was too late for us to change course and ship the old integration.

https://github.com/andrey-yantsen/home-assistant-tuya-old

Thanks, I’ll look at that. A bit of an update as I realise I’m mistaken about it not reporting to HA. I manually changed the temperature setting on the thermostat using the SmartLife app and it updated in HA. For info, this is what the states are in developer tools. As you can see, HA can’t read the current temperature and I can’t control it from HA.

hvac_modes: off, heat_cool
min_temp: 1
max_temp: 7
target_temp_step: 0.5
current_temperature: null
temperature: 2.3
friendly_name: Blah thermostat
supported_features: 1

1 Like