core icon indicating copy to clipboard operation
core copied to clipboard

ONVIF (motion) events not working

Open Geronimo2015 opened this issue 4 years ago • 30 comments

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.

Geronimo2015 avatar Jul 06 '20 06:07 Geronimo2015

onvif documentation onvif source (message by IssueLinks)

Hey there @hunterjm, mind taking a look at this issue as its been labeled with an integration (onvif) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

I'm having the same issue, my cameras are displaying the same sensors. When checking in onvif device manager I clearly see the motion alarms firing.

tipofthesowrd avatar Jul 21 '20 07:07 tipofthesowrd

I have this issue with the reolink 243-5MP also. I see the events appear in "OVNIF Device Manager." They show up as the tns1:RuleEngine/CellMotionDetector/Motion topic. One strange thing that I found though was that I needed to set the event subscription to Base Subscription is it possible that these cameras don't support PullPoint Subscription?

geiseri avatar Aug 08 '20 14:08 geiseri

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.

GreyEarl avatar Aug 23 '20 20:08 GreyEarl

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

UmbraMalison avatar Aug 25 '20 18:08 UmbraMalison

I have the same problem: ONVIF camera integration with LOOC IMOU camera seems to be okay but sensors never update in Home Asistant

few hours later, after installing HA 0.115 problem solved :-)!!

loeffen avatar Sep 17 '20 13:09 loeffen

since upgrading to 115.2 (was on 114.4 iirc) events are now working. Not precluding intermediary releases, but this is now fixed for me.

UmbraMalison avatar Sep 20 '20 19:09 UmbraMalison

I can confirm the above. I'm now on 0.115.3 and events, like motion sensor, are now working for my ONVIF camera.

@UmbraMalison, @loeffen As we have basically the same camera, do you have a sound/noise sensor listed as event? I know this camera is capable of detecting audio, but it seems it is not passed through ONVIF.

GreyEarl avatar Sep 28 '20 08:09 GreyEarl

I can confirm the above. I'm now on 0.115.3 and events, like motion sensor, are now working for my ONVIF camera.

@UmbraMalison, @loeffen As we have basically the same camera, do you have a sound/noise sensor listed as event? I know this camera is capable of detecting audio, but it seems it is not passed through ONVIF.

@GreyEarl

yes, have you enabled audio in the web interface of the camera? cctv1 2

should look like this: cctv1

UmbraMalison avatar Sep 28 '20 09:09 UmbraMalison

I can confirm the above. I'm now on 0.115.3 and events, like motion sensor, are now working for my ONVIF camera. @UmbraMalison, @loeffen As we have basically the same camera, do you have a sound/noise sensor listed as event? I know this camera is capable of detecting audio, but it seems it is not passed through ONVIF.

@GreyEarl

yes, have you enabled audio in the web interface of the camera?

should look like this:

Ah, thanks! I see you camera is actually a different model, my bad. But it is good to see that such option is passed through ONVIF. I will investigate further, thanks!

GreyEarl avatar Sep 28 '20 09:09 GreyEarl

yeah, maybe a reboot might do it. there's some process that the onvif integration goes through to scan the events available to it, I don't know when that happens (but likely on startup, or on creation of the integration). potentially if your camera isn't providing an event at the time of "scanning/probing" then it wouldn't have been seen by the integration.

i'm 100% speculating.

I have seen though that my other identical camera does not have field detection, as I have not enabled IVS intrusion, and i've also seen that IVS tripwire doesn't trigger in the onvif integration - only IVS intrusion.

So potentially on the sound events, i'm only seeing either Input Abnormal event or Intensity Change event. or maybe both!

UmbraMalison avatar Sep 28 '20 10:09 UmbraMalison

Dahua firmware doesn’t send an initialization event for sound or any of the IVS features. Go walk in front of your camera and make noise, then go back to HA and the sensors will be there.

hunterjm avatar Sep 28 '20 13:09 hunterjm

Same issue here, any news?

image image

2020-12-10 18:10:46 INFO (MainThread) [homeassistant.components.onvif] No registered handler for event from 00:2a:2a:41:9f:91: {
'SubscriptionReference': None,
'Topic': {
'_value_1': 'tns1:Device/Trigger/DigitalInput',
'Dialect': 'http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet',
'_attr_1': {
}
},
'ProducerReference': None,
'Message': {
'_value_1': {
'Source': {
'SimpleItem': [
{
'Name': 'InputToken',
'Value': 'DigitalInput0'
}
],
'ElementItem': [],
'Extension': None,
'_attr_1': None
},
'Key': None,
'Data': {
'SimpleItem': [
{
'Name': 'LogicalState',
'Value': 'false'
}
],
'ElementItem': [],
'Extension': None,
'_attr_1': None
},
'Extension': None,
'UtcTime': datetime.datetime(2020, 12, 10, 17, 10, 48, 179000),
'PropertyOperation': None,
'_attr_1': {
}
}
}
}

mgiako avatar Dec 10 '20 16:12 mgiako

Same problem:

  • I see the events in ODM .

image

  • The motion input from NVR also appears in in HA logs:

SOAP-ENV:Bodytev:PullMessagesResponsetev:CurrentTime2020-12-19T22:26:38Z</tev:CurrentTime>tev:TerminationTime2020-12-20T20:24:57Z</tev:TerminationTime>wsnt:NotificationMessagewsnt:SubscriptionReferencewsa5:Address</wsa5:Address></wsnt:SubscriptionReference><wsnt:Topic Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet">tns1:VideoSource/MotionAlarm</wsnt:Topic>wsnt:ProducerReferencewsa5:Address10.0.10.31/onvif/event/alarm</wsa5:Address></wsnt:ProducerReference>wsnt:Message<tt:Message PropertyOperation="Changed" UtcTime="2020-12-19T22:26:37Z">tt:Source<tt:SimpleItem Value="00200" Name="VideoSourceConfigurationToken"></tt:SimpleItem><tt:SimpleItem Value="0" Name="DetectWindow"></tt:SimpleItem></tt:Source>tt:Data<tt:SimpleItem Value="1" Name="State"></tt:SimpleItem></tt:Data></tt:Message></wsnt:Message></wsnt:NotificationMessage></tev:PullMessagesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>'

  • I don't see the event in home assistant onvif integration for NVR - the motion sensor always shows Clear (No motion detected) state.

System is running on VM: Operating System: Home Assistant OS 5.8

Supervisor: Version 2020.12.7

catalin2009 avatar Dec 20 '20 06:12 catalin2009

               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.

catalin2009 avatar Feb 07 '21 17:02 catalin2009

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 14 '21 12:05 github-actions[bot]

I think this is more of the same re: #49280 and #48606. Would it be best to roll these into one ticket?

geiseri avatar May 15 '21 13:05 geiseri

I have the same problem: ONVIF camera integration with LOOC IMOU camera seems to be okay but sensors never update in Home Asistant

few hours later, after installing HA 0.115 problem solved :-)!!

Same issue here but with HA core 2021.6.6. Is there a way to fix it?

Thanks

TheBisk avatar Jun 23 '21 20:06 TheBisk

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 21 '21 21:09 github-actions[bot]

Still an issue with core-2021.9.7

geiseri avatar Sep 22 '21 03:09 geiseri

Yes, it is still an issue unfortunatly.

TheBisk avatar Sep 28 '21 12:09 TheBisk

My camera (asecam from aliexpress) reports motion events in a way that is not handled correctly by current home assistant onvif module: actually 'no motion' message is handled incorrectly, while 'motion present' is handled correctly. If you restart home assistant while there is motion in camera (e.g. waving a hand), the home assistant sensor reports correctly motion, but never resets: it seems that 'no motion' message is not understood. When there is 'no motion' my camera sets the Message field to None:

{
    'CurrentTime': datetime.datetime(2021, 9, 29, 14, 37, 20, tzinfo=<isodate.tzinfo.Utc object at 0x0000015ACC471160>),
    'TerminationTime': datetime.datetime(2021, 9, 29, 14, 42, 20, tzinfo=<isodate.tzinfo.Utc object at 0x0000015ACC471160>),
    'NotificationMessage': [
        {
            'SubscriptionReference': None,
            'Topic': {
                '_value_1': 'tns1:RuleEngine/CellMotionDetector/Motion',
                'Dialect': 'http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet',
                '_attr_1': {
            }
            },
            'ProducerReference': None,
            'Message': None
        }
    ]
}

So the parse method for CellMotionDetector in parsers.py throws an Exception and NO 'no motion' event is generated for home assistant sensor.

For reference here is the 'motion present' message which is parsed correctly:

{
    'CurrentTime': datetime.datetime(2021, 9, 29, 14, 36, 50, tzinfo=<isodate.tzinfo.Utc object at 0x0000015ACC471160>),
    'TerminationTime': datetime.datetime(2021, 9, 29, 14, 41, 50, tzinfo=<isodate.tzinfo.Utc object at 0x0000015ACC471160>),
    'NotificationMessage': [
        {
            'SubscriptionReference': None,
            'Topic': {
                '_value_1': 'tns1:RuleEngine/CellMotionDetector/Motion',
                'Dialect': 'http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet',
                '_attr_1': {
            }
            },
            'ProducerReference': None,
            'Message': {
                '_value_1': {
                    'Source': {
                        'SimpleItem': [
                            {
                                'Name': 'VideoSourceConfigurationToken',
                                'Value': 'VideoAnalyticsToken'
                            }
                        ],
                        'ElementItem': [],
                        'Extension': None,
                        '_attr_1': None
                    },
                    'Key': None,
                    'Data': {
                        'SimpleItem': [
                            {
                                'Name': 'IsMotion',
                                'Value': 'true'
                            }
                        ],
                        'ElementItem': [],
                        'Extension': None,
                        '_attr_1': None
                    },
                    'Extension': None,
                    'UtcTime': datetime.datetime(2021, 9, 29, 14, 36, 50, tzinfo=<isodate.tzinfo.Utc object at 0x0000015ACC471160>),
                    'PropertyOperation': None,
                    '_attr_1': {
                }
                }
            }
        }
    ]
}

yuroller avatar Sep 30 '21 07:09 yuroller

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 29 '21 08:12 github-actions[bot]

bump

geiseri avatar Dec 29 '21 17:12 geiseri

This is still an issue in Home Assistant 2022.2.6. My Reolink RLC511 camera which has motion detection capabilities does not expose the motion detection to HA.

If I manually add motion_detection: true to the camera entity, it shows the motion detection start and stop options in for instance automations, but it reverts after a while and the entity loses the key. Possibly because it re-queried the device and didn't catch the motion detection capabilities.

manually putting in motion_detection doesn't actually make any motion events happen, so there's definitely something wrong there.

DutchessNicole avatar Feb 13 '22 20:02 DutchessNicole

@hunterjm is there an easier way to add these endpoints? It seems this is a common issue since there is a bit of "liberty" taken by vendors over what they use to notify motion events. If there was an easier way to users to put in a custom path or parser that might fix these types of issues. See #36757, #48606, #49280, #66493, and even more that got closed because they were stale.

geiseri avatar Feb 14 '22 23:02 geiseri

Same issue here with me. I'm afraid @hunterjm is not active anymore to solve this issue?

ridderr avatar May 05 '22 18:05 ridderr

same issue for IMOU VERSA the camera sends events but no new entity in HA is generated

thesebastianf avatar Aug 03 '22 11:08 thesebastianf

same issue for Reolink E1 zoom

new-kirte avatar Nov 07 '22 14:11 new-kirte