petretiandrea / home-assistant-tapo-p100

A custom integration to control Tapo devices from home assistant.
MIT License
820 stars 102 forks source link

Error Adding a Device #350

Closed douglas-keay closed 1 year ago

douglas-keay commented 1 year ago

Version of the integration

1.4.0

Configuration

Tapo P100 
Firmware 1.3.6
Build 20210827
Rel 37578

Describe the bug

After updating to the newest version my plugs stopped being avilable. I removed and tried to re add the device, the first plug was successfull but the second failed to connect. I have tried with all the other 3 plugs I own all of which return the same error. All plugs are same model and FW build

Debug log

2023-01-20 13:53:54.451 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Device url is: http://192.168.1.205/app
2023-01-20 13:53:54.452 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Will perform handshaking...
2023-01-20 13:53:54.452 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Generating keypair
2023-01-20 13:53:54.581 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Handshake params: {"key": "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDbAQKpwCdxEHxsU4oL2VNyRxtrU8XzbPbKAlb0/V2fer5h5XCtY1/9Xqm6Kli/RTnLOwPfYY31ggvEj8Xw9bwiRwd7wAG3vpR2eD2EZ8+llIPipBkZOMw3mzyM+0IDfTbJC3pPBkNdVCQJoZxkjCAgk0A63PVrhSXqQWFxMYkQjwIDAQAB\n-----END PUBLIC KEY-----\n"}
2023-01-20 13:53:54.583 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Handshake method: {"method": "handshake", "params": {"key": "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDbAQKpwCdxEHxsU4oL2VNyRxtrU8XzbPbKAlb0/V2fer5h5XCtY1/9Xqm6Kli/RTnLOwPfYY31ggvEj8Xw9bwiRwd7wAG3vpR2eD2EZ8+llIPipBkZOMw3mzyM+0IDfTbJC3pPBkNdVCQJoZxkjCAgk0A63PVrhSXqQWFxMYkQjwIDAQAB\n-----END PUBLIC KEY-----\n"}}
2023-01-20 13:53:54.584 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Request body: {'method': 'handshake', 'params': {'key': '-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDbAQKpwCdxEHxsU4oL2VNyRxtrU8XzbPbKAlb0/V2fer5h5XCtY1/9Xqm6Kli/RTnLOwPfYY31ggvEj8Xw9bwiRwd7wAG3vpR2eD2EZ8+llIPipBkZOMw3mzyM+0IDfTbJC3pPBkNdVCQJoZxkjCAgk0A63PVrhSXqQWFxMYkQjwIDAQAB\n-----END PUBLIC KEY-----\n'}}
2023-01-20 13:53:54.648 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Device responded with: {'error_code': 0, 'result': {'key': 'hpiissnFjqK15SqDfZwkpWNN0NCZ5MZQyXR9j7dcDqAHpqXvqZ1ojXCgzW+Mxt6vyiQNd3BaGeJZWtmiF5YRcqp14VZ8f08BZNWjaTdr8aDQpeiELjXpHsMZUAOyelRcIc6BdSRpsdQJpX79k3PRqxK21woPgM0QFBvTO59xhow='}}
2023-01-20 13:53:54.648 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Got TP_SESSIONID token: ...E2A2E1A241B840B810BD10BD30B
2023-01-20 13:53:54.648 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Decoding handshake key...
2023-01-20 13:53:54.656 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Will login using username 'k@keay.dev...'
2023-01-20 13:53:54.656 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Username digest: ...f12d1
2023-01-20 13:53:54.659 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Login device params: {"password": "PASSWORD_REMOVED", "username": "ZjEyZDE4ZjFkZDExM2FjNGQ2ZGY3MDM1YmEwZDhkODZiNjRkNzFmZg=="}
2023-01-20 13:53:54.664 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Login device method: {"method": "login_device", "params": {"password": "PASSWORD_REMOVED", "username": "ZjEyZDE4ZjFkZDExM2FjNGQ2ZGY3MDM1YmEwZDhkODZiNjRkNzFmZg=="}, "requestTimeMils": 1674222834.6601706}
2023-01-20 13:53:54.667 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Login device method encrypted: MjLewNnIRiFTiOamLq3OAU9UjBXb2OcksJ0gVd1CRgGznD5BFmqFX0+JHM0ilHLmowxCV2FBW0pY/IqzeZ3n2Eh494s9Fein26fy8Fm7mWDtQ+ltEPW28aWhLCg1hD0o+W5o/QtDg8bCoox14humzmf11RXCWf9v6isuRAcktXolxl9lqpIuxIsSluQYv+SK4zJ4WOOLjNRm+JEcaI0xAv2Iww3d3agLtuSzHSFKQwYuCbCVFK6+Hr31NNMB3GSi
2023-01-20 13:53:54.668 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Secure passthrough method: {"method": "securePassthrough", "params": {"request": "MjLewNnIRiFTiOamLq3OAU9UjBXb2OcksJ0gVd1CRgGznD5BFmqFX0+JHM0ilHLmowxCV2FBW0pY/IqzeZ3n2Eh494s9Fein26fy8Fm7mWDtQ+ltEPW28aWhLCg1hD0o+W5o/QtDg8bCoox14humzmf11RXCWf9v6isuRAcktXolxl9lqpIuxIsSluQYv+SK4zJ4WOOLjNRm+JEcaI0xAv2Iww3d3agLtuSzHSFKQwYuCbCVFK6+Hr31NNMB3GSi"}}
2023-01-20 13:53:54.670 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Request body: {'method': 'securePassthrough', 'params': {'request': 'MjLewNnIRiFTiOamLq3OAU9UjBXb2OcksJ0gVd1CRgGznD5BFmqFX0+JHM0ilHLmowxCV2FBW0pY/IqzeZ3n2Eh494s9Fein26fy8Fm7mWDtQ+ltEPW28aWhLCg1hD0o+W5o/QtDg8bCoox14humzmf11RXCWf9v6isuRAcktXolxl9lqpIuxIsSluQYv+SK4zJ4WOOLjNRm+JEcaI0xAv2Iww3d3agLtuSzHSFKQwYuCbCVFK6+Hr31NNMB3GSi'}}
2023-01-20 13:53:54.723 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Device responded with: {'error_code': 0, 'result': {'response': 'ryw5Uc52UFD9rL512QKnkZw7vPHmK9JyX+9fZnYHBacQGbRsqbf6sYBUc0LU4RrR0bQhhdoVeUJ81Ee982uDTzUe8hMunkD8Tx+W9idj7Xg='}}
2023-01-20 13:53:54.726 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Device inner response: {'error_code': 0, 'result': {'token': 'FBEB72ECEE9C2A9F64AF86AEA9BE58BE'}}
2023-01-20 13:53:54.727 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Method request: {"method": "get_device_info", "params": null}
2023-01-20 13:53:54.730 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Method request encrypted: QxL5eaDTHxGND6FkI0HmUdOx8b7dRRRlmR0mxXOdos0DZphRxe3ROgtT4UdGGOS+
2023-01-20 13:53:54.730 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Secure passthrough method: <plugp100.tapo_protocol.methods.secure_passthrough_method.SecurePassthroughMethod object at 0x7f6df64603a0>
2023-01-20 13:53:54.732 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Request body: {'method': 'securePassthrough', 'params': {'request': 'QxL5eaDTHxGND6FkI0HmUdOx8b7dRRRlmR0mxXOdos0DZphRxe3ROgtT4UdGGOS+'}}
2023-01-20 13:53:54.799 DEBUG (MainThread) [plugp100.tapo_protocol.tapo_protocol_client] Device responded with: {'error_code': 9999}
2023-01-20 13:53:54.800 ERROR (MainThread) [custom_components.tapo.config_flow] Tapo exception 9999
2023-01-20 13:53:54.808 ERROR (MainThread) [custom_components.tapo.config_flow] Failed to setup cannot connect 
Nerd0o0 commented 1 year ago

