Cleanup and simplitfy the async state update (#9390)
* Cleanup and simplitfy the async state update * Update test_entity.py
This commit is contained in:
1 parent
c84a099b0f
commit
90f9a6bc0a
47 files changed
+128
-102
No files matched your search
@@ -103,7 +103,7 @@ class SwitchTemplate(SwitchDevice):
|
||||
@callback
|
||||
def template_switch_state_listener(entity, old_state, new_state):
|
||||
"""Handle target device state changes."""
|
||||
self.hass.async_add_job(self.async_update_ha_state(True))
|
||||
self.async_schedule_update_ha_state(True)
|
||||
|
||||
@callback
|
||||
def template_switch_startup(event):
|
||||
@@ -111,7 +111,7 @@ class SwitchTemplate(SwitchDevice):
|
||||
async_track_state_change(
|
||||
self.hass, self._entities, template_switch_state_listener)
|
||||
|
||||
self.hass.async_add_job(self.async_update_ha_state(True))
|
||||
self.async_schedule_update_ha_state(True)
|
||||
|
||||
self.hass.bus.async_listen_once(
|
||||
EVENT_HOMEASSISTANT_START, template_switch_startup)
|
||||
|
||||
Reference in new issue
Block a user