From 5139e9e56679ce703579ff3399e2da541b808f8b Mon Sep 17 00:00:00 2001 From: David Rapan Date: Sat, 22 Nov 2025 21:19:42 +0100 Subject: [PATCH] Refactor Shelly light to reuse RPC key split (#157003) Signed-off-by: David Rapan --- homeassistant/components/shelly/light.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/shelly/light.py b/homeassistant/components/shelly/light.py index d3719de11a2..4a357ccb4c9 100644 --- a/homeassistant/components/shelly/light.py +++ b/homeassistant/components/shelly/light.py @@ -51,6 +51,8 @@ from .utils import ( async_remove_orphaned_entities, brightness_to_percentage, get_device_entry_gen, + get_rpc_channel_name, + get_rpc_key_id, is_block_channel_type_light, is_rpc_channel_type_light, percentage_to_brightness, @@ -120,6 +122,7 @@ class BlockShellyLight(ShellyBlockAttributeEntity, LightEntity): """Initialize block light.""" super().__init__(coordinator, block, attribute, description) self.control_result: dict[str, Any] | None = None + self._attr_name = None # Main device entity self._attr_unique_id: str = f"{coordinator.mac}-{block.description}" self._attr_supported_color_modes = set() self._attr_min_color_temp_kelvin = KELVIN_MIN_VALUE_WHITE @@ -377,6 +380,7 @@ class RpcShellyLightBase(ShellyRpcAttributeEntity, LightEntity): ) -> None: """Initialize light.""" super().__init__(coordinator, key, attribute, description) + self._attr_name = get_rpc_channel_name(coordinator.device, key) self._attr_unique_id = f"{coordinator.mac}-{key}" @property @@ -535,7 +539,7 @@ LIGHTS: Final = { key="switch", sub_key="output", removal_condition=lambda config, _status, key: not is_rpc_channel_type_light( - config, int(key.split(":")[-1]) + config, get_rpc_key_id(key) ), entity_class=RpcShellySwitchAsLight, ),