petretiandrea / home-assistant-tapo-p100

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

Integration doesn't work with Home Assistant 2022.9.2 #243

Closed damiano75 closed 2 years ago

damiano75 commented 2 years ago

Version of the custom_component

v1.2.15

Configuration

Added using UI

image


2022-09-12 09:16:00.772 INFO (MainThread) [homeassistant.components.switch] Setting up switch.tapo
2022-09-12 09:16:00.785 INFO (MainThread) [homeassistant.components.light] Setting up light.tapo
2022-09-12 09:16:00.813 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.tapo
2022-09-12 09:16:00.822 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.tapo
2022-09-12 09:16:00.848 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 281, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/tapo/switch.py", line 19, in async_setup_entry
_setup_from_coordinator(coordinator, async_add_devices)
File "/config/custom_components/tapo/switch.py", line 33, in _setup_from_coordinator
if coordinator.data.model.lower() in SUPPORTED_DEVICE_AS_SWITCH:
AttributeError: 'NoneType' object has no attribute 'model'
2022-09-12 09:16:00.860 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 281, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/tapo/light.py", line 34, in async_setup_entry
_setup_from_coordinator(coordinator, async_add_devices)
File "/config/custom_components/tapo/light.py", line 49, in _setup_from_coordinator
if model.lower() in coordinator.data.model.lower():
AttributeError: 'NoneType' object has no attribute 'model'
2022-09-12 09:16:00.885 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 281, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/tapo/sensor.py", line 31, in async_setup_entry
if coordinator.data.model.lower() in SUPPORTED_DEVICE_AS_SWITCH_POWER_MONITOR:
AttributeError: 'NoneType' object has no attribute 'model'
2022-09-12 09:16:00.964 INFO (MainThread) [homeassistant.components.mobile_app.notify] mobile_app push notification rate limits for iPhone di Damiano: 7 sent, 500 allowed, 0 errors, resets in 16:43:59
2022-09-12 09:16:04.227 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 428, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 503, in _async_add_entity
if entity.unique_id is not None:
File "/config/custom_components/tapo/tapo_sensor_entity.py", line 43, in unique_id
return super().unique_id + "_" + self.sensor_config.name.replace(" ", "_")
File "/config/custom_components/tapo/tapo_entity.py", line 29, in unique_id
return self.coordinator.data.device_id
AttributeError: 'NoneType' object has no attribute 'device_id'
2022-09-12 09:16:04.303 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 289, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 503, in _async_add_entity
if entity.unique_id is not None:
File "/config/custom_components/tapo/tapo_sensor_entity.py", line 43, in unique_id
return super().unique_id + "_" + self.sensor_config.name.replace(" ", "_")
File "/config/custom_components/tapo/tapo_entity.py", line 29, in unique_id
return self.coordinator.data.device_id

Describe the bug

After upgrading to Home Assistant 2022.9.2 the integration doesn't work

Debug log

loryanstrant commented 2 years ago

Oh this is good to know, I literally just upgraded to 2022.9.2 a couple of hours ago and was starting to troubleshoot why 3 of my devices (all Tapo units) weren't coming back online.

ELA-RE commented 2 years ago

Yeah I've been having issues on my unraid server for about a week now :(

Pka78 commented 2 years ago

+1 Same issue with 2022.9.3.

petretiandrea commented 2 years ago

Can you report the OS info and Hardware Info where Ha is running? Also, the firmware version of tapo device and kind of type?

loryanstrant commented 2 years ago

I'm running HAOS in a VM on a Synology DS920+ NAS. My Tapo devices: 2 x - L920 (firmware 1.0.9 Build 220422 Rel.150004) 1 x - L530 (firmware 1.2.2 Build 20220110 Rel.72329)

GoliathLabs commented 2 years ago

Same problem here.

Running HAOS on my esxi Hypervisor 4x P100 (Firmware 1.3.6 Build 20210827 Rel. 37578)

GoliathLabs commented 2 years ago
2022-09-14 14:22:31.326 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 281, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/tapo/switch.py", line 19, in async_setup_entry
_setup_from_coordinator(coordinator, async_add_devices)
File "/config/custom_components/tapo/switch.py", line 33, in _setup_from_coordinator
if coordinator.data.model.lower() in SUPPORTED_DEVICE_AS_SWITCH:
AttributeError: 'NoneType' object has no attribute 'model'
2022-09-14 14:22:31.327 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 281, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/tapo/light.py", line 34, in async_setup_entry
_setup_from_coordinator(coordinator, async_add_devices)
File "/config/custom_components/tapo/light.py", line 49, in _setup_from_coordinator
if model.lower() in coordinator.data.model.lower():
AttributeError: 'NoneType' object has no attribute 'model'
2022-09-14 14:22:31.328 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 281, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/tapo/sensor.py", line 31, in async_setup_entry
if coordinator.data.model.lower() in SUPPORTED_DEVICE_AS_SWITCH_POWER_MONITOR:
AttributeError: 'NoneType' object has no attribute 'model'
petretiandrea commented 2 years ago

CPU architecture?

loryanstrant commented 2 years ago

CPU architecture?

Of the VM, or the NAS? My DS920 has an Intel Celeron J4125.

petretiandrea commented 2 years ago

CPU architecture?

Of the VM, or the NAS? My DS920 has an Intel Celeron J4125.

Are you running vm using ARM cpu architecture?

Which version of integration are you running?

hesnuks commented 2 years ago

Same Problem with Raspberry Pi 4.

mamoel666 commented 2 years ago

With my NUC 11 Pro (NUC11TNHi3, Core i3-1115G4), Ubuntu 22.04.01 and Home Assistant 2022.9.4 (Docker), the integration doesn't work at all. I add it via HACS, do a restart, but can't find anything with 'Tapo' under 'integrations'.

hesnuks commented 2 years ago

With my NUC 11 Pro (NUC11TNHi3, Core i3-1115G4), Ubuntu 22.04.01 and Home Assistant 2022.9.4 (Docker), the integration doesn't work at all. I add it via HACS, do a restart, but can't find anything with 'Tapo' under 'integrations'.

Did you clear the Cache with Shift + F5?

mamoel666 commented 2 years ago

Did you clear the Cache with Shift + F5?

Oh man...it seems I did not! I just repeated the whole procedure and now I see my Tapo P110 in HA including the energy monitoring. No warnings or errors in the logs. Sorry!

So at least this works with my installation of Home Assistant 2022.9.4.

damiano75 commented 2 years ago

After the upgrade to Home Assistant 2022.9.4 the issue is fixed for me...

loryanstrant commented 2 years ago

After the upgrade to Home Assistant 2022.9.4 the issue is fixed for me...

Do you mean after the update in HACS that just came through today, or since upgrading to 2022.9.4 it works whereas previous 2022.9.x versions didn't?

damiano75 commented 2 years ago

After the upgrade to Home Assistant 2022.9.4 the issue is fixed for me...

Do you mean after the update in HACS that just came through today, or since upgrading to 2022.9.4 it works whereas previous 2022.9.x versions didn't?

Just upgrading to Home Assistant 2022.9.4, I did the upgrade yesterday and tapo p100 was online again

hesnuks commented 2 years ago

On Updating to 2022.9.4 for me 2 of my plugs were not available anymore. 2 of the Plugs were available... When i try to re-add them i get this: 2022-09-16 13:13:16.425 ERROR (MainThread) [custom_components.tapo.config_flow] Unexpected exception Traceback (most recent call last): File "/config/custom_components/tapo/config_flow.py", line 55, in async_step_user entry_metadata = await self._validate_input(user_input) File "/config/custom_components/tapo/config_flow.py", line 92, in _validate_input state = await tapo_api.get_state() File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 89, in get_state state=await self.get_state_as_dict(), File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 213, in get_state_as_dict return await self._execute_method_request(device_info_method) File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 238, in _execute_method_request self.validate_response(resp_dict) File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 257, in validate_response raise TapoException.from_error_code(resp['error_code']) plugp100.core.exceptions.TapoException.TapoException: Returned unknown error_code: 9999

loryanstrant commented 2 years ago

@hesnuks are the 4 plugs different models, or the same?

hesnuks commented 2 years ago

@loryanstrant all the same. P100 and all are on the newest version.

loryanstrant commented 2 years ago

Well, that's confusing. I might try to upgrade mine to 2022.9.4 tomorrow and see if it makes a difference. The only affected lights are the ones in my kids rooms, and they've gone to sleep. This is making a stronger case for me to switch over any proprietary things like these to something like ESPHome where possible, because @petretiandrea doesn't exactly have to deliver to a SLA - but I do for my kids. :-)

hesnuks commented 2 years ago

I just readded them also in the Tapo App and then readded them in the integration. Now it works again. So it seems to work in 2022.9.4 but with some extra work :)

GoliathLabs commented 2 years ago

After adding them in HomeAssistant 2022.9.4 they are available again

Pka78 commented 2 years ago

After adding them in HomeAssistant 2022.9.4 they are available again

+1, after updating 2022.9.4 Plugin works again.

loryanstrant commented 2 years ago

Also confirmed as working. Updated to 2022.9.4, removed integration, rebooted, re-added, all fine.

stain3565 commented 2 years ago

2022.9.7 has caused the issue for me. Last few versions seemed OK but now every one of my p100 and p110 plugs is unavailable. Seems each new HA version is a bit hit and miss as to whether the Tapo integration works.

In logs:

Logger: homeassistant.config_entries Source: config_entries.py:1034 First occurred: 00:13:32 (2 occurrences) Last logged: 00:15:08

Config entry 'Tapo 9' for tapo integration not ready yet: None; Retrying in background

Config entry 'Tapo 12' for tapo integration not ready yet: None; Retrying in background

Same for every plug

mamoel666 commented 2 years ago

No problems here with 2022.9.7 with one p110 plug.

shocker2 commented 2 years ago

Works fine on 2022.9.7 with 23 P110 plugs and 5 P115.

stain3565 commented 2 years ago

OK. Well mine is definitely not working now. I have had a go at removing all Tapo Controller entities and adding from scratch.

Getting invalid authentication for every one.

The id and password have not changed (lower case letters and numbers for the password). The ip addresses I am adding as the host match each plug ip address in Tapo app device info.

It was working until either version 6 or 7.

I thought that it could have been due to renaming tapo devices/entities in HA. However, the failure to add them from scratch suggests otherwise, as they are nit even getting past validation. No logs for adding new devices but before, that, I was getting the "config entry xxxx for tapo integration not ready yet".

I hope I don't have to re-pair all 18 in the Tapo app but, unless others get similar issues, I may have to.

vscmail commented 2 years ago

Hello running 2022.9.7 on Pi4, I installed the add-on (Result ok) the when I try to configure a new Tapo 100 I always get this error: Logger: homeassistant.components.switch Source: helpers/update_coordinator.py:178 Integration: Switch (documentation, issues)

Error while setting up tapo platform for switch Traceback (most recent call last): File "/config/custom_components/tapo/common_setup.py", line 96, in _update_with_fallback return await self.api.get_state() File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 89, in get_state state=await self.get_state_as_dict(), File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 213, in get_state_as_dict return await self._execute_method_request(device_info_method) File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 225, in _execute_method_request dim_encrypted = self.tp_link_cipher.encrypt(jsons.dumps(method)) AttributeError: 'NoneType' object has no attribute 'encrypt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/config/custom_components/tapo/common_setup.py", line 90, in _async_update_data return await self._update_with_fallback() File "/config/custom_components/tapo/common_setup.py", line 99, in _update_with_fallback await self.api.login() File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 85, in login await self._login_request(self.username, self.password) File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 209, in _login_request self.token = decrypted_inner_response['result']['token'] KeyError: 'result' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/tapo/common_setup.py", line 92, in _async_update_data raise UpdateFailed() from exception homeassistant.helpers.update_coordinator.UpdateFailed The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/tapo/switch.py", line 28, in async_setup_platform coordinator = await setup_tapo_coordinator_from_dictionary(hass, config) File "/config/custom_components/tapo/common_setup.py", line 31, in setup_tapo_coordinator_from_dictionary return await setup_tapo_coordinator( File "/config/custom_components/tapo/common_setup.py", line 57, in setup_tapo_coordinator await coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 178, in async_config_entry_first_refresh raise ex homeassistant.exceptions.ConfigEntryNotReady

When I try to connect a device it always gives me the feedback Invalid authentication. Reading the previous post from stain3565, I kind of understand that not only the email shall be all small caps (that's OK) but also that the password shall be only using combination of small caps and figures. So I did it. Anything else I can do to fix this issue? Thanks

stain3565 commented 2 years ago

I went back to 2022.9.4, removed all plugs from the tapo app and home assistant, re-added in tapo app and integrated again in home assistant.

My one thought during this was perhaps my plug firmware was not up to date. I know that some P100s were older firmware but the P110s were up to date.

So now all readded and latest firmware.

First time in, looked OK with no exclamation marks against any online plugs.

However, it is now haphazard as to which plugs are available in HA after any restart. Sadly today the number is just 2 out of 20. And one of those I just readded from scratch.

Log for one attempted reload is below:

Logger: homeassistant.config_entries Source: config_entries.py:1031 First occurred: 16:08:58 (1 occurrences) Last logged: 16:08:58

Config entry 'Tapo 10' for tapo integration not ready yet: None; Retrying in background

I have also tried in 2022.9.7 but results were the same.

Update: Have now upgraded to HA 2022.10.1. This has not improved matters. It seems that I have to keep resetting the plugs and going through the process from scratch in Tapo and HA, just to get these working for a while. Today, 9 of my plugs are unavailable. I absolutely understand that there could be something in my setup that is interfering but I really don't know if I can rely on these plugs anymore. They are always fine in the Tapo app. None of them behave incorrectly and they are always in the state of available/off/on that I expect them to be. I have also, with one that was not available in HA, added it manually via yaml. Admittedly, I did not expect this would make a difference but at least I tried it. That plug (named Tapo 10) did not appear in any logs and was not available in HA.

Latest logs were:

2022-10-07 12:46:31.531 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration tapo which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2022-10-07 12:47:54.158 INFO (MainThread) [homeassistant.setup] Setup of domain tapo took 0.0 seconds 2022-10-07 12:48:04.473 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 28' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:05.335 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 22' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:05.942 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 24' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:06.563 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 7' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:07.570 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 25' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:07.770 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 3' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:07.773 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 8' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:07.776 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 11' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:07.780 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 26' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:07.783 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 23' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:07.786 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 9' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:08.008 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 27' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:09.372 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 21' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:09.375 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 5' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:48:12.780 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tapo 6' for tapo integration not ready yet: None; Retrying in background 2022-10-07 12:50:19.062 ERROR (MainThread) [custom_components.tapo.common_setup] Error fetching tapo data: 2022-10-07 12:50:56.476 INFO (MainThread) [custom_components.tapo.common_setup] Fetching tapo data recovered

ANOTHER UPDATE:

I investigated the wifi connections for those that worked and those that didn't. Although within the Tapo app, all worked, on my network, it became apparent that the working HA plugs were attached to a bridge mesh network I have in place off the main BT router. I have just replaced that mesh although the same situation was clearly happening before I replaced it with a previous mesh setup, as my issues predate that replacement. Those that were not working in HA were connecting to the main BT wifi router, seemingly via either a satellite disk for this or, I believe, via the main router itself. Not too sure about the latter as I started fixing the issue when it was clear the mesh was working with Tapo HA and I saw that some plugs were connecting to the main router satellite disk. I have attached all the plugs to the mesh and, touch wood, they seem to be up and running in HA. I am still unsure as to why HA Tapo had an issue with the router wifi network. It clearly was not a problem for the Tapo app and the plugs generally but only when Tapo Controller attempted to retrieve the plug credentials. Anyway, fingers crossed this is my last entry here.

petretiandrea commented 2 years ago

I will close this issue cause 2022.9.x is now working. So if you have problem with 2022.10.x open another issue instead of writing here.

I would like to remind you that integration works with devices which have a static IP, so if not please setup it from router page.