jmcollin78 / versatile_thermostat

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

Temperature change loop in ac mode #493

Open anpavlov opened 1 week ago

anpavlov commented 1 week ago

Tried versatile thermostat for my ac, after setup with the "use internal temperature of the underlying" i encountered a loop of set temperature:

I added debug log to print old_state in _async_climate_changed, which triggers the loop. My bet the problem is that the only attribute that changes is current_temperature (internal temperature of ac), as it naturally lowers after ac is started. Then because underlying climate target temp is lower than VTherm setpoint, _async_climate_changed thinks new temperature is set in underlying ac and updates VTherm setpoint

Debug log

2024-09-04 21:32:55.045 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Кабинет умный кондей - _async_climate_changed new_state is <state climate.cabinet_ac=cool; hvac_modes=[<HVACMode.OFF: 'off'>, <HVACMode.HEAT_COOL: 'heat_cool'>, <HVACMode.COOL: 'cool'>, <HVACMode.HEAT: 'heat'>, <HVACMode.FAN_ONLY: 'fan_only'>, <HVACMode.DRY: 'dry'>], min_temp=16.0, max_temp=32.0, target_temp_step=0.5, fan_modes=['auto', 'low', 'medium', 'high', 'mute', 'turbo'], preset_modes=['none', 'sleep', 'Antifungus', 'Clean', 'Health'], swing_modes=['off', 'both', 'vertical', 'horizontal'], current_temperature=23.5, temperature=21.0, fan_mode=auto, hvac_action=cooling, preset_mode=none, swing_mode=off, friendly_name=Cabinet AC, supported_features=441 @ 2024-09-04T21:30:49.633837+03:00>
2024-09-04 21:32:55.046 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Кабинет умный кондей - _async_climate_changed old_state is <state climate.cabinet_ac=cool; hvac_modes=[<HVACMode.OFF: 'off'>, <HVACMode.HEAT_COOL: 'heat_cool'>, <HVACMode.COOL: 'cool'>, <HVACMode.HEAT: 'heat'>, <HVACMode.FAN_ONLY: 'fan_only'>, <HVACMode.DRY: 'dry'>], min_temp=16.0, max_temp=32.0, target_temp_step=0.5, fan_modes=['auto', 'low', 'medium', 'high', 'mute', 'turbo'], preset_modes=['none', 'sleep', 'Antifungus', 'Clean', 'Health'], swing_modes=['off', 'both', 'vertical', 'horizontal'], current_temperature=24.0, temperature=21.0, fan_mode=auto, hvac_action=cooling, preset_mode=none, swing_mode=off, friendly_name=Cabinet AC, supported_features=441 @ 2024-09-04T21:30:49.633837+03:00>
2024-09-04 21:32:55.048 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Кабинет умный кондей - Underlying climate climate.cabinet_ac changed. Event.new_hvac_mode is cool, current_hvac_mode=cool, new_hvac_action=cooling, old_hvac_action=cooling
2024-09-04 21:32:55.048 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Кабинет умный кондей - last_change_time=2024-09-04 21:32:13.046773+03:00 old_state_date_changed=2024-09-04 18:30:49.633837+00:00 old_state_date_updated=2024-09-04 18:32:13.713193+00:00 new_state_date_changed=2024-09-04 18:30:49.633837+00:00 new_state_date_updated=2024-09-04 18:32:55.042743+00:00
2024-09-04 21:32:55.049 DEBUG (MainThread) [custom_components.versatile_thermostat.thermostat_climate] Do temperature check. temperature is 22.5, new_state.attributes is {'hvac_modes': [<HVACMode.OFF: 'off'>, <HVACMode.HEAT_COOL: 'heat_cool'>, <HVACMode.COOL: 'cool'>, <HVACMode.HEAT: 'heat'>, <HVACMode.FAN_ONLY: 'fan_only'>, <HVACMode.DRY: 'dry'>], 'min_temp': 16.0, 'max_temp': 32.0, 'target_temp_step': 0.5, 'fan_modes': ['auto', 'low', 'medium', 'high', 'mute', 'turbo'], 'preset_modes': ['none', 'sleep', 'Antifungus', 'Clean', 'Health'], 'swing_modes': ['off', 'both', 'vertical', 'horizontal'], 'current_temperature': 23.5, 'temperature': 21.0, 'fan_mode': 'auto', 'hvac_action': <HVACAction.COOLING: 'cooling'>, 'preset_mode': 'none', 'swing_mode': 'off', 'friendly_name': 'Cabinet AC', 'supported_features': <ClimateEntityFeature.TARGET_TEMPERATURE|FAN_MODE|PRESET_MODE|SWING_MODE|TURN_OFF|TURN_ON: 441>}
2024-09-04 21:32:55.061 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Кабинет умный кондей - Target temp in underlying have change to 21.0
2024-09-04 21:32:55.062 INFO (MainThread) [custom_components.versatile_thermostat.base_thermostat] VersatileThermostat-Кабинет умный кондей - Set target temp: 21.0
2024-09-04 21:32:55.062 INFO (MainThread) [custom_components.versatile_thermostat.thermostat_climate] VersatileThermostat-Кабинет умный кондей - Calling ThermostatClimate._send_regulated_temperature force=True

Configuration

My VTherm attributes are the following:

hvac_modes: off, heat_cool, cool, heat, fan_only, dry
min_temp: 16
max_temp: 30
target_temp_step: 0.5
fan_modes: auto, low, medium, high, mute, turbo
preset_modes: none, frost, eco, comfort, boost
swing_modes: off, both, vertical, horizontal
current_temperature: 25.3
temperature: 19
fan_mode: auto
hvac_action: off
preset_mode: none
swing_mode: off
is_on: false
hvac_mode: off
type: null
is_controlled_by_central_mode: false
last_central_mode: null
frost_temp: 30
eco_temp: 30
boost_temp: 30
comfort_temp: 30
frost_away_temp: 0
eco_away_temp: 0
boost_away_temp: 0
comfort_away_temp: 0
power_temp: null
target_temperature_step: 0.5
ext_current_temperature: 17
ac_mode: true
current_power: null
current_power_max: null
saved_preset_mode: none
saved_target_temp: 20.5
saved_hvac_mode: null
motion_sensor_entity_id: null
motion_state: null
power_sensor_entity_id: null
max_power_sensor_entity_id: null
overpowering_state: null
presence_sensor_entity_id: null
presence_state: null
window_state: off
window_auto_state: off
window_bypass_state: false
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
window_action: window_turn_off
security_delay_min: 60
security_min_on_percent: 0.5
security_default_on_percent: 0.1
last_temperature_datetime: 2024-09-04T22:13:25.469717+03:00
last_ext_temperature_datetime: 2024-09-04T21:48:32.320515+03:00
security_state: false
minimal_activation_delay_sec: 10
device_power: 1
mean_cycle_power: null
total_energy: 0.04
last_update_datetime: 2024-09-04T22:13:25.491035+03:00
timezone: Europe/Moscow
temperature_unit: °C
is_device_active: false
ema_temp: 25.31
is_used_by_central_boiler: false
is_over_climate: true
start_hvac_action_date: null
underlying_climate_0: climate.cabinet_ac
underlying_climate_1: null
underlying_climate_2: null
underlying_climate_3: null
auto_fan_mode: auto_fan_none
current_auto_fan_mode: auto_fan_none
auto_activated_fan_mode: null
auto_deactivated_fan_mode: null
auto_regulation_use_device_temp: true
friendly_name: Кабинет умный кондей
supported_features: 441
jmcollin78 commented 6 days ago

Really strange. It's look like a bug. I have pretty the same configuration without this behavior.