mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 06:05:26 +01:00
Refactor Shelly light to reuse RPC key split (#157003)
Signed-off-by: David Rapan <david@rapan.cz>
This commit is contained in:
@@ -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,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user