Same problem. Existing device (Tapo P100) was marked as "device not supported anymore". After delete it (from config too) I can't add it. But my Tapo P110, unavailable when I update integration, still work properly

contrasenda commented 1 year ago

Same problem with a L900 light stripe. One of the two I have became unavailable. After deleting it, I couldn't configure it back. The other L900 kept working flawlessly. Back to 1.3.7 and I could add it again with no problem.

petretiandrea commented 1 year ago

v1.5.1 should fix the issue

contrasenda commented 1 year ago

Unfortunately, I still have errors with version 1.5.1. It happens as before, one of the light stripes keeps working and the other one doesn't. Same model and firmware version.

2023-01-31 10:13:55.075 ERROR (MainThread) [homeassistant.components.switch] Error while setting up tapo platform for switch Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/tapo/switch.py", line 24, in async_setup_entry _setup_from_coordinator(coordinator, async_add_devices) File "/config/custom_components/tapo/switch.py", line 40, in _setup_from_coordinator if coordinator.data.model.lower() in SUPPORTED_DEVICE_AS_SWITCH: AttributeError: 'NoneType' object has no attribute 'model' 2023-01-31 10:13:55.080 ERROR (MainThread) [homeassistant.components.light] Error while setting up tapo platform for light Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/tapo/light.py", line 37, in async_setup_entry _setup_from_coordinator(coordinator, async_add_devices) File "/config/custom_components/tapo/light.py", line 52, in _setup_from_coordinator if model.lower() in coordinator.data.model.lower(): AttributeError: 'NoneType' object has no attribute 'model' 2023-01-31 10:13:55.085 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up tapo platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/tapo/sensor.py", line 39, in async_setup_entry if coordinator.data.model.lower() in SUPPORTED_DEVICE_AS_SWITCH_POWER_MONITOR: AttributeError: 'NoneType' object has no attribute 'model' 2023-01-31 10:13:55.140 ERROR (MainThread) [homeassistant.components.binary_sensor] Error adding entities for domain binary_sensor with platform tapo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 438, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 494, in _async_add_entity entity.add_to_platform_start( File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 633, in add_to_platform_start if self.unique_id is None or self.device_class is None: File "/config/custom_components/tapo/sensor.py", line 59, in unique_id return super().unique_id + "_" + self._sensor_config.name.replace(" ", "_") TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' 2023-01-31 10:13:55.177 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up tapo platform for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 297, in _async_setup_platform await asyncio.gather(*pending) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 438, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 494, in _async_add_entity entity.add_to_platform_start( File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 633, in add_to_platform_start if self.unique_id is None or self.device_class is None: File "/config/custom_components/tapo/sensor.py", line 59, in unique_id return super().unique_id + "_" + self._sensor_config.name.replace(" ", "_") TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

mihing commented 1 year ago

v1.5.1 should fix the issue

Same problem on v1.5.1

athanasios-gkikas commented 1 year ago

Same problem here on v1.5.1. , but ...!!

All my plugs works perfect, but my L920 strip is unavailable. On trying re-adding, I receive "Failed to connect" message. I cannot remember if the strip was On when I was trying to connect it, but I just tried again with the strip On, and it connected @HomeAssistant. (I think I made no other updates between unsuccessful and successful tries)

Maybe it can help someone, or Andrea to debug it.

petretiandrea commented 1 year ago

Version 1.6.1 should fix this issue or log more detailed error