Merge pull request #1488 from balloob/template_component_fix
Fix noisy error on template component startup.pull/1278/merge
commit
4c64be5cfa
|
@ -90,6 +90,8 @@ class BinarySensorTemplate(BinarySensorDevice):
|
|||
hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
|
||||
|
||||
def _event_listener(self, event):
|
||||
if not hasattr(self, 'hass'):
|
||||
return
|
||||
self.update_ha_state(True)
|
||||
|
||||
@property
|
||||
|
|
|
@ -86,12 +86,13 @@ class SensorTemplate(Entity):
|
|||
self._unit_of_measurement = unit_of_measurement
|
||||
self._template = state_template
|
||||
self.update()
|
||||
self.hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
|
||||
|
||||
def _update_callback(_event):
|
||||
""" Called when the target device changes state. """
|
||||
self.update_ha_state(True)
|
||||
|
||||
self.hass.bus.listen(EVENT_STATE_CHANGED, _update_callback)
|
||||
def _event_listener(self, event):
|
||||
""" Called when the target device changes state. """
|
||||
if not hasattr(self, 'hass'):
|
||||
return
|
||||
self.update_ha_state(True)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -100,12 +100,13 @@ class SwitchTemplate(SwitchDevice):
|
|||
self._on_action = on_action
|
||||
self._off_action = off_action
|
||||
self.update()
|
||||
self.hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
|
||||
|
||||
def _update_callback(_event):
|
||||
"""Called when the target device changes state."""
|
||||
self.update_ha_state(True)
|
||||
|
||||
self.hass.bus.listen(EVENT_STATE_CHANGED, _update_callback)
|
||||
def _event_listener(self, event):
|
||||
""" Called when the target device changes state. """
|
||||
if not hasattr(self, 'hass'):
|
||||
return
|
||||
self.update_ha_state(True)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
Loading…
Reference in New Issue