fishbigger / HomeAssistant-Tapo-P100-Control

A custom integration for home assistant to control the Tapo P100 plugs
MIT License
208 stars 69 forks source link

Unknown Error #47

Closed danish-din closed 2 years ago

danish-din commented 2 years ago

Logger: homeassistant.components.switch Source: custom_components/tapo_p100_control/switch.py:86 Integration: Switch (documentation, issues) First occurred: 4:41:34 PM (1 occurrences) Last logged: 4:41:34 PM

Error while setting up tapo_p100_control platform for switch Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/tapo_p100_control/switch.py", line 44, in setup_platform add_entities([P100Plug(p100)]) File "/config/custom_components/tapo_p100_control/switch.py", line 53, in init self.update() File "/config/custom_components/tapo_p100_control/switch.py", line 86, in update data = self._p100.getDeviceInfo() File "/usr/local/lib/python3.9/site-packages/PyP100/PyP100.py", line 278, in getDeviceInfo decryptedResponse = self.tpLinkCipher.decrypt(r.json()["result"]["response"]) KeyError: 'result'

Core Version core-2021.12.6

Supervisor Version supervisor-2021.12.2

damian5602 commented 2 years ago

Also in my case Error while setting up tapo_p100_control platform for switch Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/tapo_p100_control/switch.py", line 44, in setup_platform add_entities([P100Plug(p100)]) File "/config/custom_components/tapo_p100_control/switch.py", line 53, in __init__ self.update() File "/config/custom_components/tapo_p100_control/switch.py", line 87, in update data = json.loads(data) File "/usr/local/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

core-2021.12.8 supervisor-2021.12.2 Home Assistant OS 7.1

danieleds commented 2 years ago

same here, even with the v0.0.16 of the python lib

danieleds commented 2 years ago

TypeError: the JSON object must be str, bytes or bytearray, not dict

You can fix it by commenting out this line: https://github.com/fishbigger/HomeAssistant-Tapo-P100-Control/blob/29081d0/tapo_p100_control/switch.py#L87

fishbigger commented 2 years ago

Hi all, thanks for notifying me of the issue I believe I now know what the cause is (https://github.com/fishbigger/TapoP100/issues/41). And I will work on fixing it asap.

fishbigger commented 2 years ago

I have uploaded a fix now. Please can you check if it works and close this issue respectively.

pvillaverde commented 2 years ago

Hey there! I'm trying to setup the integration and I got a similar error, Might it be related to this?

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/tapo_p100_control/light.py", line 38, in setup_platform
    l530 = PyP100.L530(ipAddress, email, password)
NameError: name 'PyP100' is not defined
fishbigger commented 2 years ago

Hey there! I'm trying to setup the integration and I got a similar error, Might it be related to this?

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/tapo_p100_control/light.py", line 38, in setup_platform
    l530 = PyP100.L530(ipAddress, email, password)
NameError: name 'PyP100' is not defined

This wasn't related to the original issue but it was a quick fix anyway. Thanks for letting me know!

danieleds commented 2 years ago

@fishbigger your fix worked great!