pergolafabio / Hikvision-Addons

Home Assistant: Hikvision Doorbell
187 stars 41 forks source link

Working via NVR (virtual host) #200

Closed AYahoo closed 6 months ago

AYahoo commented 6 months ago

Is there an existing feature request for this?

Add-on

Doorbell

Your feature request

I have two (supported) doorbells that are connected to Hikvision NVR, the NVR is acting as a NAT so the subnet of the homeassistant and the doorbells is different, I would love to have the ability to use the addon, I tried using 192.168.1.100:65002 (hikvision nvr + virtual port for the first doorbell) as the IP, but I get error 7, also tried 192.168.1.100 as IP and 65002 as port, but still I get an error - 10.

the virtual host of hikvision is assigning a port 6500x to each channel of the nvr and you can access HSAPI or even login to the doorbell with that port, so I believe it should be possible.

Kind regards.

pergolafabio commented 6 months ago

Hi, the addon allows changing the port, its in the docs... If its possible to make a connection from HA subnet, to the doorbell, it should work?

you can change port in addon config, just add the port: section

- name: DS-KD8003
  ip: 192.168.0.70
  port: 8000
  username: admin
  password: XXX
AYahoo commented 6 months ago

Thanks for the quick prompt, I've tried using: ip:192.168.0.70:65002 with no port setup, and got error 7.

tried: ip: 192.168.0.70 port: 65002

and got error 10.

pergolafabio commented 6 months ago

Yeah, those are connect and timeout issues... Are you sure you can connect from HA to doorbell? You can maybe try ping it from HA from the SSH addon? Or do port check to see if it's open?

AYahoo commented 6 months ago

The NVR is at the same IP, I can get to it from the HA and I have devices + automation working. I can't ping port 65002, port is open, if I browse to 192.168.0.70:65002 I get the login page of the doorbell.

pergolafabio commented 6 months ago

The addon uses the SDK port, that's different then the login page... You don't http access to it

Login page is different that SDK

AYahoo commented 6 months ago

Do you know what is the default port? maybe I can remap it to the doorbell?

pergolafabio commented 6 months ago

It's 8000

AYahoo commented 6 months ago

Well it is impossible to map a specific port to a specific device on the Hikvision NVR, If I try to use the NVR with the addon, I get an error that the device is not supported, I get DeviceType - 2239

Where can i edit the class DeviceType(IntEnum): OUTDOOR = 603 INDOOR = 602 VillaVTO = 605

K1T502 = 884 (unsupported)

K1T671MF = 896
K1T341AM = 10503
K1T341M = 10510
K1T343 = 10533
K1T342 = 10538
HD = 31
AccessControlTerminal = 861

to see if the NVR is exposing the events?

pergolafabio commented 6 months ago

I have no idea if the NVR creates events, never tried it ;-)

I can add it later as a test, or you can fork my GitHub and change code ?

pergolafabio commented 6 months ago

Did you try it? With the code on your GitHub? Or do you want me to make a new beta?

AYahoo commented 6 months ago

I would really appreciate it, i was unable to make the change and try.

On Sun, May 5, 2024, 08:53 Pergola Fabio @.***> wrote:

Did you try it? With the code on your GitHub? Or do you want me to make a new beta?

— Reply to this email directly, view it on GitHub https://github.com/pergolafabio/Hikvision-Addons/issues/200#issuecomment-2094643470, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPRV3RE5ONLE3QYLUIFDX3ZAXCMZAVCNFSM6AAAAABHGWPLDKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJUGY2DGNBXGA . You are receiving this because you authored the thread.Message ID: @.***>

pergolafabio commented 6 months ago

Ok , I will try to make a new beta build today or tomorrow

pergolafabio commented 6 months ago

Have you tried this one, it's for NVR ... It's based on Isapi, and not the SDK that I'm using https://github.com/maciej-or/hikvision_next

pergolafabio commented 6 months ago

I added beta 61 , try it , let me know if it supports events? probably the call sensor/relay button, stuff like those are not working ....

AYahoo commented 6 months ago

Have you tried this one, it's for NVR ... It's based on Isapi, and not the SDK that I'm using https://github.com/maciej-or/hikvision_next

Yes, i have something like that, but it doesn't work with doorbell events, only cameras.

AYahoo commented 6 months ago

I added beta 61 , try it , let me know if it supports events? probably the call sensor/relay button, stuff like those are not working ....

So I tried to run it, and it seems to work, but I don't have any devices added.

This is the log that I get:

