mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Velux use node id as fallback for unique id (#117508)
Co-authored-by: Robert Resch <robert@resch.dev>
This commit is contained in:
parent
faedba0407
commit
f5e88b8293
@ -108,10 +108,14 @@ class VeluxEntity(Entity):
|
||||
|
||||
_attr_should_poll = False
|
||||
|
||||
def __init__(self, node: Node) -> None:
|
||||
def __init__(self, node: Node, config_entry_id: str) -> None:
|
||||
"""Initialize the Velux device."""
|
||||
self.node = node
|
||||
self._attr_unique_id = node.serial_number
|
||||
self._attr_unique_id = (
|
||||
node.serial_number
|
||||
if node.serial_number
|
||||
else f"{config_entry_id}_{node.node_id}"
|
||||
)
|
||||
self._attr_name = node.name if node.name else f"#{node.node_id}"
|
||||
|
||||
@callback
|
||||
|
@ -29,7 +29,7 @@ async def async_setup_entry(
|
||||
"""Set up cover(s) for Velux platform."""
|
||||
module = hass.data[DOMAIN][config.entry_id]
|
||||
async_add_entities(
|
||||
VeluxCover(node)
|
||||
VeluxCover(node, config.entry_id)
|
||||
for node in module.pyvlx.nodes
|
||||
if isinstance(node, OpeningDevice)
|
||||
)
|
||||
@ -41,9 +41,9 @@ class VeluxCover(VeluxEntity, CoverEntity):
|
||||
_is_blind = False
|
||||
node: OpeningDevice
|
||||
|
||||
def __init__(self, node: OpeningDevice) -> None:
|
||||
def __init__(self, node: OpeningDevice, config_entry_id: str) -> None:
|
||||
"""Initialize VeluxCover."""
|
||||
super().__init__(node)
|
||||
super().__init__(node, config_entry_id)
|
||||
self._attr_device_class = CoverDeviceClass.WINDOW
|
||||
if isinstance(node, Awning):
|
||||
self._attr_device_class = CoverDeviceClass.AWNING
|
||||
|
@ -23,7 +23,7 @@ async def async_setup_entry(
|
||||
module = hass.data[DOMAIN][config.entry_id]
|
||||
|
||||
async_add_entities(
|
||||
VeluxLight(node)
|
||||
VeluxLight(node, config.entry_id)
|
||||
for node in module.pyvlx.nodes
|
||||
if isinstance(node, LighteningDevice)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user