Skip to content

Commit

Permalink
driver/power/tplink: use IotStrip instead of deprecated SmartStrip
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Bastian-Krause committed Jun 27, 2024
1 parent 976e60e commit 15dfb31
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions labgrid/driver/power/tplink.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 15dfb31

Please sign in to comment.