diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 1733f272229..b94029db4ee 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -272,6 +272,8 @@ async def async_setup(hass, config): class AutomationEntity(ToggleEntity, RestoreEntity): """Entity to show status of entity.""" + _attr_should_poll = False + def __init__( self, automation_id, @@ -287,8 +289,7 @@ class AutomationEntity(ToggleEntity, RestoreEntity): trace_config, ): """Initialize an automation entity.""" - self._id = automation_id - self._name = name + self._attr_name = name self._trigger_config = trigger_config self._async_detach_triggers = None self._cond_func = cond_func @@ -304,21 +305,7 @@ class AutomationEntity(ToggleEntity, RestoreEntity): self._raw_config = raw_config self._blueprint_inputs = blueprint_inputs self._trace_config = trace_config - - @property - def name(self): - """Name of the automation.""" - return self._name - - @property - def unique_id(self): - """Return unique ID.""" - return self._id - - @property - def should_poll(self): - """No polling needed for automation entities.""" - return False + self._attr_unique_id = automation_id @property def extra_state_attributes(self): @@ -330,8 +317,8 @@ class AutomationEntity(ToggleEntity, RestoreEntity): } if self.action_script.supports_max: attrs[ATTR_MAX] = self.action_script.max_runs - if self._id is not None: - attrs[CONF_ID] = self._id + if self.unique_id is not None: + attrs[CONF_ID] = self.unique_id return attrs @property @@ -496,7 +483,7 @@ class AutomationEntity(ToggleEntity, RestoreEntity): self.async_set_context(trigger_context) event_data = { - ATTR_NAME: self._name, + ATTR_NAME: self.name, ATTR_ENTITY_ID: self.entity_id, } if "trigger" in variables and "description" in variables["trigger"]: @@ -580,7 +567,7 @@ class AutomationEntity(ToggleEntity, RestoreEntity): """Set up the triggers.""" def log_cb(level, msg, **kwargs): - self._logger.log(level, "%s %s", msg, self._name, **kwargs) + self._logger.log(level, "%s %s", msg, self.name, **kwargs) variables = None if self._trigger_variables: @@ -597,7 +584,7 @@ class AutomationEntity(ToggleEntity, RestoreEntity): self._trigger_config, self.async_trigger, DOMAIN, - self._name, + str(self.name), log_cb, home_assistant_start, variables,