Hikvision Doorbell / Videointercom integration

Indeed, there is no ringing event on the indoor station therefore you need to connect to outdoor…

I have included an extra button, when you enable “caller_info: true” , then you make an automation that triggers that button every x seconds, so you can see the “idle” or “ringing” as an attribute of that button
But its not an ideal solution, but it should work…

Is possible to have a API “ping” to check the online status of the devices? I have a KV6113 that sometimes its freeze (I can ping it, but to the indoor station/app/API he does not respond). If this feature is possible, I can make a script to restart the POE port on the switch. Now I have factory reset it to see if it stop freezing.

Yeah , there is a ping integration in HA to check online state of devices…

Ah, nm, you can still ping when freezed? Maybe your device needs an firmware upgrade? It’s not normal that it freezes…

Do you maybe see something in the add-on log when the device freezes?

Yes, I know the ping integration. But the device freeze (WEB/API) but still ping, if it does not ping, I can resolve with POE Auto Recovery in switch. I am using the last firmware. I don´t see anything in the add-on log. I made a script to get the http://10.10.10.23/ISAPI/System/deviceInfo and if it´s fail I have another script to power cycle the port on switch. If it´s possible to implement this on the addon will be nice! :slight_smile:

It’s possible, but the addon is based on events, not on polling , I want to stay away from polling as much as possible…

But if your device freezes , probably it’s not possible to initiate a restart from the sdk anyway… you can try next time? There is a reboot button, does it work when it’s freezed?

Your approach for the addon is best way, maybe is better I implement this check from another script. When the device freezes it´s only respond for network ping, I can´t reboot from the SDK… :frowning: What I do now is power off the POE and power ON again.

Ok, but try to enable debug mode in the addon, maybe some kind of error event is triggered by the sdk, if that would be the case, i can send an alarm…

I have just tried upgrading to version 43, however it was failing with the error below.

You may need to update your documentation to make it clearer that this value Output_Relay needs to be set going forward. Once I set this to 2 it worked.

Traceback (most recent call last):

  File "/app/main.py", line 96, in <module>

    asyncio.run(main())

  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run

    return loop.run_until_complete(main)

  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete

    return future.result()

  File "/app/main.py", line 57, in main

    mqtt = MQTTHandler(config.mqtt, doorbell_registry)

  File "/app/mqtt.py", line 143, in __init__

    num_doors = doorbell.get_num_outputs_indoor()

  File "/app/doorbell.py", line 229, in get_num_outputs_indoor

    raise RuntimeError("Unable to get the number of doors, please configure the relays manually with this option in the config: output_relays")

RuntimeError: Unable to get the number of doors, please configure the relays manually with this option in the config: output_relays

Edit.

After a couple of minutes it then failed with

2023-10-01 03:28:11.688 | DEBUG    | __main__:signal_handler:90 - Received SIGINT, terminating task

2023-10-01 03:28:11.688 | INFO     | __main__:main:85 - Shutting down

2023-10-01 03:28:11.688 | DEBUG    | sdk.utils:shutdownSDK:105 - Shutting down SDK

So not sure what happened

Hmm, can you try the stable version, you are still using the beta version, what indoor station did you configure?

DS-KH8350-TE1

On pergolafabio/hikvision-doorbell:latest without Output_Relay got the first error.

2023-10-01 06:06:54.276 | DEBUG    | mqtt:__init__:144 - Configuring 1 door switches

2023-10-01 06:06:54.278 | DEBUG    | mqtt:__init__:107 - Setting up entities for base_station

2023-10-01 06:06:54.278 | DEBUG    | sdk.utils:call_ISAPI:125 - Request body: 

[2023-10-01 06:06:54.275][DBG] SimpleSTDCommandToDvr with out cmd[GET /ISAPI/System/IO/outputs], input size[0], max segment length[262144]

[2023-10-01 06:06:54.280][INF] Private connect 192.168.0.129:8000 sock=145 this=0x76ff1224 cmd=0x117000 port=41026

[2023-10-01 06:06:54.285][DBG] SimpleSTDCommandToDvr with out cmd[GET /ISAPI/System/deviceInfo], input size[0], max segment length[262144]

2023-10-01 06:06:54.285 | DEBUG    | sdk.utils:call_ISAPI:165 - Response output: <DeviceInfo version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">

<deviceName>Embedded Net VIS</deviceName>

<deviceID>xxx</deviceID>

<model>DS-KH8350-TE1</model>

<serialNumber>DS-KH8350-TE1xxxx</serialNumber>

<macAddress>xxxx</macAddress>

<firmwareVersion>V2.0.21</firmwareVersion>

<firmwareReleasedDate>build 190314</firmwareReleasedDate>

<encoderVersion>V1.0</encoderVersion>

<encoderReleasedDate>build 000000</encoderReleasedDate>

<deviceType>EmbeddedNetVIS</deviceType>

<telecontrolID>255</telecontrolID>

</DeviceInfo>


2023-10-01 06:06:54.286 | DEBUG    | doorbell:user_config:200 - No manual config found to define output relays for indoor

2023-10-01 06:06:54.286 | DEBUG    | sdk.utils:call_ISAPI:125 - Request body: 

2023-10-01 06:06:54.291 | DEBUG    | sdk.utils:call_ISAPI:162 - Response status: 

Traceback (most recent call last):

  File "/app/main.py", line 96, in <module>

    asyncio.run(main())

  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run

    return loop.run_until_complete(main)

  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete

    return future.result()

  File "/app/main.py", line 57, in main

    mqtt = MQTTHandler(config.mqtt, doorbell_registry)

  File "/app/mqtt.py", line 143, in __init__

    num_doors = doorbell.get_num_outputs_indoor()

  File "/app/doorbell.py", line 230, in get_num_outputs_indoor

    raise RuntimeError("Unable to get the number of doors, please configure the relays manually with this option in the config: output_relays")

RuntimeError: Unable to get the number of doors, please configure the relays manually with this option in the config: output_relays

With Output_Relay set seems to be working

Ok , I know what’s happening, your indoor device is failing on this command,

I will change it to return 0 on case it fails!

It´s freezed again, nothing diferent on log… :frowning:

If you can implement a pooling in the addon, will be very nice…

In log, just a lot of this message, that I read is nothing important…
[2023-10-01 12:12:33.299][DBG] Alarm chan [0] recv timeout[2]!
[2023-10-01 12:13:08.349][DBG] Alarm chan [0] recv timeout[2]!
[2023-10-01 12:13:38.392][DBG] Alarm chan [0] recv timeout[2]!
[2023-10-01 12:14:08.426][DBG] Alarm chan [0] recv timeout[2]!
[2023-10-01 12:14:33.469][DBG] Alarm chan [0] recv timeout[2]!
[2023-10-01 12:15:03.497][DBG] Alarm chan [0] recv timeout[2]!
[2023-10-01 12:15:33.535][DBG] Alarm chan [0] recv timeout[2]!
[2023-10-01 12:16:03.574][DBG] Alarm chan [0] recv timeout[2]!
[2023-10-01 12:16:33.605][DBG] Alarm chan [0] recv timeout[2]!

What happens if you try to initiate a reboot with the button from the mqtt integration when it was freezed, do you see an error?

After installed 3.0.9it can note be run.

2023-10-02 21:36:12.868 | DEBUG | config:load_mqtt_config:130 - Loading MQTT configuration from supervisor
2023-10-02 21:36:12.868 | DEBUG | config:mqtt_config_from_supervisor:36 - Requesting MQTT service configuration to supervisor
2023-10-02 21:36:12.883 | INFO | sdk.utils:loadSDK:44 - Using OS: Linux with architecture: x86_64
loop[2] find 2 mac and 0 ip
2023-10-02 21:36:13.061 | INFO | doorbell:authenticate:76 - Connected to doorbell: DS-KD8003-IME1(B)
2023-10-02 21:36:13.080 | INFO | doorbell:authenticate:76 - Connected to doorbell: DS-KH6320-WTE
2023-10-02 21:36:13.081 | INFO | event:init:87 - Setting up event handler: Console stdout
2023-10-02 21:36:13.081 | INFO | mqtt:init:95 - Setting up event handler: MQTT
Traceback (most recent call last):
File “/app/main.py”, line 96, in
asyncio.run(main())
File “/usr/local/lib/python3.10/asyncio/runners.py”, line 44, in run
return loop.run_until_complete(main)
File “/usr/local/lib/python3.10/asyncio/base_events.py”, line 649, in run_until_complete
return future.result()
File “/app/main.py”, line 57, in main
mqtt = MQTTHandler(config.mqtt, doorbell_registry)
File “/app/mqtt.py”, line 143, in init
num_doors = doorbell.get_num_outputs_indoor()
File “/app/doorbell.py”, line 225, in get_num_outputs_indoor
return endpoint()
File “/app/doorbell.py”, line 215, in isapi_door_capabilities
return int(door_number_element.text)
TypeError: int() argument must be a string, a bytes-like object or a real number, not ‘NoneType’

1 Like

me too after update

can you try 3.0.10 ?

Now is ok. Thanks

1 Like

Hello Fabio,

above the log when the KV6113 is freezed.

[2023-10-02 18:13:29.332][INF] Login dev 10.10.10.23:8000.
[2023-10-02 18:13:29.332][INF] dwTotalNum[2048]
[2023-10-02 18:13:29.336][INF] Private connect 10.10.10.23:8000 sock=135 this=0x368de414 cmd=0x10000 port=59404
[2023-10-02 18:13:29.336][INF] LogonDev1 in[10.10.10.23:8000]
[2023-10-02 18:13:29.337][DBG] CCoreGlobalCtrlBase::LoadDSo, HPR_LoadDSo Succ, Path[/app/lib-amd64/libcrypto.so], hHandleRet[915309216]
[2023-10-02 18:13:29.337][DBG] CCoreGlobalCtrlBase::LoadDSo, HPR_LoadDSo Succ, Path[/app/lib-amd64/libssl.so], hHandleRet[915310448]
[2023-10-02 18:13:29.338][INF] SSLTRANSAPI::LoadAPI, libeay, Load Real Path[/app/lib-amd64/libcrypto.so]
[2023-10-02 18:13:29.338][INF] SSLTRANSAPI::LoadAPI, libssl, Load Real Path[/app/lib-amd64/libssl.so]
[2023-10-02 18:13:29.338][INF] SSLTRANSAPI::IsAllAPILoaded, OpenSSL_version Unload
[2023-10-02 18:13:29.338][INF] OpenSSL, Not All Function Loaded!
[2023-10-02 18:13:29.338][INF] SSLTRANSAPI::PrintVersion, SSLeay_version info [OpenSSL 1.0.2t  10 Sep 2019]
[2023-10-02 18:13:29.338][INF] CSSLTrans::SSLCtxInit, dwSSLVersion[0], m_fnClientMethodV23
2023-10-02 18:13:34.531 | ERROR    | __main__:<module>:101 - Error while logging into DS-KV6113: Timeout when receiving data from the device. Error code:10
[2023-10-02 18:13:34.529][ERR] LogonDev1[10.10.10.23]
[2023-10-02 18:13:34.529][ERR] [10.10.10.23:8000]PRO_LoginHikDevice fail[err=10].[0x00000000,0x00000000]
[2023-10-02 18:13:34.530][ERR] CMemberMgrBase::AllocIndex2, MemberStart Failed, iIndex[0]
[2023-10-02 18:13:34.550][INF] COM_Logout[-1][1]

Yeah, but now you try to start the addon when it was already freezed? Do you also see an event when the addon was already started and it is freeing when addon is still running? Make sure to disable the watchdog on the addon, so it doesn’t restart

Yeah, but now you try to start the addon when it was already freezed?

It´s starts but no comunicate with KV6113, so I use the code below (it´s just a test code) to check the API and if not answer I restart the POE port on switch. I think it´s a problem with the KV6113… :frowning:

import requests
from requests.auth import HTTPDigestAuth
import time

s = requests.Session()
r = requests.Response
erro = False

try:
    r = s.get('http://10.10.10.23/ISAPI/System/deviceInfo', auth = HTTPDigestAuth('admin', 'xxxxxxx'), timeout=5)
    r.raise_for_status()
except requests.exceptions.HTTPError as errh:
    print ("Http Error:",errh)
    erro = True
except requests.exceptions.ConnectionError as errc:
    print ("Error Connecting:",errc)
    erro = True
except requests.exceptions.Timeout as errt:
    print ("Timeout Error:",errt)
    erro = True
except requests.exceptions.RequestException as err:
    print ("OOps: Something Else",err)
    erro = True
print(erro)
if erro == True:
    r = s.post('http://10.10.10.3/logon.cgi', data={'username': 'admin', 'password': 'xxxxxxx', 'logon': 'Login'}, timeout=5)
    r = s.post('http://10.10.10.3/poe_port_config.cgi', data={'aaplay': 'Apply', 'name_pstate': '1', 'sel_16': '1'}, timeout=5)
    time.sleep(1)
    r = s.post('http://10.10.10.3/poe_port_config.cgi', data={'aaplay': 'Apply', 'name_pstate': '2', 'sel_16': '1'}, timeout=5)

Do you also see an event when the addon was already started and it is freeing when addon is still running? Make sure to disable the watchdog on the addon, so it doesn’t restart

I will check once it happens again.

Thank you!