Update generic_thermostat.py

After _control_heating() is executed, current_operation() is correctly called but _is_device_active() still reports the old state if the heater switch, at least in my case. The resulting climate state is incorrect until the next refresh, which apparently occurs only when _sensor_changed() gets called (it can be minutes after).

I think the state of the heater switch should be forced to update at the end of  _control_heating(), but I don't know how to do that...
A simple sleep() fixes it, but obviously is just a temporary workaround, I'm not really expecting this PR to be actually committed, unless there's no other solution.
This commit is contained in:
Gianluca Barbaro 2017-01-18 12:20:39 +01:00 committed by GitHub
parent 3267aa8c08
commit b7bf07eaca

View File

@ -16,6 +16,7 @@ from homeassistant.const import (
from homeassistant.helpers import condition
from homeassistant.helpers.event import track_state_change
import homeassistant.helpers.config_validation as cv
import time
_LOGGER = logging.getLogger(__name__)
@ -222,6 +223,7 @@ class GenericThermostat(ClimateDevice):
if too_cold:
_LOGGER.info('Turning on heater %s', self.heater_entity_id)
switch.turn_on(self.hass, self.heater_entity_id)
time.sleep(.1)
@property
def _is_device_active(self):