mirror of
https://github.com/home-assistant/core.git
synced 2025-05-04 14:09:16 +00:00
Migrate group to use shorthand attributes for name and icon (#115244)
This commit is contained in:
parent
95958ac0ef
commit
aa85e59c6f
@ -277,11 +277,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
await group.async_update_tracked_entity_ids(entity_ids)
|
||||
|
||||
if ATTR_NAME in service.data:
|
||||
group.name = service.data[ATTR_NAME]
|
||||
group.set_name(service.data[ATTR_NAME])
|
||||
need_update = True
|
||||
|
||||
if ATTR_ICON in service.data:
|
||||
group.icon = service.data[ATTR_ICON]
|
||||
group.set_icon(service.data[ATTR_ICON])
|
||||
need_update = True
|
||||
|
||||
if ATTR_ALL in service.data:
|
||||
|
@ -150,9 +150,9 @@ class Group(Entity):
|
||||
This Object has factory function for creation.
|
||||
"""
|
||||
self.hass = hass
|
||||
self._name = name
|
||||
self._attr_name = name
|
||||
self._state: str | None = None
|
||||
self._icon = icon
|
||||
self._attr_icon = icon
|
||||
self._set_tracked(entity_ids)
|
||||
self._on_off: dict[str, bool] = {}
|
||||
self._assumed: dict[str, bool] = {}
|
||||
@ -234,30 +234,18 @@ class Group(Entity):
|
||||
await async_get_component(hass).async_add_entities([group])
|
||||
return group
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the group."""
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, value: str) -> None:
|
||||
def set_name(self, value: str) -> None:
|
||||
"""Set Group name."""
|
||||
self._name = value
|
||||
self._attr_name = value
|
||||
|
||||
@property
|
||||
def state(self) -> str | None:
|
||||
"""Return the state of the group."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
"""Return the icon of the group."""
|
||||
return self._icon
|
||||
|
||||
@icon.setter
|
||||
def icon(self, value: str | None) -> None:
|
||||
def set_icon(self, value: str | None) -> None:
|
||||
"""Set Icon for group."""
|
||||
self._icon = value
|
||||
self._attr_icon = value
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user