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

added pir support #194

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading