Restore target temperature for generic thermostat (#10635)
* Restore target temp for generic thermostat * Fix lint
This commit is contained in:
parent
be5f0fb3ac
commit
68d2076b56
2 changed files with 37 additions and 2 deletions
|
@ -21,6 +21,7 @@ from homeassistant.helpers import condition
|
|||
from homeassistant.helpers.event import (
|
||||
async_track_state_change, async_track_time_interval)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.restore_state import async_get_last_state
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -117,6 +118,17 @@ class GenericThermostat(ClimateDevice):
|
|||
if sensor_state:
|
||||
self._async_update_temp(sensor_state)
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_added_to_hass(self):
|
||||
"""Run when entity about to be added."""
|
||||
# If we have an old state and no target temp, restore
|
||||
if self._target_temp is None:
|
||||
old_state = yield from async_get_last_state(self.hass,
|
||||
self.entity_id)
|
||||
if old_state is not None:
|
||||
self._target_temp = float(
|
||||
old_state.attributes[ATTR_TEMPERATURE])
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Return the polling state."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue