Template switch change flow / add restore (#6356)
* Template switch change flow / add restore * fix tests * fix binary_sensor template
This commit is contained in:
parent
597ae2e716
commit
55dc483c91
4 changed files with 128 additions and 12 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue