JurajNyiri / HomeAssistant-Tapo-Control

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

Continued Errors After HA Restart #472

Closed kksligh closed 4 months ago

kksligh commented 7 months ago

Description

After restarting, this integration throws errors for one of the cameras. Oddly enough, it is a bit random on which one it is. I have 3 Tapo cameras connected....

Camera 1

Camera 2

Camera 3

Camera 3 was recently updated to a new firmware and it seems to be the most stable. Camera's 1 and 2 randomly will throw an error and it impacts the motion detection, ,motion alarm and noise detection functionality when it does error. They become unavailable.

Reproduction Steps

Restart HA and it happens nearly every time.

Expected behavior

Restart HA and it not error out.

If applicable, add error logs.

debug logs.txt

Device Firmware

Firmware: 1.3.9 Build 231019 Rel.31045n(5553)

Integration Version

5.4.12

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

HA OS installed on a NUC with Google Coral TPU

Search for similar issues

Yes

Additional information

No response

kranzhoff commented 7 months ago

Same issue here. I have 4 x Tapo C310 cameras setup and the availability of "binary_sensor.[…]_motion_alarm" and "binary_sensor.[…]_noise" of each camera seems to be totally random. Looking at the history chart of these sensors for a couple of days, they disappear for 6-10 hours and sometimes come back for just a few minutes to a few hours to then disappear again.

The camera settings and network setup did not change all the time. Not sure if this is related to restarts of HASS, but I restart HASS quite often these days.

Here are the relevant states from developer tools => states if this helps:

binary_sensor_states.txt

I wonder what “restored: true” means? Anyway, there are sensors without that attribute not working as well.

I had the impression that removing the cameras from the integration and adding them again gets the sensors back – but they still disappear again after a few hours.

The cameras do detect motion and noise as I receive notifications from the tapo app regularly. They just don't reach HASS - oviously because the sensors are marked as unavailable. Streams to HASS work all the time as well.

Will be happy to provide additional information if needed.

kranzhoff commented 7 months ago

