-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
Hello, trying to get this to work with my Tapo L530 bulb, I can log in and get the device list, but don't seem to get the relay_state:
>>> from tplinkcloud import TPLinkDeviceManager
>>> device_manager = TPLinkDeviceManager(username, password)
>>> devices = device_manager.get_devices()
>>> if devices:
... print(f'Found {len(devices)} devices')
... for device in devices:
... print(f'{device.model_type.name} device called {device.get_alias()}')
...
Found 1 devices
UNKNOWN device called U21hcnQgQnVsYg==
>>> device_name = "U21hcnQgQnVsYg=="
>>> device = device_manager.find_device(device_name)
>>> if device:
... print(f'Found {device.model_type.name} device: {device.get_alias()}')
... device.toggle()
...
Found UNKNOWN device: U21hcnQgQnVsYg==
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "/home/pi/.local/lib/python3.7/site-packages/tplinkcloud/device.py", line 68, in toggle
if self.is_on():
File "/home/pi/.local/lib/python3.7/site-packages/tplinkcloud/device.py", line 91, in is_on
return sys_info['relay_state'] == 1
TypeError: 'NoneType' object is not subscriptable
Trying to look through the code, I can log in and get device list using requests, but then I get this error:
>>> termId = str(uuid.uuid4())
>>> payload = {
... 'method': 'login',
... 'params': {
... 'appType': 'Kasa_Android',
... 'cloudUserName': username,
... 'cloudPassword': password,
... 'terminalUUID': termId
... }
... }
>>> url = 'https://wap.tplinkcloud.com'
>>> r = requests.post(url, json=payload)
>>> params = {
... 'token': r.json()['result']['token'],
... 'appName': 'Kasa_Android',
... 'termID': termId,
... 'appVer': '1.4.4.607',
... 'ospf': 'Android+6.0.1',
... 'netType': 'wifi',
... 'locale': 'en_GB'
... }
>>> payload2 = {"method": "getDeviceList"}
>>> r2 = requests.post(url, params=params, json=payload2)
>>> controlUrl = r2.json()["result"]["deviceList"][0]["appServerUrl"]
>>> deviceId = r2.json()["result"]["deviceList"][0]["deviceId"]
>>> payload3 = {
... "method": "passthrough",
... "params": {
... "deviceId": deviceId,
... "requestData": "{\"system\":{\"set_relay_state\":{\"state\":1}}}"
... }
... }
>>> r3 = requests.post(controlUrl, params=params, json=payload3)
>>> r3.json()
{'error_code': -20571, 'msg': 'Device is offline'}
The bulb is definitely online, and controllable through the Tapo app. It doesn't matter what I send in the requestData, it always returns the same error.
So I guess my questions are:
- Does this library work with Tapo devices?
- Has anyone got it to work on a L530 bulb?
- Has anyone seen this -20571 error?
I feel like I'm close but can't get the last step.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels