for current temperature, you would want to use this:
@property
def current_temperature(self):
“”“Return the current temperature.”""
temp = float(self.tuya.current_temperature() or 0)/2
return temp
The issue here is that null is being read as the current temperature, and trying to divide null (which is not the same as 0) by two causes the failure and for the device to not be created when using the custom component.
Current temperature isn’t really what we want here. I have the same costco TCL air conditioner, and the 158 you see is target temperature. It can be halved as well like this:
@property
def target_temperature(self):
“”“Return the temperature we try to reach.”""
“”“temp2 = float(self.tuya.target_temperature() or 0)/2
return temp2"”"
return self.tuya.target_temperature()
However, the issue I’m having, is that mine showed 153 before… and halved is 76.5. But, my AC is set to 68. So maybe someone else knows where those 8.5’ are coming from and/or how to correct them?
Hi Im new here, just set the Tuya access, it found my thermostat just right, but it shows bad temperature. For example 23,5 Celsius shows as 235 Celsius. How to solve it, divided by 10?
Than you need to create a custom component to modify the code… You have to copy ALL original tuya components into “custom_components/tuya” (you need to create this “tuya” directory), than you modify the climate.py in this newly created directory to change the corresponding temperature (example given by Fraschi earlier in this post if you want to divide the current temperature by 2):
From:
@property
def current_temperature(self):
“”“Return the current temperature.”""
return self.tuya.current_temperature()
You have the safe source of your Tuya code into home assistant (do not download it from internet), tuya is part of the package in home assistant 0.92.2… Mine is located in the following directory (HA is running in a virtual environment on raspberry pi with Python 3.7.2 installed):
/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/tuya/
I just copied all the files from the previous directory to <config_dir>/custom_components/tuya/
and then, make “homeassistant” as owner of these files (command chown) and modified the climate.py program…
Restart HA and then you should have a message in “home-assistant.log” saying that you are using a custom components for tuya, example of the message:
2019-05-11 16:13:22 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for tuya which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
Weird my tuya dimmers also turn off at 12% from home assistant, yet if I connect them directly to the Google home app they work fine, any easy fix for that?
Hello, it is maybe because the temperature is just 20°C…
Can you also check your climate sensor…Check the following attribute: “target_temp_step”… It is maybe equal to 1°C. so no need to display the value after the comma… I had to change this value in climate.py (same way you changed the current temperature) to get a 0.5°C increment…
Not sure it will help but this is what’s coming in my mind right away… Someone else has surely a better explanation or solution…
from homeassistant.const import (
ATTR_TEMPERATURE, PRECISION_WHOLE, PRECISION_TENTHS, TEMP_CELSIUS, TEMP_FAHRENHEIT)
Replace precision:
@property
def precision(self):
“”“Return the precision of the system.”""
return PRECISION_TENTHS
divide all values by 10: @property
def current_temperature(self):
“”“Return the current temperature.”""
return self.tuya.current_temperature()/10
@property
def target_temperature(self):
“”“Return the temperature we try to reach.”""
return self.tuya.target_temperature()/10
@property
def target_temperature_step(self):
“”“Return the supported step of target temperature.”""
return self.tuya.target_temperature_step()/10
I now read the right value but I am not able to send target temperature with numbers after the comma.
I will have to make some tests in Fahreneit.
The issue when sending target temperature value is probably related to this:
def set_temperature(self, **kwargs):
"""Set new target temperature."""
if ATTR_TEMPERATURE in kwargs:
self.tuya.set_temperature(kwargs[ATTR_TEMPERATURE])
Hi all,
I am on HA 0.96.2 and I also want to set up my Tuya thermostat. I got the same issue that the temperature shows double the actual temp. I tried to follow the above steps but I can’t figure out where the .py files are located. This folder doesn’t seem to exist.
Has this changed in later versions of HA?
Any further help would be appreciated.