jmcollin78 / versatile_thermostat

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

Prevent “Heating will be disabled” warning loop while HVACMode is OFF #374

Closed pdcastro closed 9 months ago

pdcastro commented 9 months ago

My Home Assistant logs were full of the following warning messages (printed about every 30 seconds) even though Versatile Thermostat was turned off (self._hvac_mode is HVACMode.OFF):

2024-02-04 17:02:53.951 WARNING (MainThread) [custom_components.versatile_thermostat.prop_algorithm] Proportional algorithm: calculation is not possible cause target_temp or current_temp is null. Heating/cooling will be disabled
2024-02-04 17:03:23.946 WARNING (MainThread) [custom_components.versatile_thermostat.prop_algorithm] Proportional algorithm: calculation is not possible cause target_temp or current_temp is null. Heating/cooling will be disabled
2024-02-04 17:03:53.978 WARNING (MainThread) [custom_components.versatile_thermostat.prop_algorithm] Proportional algorithm: calculation is not possible cause target_temp or current_temp is null. Heating/cooling will be disabled
...

current_temp was indeed None, because I had unplugged a MQTT heater + temperature sensor from the wall socket while it was not being used.

It is a useful warning message while Versatile Thermostat is turned on (HVACMode.HEAT, HVACMode.COOL), but I think it is counterproductive while Versatile Thermostat is turned off (HVACMode.OFF). Warning that “Heating/cooling will be disabled” when the user has already turned heating/cooling off is redundant. The warning that target_temp or current_temp are null is interesting but not in a loop while HVACMode is OFF, in a scenario like mine where the controlled heater + temperature sensors were unplugged.

This PR proposes dynamically amending the log level of that message depending on the on/off state of Versatile Thermostat.