Coder Social home page Coder Social logo

Using LTS NVR with pyHik about pyhik HOT 22 CLOSED

mezz64 avatar mezz64 commented on September 26, 2024
Using LTS NVR with pyHik

from pyhik.

Comments (22)

mezz64 avatar mezz64 commented on September 26, 2024

I'm attaching the device trigger file you posted over on the HASS forum here so I can easily find it later.
dvr_triggers.txt

from pyhik.

wizwuz7 avatar wizwuz7 commented on September 26, 2024

No events found if using existing code. Changed to:
ettype = eventtrigger.find('{http://www.std-cgi.com/ver20/XMLSchema}eventType')
This worked, but many duplicates due to multiple ports (like 16 iterations of VMD).
Perhaps the <id> value is unique (like VMD-1, VMD-2, etc.)

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

I've finished the changes on my other library so I should have some time to tackle this now. Also recently got access to a hikvision NVR I can use for testing. I'll make a Dev branch for the changes and post back here when I have something ready for you to test.

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

Could you post a sample from your NVR alert stream? The following command will retrieve it with curl and send the output to a file. Let it run for 5-10 mins or so, ideally capturing an event being triggered on one of your cameras.

curl -u USER:PASS http://YOUR-NVR-IP/ISAPI/Event/notification/alertStream > stream.txt

I'm seeing some variations in naming between the test NVR I have access to and the triggers XML sample you provided earlier so I want to make sure I cover all the variations.

from pyhik.

wizwuz7 avatar wizwuz7 commented on September 26, 2024

I'm sure you wish the naming conventions were a little more standardized.
This NVR is a hybrid with 16 analog inputs plus 16 IP camera inputs. It also has IO inputs.
Included several incidents - IO alarm event, videoloss event, motion detection event, and line crossing event.
stream.txt

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

Are the IO inputs a priority for you? They are reported a little differently in the event triggers list so they may not be included in the first NVR revision.

Your stream also shows some slightly different behavior in terms of the the 'videoloss' event that's continually posted to channel 0. Some adjustments might be needed to the watchdog to keep things working smoothly, but we can get that all figured out once we get to the testing phase.

from pyhik.

wizwuz7 avatar wizwuz7 commented on September 26, 2024

IO not a priority. I will be using this to trigger camera notifications.

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

I've gotten things to a point where they seem to be working reliably with my test NVR so it's time to see if you can break it. :)

I think the easiest way to test it out is download the "nvr" branch of pyhik from github and copy the pyhik folder to your hass "deps" directory.
https://github.com/mezz64/pyHik/tree/nvr

Then grab the updated hass hikvision binary sensor component from the commit linked below and place it in the following folder tree in your hass config directory: custom_components/binary_senors/. Once it's there comment out the REQUIREMENTS line at the top of the file so HASS just looks in the deps directory rather than trying to use the currently non-existent 0.1.1 version.
https://github.com/mezz64/home-assistant/blob/8b31311ae83283d9341e5cdb0574d1d168104aa0/homeassistant/components/binary_sensor/hikvision.py

Let me know if you encounter any issues.

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

Use this hass commit. I made some changes to keep sensor names the same for existing users.
https://github.com/mezz64/home-assistant/blob/6e86886120e5e9cd80dbf0aeda9418df2885567f/homeassistant/components/binary_sensor/hikvision.py

from pyhik.

wizwuz7 avatar wizwuz7 commented on September 26, 2024

See attached. Adding debug logger did not increase error logging. Using curl to the eventStream still works. Changing login password to the NVR gives a different error message.
error_1.txt

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

Make sure you have the following logging definitions in your hass config to get debug logs:

pyhik: debug
custom_components.binary_sensor.hikvision: debug

Once those are defined start things up again and post the full log.

from pyhik.

wizwuz7 avatar wizwuz7 commented on September 26, 2024

Noted the constants file was using the hikvision style - changed to std-cgi.
Attached error.
error_2.txt

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

No need to change the constants.py for the namespace. It gets updated dynamically during setup. Based on that log it looks like your are still using the last release version of pyHik, not the one from the nvr branch.

Can you double check that you commented out the requirements line in the hass hikvision binary sensor file and that the you have a pyhik folder in your deps directory that contains the pyhik files __init__.py, constants.py, hikvision.py, watchdog.py?

from pyhik.

wizwuz7 avatar wizwuz7 commented on September 26, 2024

Requirements line in binary_sensor/hikvision.py has been removed.
The pyhik folder was in loaded into deps.
Copied pyhik folder into custom_components folder.
Same errors.

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

Directories should be as follows:
custom_components/binary_sensor/hikvision.py *This should be the file from the commit linked above with REQUIREMENTS commented out.
deps/pyhik/**pyhik library files** *These should be from the nvr branch of this repo.

If that's how you have it setup then something isn't working right in hass in terms of order of imports. What version of hass are you testing with?

from pyhik.

wizwuz7 avatar wizwuz7 commented on September 26, 2024

HA v0.40.2.
Redropped the pyhik folder into deps folder.
More info now in the error file.
error_3.txt

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

Ok, we are making progress. 👍

Your logs show you are utilizing the new pyhik library, but not the new hikvision.py hass component. If for some reason you can't get it to load from the config/custom_components directory you can always overwrite the existing file in the components/binary_sensor directory also.

from pyhik.

wizwuz7 avatar wizwuz7 commented on September 26, 2024

Overwrote existing hikvision.py in components/binary_sensor folder.
Looks better now.
See attached.
error_4.txt

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

I think I fixed your error with the latest commit to the nvr branch. Please download and replace the files in your deps directory and give it another shot.

from pyhik.

wizwuz7 avatar wizwuz7 commented on September 26, 2024

Yep - that looks like it.
Both Line Detection and motion are working on various inputs, both analog and digital.
No errors - excellent work.
error_5.txt

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

Awesome. Glad it's working for you. I'll wait a day or so to merge into master and submit a PR to hass just in case something pops up after you use it for a while.

from pyhik.

mezz64 avatar mezz64 commented on September 26, 2024

Closing this now... Version 0.1.1 with NVR support has been pushed to pypi. PR to integrate with hass is submitted.

from pyhik.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.