mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 08:26:41 +01:00
Add button to reset HEPA filter to SmartThings (#164464)
This commit is contained in:
committed by
GitHub
parent
17bb14e260
commit
513e4d52fe
@@ -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."""
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
}
|
||||
},
|
||||
"button": {
|
||||
"reset_hepa_filter": {
|
||||
"default": "mdi:air-filter"
|
||||
},
|
||||
"reset_water_filter": {
|
||||
"default": "mdi:reload"
|
||||
},
|
||||
|
||||
@@ -84,6 +84,9 @@
|
||||
}
|
||||
},
|
||||
"button": {
|
||||
"reset_hepa_filter": {
|
||||
"name": "Reset HEPA filter"
|
||||
},
|
||||
"reset_hood_filter": {
|
||||
"name": "Reset filter"
|
||||
},
|
||||
|
||||
@@ -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': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'button',
|
||||
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||
'entity_id': 'button.robot_vacuum_reset_hepa_filter',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'entity_id': 'button.robot_vacuum_reset_hepa_filter',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
|
||||
Reference in New Issue
Block a user