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

DS-KD8003-IME1 with DS-KD-KP code support #204

Open
1 task done
AYahoo opened this issue May 6, 2024 · 98 comments
Open
1 task done

DS-KD8003-IME1 with DS-KD-KP code support #204

AYahoo opened this issue May 6, 2024 · 98 comments
Labels
enhancement New feature or request

Comments

@AYahoo
Copy link

AYahoo commented May 6, 2024

Is there an existing feature request for this?

  • I have searched the existing issues

Add-on

None

Your feature request

DS-KD-KP, is a numeric pad with a access control code to open relays on the KD8003, I would love to have the ability to know which user entered and if the wrong password has been pressed to know if someone is trying to mess with the code, guess it, or just playing with it. I'm sure I saw it on the SDK in the past.

@AYahoo AYahoo added the enhancement New feature or request label May 6, 2024
@AYahoo
Copy link
Author

AYahoo commented May 6, 2024

Entering the wrong Keypad pin code got me these events:

2024-05-06 21:26:58.951 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-06 21:26:58.952 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-06 21:26:58.952 | DEBUG    | mqtt:isapi_alarm:279 - Isapi alarm from Gate
2024-05-06 21:26:58.953 | INFO     | event:isapi_alarm:131 - Isapi alarm from Gate

Entering the right code, got me these events (with the door being opened):

2024-05-06 21:25:32.635 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-06 21:25:32.636 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-06 21:25:32.637 | INFO     | mqtt:update_door_entities:295 - Door 1 unlocked by 112117981081059900 , updating sensor and device trigger
2024-05-06 21:25:32.637 | DEBUG    | sdk.utils:call_ISAPI:125 - Call ISAPI request method url body: GET /ISAPI/System/deviceInfo  
2024-05-06 21:25:32.742 | DEBUG    | sdk.utils:call_ISAPI:165 - Response output: <DeviceInfo version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<deviceName>OUTDOOR STATION</deviceName>
<deviceID>DELETED</deviceID>
<deviceDescription>	Vis</deviceDescription>
<deviceLocation>STD-CGI</deviceLocation>
<systemContact>STD-CGI</systemContact>
<model>DS-KD8003-IME1</model>
<serialNumber>DELETED</serialNumber>
<macAddress>DELETED</macAddress>
<firmwareVersion>V2.2.45</firmwareVersion>
<firmwareReleasedDate>build 210430</firmwareReleasedDate>
<bootVersion>33685549</bootVersion>
<bootReleasedDate>1377310</bootReleasedDate>
<hardwareVersion>0x0</hardwareVersion>
<encoderVersion>V4.0</encoderVersion>
<encoderReleasedDate>build 181206</encoderReleasedDate>
<deviceType>	Vis</deviceType>
<telecontrolID>88</telecontrolID>
<supportBeep>true</supportBeep>
<supportVideoLoss>true</supportVideoLoss>
<alarmOutNum>2</alarmOutNum>
<alarmInNum>4</alarmInNum>
<RS485Num>1</RS485Num>
<customizedInfo></customizedInfo>
</DeviceInfo>

2024-05-06 21:25:32.746 | INFO     | mqtt:handle_device_trigger:456 - Invoking device trigger automation{'name': 'Door unlocked', 'type': 'door open', 'subtype': 'door 0', 'payload': {'control_source': '112117981081059900'}}
2024-05-06 21:25:32.748 | INFO     | event:video_intercom_event:109 - Video intercom event from Gate

@pergolafabio
Copy link
Owner

Hm, it should be an intercom event, not an isapi one...
Do you also have a badge reader? I added an illegal swipe event, there is one in the SDK for that...
But I don't think there is an illegal keypad entry

@pergolafabio
Copy link
Owner

Here is the isapi event SDK, not much usefull info...

https://open.hikvision.com/hardware/structures/NET_DVR_ALARM_ISAPI_INFO.html

@pergolafabio
Copy link
Owner

Here is the event SDK, only card access is logged, not keypad :-(

@pergolafabio
Copy link
Owner

@AYahoo
Copy link
Author

AYahoo commented May 6, 2024 via email

@AYahoo
Copy link
Author

AYahoo commented May 6, 2024

https://automatednow.com/index.php?dispatch=attachments.getfile&attachment_id=1145

"The driver will fire the Keypad - Valid Password or Keypad - Invalid Password Event when a code is entered. "

Now I know it doesn't really help, just shows that it is possible.

@pergolafabio
Copy link
Owner

do you know if that is based on SDK or ISAPI directly to port 80 ?

@pergolafabio
Copy link
Owner

if you use ivms, do you see the event there?

@AYahoo
Copy link
Author

AYahoo commented May 6, 2024

Since I'm using an NVR I need to connect the PC to the internal network of the NVR, I will try tomorrow to verify.

Also from the NET_DVR_ALARM_ISAPI_INFO:
ISAPI alarm information (XML/JSON message, does not include subsequent binary data);
the specific alarm type needs to be obtained by parsing the eventType field of the message.

Not sure that I understand it correctly but it seems like there is more data there to be obtained, even though it is weird that it is ISPAI event.

@pergolafabio
Copy link
Owner

yeah, that isapi alarm is more for cameras, not intercoms

@AYahoo
Copy link
Author

AYahoo commented May 6, 2024

do you know if that is based on SDK or ISAPI directly to port 80 ?

No Idea, never had control4 system or tried it.

@AYahoo
Copy link
Author

AYahoo commented May 6, 2024

if you use ivms, do you see the event there?

https://supportusa.hikvision.com/support/solutions/articles/17000110474-pin-code-setup-for-hikvision-keypad-readers-including-ds-k170hpk-

"If PIN entered does not even show up in iVMS-4200 but card scan does, it is likely due to PIN format being accidentally toggled. Follow instructions in the sheet manual, power cycle the reader, and scan the Data Mode card once to toggle it back to 4-bit burst and try again."

from the manual it seems like maybe Hikvision is using cards and keypad as the same integration?

@pergolafabio
Copy link
Owner

hmm, i dont think those setting are for 8003 ? i also have an ds-kd8003 btw

@AYahoo
Copy link
Author

AYahoo commented May 8, 2024

if you use ivms, do you see the event there?

Ok, Using the IVMS I can see the event when I press the wrong key - Authentication error.

@pergolafabio
Copy link
Owner

Hm, strange that it doesn't create that event using the SDK :-(

@AYahoo
Copy link
Author

AYahoo commented May 8, 2024

2024-05-06 21:26:58.953 | INFO | event:isapi_alarm:131 - Isapi alarm from Gate



    
      
    

      
    

    
  

I think we get it an ISAPI with a payload that we need to read.

@AYahoo
Copy link
Author

AYahoo commented May 8, 2024

Screenshot 2024-05-08 185555

So as you can see in the attached file:
Events type + Events Details can show if the correct code was entered or not.

@pergolafabio
Copy link
Owner

hmm, your previous reply seems empty about the isapi ? can you pots that again? do you always see the isapi event with unknnown key code? then its indeed worth investigating!

@AYahoo
Copy link
Author

AYahoo commented May 8, 2024

Everytime i pinch the wrong pin code, i get:

event:isapi_alarm:131 - Isapi alarm from Gate

@pergolafabio
Copy link
Owner

Hmm, i tried it on mine ds-kd8003, and i receive below
DO you have DS-KD8003 rev a or b ? , what firmware?

2024-05-08 20:23:24.306 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-08 20:23:24.307 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-08 20:23:24.307 | INFO     | event:video_intercom_alarm:120 - Video intercom alarm from DS-KD8003
2024-05-08 20:23:24.308 | WARNING  | mqtt:video_intercom_alarm:364 - Received unknown alarm type: 0
[2024-05-08 20:23:24.306][INF] Alarm[0] IP[192.168.0.70] data_len[568] alarm_len[568] status[430]
[2024-05-08 20:23:54.972][DBG] Alarm chan [0] recv timeout[2]!

@pergolafabio
Copy link
Owner

I just pushed beta 62, added some more isapi data in debug , can you test? i have no idea what it will show...

13f0d6f

@AYahoo
Copy link
Author

AYahoo commented May 8, 2024

Hmm, i tried it on mine ds-kd8003, and i receive below DO you have DS-KD8003 rev a or b ? , what firmware?

2024-05-08 20:23:24.306 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-08 20:23:24.307 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-08 20:23:24.307 | INFO     | event:video_intercom_alarm:120 - Video intercom alarm from DS-KD8003
2024-05-08 20:23:24.308 | WARNING  | mqtt:video_intercom_alarm:364 - Received unknown alarm type: 0
[2024-05-08 20:23:24.306][INF] Alarm[0] IP[192.168.0.70] data_len[568] alarm_len[568] status[430]
[2024-05-08 20:23:54.972][DBG] Alarm chan [0] recv timeout[2]!

DS-KD8003-IME1
Firmware: V2.2.45 build 210430

@AYahoo
Copy link
Author

AYahoo commented May 8, 2024

I just pushed beta 62, added some more isapi data in debug , can you test? i have no idea what it will show...

13f0d6f

Do I need to uninstall the stable version first?

@pergolafabio
Copy link
Owner

no need to uninstall, but just stop the addon , thats enough, then install beta addon, copy/paste the config

@pergolafabio
Copy link
Owner

Hmm, i tried it on mine ds-kd8003, and i receive below DO you have DS-KD8003 rev a or b ? , what firmware?

2024-05-08 20:23:24.306 | DEBUG    | event:_handle_callback:220 - Callback invoked from SDK
2024-05-08 20:23:24.307 | DEBUG    | event:_invoke_handlers:192 - Invoking 2 handlers
2024-05-08 20:23:24.307 | INFO     | event:video_intercom_alarm:120 - Video intercom alarm from DS-KD8003
2024-05-08 20:23:24.308 | WARNING  | mqtt:video_intercom_alarm:364 - Received unknown alarm type: 0
[2024-05-08 20:23:24.306][INF] Alarm[0] IP[192.168.0.70] data_len[568] alarm_len[568] status[430]
[2024-05-08 20:23:54.972][DBG] Alarm chan [0] recv timeout[2]!

DS-KD8003-IME1 Firmware: V2.2.45 build 210430

thats indeed an old firmware, i'm running : V2.2.62 build 230204
thats maybe why log is different

@pergolafabio
Copy link
Owner

also setup both to DEBUG::

log_level: DEBUG
sdk_log_level: DEBUG

@AYahoo
Copy link
Author

AYahoo commented May 8, 2024

2024-05-08 21:52:41.664 | DEBUG    | mqtt:isapi_alarm:277 - Isapi alarm from Gate with Alarmdata: b'0' 
2024-05-08 21:52:41.664 | INFO     | event:isapi_alarm:131 - Isapi alarm from Gate

@pergolafabio
Copy link
Owner

hmm , not really helpfull :-)

@pergolafabio
Copy link
Owner

and those screenshots they send you is the alertstream, you can see an example here:
https://www.hikvisioneurope.com/eu/portal/portal/Technology%20Partner%20Program/03-How%20to/How%20to%20get%20real-time%20event%20in%20listening%20mode.pdf

but that alertstream i have never seen it working on Intercoms, its for cameras

@Khyonox
Copy link

Khyonox commented Jun 4, 2024

I think i have some progress on this. Attached screenshot of invalid card on KD8003-B
image

@pergolafabio
Copy link
Owner

ah, thats interesting? what did you do ?

@Khyonox
Copy link

Khyonox commented Jun 4, 2024

And here is the JSON I get if I try to enter an invalid code on the DS-KD-KP module
image

@Khyonox
Copy link

Khyonox commented Jun 4, 2024

ah, thats interesting? what did you do ?

I think pAlarmData param in NET_DVR_ALARM_ISAPI_INFO struct in sdk code should be a pointer to a char, and then you can get any data from pAlarmData with length of dwAlarmDataLen

@pergolafabio
Copy link
Owner

do you have the code running, can you share it?

@pergolafabio
Copy link
Owner

or can you submit a PR ?

@Khyonox
Copy link

Khyonox commented Jun 4, 2024

Changed pAlarmData param to a pointer with char type:

class NET_DVR_ALARM_ISAPI_INFO(Structure):
fields = [
("pAlarmData", POINTER(char)),
("dwAlarmDataLen", DWORD),
("byDataType", BYTE),
("byPicturesNumber", BYTE),
("byRes", BYTE * 2),
("pPicPackData", NET_DVR_ALARM_ISAPI_PICDATA),
("byRes2", BYTE * 32),
]

And then we can read data string at pAlarmData location via string_at:

    async def isapi_alarm(
            self,
            doorbell: Doorbell,
            command: int,
            device: NET_DVR_ALARMER,
            alarm_info: NET_DVR_ALARM_ISAPI_INFO,
            buffer_length,
            user_pointer: c_void_p):
        pAlarmData = alarm_info.pAlarmData
        alarmDataLen = alarm_info.dwAlarmDataLen
        byDataType = alarm_info.byDataType
        alarmDataBuffer = ctypes.string_at(pAlarmData, alarmDataLen)

@Khyonox
Copy link

Khyonox commented Jun 4, 2024

Still, need to check if data type is xml, since NET_DVR_ALARM_ISAPI_INFO can send xml too

@pergolafabio
Copy link
Owner

I hope these events are documented somewhere, dont think they are the same as below:

https://open.hikvision.com/hardware/structures/NET_DVR_ACS_ALARM_INFO.html

@Khyonox
Copy link

Khyonox commented Jun 4, 2024

Im not sure. Just checked their SDK client demo and docs for it, not found anything really

@pergolafabio
Copy link
Owner

MINOR_INVALID_CARD | 0x09

This one is in my SDK, but the event 150 is not , i can just add it, those docs are not always up to date

@pergolafabio
Copy link
Owner

pergolafabio commented Jun 4, 2024

hey @Khyonox , what firmware do you have on your 8003 ? Probably an older one? mine doesnt give the ISAPI alarm :-(

@Khyonox
Copy link

Khyonox commented Jun 4, 2024

hey @Khyonox , what firmware do you have on your 8003 ? Probably an older one? mine doesnt give the ISAPI alarm :-(

Interesting, im using V2.2.76 build 240226

@pergolafabio
Copy link
Owner

2.2.72 ? where did you download it? i'm on 2.2.62 , and i see its the latest one here?
do you have rev A or rev B model ?

https://www.hikvisioneurope.com/eu/portal/?dir=portal/Technical%20Materials/07%20%20Video%20Intercom/00%20%20Product%20Firmware/01%20Door%20Station%20%28KD%20KV%20KB%29/KD%20Series/KD8003

@Khyonox
Copy link

Khyonox commented Jun 4, 2024

Just did a firmware update, now using V2.2.76 build 240515. Still sends the ISAPI alarm 🤔
image

@Khyonox
Copy link

Khyonox commented Jun 4, 2024

@pergolafabio
Copy link
Owner

the ISAPI alarm is good

but mine sends an EVENT alarm with type 0 ... , seems it was working on 2.2.45 according to @AYahoo , but he also upgraded to 2.2.62 , and receives the same EVENT as me

we are using rev A models, 2.2.62 is the latest :-( , maybe a bug in our firmware

@pergolafabio
Copy link
Owner

i have build : V2.2.62 build 230204 and it seems its the latest one

@AYahoo
Copy link
Author

AYahoo commented Jun 5, 2024

If you can make it work with the ISAPI I'm willing to degrade to 2.2.45.

@pergolafabio
Copy link
Owner

we should move upwards, you guys had contact with Hikvision right? Can you ask if this is a known bug in 2.2.62 (rev A) ? since it was working an previous release 2.2.45...

Also tell it works in 2.2.72 (rev B)

@AYahoo
Copy link
Author

AYahoo commented Jun 5, 2024 via email

@AYahoo
Copy link
Author

AYahoo commented Jun 7, 2024

This i the replay,

Do you use ISAPI to get the event from KD8003, but get the alarm type 0?
Could you please share your event example ?
Thanks.

@pergolafabio Could you please help with the response?

@pergolafabio
Copy link
Owner

pergolafabio commented Jun 7, 2024

Hey, you can say we are using SDK and listining for lCommand

https://open.hikvision.com/hardware/definitions/NET_DVR_StartListen_V30.html

For the invalid key code, we are receiving this:

COMM_ALARM_VIDEO_INTERCOM | 0x1133 | Video intercom alarm information | NET_DVR_VIDEO_INTERCOM_ALARM

With : byAlarmType => 0

We should receive this instead:

COMM_ISAPI_ALARM | 0x6009 | ISAPI protocol alarm information | NET_DVR_ALARM_ISAPI_INFO

For the unknown badge , in my case i dont receive any event at all , while @Khyonox does receive the event
He is using the DS-KD8003 rev B , with firmware 2.2.72

@pergolafabio
Copy link
Owner

Do you have some updates?

@AYahoo
Copy link
Author

AYahoo commented Jun 21, 2024

Yeah, just got a response:

Hello,

I think it is a bug as you described.
For the the current event, I have checked that there is no byAlarmType=0. You can test this function in our SDK ClientDemo and privide the snaphot to show this issue.
BTW, Could you please share the right event exmaple before for a check?
Thanks.

@pergolafabio
Copy link
Owner

Ok, that's good news, if they confirm it as a bug ;-)

Hopefully you can get them going to create a new firmware

@pergolafabio
Copy link
Owner

Got some updates?

@pergolafabio
Copy link
Owner

Yeah, just got a response:

Hello,

I think it is a bug as you described. For the the current event, I have checked that there is no byAlarmType=0. You can test this function in our SDK ClientDemo and privide the snaphot to show this issue. BTW, Could you please share the right event exmaple before for a check? Thanks.

hi, do you have an update from Hikvision?

@pergolafabio
Copy link
Owner

hi guys, you got some feedback on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants