I am using the Kasa smart plug library. However, when i run
asyncio.run(self.device.update())
I get an error
kasa.exceptions.SmartDeviceException: You need to await update() to access the data
Therefore, I changed my code to
await asyncio.run(self.device.update())
However, this hasn't helped. Any help is appreciated
This is my code
import asyncio
from kasa import SmartPlug
class TpLinkHandler():
def __init__(self, address):
self.device = SmartPlug(address)
self.details = self.device.hw_info
def update(self):
await asyncio.run(self.device.update())
def shutdown(self):
asyncio.run(self.device.turn_off())
return "shutdown"
def turnOn(self):
asyncio.run(self.device.turn_on())
return "Turning on"
def __repr__(self):
return self.details
if __name__ == "__main__":
device = TpLinkHandler("192.168.0.41")
device.update()
device.turnOn()
Thanks.