Remove unneeded entity_id check and blank lines.
This commit is contained in:
parent
b20d3f8b3a
commit
ced380f0cd
2 changed files with 2 additions and 11 deletions
|
@ -94,10 +94,7 @@ class SensorTemplate(Entity):
|
||||||
|
|
||||||
def _update_callback(_event):
|
def _update_callback(_event):
|
||||||
""" Called when the target device changes state. """
|
""" Called when the target device changes state. """
|
||||||
# This can be called before the entity is properly
|
self.update_ha_state(True)
|
||||||
# initialised, so check before updating state,
|
|
||||||
if self.entity_id:
|
|
||||||
self.update_ha_state(True)
|
|
||||||
|
|
||||||
self.hass.bus.listen(EVENT_STATE_CHANGED, _update_callback)
|
self.hass.bus.listen(EVENT_STATE_CHANGED, _update_callback)
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,8 @@ from homeassistant.const import (
|
||||||
CONF_VALUE_TEMPLATE)
|
CONF_VALUE_TEMPLATE)
|
||||||
|
|
||||||
from homeassistant.helpers.service import call_from_config
|
from homeassistant.helpers.service import call_from_config
|
||||||
|
|
||||||
from homeassistant.util import template, slugify
|
from homeassistant.util import template, slugify
|
||||||
|
|
||||||
from homeassistant.exceptions import TemplateError
|
from homeassistant.exceptions import TemplateError
|
||||||
|
|
||||||
from homeassistant.components.switch import DOMAIN
|
from homeassistant.components.switch import DOMAIN
|
||||||
|
|
||||||
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
||||||
|
@ -117,10 +114,7 @@ class SwitchTemplate(SwitchDevice):
|
||||||
|
|
||||||
def _update_callback(_event):
|
def _update_callback(_event):
|
||||||
""" Called when the target device changes state. """
|
""" Called when the target device changes state. """
|
||||||
# This can be called before the entity is properly
|
self.update_ha_state(True)
|
||||||
# initialised, so check before updating state,
|
|
||||||
if self.entity_id:
|
|
||||||
self.update_ha_state(True)
|
|
||||||
|
|
||||||
self.hass.bus.listen(EVENT_STATE_CHANGED, _update_callback)
|
self.hass.bus.listen(EVENT_STATE_CHANGED, _update_callback)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue