Skip to content

Commit 5139e9e

Browse files
authored
Refactor Shelly light to reuse RPC key split (home-assistant#157003)
Signed-off-by: David Rapan <[email protected]>
1 parent c536745 commit 5139e9e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

homeassistant/components/shelly/light.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
async_remove_orphaned_entities,
5252
brightness_to_percentage,
5353
get_device_entry_gen,
54+
get_rpc_channel_name,
55+
get_rpc_key_id,
5456
is_block_channel_type_light,
5557
is_rpc_channel_type_light,
5658
percentage_to_brightness,
@@ -120,6 +122,7 @@ def __init__(
120122
"""Initialize block light."""
121123
super().__init__(coordinator, block, attribute, description)
122124
self.control_result: dict[str, Any] | None = None
125+
self._attr_name = None # Main device entity
123126
self._attr_unique_id: str = f"{coordinator.mac}-{block.description}"
124127
self._attr_supported_color_modes = set()
125128
self._attr_min_color_temp_kelvin = KELVIN_MIN_VALUE_WHITE
@@ -377,6 +380,7 @@ def __init__(
377380
) -> None:
378381
"""Initialize light."""
379382
super().__init__(coordinator, key, attribute, description)
383+
self._attr_name = get_rpc_channel_name(coordinator.device, key)
380384
self._attr_unique_id = f"{coordinator.mac}-{key}"
381385

382386
@property
@@ -535,7 +539,7 @@ class RpcShellyRgbwLight(RpcShellyLightBase):
535539
key="switch",
536540
sub_key="output",
537541
removal_condition=lambda config, _status, key: not is_rpc_channel_type_light(
538-
config, int(key.split(":")[-1])
542+
config, get_rpc_key_id(key)
539543
),
540544
entity_class=RpcShellySwitchAsLight,
541545
),

0 commit comments

Comments
 (0)