mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Set automation last_triggered earlier (#35671)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
eba5b50e58
commit
dcb04acc65
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user