mirror of https://github.com/home-assistant/core
Migrate deCONZ Group and Scenes to new entity naming style (#74761)
This commit is contained in:
parent
04bb2d1e5d
commit
24ca656372
|
@ -120,6 +120,8 @@ class DeconzDevice(DeconzBase, Entity):
|
||||||
class DeconzSceneMixin(DeconzDevice):
|
class DeconzSceneMixin(DeconzDevice):
|
||||||
"""Representation of a deCONZ scene."""
|
"""Representation of a deCONZ scene."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
_device: PydeconzScene
|
_device: PydeconzScene
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -130,7 +132,9 @@ class DeconzSceneMixin(DeconzDevice):
|
||||||
"""Set up a scene."""
|
"""Set up a scene."""
|
||||||
super().__init__(device, gateway)
|
super().__init__(device, gateway)
|
||||||
|
|
||||||
self._attr_name = device.full_name
|
self.group = self.gateway.api.groups[device.group_id]
|
||||||
|
|
||||||
|
self._attr_name = device.name
|
||||||
self._group_identifier = self.get_parent_identifier()
|
self._group_identifier = self.get_parent_identifier()
|
||||||
|
|
||||||
def get_device_identifier(self) -> str:
|
def get_device_identifier(self) -> str:
|
||||||
|
@ -139,7 +143,7 @@ class DeconzSceneMixin(DeconzDevice):
|
||||||
|
|
||||||
def get_parent_identifier(self) -> str:
|
def get_parent_identifier(self) -> str:
|
||||||
"""Describe a unique identifier for group this scene belongs to."""
|
"""Describe a unique identifier for group this scene belongs to."""
|
||||||
return f"{self.gateway.bridgeid}-{self._device.group_deconz_id}"
|
return f"{self.gateway.bridgeid}-{self.group.deconz_id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
|
@ -149,4 +153,10 @@ class DeconzSceneMixin(DeconzDevice):
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return a device description for device registry."""
|
"""Return a device description for device registry."""
|
||||||
return DeviceInfo(identifiers={(DECONZ_DOMAIN, self._group_identifier)})
|
return DeviceInfo(
|
||||||
|
identifiers={(DECONZ_DOMAIN, self._group_identifier)},
|
||||||
|
manufacturer="Dresden Elektronik",
|
||||||
|
model="deCONZ group",
|
||||||
|
name=self.group.name,
|
||||||
|
via_device=(DECONZ_DOMAIN, self.gateway.api.config.bridge_id),
|
||||||
|
)
|
||||||
|
|
|
@ -289,6 +289,8 @@ class DeconzLight(DeconzBaseLight[Light]):
|
||||||
class DeconzGroup(DeconzBaseLight[Group]):
|
class DeconzGroup(DeconzBaseLight[Group]):
|
||||||
"""Representation of a deCONZ group."""
|
"""Representation of a deCONZ group."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
_device: Group
|
_device: Group
|
||||||
|
|
||||||
def __init__(self, device: Group, gateway: DeconzGateway) -> None:
|
def __init__(self, device: Group, gateway: DeconzGateway) -> None:
|
||||||
|
@ -296,6 +298,8 @@ class DeconzGroup(DeconzBaseLight[Group]):
|
||||||
self._unique_id = f"{gateway.bridgeid}-{device.deconz_id}"
|
self._unique_id = f"{gateway.bridgeid}-{device.deconz_id}"
|
||||||
super().__init__(device, gateway)
|
super().__init__(device, gateway)
|
||||||
|
|
||||||
|
self._attr_name = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique identifier for this device."""
|
"""Return a unique identifier for this device."""
|
||||||
|
|
Loading…
Reference in New Issue