-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Climate sets HVACAction.HEATING with euristic set up also when the flame in the device is not shown #502
Comments
related #502 --------- Co-authored-by: Bander <46300268+xZetsubou@users.noreply.github.com>
My heater shows the flame on the device when current temperature drops below the target temperature - 1 and the flame disappears when current temperature raises over target temperature. Is it the same as yours? It has the current temperature precision 0.1 and target temperature precision 1. |
@xZetsubou I've tried the branch but it continues not working as expected. @mmxxmm yes, more or less is the same, except for the precisions, both 0.5 |
I think the reason for the device to turn on the heater when the current temperature drops below the target temperature - target precision (for me it's 1 degree) is because it avoids frequently turn on/off the heater. |
@andeb91 You can observe your device to see when the flame icon shows. If your target and current temperature precision is both 0.5 degree and you set your target temperature 0.5 more than the current temperature the icon still doesn't show, Maybe you can try set the target temperature 1 degree more than current? The temperature difference to turn on the heater maybe more than 0.5. |
@mmxxmm I can try doing this. and added at the end of this function
|
I haven't made any changes related to this feature nor I actually fully understand yet especially You mentioned this were working for you fine? if so which version you meant because as I mentioned no changes made into this. Also I would be happy if you guys explained this for me more because from what I understand from code, this feature works as:
There is a test you may want to do in line # if precision_current_diff > target_temperature:
# hvac_action = HVACAction.IDLE
elif precision_current_diff > target_temperature:
hvac_action = HVACAction.IDLE |
On my heater device it works as follow:
My device has a current temperature precision of 0.1 degree and target temperature precision of 1 degree. The device will show a flame icon when it's heating, but will not report this state to any DPs. so we need to set the HVACAction based on the the current/target temperature of the device(so-called heuristic). |
Currently this feature function according to your config with 0.1 precision, and assuming both current/target temp is 20.
This should be heating icon "in HA at least" unless you are talking about flame icon on the device it self and this device start heating when current temperature below target by at least Keep in mind this feature uses only current temp precision for both current/target. Again can you post your device diagnostics so I can see the values of your DPS :) note: the target precision and precision are used to scale the value of the target DP and current DP, however it seems precision is used for heuristic as well |
I think the heating icon (HVAC Action) on HA should be consistent with the heating status(flame icon) on the device it self. I'm not sure if other devices have different logic. Please look into the device diagnostics The following are the DP Specs from Tuya cloud platform. |
Was this intentional to have both To be clear from your device DP data it seems the values of Current/Target temperature are Integer not Float this might be why it didn't works for you at start. can you test this code block paste from line if (
self._config.get(CONF_HEURISTIC_ACTION)
and (target_temperature := self._target_temperature) is not None
and (current_temperature := self._current_temperature) is not None
):
precision = 0.5 if isinstance(current_temperature, float) else 1
precision_target_diff = target_temperature - precision
precision_current_diff = current_temperature + precision
if hvac_mode == HVACMode.HEAT:
if current_temperature < precision_target_diff:
hvac_action = HVACAction.HEATING
if precision_current_diff > target_temperature:
hvac_action = HVACAction.IDLE
if hvac_mode == HVACMode.COOL:
if current_temperature > precision_target_diff:
hvac_action = HVACAction.COOLING
if precision_current_diff < target_temperature:
hvac_action = HVACAction.IDLE
if hvac_mode == HVACMode.HEAT_COOL:
if current_temperature < precision_target_diff:
hvac_action = HVACAction.HEATING
if current_temperature == precision_target_diff:
hvac_action = HVACAction.IDLE
if precision_current_diff > target_temperature:
hvac_action = HVACAction.COOLING
if hvac_mode == HVACMode.DRY:
hvac_action = HVACAction.DRYING
if hvac_mode == HVACMode.FAN_ONLY:
hvac_action = HVACAction.FAN |
My thermostates (but I think more or less all thermostates), to avoid frequent on/off of the heater, work with an hysteresis, so:
@mmxxmm precision_target and precision values are used to scale correctly the values from the device DP data (to be more clear, in my case I have both precisions equal to 0.5 and in DP data current_temperature and target_temperature (both integers) I always receive numbers that are twice the real value and I have to use precision values to scale them correctly (I set a target temperature in the thermostat equal to 20 and I read in the DP data 40)
For me it is not only an aesthetic question because I use home assistant (accordingly with 5 different thermostates) to turn on and off my heat pump but every single thermostat open/close the valve for the related room heating system. |
@andeb91 It seems your thermostats works the same as mine, except the precisions. I also use one thermostat per room to control the valve for the water heating pipelines for each room. So I think we should introduce the previous_hvac_action as you did and ignore the precision staff like the following:
|
@andeb91 I know how now it works and again still not sure why It uses precision to calculate that. the current method does exactly as you said. You know what I think I may know what breaking this logic, can you remove the code above line if not self._conf_hvac_action_dp:
if hvac_mode == HVACMode.COOL:
hvac_action = HVACAction.COOLING
if hvac_mode == HVACMode.HEAT:
hvac_action = HVACAction.HEATING
if hvac_mode == HVACMode.DRY:
hvac_action = HVACAction.DRYING
if hvac_mode == HVACMode.FAN_ONLY:
hvac_action = HVACAction.FAN |
@andeb91 The original code in https://github.com/rospogrigio/localtuya/blob/master/custom_components/localtuya/climate.py is
in your case self._precision = 0.5, but you said it starts heating when the current temperature is 1 degree less of target temperature. |
Yes using precision doesn't matter to be fair any number from 0.1 to 1 would works. Now why did this works for @andeb91 and probably for other uses before and would works for @mmxxmm as well it's because the device reports the current temperature on whole numbers which means it will always be |
@xZetsubou The current temperature variable is not always whole numbers. in the status_updated event:
In my posted device diagnostics the reported value is 168 and precision is 0.1, 168*0.1=16.8. It can be float numbers. |
I think your issue is due to the fact the target is scaled 1 and current is scaled 0.1 I assumes the feature made with both of them has the same scale in mind., I wonder if your device @mmxxmm round it to 17 or does it shows 16.8. either way what If we refactored this to this and took 1 difference instead since this function. if (
(self._config.get(CONF_HEURISTIC_ACTION) or not self._conf_hvac_action_dp)
and (target_temperature := self._target_temperature) is not None
and (current_temperature := self._current_temperature) is not None
):
# This function assumes that action changes if target is "1" different from current.
target_current_diff = current_temperature - target_temperature
device_react_diff = 1
if hvac_mode == HVACMode.HEAT:
if target_current_diff > device_react_diff:
hvac_action = HVACAction.HEATING
elif target_current_diff < device_react_diff:
hvac_action = HVACAction.IDLE
elif hvac_mode == HVACMode.COOL:
if target_current_diff > device_react_diff:
hvac_action = HVACAction.COOLING
elif target_current_diff < device_react_diff:
hvac_action = HVACAction.IDLE
elif hvac_mode == HVACMode.HEAT_COOL:
if current_temperature < device_react_diff:
hvac_action = HVACAction.HEATING
elif target_current_diff > device_react_diff:
hvac_action = HVACAction.COOLING
elif current_temperature == target_temperature:
hvac_action = HVACAction.IDLE
elif hvac_mode == HVACMode.DRY:
hvac_action = HVACAction.DRYING
elif hvac_mode == HVACMode.FAN_ONLY:
hvac_action = HVACAction.FAN |
Sorry for the late reply but I was out for work. @mmxxmm I don't remember which version of the old local_tuya component I had, because when something works fine, I don't always update it as soon as a new version is released. Maybe it was a one or two years old version.... @xZetsubou I tried your code below but it continues not working for my thermostats. My precision is 0.5 for both temperatures (current and target)
It is not working because I'm pretty sure you exchange the temperature in
By the way also if you correct this into
It is not working as expected surely for the middle temperatures. I give you an example to try to be clear: Imagine to have a target_temperature = 20° For my opinion the best things is to introduce also the device_react_diff in climate configuration (as the other parameters and to complain with other thermostats that can have different hysterisis values) and then use the previous_hvac_action in this way:
then using the same logic it is possible also to fix for HVACMode.COOL and HVACMode.HEAT_COOL I never wrote a ha custom component but if I can help you in some way, please let me know. |
My device shows 16.8 on screen. The above code will not work. target_current_diff = current_temperature - target_temperature, If current_temperature < target_temperature it will return negative value therefore will not set hvac_action = HVACAction.HEATING and IDLE state cannot be simply be determined using the target_current_diff, for example current_temperature = 18.9 , target temperature = 20, the difference is 1.1. The heater turned on , after a while the temperature raised to 19.2 which the difference is now 0.8, but the heater will keep working until the current_temperature >= target_temperature. so we should probably change state like this
|
what's the point of this "hvac_action = self._previous_hvac_action" to be clear both condition fails it will stays on the previous HVAC action since it did not changed! however this #502 (comment) were breaking the logic of previous HVAC action so removing that should fix! with your code I made fixes to this it should handle other modes as well. if (
(self._config.get(CONF_HEURISTIC_ACTION) or not self._conf_hvac_action_dp)
and (target_temperature := self._target_temperature) is not None
and (current_temperature := self._current_temperature) is not None
):
# This function assumes that action changes if target is "1" different from current.
target_react_diff = target_temperature - 1
if hvac_mode == HVACMode.HEAT:
if current_temperature <= target_react_diff:
hvac_action = HVACAction.HEATING
elif current_temperature >= target_temperature:
hvac_action = HVACAction.IDLE
elif hvac_mode == HVACMode.COOL:
if current_temperature <= target_react_diff:
hvac_action = HVACAction.COOLING
elif current_temperature >= target_temperature:
hvac_action = HVACAction.IDLE
elif hvac_mode == HVACMode.HEAT_COOL:
if current_temperature <= target_react_diff:
hvac_action = HVACAction.HEATING
elif current_temperature > target_temperature:
hvac_action = HVACAction.COOLING
elif current_temperature == target_temperature:
hvac_action = HVACAction.IDLE
elif hvac_mode == HVACMode.DRY:
hvac_action = HVACAction.DRYING
elif hvac_mode == HVACMode.FAN_ONLY:
hvac_action = HVACAction.FAN Tests
Test current 20 to 19
Test Current went 19 to 20
|
@xZetsubou You are absolutely correct. We don't need to handle not self._conf_hvac_action_dp separately. Removing that code block will make it work. |
I think this related to target temperature STEP? if step is whole number 1 then for sure the device react to "1" otherwise, If it's possible to set decimal numbers then the device also do that as well. so we may use |
There is a Generic Thermostat Integration in HA. It has separate cold_tolerance and hot_tolerance configurations which is different from target_temp_step. |
That's a helper entity, you can create it from HA UI, For now I will assume that device action depends of temperature step. |
This issue was closed because it was resolved on the release: 2025.2.0 |
LocalTuya Version
2025.1.1
Home Assistant Version
2025.1.3
Environment
What happened?
With euristic option checked, climate sets HVACAction.HEATING also when the flame in the device is not shown. In the past versions, the action perfectly followed the flame.
Steps to reproduce.
I have already the devices added. If I set the target temperature 0.5°C more than the actual temperature the climate sets HVACAction.HEATING as action but the device doesn't show the flame icon.
Relevant log output
Diagnostics information.
No response
The text was updated successfully, but these errors were encountered: