Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Geronimo2015 opened this issue Jul 6, 2020 · 50 comments · Fixed by #91866
Closed

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

Geronimo2015 opened this issue Jul 6, 2020 · 50 comments · Fixed by #91866
Assignees

Comments

@Geronimo2015
Copy link
Contributor

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.

@probot-home-assistant
Copy link

onvif documentation
onvif source
(message by IssueLinks)

@probot-home-assistant
Copy link

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)

@tipofthesowrd
Copy link

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.

@geiseri
Copy link

geiseri commented Aug 8, 2020

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?

@GreyEarl
Copy link

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.

@UmbraMalison
Copy link

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

@loeffen
Copy link

loeffen commented Sep 17, 2020

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 :-)!!

@UmbraMalison
Copy link

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.

@GreyEarl
Copy link

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.

@UmbraMalison
Copy link

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

@GreyEarl
Copy link

GreyEarl commented Sep 28, 2020

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!

@UmbraMalison
Copy link

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!

@hunterjm
Copy link
Member

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.

@mgiako
Copy link
Contributor

mgiako commented Dec 10, 2020

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': {
}
}
}
}

@catalin2009
Copy link

catalin2009 commented Dec 20, 2020

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
Copy link

catalin2009 commented Feb 7, 2021

               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.

@github-actions
Copy link

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 github-actions bot added the stale label May 14, 2021
@geiseri
Copy link

geiseri commented May 15, 2021

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

@TheBisk
Copy link

TheBisk commented Jun 23, 2021

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

@github-actions
Copy link

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 github-actions bot added the stale label Sep 21, 2021
@guillesanzs
Copy link

Same issue for ANPVIZ_IPC-0350

@marxus4
Copy link

marxus4 commented Nov 14, 2022

Same issue for P3SB-8MP-EU
Home Assistant 2022.11.2
Supervisor 2022.10.2
Operating System 9.3

@kazir1
Copy link

kazir1 commented Dec 12, 2022

UNV Camera. Такая же беда.
В самой камере детекция срабатывает. начинает писать на флешку. Но в HA может придти через минуту. а может и вовсе не придти.
core-2022.12.3

@raffaelevall
Copy link

Same issue with Milesight cameras MS-C5375-PB, MS-C5383-PB e MS-C5375-EPB. Works with Safire SF-IPB025WA-4E
Home Assistant 2023.3.1
Supervisor 2023.01.1
Operating System 9.5

@raffaelevall
Copy link

Has anyone fix it?

@bdraco
Copy link
Member

bdraco commented Apr 15, 2023

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.

@raffaelevall
Copy link

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.

Hi @bdraco, even after the update the sensors remain "unavailable" :-(

`

binary_sensor.cucina_digital_inputCucina Digital Input unavailable restored: true friendly_name: Cucina Digital Input supported_features: 0
binary_sensor.myfielddetector1_field_detection_6Cucina Field Detection unavailable restored: true device_class: motion friendly_name: Cucina Field Detection supported_features: 0
binary_sensor.mytamperdetectorrule_tamper_detection_7Cucina Tamper Detection unavailable restored: true device_class: problem friendly_name: Cucina Tamper Detection supported_features: 0
binary_sensor.videosource_motion_alarm_6Motion Cucina unavailable restored: true device_class: motion friendly_name: Motion Cucina supported_features: 0
`

@bdraco
Copy link
Member

bdraco commented Apr 18, 2023

There are at least 3 problems going on here

  1. Some cameras need to have custom rules written
  2. There is a problem with subscriptions not being cleaned up on shutdown which means the camera runs out of slots. This should be fixed in Add webhook support to onvif #91485
  3. Some cameras only support notifications and not PullPoint. Notifications/webhooks are implemented in Add webhook support to onvif #91485

If you fall in 1 and need a custom rule you'll see No registered handler for event in the log

Open a feature request at https://community.home-assistant.io/c/feature-requests/13

You'll need to post the following:

  • A new thread ONVIF Event parser for <Camera Name> if one does not exist for that specific camera
  • The full contents of the log message that contains No registered handler for event
  • The name and model of the camera
  • Where to purchase the camera

If you leave out any data we likely will not be able to add support for that camera.

@raffaelevall
Copy link

No registered handler for event

Hi, in the debug logs I don't find No registered handler for event, probably the problem will be different or worse.
The only interesting thing there is 2023-04-18T07:39:09+00:00</wsu:Created></wsse:UsernameToken></wsse:Security></soap-env:Header><soap- env:Body><ns0:PullMessages xmlns:ns0="http://www.onvif.org/ver10/events/wsdl"><ns0:Timeout>PT1M</ns0:Timeout><ns0:MessageLimit>100</ ns0:MessageLimit></ns0:PullMessages></soap-env:Body></soap-env:Envelope>' but I don't know if it's useful. Thanks

@bdraco
Copy link
Member

bdraco commented Apr 18, 2023

It might be case number 3 and the camera doesn't send events via pull point. I have a few of them that have never worked until #91485

@raffaelevall
Copy link

It might be case number 3 and the camera doesn't send events via pull point. I have a few of them that have never worked until #91485

If I can help for some tests let me know, thanks

@bdraco
Copy link
Member

bdraco commented Apr 18, 2023

If you can test #91485 that would be awesome

@raffaelevall
Copy link

raffaelevall commented Apr 18, 2023

@bdraco sure, but please tell me what I have to do :-)

@bdraco

This comment was marked as outdated.

@bdraco
Copy link
Member

bdraco commented Apr 18, 2023

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

@raffaelevall
Copy link

raffaelevall commented Apr 18, 2023

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

I'll try tomorrow, It's too late now in Italy😅, tks

Hi @bdraco, I installed your component "https://github.com/bdraco/onvif" , the motion sensors are back available and it seems that work correctly even if with same false alarms for the external cameras.
For MIlesight camera only:
binary_sensor.myfielddetector1_field_detection_5
binary_sensor.mymotiondetectorrule_cell_motion_detection_5
binary_sensor.mytamperdetectorrule_tamper_detection_5
remain unavailable (but I have no idea what they are).
For Safire I lost:
sensor.last_reboot
sensor.last_reset
It seems that there are no errors in the debug log. I'll update as soon as possible, thanks

@bdraco bdraco changed the title ONVIF (motion) events not working ONVIF (motion) events not working with Dahua DH-SD22404T-GN-W Apr 19, 2023
@bdraco bdraco changed the title ONVIF (motion) events not working with Dahua DH-SD22404T-GN-W ONVIF (motion) events not working with Dahua DH-SD22404T-GN-W and anpviz Apr 22, 2023
@bdraco
Copy link
Member

bdraco commented Apr 22, 2023

It looks like the problem is that if the device management services gets WSA it times out on these cameras.
We only really need them for events so I think we can disable WSA on device management

@bdraco
Copy link
Member

bdraco commented Apr 22, 2023

I don't think its the WSAs
These anpviz cameras are so slow they timeout

@bdraco
Copy link
Member

bdraco commented Apr 22, 2023

I opened #91866 to guard a few more places to retry when it does timeout

@bdraco
Copy link
Member

bdraco commented Apr 22, 2023

#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.