From b7bf07eaca92f5c948a5868578c61b707e8ed946 Mon Sep 17 00:00:00 2001 From: Gianluca Barbaro Date: Wed, 18 Jan 2017 12:20:39 +0100 Subject: [PATCH] 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. --- homeassistant/components/climate/generic_thermostat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/components/climate/generic_thermostat.py b/homeassistant/components/climate/generic_thermostat.py index a40795c37c5..a61c71a6551 100644 --- a/homeassistant/components/climate/generic_thermostat.py +++ b/homeassistant/components/climate/generic_thermostat.py @@ -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):