JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
953 stars 80 forks source link

Getting ValueError everytime HAS is restarted #535

Closed marco-calautti closed 3 months ago

marco-calautti commented 3 months ago

Description

I have a C200 and a C500 camera. When I restart HAS (e.g., with docker restart), HAS throws a ValueError regarding the C200 camera, saying that "config entry has already been setup". This makes HAS unreachable, and I have to restart it multiple times until I am finally able to reach it again.

I am using the latest version of the integration, but for some reasons its manifests still says 5.4.13, and not 5.4.17

Reproduction Steps

  1. Configure the C200 camera with credentials
  2. Restart HAS

Expected behavior

Not throw any errors

If applicable, add error logs.

File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 183, in async_setup_entry

raise ValueError("Config entry has already been setup!")

ValueError: Config entry has already been setup!

2024-03-20 09:30:14.172 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Telecamera Soggiorno for number

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup

result = await component.async_setup_entry(hass, self)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/components/number/init.py", line 119, in async_setup_entry

return await component.async_setup_entry(entry)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 183, in async_setup_entry

raise ValueError("Config entry has already been setup!")

ValueError: Config entry has already been setup!

2024-03-20 09:30:14.175 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Telecamera Soggiorno for select

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup

result = await component.async_setup_entry(hass, self)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/components/select/init.py", line 109, in async_setup_entry

return await component.async_setup_entry(entry)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 183, in async_setup_entry

raise ValueError("Config entry has already been setup!")

ValueError: Config entry has already been setup!

2024-03-20 09:30:14.177 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Telecamera Soggiorno for siren

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup

result = await component.async_setup_entry(hass, self)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/components/siren/init.py", line 153, in async_setup_entry

return await component.async_setup_entry(entry)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 183, in async_setup_entry

raise ValueError("Config entry has already been setup!")

ValueError: Config entry has already been setup!

2024-03-20 09:30:14.179 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Telecamera Soggiorno for update

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup

result = await component.async_setup_entry(hass, self)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/components/update/init.py", line 122, in async_setup_entry

return await component.async_setup_entry(entry)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 183, in async_setup_entry

raise ValueError("Config entry has already been setup!")

ValueError: Config entry has already been setup!

2024-03-20 09:30:14.182 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Telecamera Soggiorno for binary_sensor

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup

result = await component.async_setup_entry(hass, self)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/components/binary_sensor/init.py", line 238, in async_setup_entry

return await component.async_setup_entry(entry)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 183, in async_setup_entry

raise ValueError("Config entry has already been setup!")

ValueError: Config entry has already been setup!

2024-03-20 09:30:14.185 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Telecamera Soggiorno for sensor

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup

result = await component.async_setup_entry(hass, self)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 139, in async_setup_entry

return await component.async_setup_entry(entry)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 183, in async_setup_entry

raise ValueError("Config entry has already been setup!")

ValueError: Config entry has already been setup!

Device Firmware

1.3.11 Build 231115 Rel.85400n(4555)

Integration Version

5.4.17

Using stream component

No

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Docker

Search for similar issues

Yes

Additional information

I have already searched for a similar issue, which apparently has been closed because seemingly was fixed with the latest tapo firmware 1.3.11 (which my camera has). But it does not seem it has actually been fixed.

JurajNyiri commented 3 months ago

Clear all references to tapo_control from .storage manually. Restart ha and try to add camera again. This is most probably an env corruption.

marco-calautti commented 2 months ago

Sorry but I did not have time to reply in time. Saying "clear all references to tapo_control from .storage" is very vague and doe snot tell me actually how to fix the issue. There are many files in the .storage folder. For which files should I remove these references? And what do you mean by that?

basrieter commented 1 month ago

I have the exact same issue after some time. Initially it works. The the binary_sensors become unavailable and this error happens on reload.

EDIT: I can fix it by reloading the integration several times.