From 15dfb3196b17a8965c22ec8176168f5ca963af34 Mon Sep 17 00:00:00 2001 From: Bastian Krause Date: Tue, 25 Jun 2024 15:46:20 +0200 Subject: [PATCH] driver/power/tplink: use IotStrip instead of deprecated SmartStrip Since python-kasa 0.7.0, the SmartStrip class is deprecated [1]. The docs state [2]: "If you want to continue to use the old API for older devices, you can use the classes in the iot module to avoid deprecation warnings." Do that. [1] https://python-kasa.readthedocs.io/en/stable/smartstrip.html [2] https://python-kasa.readthedocs.io/en/stable/deprecated.html#deprecated-api-reference Signed-off-by: Bastian Krause --- labgrid/driver/power/tplink.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/labgrid/driver/power/tplink.py b/labgrid/driver/power/tplink.py index 6a538e776..e556a8732 100644 --- a/labgrid/driver/power/tplink.py +++ b/labgrid/driver/power/tplink.py @@ -1,14 +1,14 @@ """ Tested with TP Link KP303, and should be compatible with any strip supported by kasa """ import asyncio -from kasa import SmartStrip +from kasa.iot import IotStrip async def _power_set(host, port, index, value): """We embed the coroutines in an `async` function to minimise calls to `asyncio.run`""" assert port is None index = int(index) - strip = SmartStrip(host) + strip = IotStrip(host) await strip.update() assert ( len(strip.children) > index @@ -26,7 +26,7 @@ def power_set(host, port, index, value): def power_get(host, port, index): assert port is None index = int(index) - strip = SmartStrip(host) + strip = IotStrip(host) asyncio.run(strip.update()) assert ( len(strip.children) > index