From 8e9f66bc24f9a6c3174ffb6faf00ec80ec735d92 Mon Sep 17 00:00:00 2001 From: sdb9696 Date: Fri, 21 Jun 2024 16:18:25 +0100 Subject: [PATCH 1/5] Update feature names and units and import ThermostatState into kasa --- kasa/__init__.py | 2 ++ kasa/smart/modules/reportmode.py | 1 + kasa/smart/modules/temperaturecontrol.py | 4 ++-- kasa/smart/modules/time.py | 4 ++-- kasa/smart/smartdevice.py | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kasa/__init__.py b/kasa/__init__.py index d383d3a79..6def7dd78 100755 --- a/kasa/__init__.py +++ b/kasa/__init__.py @@ -42,6 +42,7 @@ ) from kasa.module import Module from kasa.protocol import BaseProtocol +from kasa.smart.modules.temperaturecontrol import ThermostatState from kasa.smartprotocol import SmartProtocol __version__ = version("python-kasa") @@ -74,6 +75,7 @@ "DeviceConnectionParameters", "DeviceEncryptionType", "DeviceFamily", + "ThermostatState", ] from . import iot diff --git a/kasa/smart/modules/reportmode.py b/kasa/smart/modules/reportmode.py index f0af4c1c6..704476625 100644 --- a/kasa/smart/modules/reportmode.py +++ b/kasa/smart/modules/reportmode.py @@ -26,6 +26,7 @@ def __init__(self, device: SmartDevice, module: str): name="Report interval", container=self, attribute_getter="report_interval", + unit="s", category=Feature.Category.Debug, ) ) diff --git a/kasa/smart/modules/temperaturecontrol.py b/kasa/smart/modules/temperaturecontrol.py index ae487bdf2..e582d77a0 100644 --- a/kasa/smart/modules/temperaturecontrol.py +++ b/kasa/smart/modules/temperaturecontrol.py @@ -79,8 +79,8 @@ def __init__(self, device: SmartDevice, module: str): self._add_feature( Feature( device, - id="mode", - name="Mode", + id="thermostat_mode", + name="Thermostat mode", container=self, attribute_getter="mode", category=Feature.Category.Primary, diff --git a/kasa/smart/modules/time.py b/kasa/smart/modules/time.py index 3c2b96af3..dc4fad3fc 100644 --- a/kasa/smart/modules/time.py +++ b/kasa/smart/modules/time.py @@ -25,8 +25,8 @@ def __init__(self, device: SmartDevice, module: str): self._add_feature( Feature( device=device, - id="time", - name="Time", + id="device_time", + name="Device time", attribute_getter="time", container=self, category=Feature.Category.Debug, diff --git a/kasa/smart/smartdevice.py b/kasa/smart/smartdevice.py index bf3eb25e8..675568e28 100644 --- a/kasa/smart/smartdevice.py +++ b/kasa/smart/smartdevice.py @@ -277,6 +277,7 @@ async def _initialize_features(self): name="RSSI", attribute_getter=lambda x: x._info["rssi"], icon="mdi:signal", + unit="dBm", category=Feature.Category.Debug, ) ) From 405348ef08fb946f9df098a4ed1ed459ac0a0119 Mon Sep 17 00:00:00 2001 From: sdb9696 Date: Fri, 21 Jun 2024 16:29:41 +0100 Subject: [PATCH 2/5] Make on_since category debug --- kasa/iot/iotdevice.py | 1 + kasa/iot/iotstrip.py | 1 + kasa/smart/smartdevice.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/kasa/iot/iotdevice.py b/kasa/iot/iotdevice.py index 4b8325a21..db9a9d94e 100755 --- a/kasa/iot/iotdevice.py +++ b/kasa/iot/iotdevice.py @@ -352,6 +352,7 @@ async def _initialize_features(self): name="On since", attribute_getter="on_since", icon="mdi:clock", + category=Feature.Category.Debug, ) ) diff --git a/kasa/iot/iotstrip.py b/kasa/iot/iotstrip.py index c2f2bb860..81721a99d 100755 --- a/kasa/iot/iotstrip.py +++ b/kasa/iot/iotstrip.py @@ -340,6 +340,7 @@ async def _initialize_features(self): name="On since", attribute_getter="on_since", icon="mdi:clock", + category=Feature.Category.Debug, ) ) for module in self._supported_modules.values(): diff --git a/kasa/smart/smartdevice.py b/kasa/smart/smartdevice.py index 675568e28..ebe73b1c6 100644 --- a/kasa/smart/smartdevice.py +++ b/kasa/smart/smartdevice.py @@ -317,7 +317,7 @@ async def _initialize_features(self): name="On since", attribute_getter="on_since", icon="mdi:clock", - category=Feature.Category.Info, + category=Feature.Category.Debug, ) ) From aa692122f9794d582ede5bd10ced5048d379c8ea Mon Sep 17 00:00:00 2001 From: sdb9696 Date: Fri, 21 Jun 2024 16:52:40 +0100 Subject: [PATCH 3/5] Fix readme tests --- docs/tutorial.py | 2 +- kasa/feature.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorial.py b/docs/tutorial.py index 5dc768c77..7bb3381a3 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\nTime: 2024-02-23 02:40:15+01:00 +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 """ diff --git a/kasa/feature.py b/kasa/feature.py index 38c6fca99..53532932b 100644 --- a/kasa/feature.py +++ b/kasa/feature.py @@ -37,7 +37,7 @@ Light preset (light_preset): Not set Smooth transition on (smooth_transition_on): 2 Smooth transition off (smooth_transition_off): 2 -Time (time): 2024-02-23 02:40:15+01:00 +Device time (device_time): 2024-02-23 02:40:15+01:00 To see whether a device supports a feature, check for the existence of it: From 7f365306bbeca350aeffa4fda568531375c92ddd Mon Sep 17 00:00:00 2001 From: sdb9696 Date: Fri, 21 Jun 2024 16:56:00 +0100 Subject: [PATCH 4/5] Do not expose thermostat state enum --- kasa/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/kasa/__init__.py b/kasa/__init__.py index 6def7dd78..d383d3a79 100755 --- a/kasa/__init__.py +++ b/kasa/__init__.py @@ -42,7 +42,6 @@ ) from kasa.module import Module from kasa.protocol import BaseProtocol -from kasa.smart.modules.temperaturecontrol import ThermostatState from kasa.smartprotocol import SmartProtocol __version__ = version("python-kasa") @@ -75,7 +74,6 @@ "DeviceConnectionParameters", "DeviceEncryptionType", "DeviceFamily", - "ThermostatState", ] from . import iot From 41a31c4e1a26d3ae14aced6799b4fc11b304c208 Mon Sep 17 00:00:00 2001 From: sdb9696 Date: Fri, 21 Jun 2024 17:05:26 +0100 Subject: [PATCH 5/5] Revert on_since to category Info --- kasa/iot/iotdevice.py | 2 +- kasa/iot/iotstrip.py | 2 +- kasa/smart/modules/time.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kasa/iot/iotdevice.py b/kasa/iot/iotdevice.py index db9a9d94e..e181d7ca9 100755 --- a/kasa/iot/iotdevice.py +++ b/kasa/iot/iotdevice.py @@ -352,7 +352,7 @@ async def _initialize_features(self): name="On since", attribute_getter="on_since", icon="mdi:clock", - category=Feature.Category.Debug, + category=Feature.Category.Info, ) ) diff --git a/kasa/iot/iotstrip.py b/kasa/iot/iotstrip.py index 81721a99d..eea9f32c3 100755 --- a/kasa/iot/iotstrip.py +++ b/kasa/iot/iotstrip.py @@ -340,7 +340,7 @@ async def _initialize_features(self): name="On since", attribute_getter="on_since", icon="mdi:clock", - category=Feature.Category.Debug, + category=Feature.Category.Info, ) ) for module in self._supported_modules.values(): diff --git a/kasa/smart/modules/time.py b/kasa/smart/modules/time.py index dc4fad3fc..c2007ceba 100644 --- a/kasa/smart/modules/time.py +++ b/kasa/smart/modules/time.py @@ -29,7 +29,7 @@ def __init__(self, device: SmartDevice, module: str): name="Device time", attribute_getter="time", container=self, - category=Feature.Category.Debug, + category=Feature.Category.Info, ) )