Migrate script entities to use more shorthand attrs (#115245)
parent
59d92f16bd
commit
1de1e413a9
|
@ -459,15 +459,10 @@ class UnavailableScriptEntity(BaseScriptEntity):
|
|||
raw_config: ConfigType | None,
|
||||
) -> None:
|
||||
"""Initialize a script entity."""
|
||||
self._name = raw_config.get(CONF_ALIAS, key) if raw_config else key
|
||||
self._attr_name = raw_config.get(CONF_ALIAS, key) if raw_config else key
|
||||
self._attr_unique_id = key
|
||||
self.raw_config = raw_config
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the entity."""
|
||||
return self._name
|
||||
|
||||
@cached_property
|
||||
def referenced_labels(self) -> set[str]:
|
||||
"""Return a set of referenced labels."""
|
||||
|
@ -503,6 +498,7 @@ class ScriptEntity(BaseScriptEntity, RestoreEntity):
|
|||
"""Representation of a script entity."""
|
||||
|
||||
icon = None
|
||||
_attr_should_poll = False
|
||||
|
||||
def __init__(self, hass, key, cfg, raw_config, blueprint_inputs):
|
||||
"""Initialize the script."""
|
||||
|
@ -531,16 +527,7 @@ class ScriptEntity(BaseScriptEntity, RestoreEntity):
|
|||
self.raw_config = raw_config
|
||||
self._trace_config = cfg[CONF_TRACE]
|
||||
self._blueprint_inputs = blueprint_inputs
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the entity."""
|
||||
return self.script.name
|
||||
self._attr_name = self.script.name
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
|
|
Loading…
Reference in New Issue