mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Add lamp capability for hood component in SmartThings (#145036)
This commit is contained in:
parent
77bab39ed0
commit
68c3d5a159
@ -32,6 +32,8 @@ class SmartThingsSelectDescription(SelectEntityDescription):
|
|||||||
command: Command
|
command: Command
|
||||||
options_map: dict[str, str] | None = None
|
options_map: dict[str, str] | None = None
|
||||||
default_options: list[str] | None = None
|
default_options: list[str] | None = None
|
||||||
|
extra_components: list[str] | None = None
|
||||||
|
capability_ignore_list: list[Capability] | None = None
|
||||||
|
|
||||||
|
|
||||||
CAPABILITIES_TO_SELECT: dict[Capability | str, SmartThingsSelectDescription] = {
|
CAPABILITIES_TO_SELECT: dict[Capability | str, SmartThingsSelectDescription] = {
|
||||||
@ -88,6 +90,8 @@ CAPABILITIES_TO_SELECT: dict[Capability | str, SmartThingsSelectDescription] = {
|
|||||||
command=Command.SET_BRIGHTNESS_LEVEL,
|
command=Command.SET_BRIGHTNESS_LEVEL,
|
||||||
options_map=LAMP_TO_HA,
|
options_map=LAMP_TO_HA,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
extra_components=["hood"],
|
||||||
|
capability_ignore_list=[Capability.SAMSUNG_CE_CONNECTION_STATE],
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,12 +104,25 @@ async def async_setup_entry(
|
|||||||
"""Add select entities for a config entry."""
|
"""Add select entities for a config entry."""
|
||||||
entry_data = entry.runtime_data
|
entry_data = entry.runtime_data
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
SmartThingsSelectEntity(
|
SmartThingsSelectEntity(entry_data.client, device, description, component)
|
||||||
entry_data.client, device, CAPABILITIES_TO_SELECT[capability]
|
for capability, description in CAPABILITIES_TO_SELECT.items()
|
||||||
)
|
|
||||||
for device in entry_data.devices.values()
|
for device in entry_data.devices.values()
|
||||||
for capability in device.status[MAIN]
|
for component in device.status
|
||||||
if capability in CAPABILITIES_TO_SELECT
|
if capability in device.status[component]
|
||||||
|
and (
|
||||||
|
component == MAIN
|
||||||
|
or (
|
||||||
|
description.extra_components is not None
|
||||||
|
and component in description.extra_components
|
||||||
|
)
|
||||||
|
)
|
||||||
|
and (
|
||||||
|
description.capability_ignore_list is None
|
||||||
|
or any(
|
||||||
|
capability not in device.status[component]
|
||||||
|
for capability in description.capability_ignore_list
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -119,14 +136,15 @@ class SmartThingsSelectEntity(SmartThingsEntity, SelectEntity):
|
|||||||
client: SmartThings,
|
client: SmartThings,
|
||||||
device: FullDevice,
|
device: FullDevice,
|
||||||
entity_description: SmartThingsSelectDescription,
|
entity_description: SmartThingsSelectDescription,
|
||||||
|
component: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the instance."""
|
"""Initialize the instance."""
|
||||||
capabilities = {entity_description.key}
|
capabilities = {entity_description.key}
|
||||||
if entity_description.requires_remote_control_status:
|
if entity_description.requires_remote_control_status:
|
||||||
capabilities.add(Capability.REMOTE_CONTROL_STATUS)
|
capabilities.add(Capability.REMOTE_CONTROL_STATUS)
|
||||||
super().__init__(client, device, capabilities)
|
super().__init__(client, device, capabilities, component=component)
|
||||||
self.entity_description = entity_description
|
self.entity_description = entity_description
|
||||||
self._attr_unique_id = f"{device.device.device_id}_{MAIN}_{entity_description.key}_{entity_description.status_attribute}_{entity_description.status_attribute}"
|
self._attr_unique_id = f"{device.device.device_id}_{component}_{entity_description.key}_{entity_description.status_attribute}_{entity_description.status_attribute}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def options(self) -> list[str]:
|
def options(self) -> list[str]:
|
||||||
|
@ -1,4 +1,62 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
|
# name: test_all_entities[da_ks_microwave_0101x][select.microwave_lamp-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'options': list([
|
||||||
|
'off',
|
||||||
|
'low',
|
||||||
|
'high',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'config_subentry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'select',
|
||||||
|
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||||
|
'entity_id': 'select.microwave_lamp',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': None,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Lamp',
|
||||||
|
'platform': 'smartthings',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'lamp',
|
||||||
|
'unique_id': '2bad3237-4886-e699-1b90-4a51a3d55c8a_hood_samsungce.lamp_brightnessLevel_brightnessLevel',
|
||||||
|
'unit_of_measurement': None,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[da_ks_microwave_0101x][select.microwave_lamp-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'friendly_name': 'Microwave Lamp',
|
||||||
|
'options': list([
|
||||||
|
'off',
|
||||||
|
'low',
|
||||||
|
'high',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'select.microwave_lamp',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_all_entities[da_ks_oven_01061][select.oven_lamp-entry]
|
# name: test_all_entities[da_ks_oven_01061][select.oven_lamp-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user