From 513e4d52febbaf2e270c74c0720e5e573f982e1e Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Sun, 1 Mar 2026 07:33:10 +0100 Subject: [PATCH] Add button to reset HEPA filter to SmartThings (#164464) --- .../components/smartthings/button.py | 21 +++++--- .../components/smartthings/icons.json | 3 ++ .../components/smartthings/strings.json | 3 ++ .../smartthings/snapshots/test_button.ambr | 49 +++++++++++++++++++ 4 files changed, 69 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/smartthings/button.py b/homeassistant/components/smartthings/button.py index bcfbf2cafb3..feffc96c116 100644 --- a/homeassistant/components/smartthings/button.py +++ b/homeassistant/components/smartthings/button.py @@ -22,6 +22,7 @@ class SmartThingsButtonDescription(ButtonEntityDescription): key: Capability command: Command + component: str = MAIN CAPABILITIES_TO_BUTTONS: dict[Capability | str, SmartThingsButtonDescription] = { @@ -42,6 +43,13 @@ CAPABILITIES_TO_BUTTONS: dict[Capability | str, SmartThingsButtonDescription] = command=Command.RESET_HOOD_FILTER, entity_category=EntityCategory.DIAGNOSTIC, ), + Capability.CUSTOM_HEPA_FILTER: SmartThingsButtonDescription( + key=Capability.CUSTOM_HEPA_FILTER, + translation_key="reset_hepa_filter", + command=Command.RESET_HEPA_FILTER, + entity_category=EntityCategory.DIAGNOSTIC, + component="station", + ), } @@ -53,12 +61,11 @@ async def async_setup_entry( """Add button entities for a config entry.""" entry_data = entry.runtime_data async_add_entities( - SmartThingsButtonEntity( - entry_data.client, device, CAPABILITIES_TO_BUTTONS[capability] - ) + SmartThingsButtonEntity(entry_data.client, device, description) + for capability, description in CAPABILITIES_TO_BUTTONS.items() for device in entry_data.devices.values() - for capability in device.status[MAIN] - if capability in CAPABILITIES_TO_BUTTONS + if description.component in device.status + and capability in device.status[description.component] ) @@ -74,9 +81,9 @@ class SmartThingsButtonEntity(SmartThingsEntity, ButtonEntity): entity_description: SmartThingsButtonDescription, ) -> None: """Initialize the instance.""" - super().__init__(client, device, set()) + super().__init__(client, device, set(), component=entity_description.component) self.entity_description = entity_description - self._attr_unique_id = f"{device.device.device_id}_{MAIN}_{entity_description.key}_{entity_description.command}" + self._attr_unique_id = f"{device.device.device_id}_{entity_description.component}_{entity_description.key}_{entity_description.command}" async def async_press(self) -> None: """Press the button.""" diff --git a/homeassistant/components/smartthings/icons.json b/homeassistant/components/smartthings/icons.json index 848a545e7f9..c3d8c03aa05 100644 --- a/homeassistant/components/smartthings/icons.json +++ b/homeassistant/components/smartthings/icons.json @@ -24,6 +24,9 @@ } }, "button": { + "reset_hepa_filter": { + "default": "mdi:air-filter" + }, "reset_water_filter": { "default": "mdi:reload" }, diff --git a/homeassistant/components/smartthings/strings.json b/homeassistant/components/smartthings/strings.json index 140f42eb5b6..38e4a5cba18 100644 --- a/homeassistant/components/smartthings/strings.json +++ b/homeassistant/components/smartthings/strings.json @@ -84,6 +84,9 @@ } }, "button": { + "reset_hepa_filter": { + "name": "Reset HEPA filter" + }, "reset_hood_filter": { "name": "Reset filter" }, diff --git a/tests/components/smartthings/snapshots/test_button.ambr b/tests/components/smartthings/snapshots/test_button.ambr index 849c06a45b2..66d7e1b524f 100644 --- a/tests/components/smartthings/snapshots/test_button.ambr +++ b/tests/components/smartthings/snapshots/test_button.ambr @@ -440,3 +440,52 @@ 'state': 'unknown', }) # --- +# name: test_all_entities[da_rvc_map_01011][button.robot_vacuum_reset_hepa_filter-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'button', + 'entity_category': , + 'entity_id': 'button.robot_vacuum_reset_hepa_filter', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Reset HEPA filter', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Reset HEPA filter', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'reset_hepa_filter', + 'unique_id': '01b28624-5907-c8bc-0325-8ad23f03a637_station_custom.hepaFilter_resetHepaFilter', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[da_rvc_map_01011][button.robot_vacuum_reset_hepa_filter-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Robot Vacuum Reset HEPA filter', + }), + 'context': , + 'entity_id': 'button.robot_vacuum_reset_hepa_filter', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# ---