core: ONVIF (motion) events not working with Dahua DH-SD22404T-GN-W and anpviz

The problem

ONVIF integration does not receive events from my onvif camera.

Environment

  • Home Assistant Core release with the issue: 0.112.2
  • Last working Home Assistant Core release (if known): n/a
  • Operating environment (OS/Container/Supervised/Core): Container
  • Integration causing this issue: ONVIF
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/onvif

Problem-relevant configuration.yaml


Traceback/Error logs


Additional information

Onvif manager is receiving motion detection and alarm events from my camera but binary sensors created in home assistant do not change state. In debug logging I also see no trace of the events:

2020-07-06 07:57:46 INFO (MainThread) [homeassistant.setup] Setup of domain onvif took 0.2 seconds.
2020-07-06 07:57:51 DEBUG (MainThread) [homeassistant.components.onvif] Setting up the ONVIF device management service
2020-07-06 07:57:51 DEBUG (MainThread) [homeassistant.components.onvif] Retrieving current device date/time
2020-07-06 07:57:51 DEBUG (MainThread) [homeassistant.components.onvif] Setting up the ONVIF device management service
2020-07-06 07:57:51 DEBUG (MainThread) [homeassistant.components.onvif] Retrieving current device date/time
2020-07-06 07:57:52 DEBUG (MainThread) [homeassistant.components.onvif] Device date/time: 2020-07-06 05:57:52+00:00 | System date/time: 2020-07-06 05:57:51.328419+00:00
2020-07-06 07:57:52 DEBUG (MainThread) [homeassistant.components.onvif] Device date/time: 2020-07-06 05:57:51+00:00 | System date/time: 2020-07-06 05:57:51.488747+00:00
2020-07-06 07:58:01 INFO (MainThread) [homeassistant.components.camera] Setting up camera.onvif
2020-07-06 07:58:01 INFO (MainThread) [homeassistant.components.camera] Setting up camera.onvif
2020-07-06 07:58:01 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.onvif
2020-07-06 07:58:01 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.onvif

image

image

reboot event is also not coming in.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 50 (12 by maintainers)

Commits related to this issue

Most upvoted comments

#91866 will fix a few of the cameras here but I have no way of knowing which ones.

If there is still a problem in 2023.5.x, please open a new fresh issue with ONE camera per issue with the name and model of the camera in the report so we don’t end up closing it prematurely when we fix one. It would also be helpful to include a link to purchase the camera

Make sure to include debug logs and diagnostics for the camera https://www.home-assistant.io/docs/configuration/troubleshooting/#debug-logs-and-diagnostics

I put the changes up at https://github.com/bdraco/onvif

mkdir -p /config/custom_components
cd /config/custom_components
git clone https://github.com/bdraco/onvif

Restart

Please give it another try after 2023.4.5 is released. It should work with a few more cameras. It will not fix all of them though as each one has to be examined separately as not every vendor implements the onvif standard in the same way.

bump

Still an issue with core-2021.9.7

               I found a solution  (possible bug) for this in the file parser.py from onvif integration.
              This could be a solution also for  #37878, #36757, #40175, #42784, #37545, #36145


                 My NVR ONVIF reports data movement event state like this: (see my previous message from Dec 20, 2020):

tt:Data <tt:SimpleItem Value=“1” Name=“State”></tt:SimpleItem></tt:Data>

                In Onvif integration  from    https://github.com/home-assistant/core/tree/dev/homeassistant/components/onvif
                The file       parser.py            compares onvif event data state with a value equal to "true":

try: source = msg.Message.value_1.Source.SimpleItem[0].Value return Event( f"{uid}{msg.Topic.value_1}{source}“, f”{source} Motion Alarm", “binary_sensor”, “motion”, None, msg.Message._value_1.Data.SimpleItem[0].Value == “true”

                 As my NVR reports "1" for movement, I simply replaced value "true" with "1" ., like this: 

try: source = msg.Message.value_1.Source.SimpleItem[0].Value return Event( f"{uid}{msg.Topic.value_1}{source}“, f”{source} Motion Alarm", “binary_sensor”, “motion”, None, msg.Message._value_1.Data.SimpleItem[0].Value == “1”

       To modify parser.py I installed ONVIF as custom_component by creating custom_components folder in config folder 
        and by copying there the onvif folder from github. I modified parser.py in this folder. So onvif now works from 
        custom_components, not from original integration.

           Now the events work.
            I hope this helps somebody.

I see the events in ODM after setting ODM to pullpoint only after restarting ODM (to be sure it is using pullpoint).

I don’t see the event in home assistant onvif integration.

Camera is Dahua IPC-HDW5231R-ZE.

Happy to do further debuging, testing, etc

Same issue here with an ONVIF Profile S camera (Imou/Dahua LOOC IPC-C26E). Entities are created, but no state update of the various entities.