eu-evops / homebridge-hikvision

28 stars 21 forks source link

getting this to work #8

Open steverae68 opened 3 years ago

steverae68 commented 3 years ago

Hello and thank you for making this plugin.

I have it installed and it shows my 3 camera's from my NVR as expected in Homebridge, however, in homekit, im getting a no response window.

These worked perfectly in camera-ffmpeg so i know they work fine, in fact, if i have the config for camera-ffmpeg - i get 2 sets of camera's one working, one not.

what else is needed to get this working also (MOST IMPORTANT) how do you configure the motion detection to trigger ?

sponte commented 3 years ago

Hello

It would be hard to advise with regards to why you're getting "no response" window - some screenshots and logs would be helpful.

With regards to motion trigger though - It's quite annoying but Homekit does not enable push triggers automatically for cameras (it does for doorbells). For cameras, you need to manually enable them in your home app - check this page for more information https://support.apple.com/en-gb/HT208939

steverae68 commented 3 years ago

Hi so the logs show that the camera's are being registered from my NVR using this config.

    {
        "platform": "Hikvision",
        "host": "192.168.1.93",
        "port": 80,
        "username": "useraccount",
        "password": "password"
    },

[12/9/2020, 17:11:01] [Camera FFmpeg] [Front Door Camera] Snapshot requested: 1280 x 720 [12/9/2020, 17:11:01] [Camera FFmpeg] [Front Door Camera] Sending snapshot: 1280 x 720 [12/9/2020, 17:11:01] [Camera FFmpeg] [Front Door Camera] Snapshot command: /usr/local/lib/node_modules/homebridge-camera-ffmpeg/node_modules/ffmpeg-for-homebridge/ffmpeg -rtsp_transport tcp -re -i rtsp://username/password@192.168.1.96:554/Streaming/Channels/102 -frames:v 1 -filter:v scale='min(1280,iw)':'min(720,ih)':force_original_aspect_ratio=decrease,scale=trunc(iw/2)2:trunc(ih/2)2 -f image2 - (node:13433) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getLocalAddress' of undefined at RTPStreamManagement.generateSetupEndpointResponse (/usr/local/lib/node_modules/hap-nodejs/src/lib/camera/RTPStreamManagement.ts:1012:27) at /usr/local/lib/node_modules/hap-nodejs/src/lib/camera/RTPStreamManagement.ts:969:16 at /usr/local/lib/node_modules/hap-nodejs/src/lib/util/once.ts:10:18 at StreamingDelegate.prepareStream (/usr/local/lib/node_modules/@evops/homebridge-hikvision/node_modules/homebridge-camera-ffmpeg/src/streamingDelegate.ts:276:5) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) (node:13433) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8) (node:13433) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. root : TTY=pts/3 ; PWD=/var/homebridge ; USER=root ; COMMAND=/bin/journalctl -o cat -n 500 -f -u homebridge

looks llike an issue with possibly the hap-nodejs module ?

Do the camera's need to be specified directly in the config ?

steverae68 commented 3 years ago

Also would it make a difference if the camera's were not plugged directly into the back of the NVR but via a POE switch ? so each have a unique IP

sponte commented 3 years ago

Hey

The setup I've got is NVR with all cameras plugged in directly, not through PoE switch which might be the issue here. Looking at your error message here it is possible that incorrect URL is generated based on your credentials:

rtsp://username/password@192.168.1.96:554/Streaming/Channels/102

Perhaps you added / when replacing real credentials, but if you're using special characters such as / in your password, this might be the cause of the issue. Can you confirm you are/are not using special characters in your password?

steverae68 commented 3 years ago

Hi,

Yes password is basic - nothing special - that rtsp link is from the camera-ffmpeg for one of my camera’s.

Is it possible to reference the camera’s individually in your plugin as you can with camera-ffmpeg. This works fine for streaming live feed, just does not work with the motion detection from the hikvision cams so have to use third party motion sensor (Phillips) which works fine but is a bit overkill if I can get the camera itself to general the motion notification.

Sent from my iPhone

On 9 Dec 2020, at 18:42, Stanislaw Wozniak notifications@github.com wrote:

 Hey

The setup I've got is NVR with all cameras plugged in directly, not through PoE switch which might be the issue here. Looking at your error message here it is possible that incorrect URL is generated based on your credentials:

rtsp://username/password@192.168.1.96:554/Streaming/Channels/102

Perhaps you added / when replacing real credentials, but if you're using special characters such as / in your password, this might be the cause of the issue. Can you confirm you are/are not using special characters in your password?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

steverae68 commented 3 years ago

(node:25361) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getLocalAddress' of undefined at RTPStreamManagement.generateSetupEndpointResponse (/usr/local/lib/node_modules/hap-nodejs/src/lib/camera/RTPStreamManagement.ts:1012:27) at /usr/local/lib/node_modules/hap-nodejs/src/lib/camera/RTPStreamManagement.ts:969:16 at /usr/local/lib/node_modules/hap-nodejs/src/lib/util/once.ts:10:18 at StreamingDelegate.prepareStream (/usr/local/lib/node_modules/@evops/homebridge-hikvision/node_modules/homebridge-camera-ffmpeg/src/streamingDelegate.ts:276:5) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) (node:25361) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5) [12/9/2020, 21:29:13] [Hikvision] [Back Camera] Stopped video stream.

This is the log when I attempt to stream from one of the camera's presented by the HikVision plugin

sponte commented 3 years ago

Ok, I get it. I'll look into adding debugging code so that I can investigate these issues. I'll try to do that next week. For now if you could run your homebridge with NODE_DEBUG= and DEBUG=, this will spit out a lot of information but might have sensitive information such as your credentials. If you comfortable providing this then I can have a look, otherwise you'll have to wait for my debugging update.

steverae68 commented 3 years ago

Well I've just tried the new version of your plugin and everything just worked like clockwork - The plugin has picked up the camera's from my NVR now even though they are still connected via a POE switch and not directly into the back of the NVR.

Very happy - now I need to figure out how to expose the motion sensor of this plugin to Homekit 👍

steverae68 commented 3 years ago

So how do I expose the motion sensors to Homebridge / HomeKit - the Native NVR config is to notify the Notification Center of any motion which generates an event ion the box.

Is there another config I need to set in homebridsge

Live stream is working fine as shown below :-

[12/26/2020, 20:55:23] [Hikvision DVR] [Back Camera] Starting video stream: 1280 x 720, 30 fps, 299 kbps [12/26/2020, 20:55:31] [Hikvision DVR] [Back Camera] Stopped video stream. [12/26/2020, 20:55:36] [Hikvision DVR] [Back Camera] Starting video stream: 1280 x 720, 30 fps, 299 kbps [12/26/2020, 20:55:44] [Hikvision DVR] [Back Camera] Device appears to be inactive. Stopping stream. [12/26/2020, 20:55:44] [Hikvision DVR] [Back Camera] Stopped video stream. [12/26/2020, 20:55:44] [Hikvision DVR] [Back Camera] Stopped video stream. [12/26/2020, 20:55:45] [Hikvision DVR] [Front Camera] Starting video stream: 1280 x 720, 30 fps, 299 kbps [12/26/2020, 20:55:46] [Hikvision DVR] [Front Camera] Stopped video stream. [12/26/2020, 20:55:57] [Hikvision DVR] [Front Camera] Starting video stream: 1280 x 720, 30 fps, 299 kbps [12/26/2020, 20:56:04] [Hikvision DVR] [Front Camera] Stopped video stream. [12/26/2020, 20:56:06] [Hikvision DVR] [Front Door Camera] Starting video stream: 1280 x 720, 30 fps, 299 kbps [12/26/2020, 20:56:09] [Hikvision DVR] [Front Door Camera] Stopped video stream. [12/26/2020, 20:56:15] [Hikvision DVR] [Front Door Camera] Starting video stream: 1280 x 720, 30 fps, 299 kbps [12/26/2020, 20:56:22] [Hikvision DVR] [Front Door Camera] Stopped video stream. [12/26/2020, 20:56:39] [Hikvision DVR] [Front Camera] Starting video stream: 1280 x 720, 30 fps, 299 kbps [12/26/2020, 20:56:41] [Hikvision DVR] [Front Camera] Stopped video stream.

[12/26/2020, 21:09:30] [Hikvision DVR] Configuring accessory Back Camera [12/26/2020, 21:09:30] [Hikvision DVR] [HikvisionCamera] Configuring accessory: Back Camera [12/26/2020, 21:09:30] [Hikvision DVR] Re-creating motion sensor [12/26/2020, 21:09:30] [Hikvision DVR] Configuring accessory Front Camera [12/26/2020, 21:09:30] [Hikvision DVR] [HikvisionCamera] Configuring accessory: Front Camera [12/26/2020, 21:09:30] [Hikvision DVR] Re-creating motion sensor [12/26/2020, 21:09:30] [Hikvision DVR] Configuring accessory Front Door Camera [12/26/2020, 21:09:30] [Hikvision DVR] [HikvisionCamera] Configuring accessory: Front Door Camera [12/26/2020, 21:09:30] [Hikvision DVR] Re-creating motion sensor

The motion sensors are there but don't seem do anything.....

sponte commented 3 years ago

Did you enable motion notifications in the home app under cameras and doorbells? There are under Home settings -> Cameras & Doorbells - you need to enable for each individual camera.

steverae68 commented 3 years ago

Yep, did that and also enabled notifications on my phone. Does your plugin work differently to the standard ffmpeg, does it interrogate the settings and look for the notification the dvr sends out, or do I need to do something else. Even when I watch the motion sensor on my phone and walk in front of the camera it doesn’t activate.

What do I need to set specificially to trigger the motion on my dvr. I know of several other plugins that hook into the email system and are triggered by that?

Sent from my iPhone

On 27 Dec 2020, at 15:04, Stanislaw Wozniak notifications@github.com wrote:

 Did you enable motion notifications in the home app under cameras and doorbells? There are under Home settings -> Cameras & Doorbells - you need to enable for each individual camera.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

sponte commented 3 years ago

You need to have notifications enabled first in the NVR i.e. for each camera set which type of notification (motion, intrusion alert etc), and then connect it to the "Notify surveillance center" option. Have you got that set up?

steverae68 commented 3 years ago

Hello, thanks for getting back to me.

I’ve switched to another plugin which works by detecting motion from the camera and sending a email which is picked up by the new plugin, converted to an http request which is in turn picked up by camera-ffmpeg which seems to work very well.

I could not get your plugin to respond to a motion event from the camera’s so switched to this other (more complex) method which works a treat.

I’m not sure how your plugin was determining motion and how it would trigger the camera to take a snapshot without delving into the code itself.

Thanks again for getting back to me though 👍

Sent from my iPhone

On 29 Dec 2020, at 12:03, Stanislaw Wozniak notifications@github.com wrote:

 You need to have notifications enabled first in the NVR i.e. for each camera set which type of notification (motion, intrusion alert etc), and then connect it to the "Notify surveillance center" option. Have you got that set up?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

sponte commented 3 years ago

I'm sorry you couldn't get it to work - my plugin does not detect motion itself, it responds to events generated by the NVR using HTTP Event API. The relevant code for this lives at https://github.com/eu-evops/homebridge-hikvision/blob/master/src/HikvisionApi.ts#L73.

As I said in my earlier message, you must set up notifications in the NVR configuration, perhaps below screenshot will help:

image

You might also find this YouTube video useful:

https://www.youtube.com/watch?v=-R_dtE9o9WI

Setup Notifications

tstordyallison commented 3 years ago

(Makes me think this should probably be copy and pasted to the README! I had to mess around a bit to find out it was that option).

steverae68 commented 3 years ago

So it responds generates an http request when the Notification Center triggers.... so this is then picked up by the camera-ffmpeg http system which can then be used to trigger the event.

This was not made at all clear in the documentation.

I will revisit this at some point this week - if this works purely based on the Notification Center trigger which activates the recording in the HikVision app itself without the need for any further configuration / plugin ,this would be brill.

Detailed description of what call this makes and what port needs to be opened within the camera-ffmpeg http side would also be useful

Sent from my iPhone

On 29 Dec 2020, at 14:40, Stanislaw Wozniak notifications@github.com wrote:

 I'm sorry you couldn't get it to work - my plugin does not detect motion itself, it responds to events generated by the NVR using HTTP Event API. The relevant code for this lives at https://github.com/eu-evops/homebridge-hikvision/blob/master/src/HikvisionApi.ts#L73.

As I said in my earlier message, you must set up notifications in the NVR configuration, perhaps below screenshot will help:

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

sponte commented 3 years ago

I'll update the README to reflect that :) Pull requests welcome too :)

I have now updated the readme: https://github.com/eu-evops/homebridge-hikvision