jmcollin78 / versatile_thermostat

A full featured Thermostat for Home Assistant: presets, window, motion, presence and overpowering management
MIT License
328 stars 34 forks source link

Endless loop created by turning VTherm with multiple climate devices on and off very quickly #334

Closed gpayer closed 10 months ago

gpayer commented 10 months ago

Version of the custom_component

5.2.0

Configuration

My VTherm attributes are the following:

hvac_modes: off, heat
min_temp: 7
max_temp: 25
target_temp_step: 0.5
preset_modes: none, frost, eco, comfort, boost
current_temperature: 22.8
temperature: 20.5
hvac_action: idle
preset_mode: none
is_on: true
hvac_mode: heat
type: null
is_controlled_by_central_mode: true
last_central_mode: null
frost_temp: 5
eco_temp: 20
boost_temp: 22
comfort_temp: 21.5
frost_away_temp: 7
eco_away_temp: 7
boost_away_temp: 7
comfort_away_temp: 7
power_temp: null
target_temperature_step: 0.5
ext_current_temperature: 0.35
ac_mode: false
current_power: null
current_power_max: null
saved_preset_mode: eco
saved_target_temp: 21.5
saved_hvac_mode: null
window_state: off
motion_state: null
overpowering_state: null
presence_state: null
window_auto_state: off
window_bypass_state: false
security_delay_min: 60
security_min_on_percent: 0.5
security_default_on_percent: 0.1
last_temperature_datetime: 2024-01-11T15:30:07.562536+01:00
last_ext_temperature_datetime: 2024-01-11T15:30:55.620098+01:00
security_state: false
minimal_activation_delay_sec: 10
device_power: 1
mean_cycle_power: null
total_energy: 146.75
last_update_datetime: 2024-01-11T15:30:55.629160+01:00
timezone: Europe/Berlin
window_sensor_entity_id: null
window_delay_sec: null
window_auto_enabled: false
window_auto_open_threshold: null
window_auto_close_threshold: null
window_auto_max_duration: null
motion_sensor_entity_id: null
presence_sensor_entity_id: null
power_sensor_entity_id: null
max_power_sensor_entity_id: null
temperature_unit: °C
is_device_active: false
ema_temp: 22.74
is_over_climate: true
start_hvac_action_date: null
underlying_climate_0: climate.thermostat_wohnzimmer_fenster_links
underlying_climate_1: climate.thermostat_wohnzimmer_fenster_rechts
underlying_climate_2: climate.thermostat_wohnzimmer_mitte
underlying_climate_3: null
is_regulated: true
regulated_target_temperature: 20.5
auto_regulation_mode: auto_regulation_light
regulation_accumulated_error: -10
auto_fan_mode: auto_fan_none
current_auto_fan_mode: auto_fan_none
auto_activated_fan_mode: null
auto_deactivated_fan_mode: null
friendly_name: V Thermostat Wohnzimmer
supported_features: 17

Describe the bug

If a VTherm controlling multiple climate devices is turned on (hvac_mode heat) and off (hvac_mode off) again very quickly, it enters an endless loop turning itself on and off all the time and also sending endless on/off commands to the underlying climate devices.

I'm trying to: Turn off the VTherm immediately after I turned it on accidently.

And I expect: The VTherm must stay in in the state I set it to, in this case off.

But I observe this .... And endless loop of the VTherm turning itself on then off again. The only solution is then to deactivate it, wait until the command storm disappears (restarting zigbee2mqtt and mosquito might have helped as well) and then activate it again.

My idea for a solution would be

And finally: never blast out commands without throttling! There really should be a failsafe, so if the VTherm finds itself sending out commands way too quickly, then it should just deactivate itself.

I read the documentation on the README.md file and I don't find any relevant information about this issue.

Debug log

logger:
    default: info
    logs:
        custom_components.versatile_thermostat: info
