mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Add switch for icemaker in SmartThings (#141313)
* Add switch for icemaker in SmartThings * Fix
This commit is contained in:
parent
74ff40e253
commit
ed7c864869
@ -51,6 +51,9 @@
|
||||
"state": {
|
||||
"off": "mdi:tumble-dryer-off"
|
||||
}
|
||||
},
|
||||
"ice_maker": {
|
||||
"default": "mdi:delete-variant"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -469,6 +469,9 @@
|
||||
},
|
||||
"wrinkle_prevent": {
|
||||
"name": "Wrinkle prevent"
|
||||
},
|
||||
"ice_maker": {
|
||||
"name": "Ice maker"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -43,6 +43,7 @@ class SmartThingsSwitchEntityDescription(SwitchEntityDescription):
|
||||
"""Describe a SmartThings switch entity."""
|
||||
|
||||
status_attribute: Attribute
|
||||
component_translation_key: dict[str, str] | None = None
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
@ -72,7 +73,14 @@ CAPABILITY_TO_SWITCHES: dict[Capability | str, SmartThingsSwitchEntityDescriptio
|
||||
key=Capability.SAMSUNG_CE_WASHER_BUBBLE_SOAK,
|
||||
translation_key="bubble_soak",
|
||||
status_attribute=Attribute.STATUS,
|
||||
)
|
||||
),
|
||||
Capability.SWITCH: SmartThingsSwitchEntityDescription(
|
||||
key=Capability.SWITCH,
|
||||
status_attribute=Attribute.SWITCH,
|
||||
component_translation_key={
|
||||
"icemaker": "ice_maker",
|
||||
},
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@ -107,10 +115,19 @@ async def async_setup_entry(
|
||||
device,
|
||||
description,
|
||||
Capability(capability),
|
||||
component,
|
||||
)
|
||||
for device in entry_data.devices.values()
|
||||
for capability, description in CAPABILITY_TO_SWITCHES.items()
|
||||
if capability in device.status[MAIN]
|
||||
for component in device.status
|
||||
if capability in device.status[component]
|
||||
and (
|
||||
(description.component_translation_key is None and component == MAIN)
|
||||
or (
|
||||
description.component_translation_key is not None
|
||||
and component in description.component_translation_key
|
||||
)
|
||||
)
|
||||
)
|
||||
async_add_entities(entities)
|
||||
|
||||
@ -126,12 +143,19 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchEntity):
|
||||
device: FullDevice,
|
||||
entity_description: SmartThingsSwitchEntityDescription,
|
||||
capability: Capability,
|
||||
component: str = MAIN,
|
||||
) -> None:
|
||||
"""Initialize the switch."""
|
||||
super().__init__(client, device, {capability})
|
||||
super().__init__(client, device, {capability}, component=component)
|
||||
self.entity_description = entity_description
|
||||
self.switch_capability = capability
|
||||
self._attr_unique_id = f"{device.device.device_id}_{MAIN}_{capability}_{entity_description.status_attribute}_{entity_description.status_attribute}"
|
||||
self._attr_unique_id = f"{device.device.device_id}_{component}_{capability}_{entity_description.status_attribute}_{entity_description.status_attribute}"
|
||||
if (
|
||||
translation_keys := entity_description.component_translation_key
|
||||
) is not None and (
|
||||
translation_key := translation_keys.get(component)
|
||||
) is not None:
|
||||
self._attr_translation_key = translation_key
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch off."""
|
||||
|
@ -93,6 +93,53 @@
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_ref_normal_000001][switch.refrigerator_ice_maker-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.refrigerator_ice_maker',
|
||||
'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': 'Ice maker',
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'ice_maker',
|
||||
'unique_id': '7db87911-7dce-1cf2-7119-b953432a2f09_icemaker_switch_switch_switch',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_ref_normal_000001][switch.refrigerator_ice_maker-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'Refrigerator Ice maker',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.refrigerator_ice_maker',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_rvc_normal_000001][switch.robot_vacuum-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
Loading…
x
Reference in New Issue
Block a user