Smart Life (tuya) show wrong temperature

I’m using the Tuya v2 to control two thermostats (brandname “Warmme”). They work and I can control the temperatures from HA. However the current_temperature is only updated after restarting HA or reloading the integration from the configuration->integrations screen. Would it be possible to script an automatic reload every few minutes? That would iron out the last wrinkle for me.

:thinking:

...
action:
  - service: homeassistant.reload_config_entry
    data:
      entity_id:
        -  thermostat.tuya

My auto refresh Tuya

Logs error
ScreenShot_20220318200436

configuration.yaml

system_log:
 fire_event: true

ScreenShot_20220318200511

Automations:

alias: TuyaAuto
description: ''
trigger:
  - platform: event
    event_type: system_log_event
    event_data:
      level: ERROR
      name: tuya_iot
condition:
  - condition: template
    value_template: '{{ "error while get mqtt config" in trigger.event.data.message[0] }}'
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id:
        - one_Tuya.device
mode: single

Restart HA

I have managed to get it working with a similar setup, thanks!

Am I retarded or WAHT?
HOW DID YOU GOT TO THIS MENU???

Having this on docker, Tuya Integrated, but wrong current temp

Verze core-2022.4.5
Typ instalace Home Assistant Container
Vývoj false
Supervisor false
Docker true

BUT I CAN NOT FIND THIS CONFIG…
Have czech translation. so only see an “System Options” on tuya and there is only something about actualizing device (T/F slider)

Thanks for help, Jan

What version doyou have, what type of instalation…i have grown grey on this…i don’t have it there

I’m sorry, don’t have “Configure” on Tuya, only advanced options, which goes to “Enable actualiztion for newly added…”, but no config…could you be so kind and make screenshot, where are you clocking on “Configure”?
…sorry I’m probably braindead, but can’t see it
Regards
Jan

In case if anyone have to divide the temp, this is what I did. In my case temp was 5 times higher than it should be and max temp was 10 times higher.

Home Assistant 2022.4.6

For Docker:
vi /usr/src/homeassistant/homeassistant/components/tuya/climate.py

1. Setting MAX temp to 35

From:

        if self._set_temperature:
            self._attr_supported_features |= SUPPORT_TARGET_TEMPERATURE
            self._attr_max_temp = self._set_temperature.max_scaled
            self._attr_min_temp = self._set_temperature.min_scaled
            self._attr_target_temperature_step = self._set_temperature.step_scaled

To:

        if self._set_temperature:
            self._attr_supported_features |= SUPPORT_TARGET_TEMPERATURE
            self._attr_max_temp = self._set_temperature.max_scaled / 10
            self._attr_min_temp = self._set_temperature.min_scaled
            self._attr_target_temperature_step = self._set_temperature.step_scaled

You can change the min too, if it’s not set to 5.

2. Setting step value (for setting the correct temp)

From:

                   "code": self._set_temperature.dpcode,
                    "value": round(
                        self._set_temperature.scale_value_back(kwargs["temperature"])
                    ),

To:

                   "code": self._set_temperature.dpcode,
                    "value": round(
                        self._set_temperature.scale_value_back(kwargs["temperature"]) * 5
                    ),

3. To show correct current temp

From:

        if self._current_temperature.scale == 0 and self._current_temperature.step != 1:
            # The current temperature can have a scale of 0 or 1 and is used for
            # rounding, Home Assistant doesn't need to round but we will always
            # need to divide the value by 10^1 in case of 0 as scale.
            # https://developer.tuya.com/en/docs/iot/shift-temperature-scale-follow-the-setting-of-app-account-center?id=Ka9
            temperature = temperature / 10

        return self._current_temperature.scale_value(temperature)

To:

        if self._current_temperature.scale == 0 and self._current_temperature.step != 1:
            # The current temperature can have a scale of 0 or 1 and is used for
            # rounding, Home Assistant doesn't need to round but we will always
            # need to divide the value by 10^1 in case of 0 as scale.
            # https://developer.tuya.com/en/docs/iot/shift-temperature-scale-follow-the-setting-of-app-account-center?id=Ka9
            temperature = temperature / 10

        temperature = temperature / 5

        return self._current_temperature.scale_value(temperature)

4. To show current set temp:

From:

        temperature = self.device.status.get(self._set_temperature.dpcode)
        if temperature is None:
            return None

        return self._set_temperature.scale_value(temperature)