2024-01-11 06:33:16.031 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Set hvac mode: heat
2024-01-11 06:33:16.032 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:16.032 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:16.032 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - regulation calculation will be done
2024-01-11 06:33:16.033 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Regulated temp have changed to 23.0. Resend it to underlyings
2024-01-11 06:33:16.034 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Sending event EventType.HVAC_MODE_EVENT with data: {'hvac_mode': <HVACMode.HEAT: 'heat'>}
2024-01-11 06:33:16.073 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:16.073 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying event is received less than 10 sec after command. Forget it to avoid loop
2024-01-11 06:33:16.087 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Set preset_mode: comfort force=False
2024-01-11 06:33:16.087 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:16.088 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:16.088 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.0) min is < 5 min -> forget the regulation send
2024-01-11 06:33:16.591 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:16.591 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying event is received less than 10 sec after command. Forget it to avoid loop
2024-01-11 06:33:16.664 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:16.665 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying event is received less than 10 sec after command. Forget it to avoid loop
2024-01-11 06:33:17.093 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:17.093 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying event is received less than 10 sec after command. Forget it to avoid loop
2024-01-11 06:33:17.102 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:17.102 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying event is received less than 10 sec after command. Forget it to avoid loop
2024-01-11 06:33:17.170 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:17.170 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying event is received less than 10 sec after command. Forget it to avoid loop
2024-01-11 06:33:17.598 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:17.599 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying event is received less than 10 sec after command. Forget it to avoid loop
2024-01-11 06:33:17.608 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:17.608 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying event is received less than 10 sec after command. Forget it to avoid loop
2024-01-11 06:33:17.741 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Set hvac mode: off
2024-01-11 06:33:17.742 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:17.743 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Sending event EventType.HVAC_MODE_EVENT with data: {'hvac_mode': <HVACMode.OFF: 'off'>}
2024-01-11 06:33:19.402 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:19.404 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:28.916 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:28.918 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:35.710 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:35.712 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:35.713 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:35.713 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.3) min is < 5 min -> forget the regulation send
2024-01-11 06:33:36.129 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:37.696 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:37.698 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:38.212 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hv
ac_action=heating, old_hvac_action=idle
2024-01-11 06:33:38.212 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying just switch ON. Set power and energy start date 2024-01-11T06:33:38.208431+01:00
2024-01-11 06:33:38.215 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:38.216 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:38.217 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.4) min is < 5 min -> forget the regulation send
2024-01-11 06:33:38.230 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hv
ac_action=idle, old_hvac_action=idle
2024-01-11 06:33:38.232 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:38.757 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:38.760 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:38.761 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:38.761 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.4) min is < 5 min -> forget the regulation send
2024-01-11 06:33:39.755 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_h
vac_action=idle, old_hvac_action=idle
2024-01-11 06:33:40.263 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:40.265 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:41.295 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=off, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:41.522 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hv
ac_action=heating, old_hvac_action=idle
2024-01-11 06:33:41.522 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - underlying just switch ON. Set power and energy start date 2024-01-11T06:33:41.520104+01:00
2024-01-11 06:33:41.524 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:41.525 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:41.525 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.4) min is < 5 min -> forget the regulation send
2024-01-11 06:33:41.798 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:42.837 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:43.332 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:43.334 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:44.365 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=off, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:44.869 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hv
ac_action=idle, old_hvac_action=idle
2024-01-11 06:33:44.870 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:44.872 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:44.872 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.5) min is < 5 min -> forget the regulation send
2024-01-11 06:33:45.133 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=heating, old_hvac_action=heating
2024-01-11 06:33:45.907 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_h
vac_action=idle, old_hvac_action=idle
2024-01-11 06:33:46.414 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:46.416 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:47.444 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=off, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:47.953 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hv
ac_action=idle, old_hvac_action=idle
2024-01-11 06:33:47.955 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:47.955 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:47.955 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.5) min is < 5 min -> forget the regulation send
2024-01-11 06:33:48.834 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=heating, old_hvac_action=heating
2024-01-11 06:33:48.836 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:48.975 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hv
ac_action=idle, old_hvac_action=idle
2024-01-11 06:33:48.977 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:48.978 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:48.978 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.5) min is < 5 min -> forget the regulation send
2024-01-11 06:33:49.328 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=heating, old_hvac_action=heating
2024-01-11 06:33:49.330 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:49.486 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=off, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:49.841 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hvac_action=heating, old_hvac_action=heating
2024-01-11 06:33:49.843 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:49.844 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:49.844 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.6) min is < 5 min -> forget the regulation send
2024-01-11 06:33:50.528 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hv
ac_action=idle, old_hvac_action=idle
2024-01-11 06:33:50.530 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:51.021 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:51.023 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled2024-01-11 06:33:51.024 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:51.024 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.6) min is < 5 min -> forget the regulation send
2024-01-11 06:33:52.043 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_h
vac_action=idle, old_hvac_action=idle
2024-01-11 06:33:52.551 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:52.553 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:52.866 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hvac_action=heating, old_hvac_action=heating
2024-01-11 06:33:52.867 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:52.868 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:52.868 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.6) min is < 5 min -> forget the regulation send
2024-01-11 06:33:53.577 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:53.580 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:54.084 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=off, new_hvac_action=idle, old_hvac_action=idle
2024-01-11 06:33:54.087 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Window auto event is ignored because bypass is ON or window auto detection is disabled
2024-01-11 06:33:54.088 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
2024-01-11 06:33:54.088 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - period (0.6) min is < 5 min -> forget the regulation send
2024-01-11 06:33:55.131 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle

