Skip to content
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

Using AI calibration mode caused for the TRV to be set to idle even if the BT thermostat was set to heat #1580

Open
radupantiru opened this issue Jan 20, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@radupantiru
Copy link

radupantiru commented Jan 20, 2025

Description

Using AI calibration stopped the target TRV using the same temperature as target as the one measured internally.
Using Aggressive calibration fixed the issue but would like to know what happened.

Steps to Reproduce

Set BT TRV to heat but radiator TRV was set to idle

Expected behavior:
Radiator TRV to be seat to heat.

Actual behavior:

Radiator TRV was idle.

Versions and HW

Home Assistant: 2025.1.2
Better Thermostat: 1.6.1

TRV(s):
TS0601
by _TZE200_hue3yfsn

Debug data

diagnostic data

debug log
2025-01-20 22:03:03.732 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat None: climate.trvb1_thermostat - new setpoint calibration: 19.0 | external_temp: 19.4, target_temp: 22.8, trv_temp: 15.6
2025-01-20 22:03:03.733 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: TO TRV set_hvac_mode: climate.trvb1_thermostat from: heat to: off
2025-01-20 22:03:03.733 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat None: set_hvac_mode off
2025-01-20 22:03:10.593 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat None: climate.trvb1_thermostat / heating_power_valve_position - temp diff: 3.4 - heating power: -0.0051 - expected valve position: 0%
2025-01-20 22:03:10.593 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat None: climate.trvb1_thermostat - new setpoint calibration: 15.5 | external_temp: 19.4, target_temp: 22.8, trv_temp: 15.6
2025-01-20 22:03:10.593 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: TO TRV set_hvac_mode: climate.trvb1_thermostat from: off to: heat
2025-01-20 22:03:10.593 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat None: set_hvac_mode heat
2025-01-20 22:03:10.831 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: TO TRV set_temperature: climate.trvb1_thermostat from: 15.5 to: 15.5
2025-01-20 22:03:10.831 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: climate.trvb1_thermostat / check_target_temp / _last: 15.5 - _current: None
2025-01-20 22:03:13.834 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat None: climate.trvb1_thermostat - new setpoint calibration: 19.0 | external_temp: 19.4, target_temp: 22.8, trv_temp: 15.6
2025-01-20 22:03:13.834 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: TO TRV set_hvac_mode: climate.trvb1_thermostat from: heat to: off
2025-01-20 22:03:13.834 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat None: set_hvac_mode off
2025-01-20 22:03:18.670 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat None: climate.trvb1_thermostat / heating_power_valve_position - temp diff: 3.4 - heating power: -0.0051 - expected valve position: 0%
2025-01-20 22:03:18.670 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat None: climate.trvb1_thermostat - new setpoint calibration: 15.5 | external_temp: 19.4, target_temp: 22.8, trv_temp: 15.6
2025-01-20 22:03:18.670 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: TO TRV set_hvac_mode: climate.trvb1_thermostat from: off to: heat
2025-01-20 22:03:18.670 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat None: set_hvac_mode heat
2025-01-20 22:03:20.581 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: TO TRV set_temperature: climate.trvb1_thermostat from: 15.5 to: 15.5
2025-01-20 22:03:20.582 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: climate.trvb1_thermostat / check_target_temp / _last: 15.5 - _current: None

Additional Information

@radupantiru radupantiru added the new bug incoming bug issue label Jan 20, 2025
@folfy
Copy link
Collaborator

folfy commented Jan 21, 2025

@radupantiru Thanks for your bug report and also providing the proper debug data.

2025-01-20 22:03:18.670 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat None: climate.trvb1_thermostat / heating_power_valve_position - temp diff: 3.4 - heating power: -0.0051 - expected valve position: 0%

-> The "AI" for some reason seems to have learned to expect 0% heating rn for a 3.4°C difference, very odd.
The "heating power: -0.0051" means, that BT determined a "negative" heating effect of your heater, therefore calculation resulting in the decision that your're better off without it 😅
We would need the logs from the start, when BT was running the calibration ("calculate_heating_power" in logs), for determining from the TRV and sensor data, what went wrong there actually.

You can actually call the BT "reset_heating_power" service, which will set the value back to the initial 0.01.

Some more undocumented info about the AI algorithm, that I just analyzed from the code now:

  • The value is persisted across restarts through HA in the "state" attributes of the entity
  • First time it's initialized to 0.01, and is calibrating itself every time BT changes from heating to idle, if the heating phase was longer than 1min:
    async def calculate_heating_power(self):
    if (
    self.heating_start_temp is not None
    and self.heating_end_temp is not None
    and self.cur_temp < self.heating_end_temp
    ):
    _temp_diff = self.heating_end_temp - self.heating_start_temp
    _time_diff_minutes = round(
    (self.heating_end_timestamp - self.heating_start_timestamp).seconds
    / 60.0,
    1,
    )
    if _time_diff_minutes > 1:
    _degrees_time = round(_temp_diff / _time_diff_minutes, 4)
    self.heating_power = round(
    (self.heating_power * 0.9 + _degrees_time * 0.1), 4
    )

    The new sample is weighted with 10% -> This means, if you for example open a window, and heating stops after it was opened, the "heating end" temperature might be way lower than the heating start temperature. This can result in a big, negative number (big temperature decrease in short time), that might be able to overrule any normal, positive calibration value to a negative one within one event. Even a late / slow sensor update, could cause such "bad" jump, that could lead to this issue, if heating turned off again right after. For example you have -0.7°C in 5min -> -0.14°/min * 0.1 + 0.01 (assumed initial value) * 0.9 = -0.005, i.e. heating would never start again.

An additional check at L973 would be required, making sure t_end is larger than t_start. Or at least clamping the heating power value to be bigger than idk, 0.001 (1.44°C per day), but this can then still affect / offset the heating power value with such erroneous samples. Negative values generally could make sense, like if we're not heating enough, and there's a big heat demand, temperature could still fall, but it's hard to distinguish "bad" samples from this...

Some nice write-up on the algorithm: #1086 (comment)

@folfy folfy added bug Something isn't working and removed new bug incoming bug issue labels Jan 21, 2025
@radupantiru
Copy link
Author

Tried to reproduce the same situation as yesterday twice, but was not successful with a large temperature drop.

Will leave log settings with DEBUG enabled and if the same situation surfaces I will add a new comment with the new logs.

Also thank you for your proposed fix.

@folfy
Copy link
Collaborator

folfy commented Jan 21, 2025

@radupantiru It depends when the sensor updates and how big your "window opened" delay in BT is - The drop must be reported by the sensor, before BT turns off heating (due to the window open detection). Also this all only applies to "AI calibration" mode.

@jkrenzer
Copy link

I have the same issue and it seems to correlate well with the room being quite cold and the radiator having problems to reach the temperature target over the day and encountering falling temperatures while heating when warm air escapes the room.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants