Update generic_thermostat.py
As suggested, I added a callback on the heater switch state change. Still it doesn't solve the problem.pull/5420/head
parent
72dca1da09
commit
a87d653077
|
@ -5,7 +5,6 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/climate.generic_thermostat/
|
||||
"""
|
||||
import logging
|
||||
import time
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -88,6 +87,7 @@ class GenericThermostat(ClimateDevice):
|
|||
self._unit = hass.config.units.temperature_unit
|
||||
|
||||
track_state_change(hass, sensor_entity_id, self._sensor_changed)
|
||||
track_state_change(hass, heater_entity_id, self._switch_changed)
|
||||
|
||||
sensor_state = hass.states.get(sensor_entity_id)
|
||||
if sensor_state:
|
||||
|
@ -166,6 +166,12 @@ class GenericThermostat(ClimateDevice):
|
|||
self._control_heating()
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def _switch_changed(self, entity_id, old_state, new_state):
|
||||
"""Called when heater switch changes state."""
|
||||
if new_state is None:
|
||||
return
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def _update_temp(self, state):
|
||||
"""Update thermostat with latest state from sensor."""
|
||||
unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||
|
@ -223,7 +229,6 @@ 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):
|
||||
|
|
Loading…
Reference in New Issue