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 broken #42784

Closed
ricarva opened this issue Nov 3, 2020 · 14 comments
Closed

ONVIF Motion Events broken #42784

ricarva opened this issue Nov 3, 2020 · 14 comments

Comments

@ricarva
Copy link

ricarva commented Nov 3, 2020

The problem

Motion Events for ONVIF cameras were working correctly in my setup (Reolink cameras) on HA 117.1, but the update to 117.2 broke this functionality: the motion sensor has since become "Unavailable".

Environment

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

Problem-relevant configuration.yaml

Configured through UI, no YAML.

Traceback/Error logs

No relevant log entries.

Additional information

Should be connected to commit #42651

@frenck frenck changed the title ONVIF update in 117.2 broke Motion Events ONVIF Motion Events broken Nov 3, 2020
@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)

@hunterjm
Copy link
Member

hunterjm commented Nov 3, 2020

This is a known regression from 0.117.0 to 0.117.2 in order to fix a memory issue. I’m looking into restoring the functionality in 0.118.

@ricarva
Copy link
Author

ricarva commented Nov 19, 2020

@hunterjm, hi. Any ETA on the fix for this? I'm asking since it did not drop with 0.118. Thanks in advance.

@hunterjm
Copy link
Member

@ricarva - I didn't get around to re-enabling in time for 0.118. Still looking into it.

@ricarva
Copy link
Author

ricarva commented Nov 19, 2020

@hunterjm thanks for the update, Jason!

@gomble
Copy link

gomble commented Dec 13, 2020

hello will this be fixed in further updates?

@ricarva
Copy link
Author

ricarva commented Jan 3, 2021

@hunterjm Jason, Happy New Year!

Any progress on this issue? Thanks!

@timdonovanuk
Copy link

Also: #42784, #37545, #36145

As a workaround, you can bypass the broken ONVIF motion sensor integration and use a manual REST integration to pull the camera motion state. On my camera (C1-Pro) the state is at: http://192.168.1.5/api.cgi?cmd=GetMdState&user=admin&password=password

So a rest sensor, something like this should work:

binary_sensor:
  - platform: rest
    resource: http://192.168.1.5/api.cgi?cmd=GetMdState&user=admin&password=<password>
    name: Camera Motion Sensor Occupancy
    scan_interval: 5
    value_template: "{{ value_json[0].value.state }}"
    device_class: motion

@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  #37545, #37878, #42784, #36757, #36145


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

........................................
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
@mathmaniac43
Copy link

I am on HA version 2021.5.2 and this is still not working. Please do not close the issue.

@gomble
Copy link

gomble commented May 14, 2021

Its not working with 2021.5.3, Dont close the issue

@github-actions github-actions bot removed the stale label May 14, 2021
@simonyel
Copy link

simonyel commented Aug 2, 2021

Still not working in 2021.7.4

@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 Oct 31, 2021
@github-actions github-actions bot closed this as completed Nov 7, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants