ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
352 stars 50 forks source link

Fix of visual feedback of IDLE/HEATING state when using valve and pwm is zero #166

Closed bemobolo closed 12 months ago

bemobolo commented 12 months ago

Issue: In the current implementation of the hvac_action property the _is_device_activeproperty is used to decide whether the device is active or not. But _is_device_active property only checks if the (toggle) heating entity state is OFF or ON. When setting pwm: 0 the heating entity is considered a valve like entity which is able to accept values between 0-100 and therefore it does not have ON/OFF states. As a consequence in pwm: 0 mode the _is_device_active property returns always false -> the hvac_action is always IDLE even if the control_output is above 0 or even when it's 100. Fix: There is a branch added to _is_device_active to check whether we're in pwm mode or not (aka. toggle or valve device is used) and if non pwm mode then the return value of the property is based on the float value of the valve device state (ON if state > 0, OFF if state == 0).

ScratMan commented 12 months ago

Hello, thanks for the fix. But "inverted" is useless when state is "analog" 0/100. You should remove the ==0 option and if pm == 0, only return True if state is >0

bemobolo commented 12 months ago

Thank you, I've made the requested changes!