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

Error in 2021.8.8 - KeyError 'result' #36

Closed thorin8k closed 3 years ago

thorin8k commented 3 years ago

Since latest patch the integration has stopped working. It was working correctly in version 2021.8.6.

Error:

Logger: homeassistant.components.switch
Source: custom_components/tapo_p100_control/switch.py:80
Integration: Interruptor (documentation, issues)
First occurred: 11:14:41 (1 occurrences)
Last logged: 11:14:41

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 41, in setup_platform
    add_entities([P100Plug(p100)])
  File "/config/custom_components/tapo_p100_control/switch.py", line 49, in __init__
    self.update()
  File "/config/custom_components/tapo_p100_control/switch.py", line 80, in update
    data = self._p100.getDeviceInfo()
  File "/usr/local/lib/python3.9/site-packages/PyP100/PyP100.py", line 247, in getDeviceInfo
    decryptedResponse = self.tpLinkCipher.decrypt(r.json()["result"]["response"])
KeyError: 'result'
thorin8k commented 3 years ago

Nevermind, it was a connectivity error between the plug and the router. It became online again after a couple of disconnections.

I will close the issue.

jkerdreux-imt commented 2 years ago

Firmware 1.4.10 seems raise an error 9999 if you try to do a handshake/login too frequently. In home assistant, update is called every 30 sec, so handshake/login too.

I applied a quick and dirty patch that simply return if we received a 9999 error_code. It seems to work without error right now.