Just tried removing and adding the cameras with "binary_sensor.[…]_motion_alarm" and "binary_sensor.[…]_noise" shown as "unavailable". One camera (#4) has both sensors working.

Removed and added the first camera and provoked noise and motion trigger: Both sensors of this camera are back again.

Removed and added camera 2 + 3 and trigeered motion and noise. Camera #3 both sensors working, camera #2 noise working but "motion" sonsor missing entirly.

Restarted HA:

Cameras 1,3 and 4(!): both sensors "unavailable" (even after triggering the sensors multiple times. Camera 2: noise "unavilable", motion missing entirely.

CONCLUSION:

Restarting HA removes sensors that have been working fine before. Even triggering the sensors does not bring them back.

JurajNyiri commented 7 months ago

Restarting HA removes sensors that have been working fine before. Even triggering the sensors does not bring them back.

Read FAQ in readme.

kranzhoff commented 7 months ago

Thanks for getting back on this. I read the FAQ at least 10 times and I don't see what I'm missing.

Sensors of all 4 cameras did work a couple of times, therefore network including webhooks should be fine. There are no disabled entities in .storage/core.entity_registry.

All cameras run the latest firmware version 1.3.9

Meanwhile camera #3 has both sensors back (without me doing anything). All other cameras have both sensors "unavailable" and one even "missing entity".

JurajNyiri commented 7 months ago

Motion sensor is added only after a motion is detected for the first time.

kranzhoff commented 7 months ago

Sure, but as I said before:

I triggerd motion and noise alarm on all cameras after restarting HA - to no avail. Camera #1 reports 10+ motion events via Tapo APP since the restart, but the sensor is "unavailable":

[binary_sensor.camera_eingang_motion_alarm] Camera_Eingang Motion Alarm unavailable restored: true device_class: motion friendly_name: Camera_Eingang Motion Alarm supported_features: 0

JurajNyiri commented 7 months ago

This integration reuses official onvif integration. See if it works there with no issues if you have tried everything else in the faq.

You can also enable debug logs both for onvif and this integration to see what exactly is going on with onvif.

kranzhoff commented 7 months ago

Thanks again for the speedy reply!

The debug log for the Tapo integration shows the same error for all cameras:

Logger: homeassistant.config_entries Source: config_entries.py:402 First occurred: 11:30:58 (60 occurrences) Last logged: 15:53:04 Error setting up entry 192.168.0.87 for select Error setting up entry 192.168.0.87 for siren Error setting up entry 192.168.0.87 for update Error setting up entry 192.168.0.87 for binary_sensor Error setting up entry 192.168.0.87 for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 402, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/camera/init.py", line 440, in async_setup_entry return await component.async_setup_entry(entry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry raise ValueError("Config entry has already been setup!") ValueError: Config entry has already been setup!

I will dig into the onvif logs now.

JurajNyiri commented 7 months ago

That looks like something wrong with the environment.

Try completely removing the cameras including entries for tapo_control inside .storage.

Then add cameras back and it should be ok.

kranzhoff commented 7 months ago

Thanks, I will give that a try.

Available sensors should stay available until a restart of HA, correct? After a restart they will be unavailable until they are triggered once again, correct?

falseunity commented 7 months ago

Same problem here. Everything works for a few days then 1 of the 4 cams shows unavailable for the motion entity. Triggering it, reloading integration, rebooting cam, rebooting HA, nothing brings it back. Removing the cam and re-setting it up again, brings it back working for a few more days. Then start all over again with a different cam unavailable. All C110, All same FW, etc. can't see any reason why...

falseunity commented 7 months ago

Also, FYI, installed the ONVIF integration a few days ago and it works without issue. The motion sensors appear and they've never gone unavailable since I installed it.

kksligh commented 7 months ago

@falseunity interesting, I will try this out - thank you for sharing.

Veda82 commented 7 months ago

I also have the same problem, 2 Tapo C200 on firmware 1.3.9 as well. Tried removing and adding them back, it worked for some time but then the issue came back. It seems the problem started after the update to the new firmware...

kksligh commented 7 months ago

I’ve tried the removal, including the .storage removal, and even removed the integration completely - still throws this error every restart. I’ve tried the ONVIF integration and it only exposes a fraction of the entities. So that’s not an option either.

falseunity commented 7 months ago

I agree with the ONVIF comment, it was just suggested we try it to see if the Motion Sensors do the same thing in there, and from my observations, they don't. But yes, ONVIF has many less entities that the Tapo integration for sure....

Veda82 commented 7 months ago

BTW, is there a way to revert to an older firmware? I'd like to try to understand if it might be related to firmware 1.3.9...

scetu commented 7 months ago

Hmm I had completely stable environment with three C200's, and this week I pulled trigger for new firmware 1.3.9 and since then I am having same issues as others in this thread.

I am now unable to move cameras - they cannot be put into patrol mode neither to preset.

Here is what is in logger when I try to change the input_select field

Logger: homeassistant.helpers.service
Source: helpers/service.py:243
First occurred: 16:28:55 (6 occurrences)
Last logged: 16:32:43

Referenced entities select.tapo_camera_kuchyn_move_to_preset are missing or not currently available
Referenced entities select.tapo_camera_loznice_move_to_preset are missing or not currently available
Referenced entities select.tapo_camera_obyvak_move_to_preset are missing or not currently available
Referenced entities select.tapo_camera_kuchyn_patrol_mode are missing or not currently available

And some other errors from reloading the integration.

Logger: homeassistant.components.select
Source: helpers/entity_platform.py:610
Integration: Select (documentation, issues)
First occurred: 16:31:17 (10 occurrences)
Last logged: 16:31:17

Platform tapo_control does not generate unique IDs. ID 28-87-ba-18-55-16-tapo_camera_kuchyn-babycrydetection already exists - ignoring select.tapo_camera_kuchyn_baby_cry_detection
Platform tapo_control does not generate unique IDs. ID 28-87-ba-18-55-16-tapo_camera_kuchyn-tamperdetection already exists - ignoring select.tapo_camera_kuchyn_tamper_detection
Platform tapo_control does not generate unique IDs. ID 28-87-ba-18-55-16-tapo_camera_kuchyn-movetopreset already exists - ignoring select.tapo_camera_kuchyn_move_to_preset
Platform tapo_control does not generate unique IDs. ID 28-87-ba-18-55-16-tapo_camera_kuchyn-patrolmode already exists - ignoring select.tapo_camera_kuchyn_patrol_mode
Platform tapo_control does not generate unique IDs. ID 28-87-ba-18-55-16-tapo_camera_kuchyn-spotlightintensity already exists - ignoring select.tapo_camera_kuchyn_spotlight_intensity
Logger: homeassistant.config_entries
Source: config_entries.py:402
First occurred: 16:31:22 (10 occurrences)
Last logged: 16:31:22

Error setting up entry 192.168.1.152 for select
Error setting up entry 192.168.1.152 for siren
Error setting up entry 192.168.1.152 for update
Error setting up entry 192.168.1.152 for binary_sensor
Error setting up entry 192.168.1.152 for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 402, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 440, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
    raise ValueError("Config entry has already been setup!")
ValueError: Config entry has already been setup!
scetu commented 7 months ago

I have started to reverting firmware (https://github.com/nervous-inhuman/tplink-tapo-c200-re/issues/4) on my C200's back to 1.3.4 (and also 1.3.5) but patrol mode or Move to preset did not worked even while downgraded and Tapo Integration has been setup from scratch.

But once I have downgraded them, I have recieved also new formware version Tapo_C200v3_en_1.3.11_Build_231115_Rel.85400n and this seems to work! For now...

JurajNyiri commented 4 months ago

Closing as this now looks to be fixed on new firmware. If issue persists, please open new issue.