HomeAssistant-Tapo-Control: Bug: C310 Motion sensor stops working or becomes unavailable
Describe the bug Motion sensor stops reporting state change after some time. (daily). Stream still works. Sometimes motion sensor in HA reports unavailabe and somtimes it just stays in off state. Motion is still detected on camera and recordings work on Android Tapo app.
Reseting motion detection on camera or rebooting camera does not help. Only HA restart recovers motion detection state change.
I have explicitly opened ports on firewall 2020,554,443,1024 but result is the same.
Log No log entries.
**Camera (please complete the following information):**
C310
**Using stream component**
Yes
**Camera works through onvif component OR different cameras work in general**
Camera and motion detection works in Android Tapo app.
**Camera has all attributes filled out properly in developer tools**
yes
**HASS Environment**
Supervised HA OS (RP 4)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 57 (19 by maintainers)
I’m having the same issue with a Tapo C110. In my case restarting HA does not solve the issue. It actually shows up after restarting HA. Maybe it stops working earlier, but the sensor shows as “Clear” and after HA restart it shows as “Unavailable”. Any further restarts of HA (Even full OS reboot) have no effect and do not fix the issue. Disabling “Enable motion sensor” and then enabling it again seems to make the motion sensor work again (No HA restart necessary). I’ll try to play with the integration’s Debug options and how OVNIF is working here (Smells to me like a subscription to the motion event expires and is never refreshed, but I haven’t yet looked how the integration works). I’ll report back.
That confirms my belief that the Home Assistant event manager is not able to recover properly.
Lets add debug for it and observe how it behaves when it stops working.
This is an example of successful recovery on camera reboot:
Lets see what does it do when it stops receiving events. Once we have that information we can move forward and create a bug report on Home Assistant and/on workaround it via integration somehow.
To try to debug this issue, I am currently running this HA-Tapo Control in parallel with the ONVIF component. In addition, it seems to me that restarting HA (and thus connection to the Tapo devices) helps, while restarting the devices doesn’t seem to (curious, right?).
In the picture above (of two cameras), the top 2 rows is the HA-TC (motion and motion2), while the bottom two are from ONVIF. For whatever reason, I rarely see the “motion” sensor available for TC, and it seems always ‘off’ for ONVIF. The interesting part is the difference in the detected activity on the first camera… But as evident, sometimes ONVIF catches, sometimes HA-TC, sometimes both.
Also, in the picture @ 1:00 , HA was restarted.
So I’ll be watching it for the coming few days, in the meantime I’m using both motion2 sources as triggers I guess.
Let me share some of my experiences with this device.
Motion sensor uses to dissapear in some cases:
1 - bad network connection: high network latency ie. makes sensor to dissapear in some cases. To solve, check the cam and AP location (if wireless) and do a ping test.
2 - other app in use with the cam (like the tapo app). Kill the app in your device to prevent it running in backgroud. This devices uses software detections, and looks like creating multiple sockets complicates the functionality.
3 - remove cam from integration and re-add it. So, device is re consulted about their capacities and report correctly the motion detection sensor. (in the first start, the sensor uses not to be reported as active or valid, but at first motion detected, it uses to appears normally.
Hope this tips helps.
El 4/1/23 a las 07:43, Fabrizio Balliano escribió:
Reporting here
I am having the same issue with C310, C200 and C100 cameras, sometimes the motion comeback as motion_2
Having the same issue with both C200, C310 and C320:s becoming unavailable every now and then, have not been able to identify root cause. Video streams work flawlessly from the cameras to HA all the time, so only issue is with motion detection in HA via onvif. Motion detection with the Tapo app works without issues, it is the Onvif cell_motion_detection sensor that becomes unavailable. Sometimes a HA reboot solves the problem, but not always, very confusing behaviour. Happy to help with submitting logs, here is an example how it looks after HA startup. The three first cameras below have events = False as capability, they are also the cameras which are currently unavailable (but this differs between different times, so no static, i.e. sometimes it is other cameras becoming unavailable):
**2022-07-24 16:33:11 DEBUG (MainThread) [homeassistant.components.onvif] Camera Kamera tvrum C200 capabilities = Capabilities(snapshot=False, events=False, ptz=True) 2022-07-24 16:33:11 DEBUG (MainThread) [homeassistant.components.onvif] Camera Kamera huvudentre gång C320 capabilities = Capabilities(snapshot=False, events=False, ptz=False) 2022-07-24 16:33:18 DEBUG (MainThread) [homeassistant.components.onvif] Camera Kamera vattentank odlingslimpa C310 capabilities = Capabilities(snapshot=False, events=False, ptz=False)** 2022-07-24 16:33:31 DEBUG (MainThread) [homeassistant.components.onvif] Camera Kamera uppfart brevlåda C320 capabilities = Capabilities(snapshot=False, events=True, ptz=False) 2022-07-24 16:33:31 DEBUG (MainThread) [homeassistant.components.onvif] Camera Kamera tvättstuga C310 capabilities = Capabilities(snapshot=False, events=True, ptz=False) 2022-07-24 16:33:31 DEBUG (MainThread) [homeassistant.components.onvif] Camera Kamera parkering C310 capabilities = Capabilities(snapshot=False, events=True, ptz=False) 2022-07-24 16:33:31 DEBUG (MainThread) [homeassistant.components.onvif] Camera Kamera vattentank parkering C310 capabilities = Capabilities(snapshot=False, events=True, ptz=False)See camera availability corresponding to the HA log above. Again, it might be different cameras that become unavailable another time.
home-assistant.zip Here it is. It happend. I noticed around 14:45. Rebooted camera and nothing changed. I noticed in log that it reports everything is ok. But, motion is not detected. In Tapo App motion is detected and all i ok.
Its a big log.
Last recorded video on motion in on 14:54:42 This is camera Reboot 2021-04-23 14:57:43 ERROR (stream_worker) [homeassistant.components.stream.worker] Error demuxing stream: 2021-04-23 14:58:12 ERROR (MainThread) [custom_components.tapo_control] HTTPSConnectionPool(host=‘192.168.3.4’, port=443): Max retries exceeded with url: /stok=5e44aa5a80dab7c7f9e3e14841323312/ds (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x7f6a2f9400>: Failed to establish a new connection: [Errno 113] Host is unreachable’))
d.
My version on C200 is 1.1.7 Build 210406. Yours seems to be from January. Maybe they have different versions for C310 or are rolling it out in phases which is a common practice. That build seems to be pretty old though.
For motion sensor onvif event manager from home assistant is used, which is keeping itself alive during camera restarts, connection loss etc, so most likely change will be needed on Home Assistant side.
Before that we need to determine the cause though that’s why I added the debugging.
There might be a way how to work around it until it is fixed or it might be something I missed. Either way we will find out when it happens again.
As for replicating, I tried many things to try and replicate it - reconnect camera, reboot, disconnect it for a while… it always recovered properly so its really hard to debug without it happening.
Hello @dankocrnkovic
I have pushed a version with debug logs into main branch. Please download that manually (not available on HACS) and configure logger to log debug for this component.
On a first successful motion detection you should see a message “Found event which doesn’t have entity yet, adding binary sensor!”.
When it happens the next time, please restart the camera without restarting home assistant and post all the logs here (ideally from the time when it was still working).