Skip to content

Commit

Permalink
pir support (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-or authored Aug 6, 2024
1 parent 92ae806 commit a7c82fc
Show file tree
Hide file tree
Showing 6 changed files with 1,200 additions and 0 deletions.
8 changes: 8 additions & 0 deletions custom_components/hikvision_next/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
EVENT_BASIC: Final = "basic"
EVENT_IO: Final = "io"
EVENT_SMART: Final = "smart"
EVENT_PIR: Final = "pir"
EVENTS = {
"motiondetection": {
"type": EVENT_BASIC,
Expand Down Expand Up @@ -83,6 +84,13 @@
"proxied_node": "IOProxyInputPort",
"device_class": BinarySensorDeviceClass.MOTION,
},
"pir": {
"type": EVENT_PIR,
"label": "PIR",
"slug": "WLAlarm/PIR",
"direct_node": "PIRAlarm",
"device_class": BinarySensorDeviceClass.MOTION,
}
}

EVENTS_ALTERNATE_ID = {
Expand Down
4 changes: 4 additions & 0 deletions custom_components/hikvision_next/isapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
DOMAIN,
EVENT_BASIC,
EVENT_IO,
EVENT_PIR,
EVENTS,
EVENTS_ALTERNATE_ID,
MUTEX_ALTERNATE_IDS,
Expand Down Expand Up @@ -462,6 +463,9 @@ def get_event_url(self, event: SupportedEventsInfo, connection_type: str) -> str
else:
# ISAPI/System/IO/{slug}}/{channel_id}
url = f"System/IO/{slug}/{event.io_port_id}"
elif event_type == EVENT_PIR:
# ISAPI/WLAlarm/PIR
url = slug
else:
# ISAPI/Smart/{event}/{channel_id}
url = f"Smart/{slug}/{event.channel_id}"
Expand Down
19 changes: 19 additions & 0 deletions tests/fixtures/ISAPI/EventNotificationAlert/pir.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<EventNotificationAlert version="1.0"
xmlns="urn:psialliance-org">
<ipAddress>1.0.0.255</ipAddress>
<protocolType>HTTP</protocolType>
<macAddress>c6:e6:61:0a:46:37</macAddress>
<channelID>1</channelID>
<dateTime>2023-04-06T22:22:21+01:00</dateTime>
<activePostCount>4268</activePostCount>
<eventType>PIR</eventType>
<eventState>active</eventState>
<eventDescription>PIR alarm</eventDescription>
<channelName>Bedroom</channelName>
<Extensions version="1.0"
xmlns="urn:psialliance-org">
<serialNumber xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2443G0-IW00000000AAWRE00000000</serialNumber>
<eventPush xmlns="urn:selfextension:psiaext-ver10-xsd">PIR&amp;&amp;DS-2CD2443G0-IW00000000AAWRE00000000,2023-04-06T22:22:21+01:00,1,1.0</eventPush>
</Extensions>
</EventNotificationAlert>
Loading

0 comments on commit a7c82fc

Please sign in to comment.