still update sensor on startup (#17319)
This commit is contained in:
1 parent
f5d3aa1826
commit
ebff253cc9
2 files changed
+20
-11
No files matched your search
@@ -137,10 +137,6 @@ class SensorTemplate(Entity):
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
# We don't render on every update
|
||||
if self._entities == MATCH_ALL:
|
||||
return
|
||||
|
||||
@callback
|
||||
def template_sensor_state_listener(entity, old_state, new_state):
|
||||
"""Handle device state changes."""
|
||||
@@ -149,8 +145,10 @@ class SensorTemplate(Entity):
|
||||
@callback
|
||||
def template_sensor_startup(event):
|
||||
"""Update template on startup."""
|
||||
async_track_state_change(
|
||||
self.hass, self._entities, template_sensor_state_listener)
|
||||
if self._entities != MATCH_ALL:
|
||||
# Track state change only for valid templates
|
||||
async_track_state_change(
|
||||
self.hass, self._entities, template_sensor_state_listener)
|
||||
|
||||
self.async_schedule_update_ha_state(True)
|
||||
|
||||
|
||||
Reference in new issue
Block a user