Skip to content

Commit

Permalink
back to mapping thermometry to motion event and test for notification
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-or committed Nov 14, 2024
1 parent e081136 commit f6d28ed
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
4 changes: 0 additions & 4 deletions custom_components/hikvision_next/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,4 @@
**ISAPI_EVENTS["pir"],
"device_class": BinarySensorDeviceClass.MOTION,
},
"thermometry": {
**ISAPI_EVENTS["thermometry"],
"device_class": BinarySensorDeviceClass.MOTION,
}
}
6 changes: 1 addition & 5 deletions custom_components/hikvision_next/isapi/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@
"slug": "WLAlarm/PIR",
"direct_node": "PIRAlarm",
},
"thermometry": {
"type": EVENT_BASIC,
"label": "Thermometry",
"slug": "thermometry",
},
}

STREAM_TYPE = {
Expand All @@ -86,6 +81,7 @@

EVENTS_ALTERNATE_ID = {
"vmd": "motiondetection",
"thermometry": "motiondetection",
"shelteralarm": "tamperdetection",
"VMDHumanVehicle": "motiondetection",
}
Expand Down
6 changes: 0 additions & 6 deletions custom_components/hikvision_next/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
},
"io": {
"name": "Alarm Input {io_port_id}"
},
"thermometry": {
"name": "Temperature"
}
},
"switch": {
Expand Down Expand Up @@ -91,9 +88,6 @@
},
"io": {
"name": "Alarm Input {io_port_id}"
},
"thermometry": {
"name": "Temperature detection"
}
},
"camera": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<EventNotificationAlert>
<ipAddress>1.0.0.255</ipAddress>
<portNo>8123</portNo>
<protocol>HTTP</protocol>
<macAddress>a6:60:9e:f8:01:09</macAddress>
<dynChannelID>2</dynChannelID>
<channelID>2</channelID>
<dateTime>2024-11-13T20:20:52+01:00</dateTime>
<activePostCount>1</activePostCount>
<eventType>VMD</eventType>
<eventState>active</eventState>
<eventDescription>Motion alarm</eventDescription>
<channelName>Camera 02</channelName>
</EventNotificationAlert>
4 changes: 2 additions & 2 deletions tests/fixtures/devices/DS-2TD1228-2-QA.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"deviceLocation": "hangzhou",
"systemContact": "Hikvision.China",
"model": "DS-2TD1228-2-QA",
"serialNumber": "xxxxxxxxxxxxxxxxxxx",
"macAddress": "xxxxxxxxxxxxxxxxxxx",
"serialNumber": "DS-2TD1228-2/QA/xxxxxxxxxxxxxxxxxx",
"macAddress": "a6:60:9e:f8:01:09",
"firmwareVersion": "V5.5.98",
"firmwareReleasedDate": "build 240726",
"encoderVersion": "V7.3",
Expand Down
20 changes: 20 additions & 0 deletions tests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ async def test_ipc_intrusion_detection_alert(
assert sensor.state == STATE_ON


@pytest.mark.parametrize("init_integration", ["DS-2TD1228-2-QA"], indirect=True)
async def test_ipc_motion_detection_on_thermometry_channel_alert(
hass: HomeAssistant, init_integration: MockConfigEntry,
) -> None:
"""Test incoming motion detection event alert on thermometry channel from ip multi channel camera."""

entity_id = "binary_sensor.ds_2td1228_2_qa_xxxxxxxxxxxxxxxxxx_2_motiondetection"

assert (sensor := hass.states.get(entity_id))
assert sensor.state == STATE_OFF

view = EventNotificationsView(hass)
mock_request = mock_event_notification("ipc_thermometry_motiondetection")
response = await view.post(mock_request)

assert response.status == HTTPStatus.OK
assert (sensor := hass.states.get(entity_id))
assert sensor.state == STATE_ON


@pytest.mark.parametrize("init_integration", ["DS-2CD2146G2-ISU"], indirect=True)
async def test_field_detection_alert(
hass: HomeAssistant, init_integration: MockConfigEntry,
Expand Down

0 comments on commit f6d28ed

Please sign in to comment.