diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 9fabe0e2206..8b2c036034b 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -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()