Set automation last_triggered earlier (#35671)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
1 parent
eba5b50e58
commit
dcb04acc65
1 file changed
+2
-3
@@ -389,6 +389,8 @@ class AutomationEntity(ToggleEntity, RestoreEntity):
|
||||
trigger_context = Context(parent_id=parent_id)
|
||||
|
||||
self.async_set_context(trigger_context)
|
||||
self._last_triggered = utcnow()
|
||||
self.async_write_ha_state()
|
||||
self.hass.bus.async_fire(
|
||||
EVENT_AUTOMATION_TRIGGERED,
|
||||
{ATTR_NAME: self._name, ATTR_ENTITY_ID: self.entity_id},
|
||||
@@ -402,9 +404,6 @@ class AutomationEntity(ToggleEntity, RestoreEntity):
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
|
||||
self._last_triggered = utcnow()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
"""Remove listeners when removing automation from Home Assistant."""
|
||||
await super().async_will_remove_from_hass()
|
||||
|
||||
Reference in new issue
Block a user