AYahoo commented 6 months ago
2024-05-05 19:28:17.734 | DEBUG    | mqtt:__init__:163 - Configuring 7 door switches
2024-05-05 19:28:17.759 | DEBUG    | event:register_handler:234 - Adding event handler MQTT
2024-05-05 19:28:17.760 | DEBUG    | mqtt_input:__init__:21 - Setting up MQTTInput
2024-05-05 19:28:17.760 | DEBUG    | sdk.utils:call_ISAPI:125 - Call ISAPI request method url body: GET /ISAPI/System/deviceInfo  
2024-05-05 19:28:17.790 | DEBUG    | sdk.utils:call_ISAPI:165 - Response output: <DeviceInfo version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<deviceName>AcuSense</deviceName>
<deviceID>DELETED</deviceID>
<model>DS-7608NXI-I2/8P/S</model>
<serialNumber>DELETED</serialNumber>
<macAddress>DELETED</macAddress>
<firmwareVersion>V4.62.210</firmwareVersion>
<firmwareReleasedDate>build 230619</firmwareReleasedDate>
<encoderVersion>V5.0</encoderVersion>
<encoderReleasedDate>build 230530</encoderReleasedDate>
<deviceType>NVR</deviceType>
<telecontrolID>255</telecontrolID>
<hardwareVersion>0100000092130000</hardwareVersion>
<decordChannelNums>8</decordChannelNums>
<VGANums>1</VGANums>
<USBNums>2</USBNums>
<auxoutNums>0</auxoutNums>
<regionVersion>basic</regionVersion>
</DeviceInfo>

2024-05-05 19:28:17.822 | DEBUG    | event:start:255 - Registering callback function using SDK
2024-05-05 19:28:17.823 | DEBUG    | doorbell:setup_alarm:91 - Arming the device via SDK
2024-05-05 19:28:17.834 | DEBUG    | input:loop_forever:29 - Waiting for input command
pergolafabio commented 6 months ago

Does the addon keeps running? What about events?

AYahoo commented 6 months ago

Keeps on running, not problem, on the log I get:

2024-05-05 20:17:04.565 | WARNING  | mqtt:unhandled_event:452 - Unknown event from TestNVRDoor
2024-05-05 20:17:04.880 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-05 20:17:04.881 | WARNING  | event:_cast_alarm_info:186 - Received unhandled command: 4354
2024-05-05 20:17:04.883 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-05 20:17:04.883 | WARNING  | event:unhandled_event:153 - Unknown event from TestNVRDoor
2024-05-05 20:17:04.884 | WARNING  | mqtt:unhandled_event:452 - Unknown event from TestNVRDoor
2024-05-05 20:17:05.787 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-05 20:17:05.788 | WARNING  | event:_cast_alarm_info:186 - Received unhandled command: 4354
2024-05-05 20:17:05.790 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-05 20:17:05.791 | WARNING  | event:unhandled_event:153 - Unknown event from TestNVRDoor
2024-05-05 20:17:05.792 | WARNING  | mqtt:unhandled_event:452 - Unknown event from TestNVRDoor
2024-05-05 20:17:07.984 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-05 20:17:07.984 | WARNING  | event:_cast_alarm_info:186 - Received unhandled command: 4354
2024-05-05 20:17:07.986 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-05 20:17:07.987 | WARNING  | event:unhandled_event:153 - Unknown event from TestNVRDoor
2024-05-05 20:17:07.988 | WARNING  | mqtt:unhandled_event:452 - Unknown event from TestNVRDoor
2024-05-05 20:17:09.995 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-05 20:17:09.995 | WARNING  | event:_cast_alarm_info:186 - Received unhandled command: 4354
2024-05-05 20:17:09.996 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-05 20:17:09.997 | WARNING  | event:unhandled_event:153 - Unknown event from TestNVRDoor
2024-05-05 20:17:09.998 | WARNING  | mqtt:unhandled_event:452 - Unknown event from TestNVRDoor
2024-05-05 20:17:12.196 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-05 20:17:12.197 | WARNING  | event:_cast_alarm_info:186 - Received unhandled command: 4354
2024-05-05 20:17:12.198 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-05 20:17:12.199 | WARNING  | event:unhandled_event:153 - Unknown event from TestNVRDoor
2024-05-05 20:17:12.199 | WARNING  | mqtt:unhandled_event:452 - Unknown event from TestNVRDoor
2024-05-05 20:17:14.229 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-05 20:17:14.230 | WARNING  | event:_cast_alarm_info:186 - Received unhandled command: 4354
2024-05-05 20:17:14.231 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-05 20:17:14.232 | WARNING  | event:unhandled_event:153 - Unknown event from TestNVRDoor
2024-05-05 20:17:14.233 | WARNING  | mqtt:unhandled_event:452 - Unknown event from TestNVRDoor
2024-05-05 20:17:17.392 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK

But I think it is the line crossing alarm and other alarms from the NVR, I have a feeling that the NVR doesn't expose the events of the doorbell ring.

pergolafabio commented 6 months ago

Yeah, I didn't implement all events, what are you doing when that 4354 event is triggered? I can add that one if it's interesting

AYahoo commented 6 months ago

Thanks, but I already manage these events. The only Idea that I have right now is to add another ethernet to the HA and connect it to the Doorbell network, than I can use the plugin.

pergolafabio commented 6 months ago

Ok, I will remove the NVR from my addon