fishbigger / TapoP100

A module for controlling the TP-Link Tapo P100 Plugs
MIT License
567 stars 139 forks source link

P100.getDeviceName() Exception "the JSON object must be str, bytes or bytearray, not dict" #41

Closed realzoulou closed 2 years ago

realzoulou commented 2 years ago

Calling P100.getDeviceName() always results in Exception "the JSON object must be str, bytes or bytearray, not dict"

2022-01-09 18:55:20 ERROR (MainThread) [custom_components.tplink_tapo_cloud.config_flow] Unexpected exception Traceback (most recent call last): ---cut--- File "/srv/homeassistant/lib/python3.9/site-packages/PyP100/PyP100.py", line 356, in getDeviceName data = json.loads(data) File "/usr/lib/python3.9/json/init.py", line 339, in loads raise TypeError(f'the JSON object must be str, bytes or bytearray, ' TypeError: the JSON object must be str, bytes or bytearray, not dict

Introduced with PR https://github.com/fishbigger/TapoP100/pull/21

See my comment https://github.com/fishbigger/TapoP100/commit/7d3d25ba8d12ba2816b3ee50f918c4ad1a8fb74b#r63179338

realzoulou commented 2 years ago

@fishbigger I think all APIs returning a non-trivial result should follow one scheme. Either all return a dict, or all return a json string. Currently getDeviceInfo() is a bit of an exception.

fishbigger commented 2 years ago

Both getDeviceInfo and getEnergyUsage now return a json dict (2a15f46)

fishbigger commented 2 years ago

Uploaded to pypi in version 0.0.17.