From 64693eaca2b37576c63fb56d7f445b678ee30a53 Mon Sep 17 00:00:00 2001 From: "Teemu R." Date: Fri, 11 Oct 2024 12:21:36 +0200 Subject: [PATCH] Add reboot button for tplink (#127935) * Add reboot button for tplink * Add device_class, remove unnecessary translation and update fixtures * update snapshot --- homeassistant/components/tplink/button.py | 5 +++ .../components/tplink/fixtures/features.json | 5 +++ .../tplink/snapshots/test_button.ambr | 33 +++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/homeassistant/components/tplink/button.py b/homeassistant/components/tplink/button.py index fd2d7fb664f..131325e489d 100644 --- a/homeassistant/components/tplink/button.py +++ b/homeassistant/components/tplink/button.py @@ -9,6 +9,7 @@ from kasa import Feature from homeassistant.components.button import ( DOMAIN as BUTTON_DOMAIN, + ButtonDeviceClass, ButtonEntity, ButtonEntityDescription, ) @@ -45,6 +46,10 @@ BUTTON_DESCRIPTIONS: Final = [ breaks_in_ha_version="2025.4.0", ), ), + TPLinkButtonEntityDescription( + key="reboot", + device_class=ButtonDeviceClass.RESTART, + ), ] BUTTON_DESCRIPTIONS_MAP = {desc.key: desc for desc in BUTTON_DESCRIPTIONS} diff --git a/tests/components/tplink/fixtures/features.json b/tests/components/tplink/fixtures/features.json index 9f9d61b6e11..30e1654001b 100644 --- a/tests/components/tplink/fixtures/features.json +++ b/tests/components/tplink/fixtures/features.json @@ -205,6 +205,11 @@ "type": "BinarySensor", "category": "Info" }, + "reboot": { + "value": "", + "type": "Action", + "category": "Debug" + }, "test_alarm": { "value": "", "type": "Action", diff --git a/tests/components/tplink/snapshots/test_button.ambr b/tests/components/tplink/snapshots/test_button.ambr index d6019861804..bb75f4642e1 100644 --- a/tests/components/tplink/snapshots/test_button.ambr +++ b/tests/components/tplink/snapshots/test_button.ambr @@ -1,4 +1,37 @@ # serializer version: 1 +# name: test_states[button.my_device_restart-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': , + 'domain': 'button', + 'entity_category': , + 'entity_id': 'button.my_device_restart', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Restart', + 'platform': 'tplink', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'reboot', + 'unique_id': '123456789ABCDEFGH_reboot', + 'unit_of_measurement': None, + }) +# --- # name: test_states[button.my_device_stop_alarm-entry] EntityRegistryEntrySnapshot({ 'aliases': set({