[skipped many more lines like that]
gpayer commented 10 months ago

I did some digging and I assume the problem is that async_set_hvac_mode does not have a protection against running two times in parallel. There should be some hvac_mode_change_in_progress flag. Until the total system state settles more calls to async_set_hvac_mode should simply wait. E.g. method _async_climate_changed in thermostat_climate.py can handle the detection when the underlying thermostats are in sync with VTherm. I assume there are similar methods in the other implementations.

jmcollin78 commented 10 months ago

Hello @gpayer ,

I had already this issue in the past and have done some improvements to avoid it. See https://github.com/jmcollin78/versatile_thermostat/issues/121, https://github.com/jmcollin78/versatile_thermostat/issues/95.

So I'm very surprise you ran into this case once more.

This is a severe issue than make HA unusable and I will need your help to understand how it is possible.

Are your 3 underlying devices the same brand and type ? underlying_climate_0: climate.thermostat_wohnzimmer_fenster_links underlying_climate_1: climate.thermostat_wohnzimmer_fenster_rechts underlying_climate_2: climate.thermostat_wohnzimmer_mitte

or have you different climate of different brands with different behavior ?

In there are not the same, I guess this is possible to ran into this case and I would recommend to build 3 VTherm and not only one with 3 devices. I know it is annoying but before I (with your help) find the case, this could takes a long time.

I will have more investigation this week end so be patient please (and maybe build 3 VTherm while waiting for a complete fix).

jmcollin78 commented 10 months ago

I see you are in 5.2.0. Can you do the further test in 5.2.1 ? This will be easier to map the code with your logs.

gpayer commented 10 months ago

As soon as HACS offer the new version, I will upgrade. The thermostats are all the same brand and type and firmware version (Bosch BTH-RA). Thanks for the idea to use 3 VTherms, I might try that! VTherms with only one underlying device seem to be unaffected by this bug.

For joining the debugging and development effort, do you have any good ideas how to that? Like, are there mockup climate devices I can integrate into a test setup?

jmcollin78 commented 10 months ago

5.2.1 have been released this week-end. It should definitively be available now.

For joining the debugging and development effort, do you have any good ideas how to that? Like, are there mockup climate devices I can integrate into a test setup?

Yes. There is full unitary tests framework you can have a look. It is in the dir /tests. If you want to start slowy, try to look at test_start.py which is basic start of VTherm with mocks.

Mocks are in the tests/commons.py.

Of course the first thing you have to do is to fork/clone the repo on the main branch, start devcontainer and run all the tests with the test explorator: Capture d’écran 2024-01-12 à 08 35 19

All should be green before you start something.

Feel free to ask more questions if needed.

gpayer commented 10 months ago

I solved the 5.2.0/5.2.1 mystery, in github there is a 5.2.1 tag, but the manfest.json included in this commit still has version 5.2.0 in it.

jmcollin78 commented 10 months ago

I solved the 5.2.0/5.2.1 mystery, in github there is a 5.2.1 tag, but the manfest.json included in this commit still has version 5.2.0 in it.

And HACS don't see the change ? So nobody have installed the 5.2.1 👎

I will fix that

jmcollin78 commented 10 months ago

Should be a 5.2.2 visible.

jmcollin78 commented 10 months ago

After looking more in details of your case, here is what I saw:

2024-01-11 06:33:16.073

Thermostat Wohnzimmer - Set hvac mode: heat
Thermostat Wohnzimmer - Calling ThermostatClimate._send_regulated_temperature force=False
Thermostat Wohnzimmer - regulation calculation will be done
Thermostat Wohnzimmer - Regulated temp have changed to 23.0. Resend it to underlyings
Thermostat Wohnzimmer - Sending event EventType.HVAC_MODE_EVENT with data: {'hvac_mode': <HVACMode.HEAT: 'heat'>}
Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off, current_hvac_mode=heat, new_hvac_action=idle, old_hvac_action=idle
Thermostat Wohnzimmer - underlying event is received less than 10 sec after command. Forget it to avoid loop
  1. VT switch to heat mode (and sends heat to underlying of Wohnzimmer),
  2. VT sends regulation target temperature to underlying to 23°,
  3. In the same second, one of the underlying says "i switch to off". New hvac_mode is off.

Then Vtherm should switch to off to follow the underlying state change. But because hvac_mode have been manually set to heat just before, this return is ignored (this is the throttle feature I speak above).

So what is weird here is that VTherm send hvac_mode heat and the underlying says "ok I'm off". This is the first point (but correctly managed by the throttling feature).

One second after, you send an hvac_off off command (I guess you change your mind or something like that):

2024-01-11 06:33:17.741 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-V Thermostat Wohnzimmer - Set hvac mode: off

and then it the mess because some all of the underlying are not synchronized (some are managing the first hvac_heat command I guess):

2024-01-11 06:33:35.710 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat

VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat,

VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is off,

VersatileThermostat-V Thermostat Wohnzimmer - Underlying climate changed. Event.new_hvac_mode is heat,

3 are in heat and one is off. And because 06:33:35 is > 06:33:17 + 10sec, this return is taken into account. So VTherm takes this change as it have been done directly on underlying, and the loop starts.

The main reason is that your underlying react to the second hvac_off command with 18 sec late which is > of the 10 sec of throttling and are not synchronized.

On the other hand, I've got some users that are annoying by this 10 sec throttling because its preventing from changing the target temperature on a physical thermostat (see #331).

jmcollin78 commented 10 months ago

If you look at the code at thermostat_climate.py line 661, you will see that:

# Issue #120 - Some TRV are changing target temperature a very long time (6 sec) after the change.
# In that case a loop is possible if a user change multiple times during this 6 sec.

This is exactly your case but with 18 sec and not 6 sec. I suppose this is because of the hvac_heat just one second before the hvac_off command from HA. TRV are long to change their internal state.

Maybe I should ignore command from HA if all underlyings are not synchronized (which means a previous command is running).

gpayer commented 10 months ago

Just a quick reply from my phone: yes, this is exactly what I was thinking about. hvac_mode should not be derived from the underlyings. Unless maybe configured to do so.

It would be better to have a master hvac_mode and a derived effective_hvac_mode from the underlyings. The latter one can be used for the frontend visualization.

With temperature this is much less of a problem, this can actually be derived from the underlyings.

Waiting until all underlyings are in sync is another important safety layer.

Thanks for your effort, I really appreciate it!

Jean-Marc Collin @.***> schrieb am Sa., 13. Jan. 2024, 10:21:

If you look at the code at thermostat_climate.py line 661, you will see that:

Issue #120 - Some TRV are changing target temperature a very long time (6 sec) after the change.

In that case a loop is possible if a user change multiple times during this 6 sec.

This is exactly your case but with 18 sec and not 6 sec. I suppose this is because of the hvac_heat just one second before the hvac_off command from HA. TRV are long to change their internal state.

Maybe I should ignore command from HA if all underlyings are not synchronized (which means a previous command is running).

— Reply to this email directly, view it on GitHub https://github.com/jmcollin78/versatile_thermostat/issues/334#issuecomment-1890391987, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANIEFT2WNYU5GLID45QTDDYOJGYDAVCNFSM6AAAAABBWXGAOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJQGM4TCOJYG4 . You are receiving this because you were mentioned.Message ID: @.***>

jmcollin78 commented 10 months ago

Hello @gpayer,

I try a fix that should work and robustify once more the loop issue. This is embedded in this release: https://github.com/jmcollin78/versatile_thermostat/releases/tag/5.2.3.beta1

Can you please give it a try because I cannot reproduce this in my environment ?

To be significant, you should:

  1. put the Versatile Thermostat log level to debug (in your configuration.yaml add something like:
    logger:
    default: info
    logs:
        custom_components.versatile_thermostat: debug
  2. have a VTherm over_climate with multiple underlying climate entities,
  3. stop the VTherm (with the HA interface),
  4. immedialty after stop, try to set the Heat mode (with the HA interface)

If this loop one again (always possible), you can just reload all VTherm entities with the Dev Tools / Reload configuration / Versatile Thermostat. It will stop the loop.

After the test (ok or not), I would you to send me the logs so that I will have the proof that the bug is now fixed.

Thanks a lot for your help !

After the test don't forget to put the log level back to INFO, VTherm is very verbose in debug mode.

gpayer commented 10 months ago

Ok, I'll test it, but due to external circumstances, I won't be able to test it until this evening or tomorrow.

And one stupid question, how can I upgrade to a beta version?

Thank you!

Jean-Marc Collin @.***> schrieb am Sa., 13. Jan. 2024, 12:39:

Hello @gpayer https://github.com/gpayer,

I try a fix that should work and robustify once more the loop issue. This is embedded in this release: https://github.com/jmcollin78/versatile_thermostat/releases/tag/5.2.3.beta1

Can you please give it a try because I cannot reproduce this in my environment ?

To be significant, you should:

  1. put the Versatile Thermostat log level to debug (in your configuration.yaml add something like:

logger: default: info logs: custom_components.versatile_thermostat: debug

  1. have a VTherm over_climate with multiple underlying climate entities,
  2. stop the VTherm (with the HA interface),
  3. immedialty after stop, try to set the Heat mode (with the HA interface)

If this loop one again (always possible), you can just reload all VTherm entities with the Dev Tools / Reload configuration / Versatile Thermostat. It will stop the loop.

After the test (ok or not), I would you to send me the logs so that I will have the proof that the bug is now fixed.

Thanks a lot for your help !

— Reply to this email directly, view it on GitHub https://github.com/jmcollin78/versatile_thermostat/issues/334#issuecomment-1890426528, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANIEFS6ELZDR6M6BHYUTBDYOJW6JAVCNFSM6AAAAABBWXGAOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJQGQZDMNJSHA . You are receiving this because you were mentioned.Message ID: @.***>

jmcollin78 commented 10 months ago

In hacs you have to select the integration click on the menu and select 'download' (retélécharger in French). Then you will be able to check 'Display beta release' and to select the beta release.

Tomorrow this will be perfect.

Thank you for your help.

Capture d’écran 2024-01-13 à 16 27 28

Capture d’écran 2024-01-13 à 16 28 11

gpayer commented 10 months ago

I was able to trigger your new failsafe by switching the VTherm wildly between heat and off, so everything worked very well! After this the underlying thermostats are not in sync, but this is perfectly fine as it is the expected behaviour. It's very easy to fix this via the app.

Your code change is very nice as well, if we were in the same team and I were to do the code review, I would merge it without further discussion. :smiley:

jmcollin78 commented 10 months ago

Thank you for your fine report !

If you want, we could be in the same team and if think so I would be please to propose a review to reviewer. I'm alone to code and review which is certainly not a good practice.

jmcollin78 commented 10 months ago

I have a major enhancement running (central boiler control) and then I will release hopefully next week. Keep you beta until the release.

gpayer commented 10 months ago

Thank you for your fine report !

If you want, we could be in the same team and if think so I would be please to propose a review to reviewer. I'm alone to code and review which is certainly not a good practice.

Sure, you can add me as reviewer!

jmcollin78 commented 10 months ago

https://github.com/jmcollin78/versatile_thermostat/releases/tag/5.3.3