Template switch change flow / add restore (#6356)

* Template switch change flow / add restore

* fix tests

* fix binary_sensor template
This commit is contained in:
Pascal Vizeli authored and GitHub committed 2017-03-02 14:09:53 +01:00
1 parent 597ae2e716
commit 55dc483c91
4 files changed
+128 -12

No files matched your search

@@ -16,7 +16,7 @@ from homeassistant.components.binary_sensor import (
from homeassistant.const import (
ATTR_FRIENDLY_NAME, ATTR_ENTITY_ID, CONF_VALUE_TEMPLATE,
CONF_SENSOR_CLASS, CONF_SENSORS, CONF_DEVICE_CLASS,
EVENT_HOMEASSISTANT_START)
EVENT_HOMEASSISTANT_START, STATE_ON)
from homeassistant.exceptions import TemplateError
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.deprecation import get_deprecated
@@ -92,7 +92,7 @@ class BinarySensorTemplate(BinarySensorDevice):
"""Register callbacks."""
state = yield from async_get_last_state(self.hass, self.entity_id)
if state:
self._state = state.state
self._state = state.state == STATE_ON
@callback
def template_bsensor_state_listener(entity, old_state, new_state):