From 2e3e563990dabde5fcb9f4745618dfc6404abfab Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Wed, 17 Jul 2024 17:56:25 +0300 Subject: [PATCH 1/2] Expose reboot action --- kasa/iot/iotdevice.py | 12 ++++++++++++ kasa/smart/smartdevice.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/kasa/iot/iotdevice.py b/kasa/iot/iotdevice.py index c637387ae..28ae12281 100755 --- a/kasa/iot/iotdevice.py +++ b/kasa/iot/iotdevice.py @@ -359,6 +359,18 @@ async def _initialize_features(self): ) ) + self._add_feature( + Feature( + device=self, + id="reboot", + name="Reboot", + attribute_setter="reboot", + icon="mdi:restart", + category=Feature.Category.Debug, + type=Feature.Type.Action, + ) + ) + for module in self._supported_modules.values(): module._initialize_features() for module_feat in module._module_features.values(): diff --git a/kasa/smart/smartdevice.py b/kasa/smart/smartdevice.py index 21e46cc34..d94f725b0 100644 --- a/kasa/smart/smartdevice.py +++ b/kasa/smart/smartdevice.py @@ -441,6 +441,18 @@ async def _initialize_features(self): ) ) + self._add_feature( + Feature( + device=self, + id="reboot", + name="Reboot", + attribute_setter="reboot", + icon="mdi:restart", + category=Feature.Category.Debug, + type=Feature.Type.Action, + ) + ) + for module in self.modules.values(): module._initialize_features() for feat in module._module_features.values(): From 8a67a14b643b9d8dfe7d33b92f2766d758473d30 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Wed, 17 Jul 2024 19:15:33 +0300 Subject: [PATCH 2/2] Fix tests --- docs/tutorial.py | 2 +- kasa/device.py | 1 + kasa/feature.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/tutorial.py b/docs/tutorial.py index 7bb3381a3..f2b777b16 100644 --- a/docs/tutorial.py +++ b/docs/tutorial.py @@ -91,5 +91,5 @@ True >>> for feat in dev.features.values(): >>> print(f"{feat.name}: {feat.value}") -Device ID: 0000000000000000000000000000000000000000\nState: True\nSignal Level: 2\nRSSI: -52\nSSID: #MASKED_SSID#\nOverheated: False\nBrightness: 50\nCloud connection: True\nHSV: HSV(hue=0, saturation=100, value=50)\nColor temperature: 2700\nAuto update enabled: True\nUpdate available: False\nCurrent firmware version: 1.1.6 Build 240130 Rel.173828\nAvailable firmware version: 1.1.6 Build 240130 Rel.173828\nLight effect: Party\nLight preset: Light preset 1\nSmooth transition on: 2\nSmooth transition off: 2\nDevice time: 2024-02-23 02:40:15+01:00 +Device ID: 0000000000000000000000000000000000000000\nState: True\nSignal Level: 2\nRSSI: -52\nSSID: #MASKED_SSID#\nOverheated: False\nReboot: \nBrightness: 50\nCloud connection: True\nHSV: HSV(hue=0, saturation=100, value=50)\nColor temperature: 2700\nAuto update enabled: True\nUpdate available: False\nCurrent firmware version: 1.1.6 Build 240130 Rel.173828\nAvailable firmware version: 1.1.6 Build 240130 Rel.173828\nLight effect: Party\nLight preset: Light preset 1\nSmooth transition on: 2\nSmooth transition off: 2\nDevice time: 2024-02-23 02:40:15+01:00 """ diff --git a/kasa/device.py b/kasa/device.py index 69b7370b0..e07c4853c 100644 --- a/kasa/device.py +++ b/kasa/device.py @@ -84,6 +84,7 @@ state rssi on_since +reboot current_consumption consumption_today consumption_this_month diff --git a/kasa/feature.py b/kasa/feature.py index 0ce13d45f..ab73f9913 100644 --- a/kasa/feature.py +++ b/kasa/feature.py @@ -25,6 +25,7 @@ RSSI (rssi): -52 SSID (ssid): #MASKED_SSID# Overheated (overheated): False +Reboot (reboot): Brightness (brightness): 100 Cloud connection (cloud_connection): True HSV (hsv): HSV(hue=0, saturation=100, value=100)