Expose reboot action (#1073)

Expose reboot through the feature interface.
This can be useful in situations where one wants to reboot the device,
e.g., in recent cases where frequent update calls will render the device
unresponsive after a specific amount of time.
This commit is contained in:
Teemu R. 2024-07-24 15:47:38 +02:00 committed by GitHub
parent ed033679e5
commit dc0aedad20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 1 deletions

View File

@ -91,5 +91,5 @@ False
True True
>>> for feat in dev.features.values(): >>> for feat in dev.features.values():
>>> print(f"{feat.name}: {feat.value}") >>> 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: <Action>\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
""" """

View File

@ -84,6 +84,7 @@ added to the API.
state state
rssi rssi
on_since on_since
reboot
current_consumption current_consumption
consumption_today consumption_today
consumption_this_month consumption_this_month

View File

@ -25,6 +25,7 @@ Signal Level (signal_level): 2
RSSI (rssi): -52 RSSI (rssi): -52
SSID (ssid): #MASKED_SSID# SSID (ssid): #MASKED_SSID#
Overheated (overheated): False Overheated (overheated): False
Reboot (reboot): <Action>
Brightness (brightness): 100 Brightness (brightness): 100
Cloud connection (cloud_connection): True Cloud connection (cloud_connection): True
HSV (hsv): HSV(hue=0, saturation=100, value=100) HSV (hsv): HSV(hue=0, saturation=100, value=100)

View File

@ -359,6 +359,18 @@ class IotDevice(Device):
) )
) )
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(): for module in self._supported_modules.values():
module._initialize_features() module._initialize_features()
for module_feat in module._module_features.values(): for module_feat in module._module_features.values():

View File

@ -439,6 +439,18 @@ class SmartDevice(Device):
) )
) )
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(): for module in self.modules.values():
module._initialize_features() module._initialize_features()
for feat in module._module_features.values(): for feat in module._module_features.values():