To:

        temperature = self.device.status.get(self._set_temperature.dpcode)
        if temperature is None:
            return None

        temperature = temperature / 5

        return self._set_temperature.scale_value(temperature)

obraz

3 Likes

Hello Yozen,
thanks a million, got it working, thanks to you.
I had my modified climate.py in …/custom_components and was on version 2022.4.5. After copying script to /components with old version of HA, nothing happened, but after updating HA to current, everything works flawlessly.
Thanks again
SLMQ

Hello Yozen,
just addendum - I have tried to edit climate.py on upgraded version of HA again and nothing changed, so I will wait till next update to recreate container with new settings in config.
Did you have to delete an install HA againt after edit? Restart seems to be not sufficient.

Regards
Jan

1 Like

Found an open Issue on the Tuya integration and I’ve posted my issue there:

However just to repeat here because this is one of the top results when googling. This is utterly ridiculous and maddening.

If I run an API call against my AirCon unit I get the exact correct information:

{“result”:[{“code”:“switch”,“value”:false},{“code”:“temp_set”,“value”:24},{“code”:“temp_current”,“value”:26},{“code”:“humidity_set”,“value”:90},{“code”:“mode”,“value”:“cold”},{“code”:“windspeed”,“value”:“3”},{“code”:“c_f”,“value”:“C”},{“code”:“temp_set_f”,“value”:62},{“code”:“temp_current_f”,“value”:32},{“code”:“humidity_curre
nt”,“value”:55}],“success”:true}

And yet, what gets reported in Home Assistant via (and I will state because people here are using a variety) the OFFICIAL TUYA INTEGRATION:

hvac_modes:

  • ‘off’
  • heat_cool
  • cool
  • heat
  • dry
  • fan_only
    min_temp: -8.9
    max_temp: -0.6
    target_temp_step: 1
    min_humidity: 0
    max_humidity: 100
    fan_modes:
  • ‘1’
  • ‘2’
  • ‘3’
    current_temperature: 0
    temperature: -4.4
    humidity: 90
    fan_mode: null
    friendly_name: Cabin Air Conditioner
    supported_features: 13

Brilliant.

I’ve tried all various attempts of my least favourite subject, Math, to figure it out via custom integration to no avail. I get it close, but that’s with static figures, no idea if it relates once they move.

If anyone can see wood for the trees in the above figures and have a suggestion on the math, I’ll forever be in your debt. Until then, I guess I and we are at the mercy of Tuya and HA sorting this out.

hello,

i have the same problem, but i cannot find this file, climate.py to edit…

Home Assistant 2022.7.7
Supervisor 2022.07.0
Operating System 8.4
Frontend 20220707.1 - latest

1 Like

Are there any Updates on this issue?
I have 6 BecaSmart BHT-6000 thermostats they are detected as thermostat (IAYz2WK1th0cMLmL), and they all show a wrong temperature. The real room temperature is 27.5°C, the displayed temperature is 5.5°C, so it’s divided by 5.

I’m using the official tuya integration on a raspberry pi:
Home Assistant 2022.8.3
Supervisor 2022.08.3
Operating System 8.4
Frontend 20220802.0 - latest

2 Likes

To fix the temperature issue with Tuya BHT-002 thermostats i recommend you to use my custom component based on the official Tuya integration found here

3 Likes

Thanks for clearly explaining the cause of the problem and providing a fix. I can sort of understand the developers of tuya integration refusing in include hacks to fix minstakes of individual HW manufacturers, but that doesn’t make our life any easier.

Could you publish a patch or even the whole climate.py file that can be droppped on top of exiting one? That would simplify the fix process. Even MACs filtering can be omitted as i only use a single type of the thermostat.

Thanks again for your efforts!

There might be something i´m doing wrong, the error persists

Thanks! Working perfectly!!!

Check the code changes i made to climate.py and base.py here Comparing home-assistant:dev...midstar:tuya_BHT-002_thermostat_workaround · home-assistant/core · GitHub

2 Likes

This turned out to be the easiest, (with the downside of having to repeat the process after upgrade). Much thanks!

Hi @midstar
I trying this fix but I don’t understand why my tuya app still from cloud?

  1. I uploaded modified tuya directory to the HA server:
  2. Rebooted server
  3. Added tuya integration through GUI.