Alarm events pushed by the camera (cmd 33).
The camera pushes its alarm state for each channel whenever it changes:
<body> <AlarmEventList> <AlarmEvent> <channelId>0</channelId> <status>MD,visitor</status> <AItype>people</AItype> </AlarmEvent> </AlarmEventList> </body>
Each push is state, not a happening: visitor stays true for as long as
the camera reports the doorbell as active. Turning a false to true flip
into a "pressed" signal is up to the consumer.
Parse a doorbell press
Parse a doorbell press
import { assertEquals } from "@std/assert"; import { parseAlarmEvents } from "@hertzg/reolink-api/protocol/event"; const events = parseAlarmEvents( "<body><AlarmEventList><AlarmEvent>" + "<channelId>0</channelId><status>visitor</status><AItype>none</AItype>" + "</AlarmEvent></AlarmEventList></body>", ); assertEquals(events, [ { channel: 0, motion: false, visitor: true, tamper: false, ai: [] }, ]);
f
parseAlarmEvents(xml: string): AlarmEvent[]
Reads every <AlarmEvent> from a decrypted cmd 33 push.
T
AlarmEvent = { channel: number; motion: boolean; visitor: boolean; tamper: boolean; ai: string[]; }
The alarm state of one channel, as the camera pushed it.
-
ai: string[]
AI detections the camera reports, such as
people,vehicleordog_cat. Empty fornone. -
channel: number
Zero-based channel number. A standalone camera or doorbell is channel
0. -
motion: boolean
Motion detected:
MDin the status. -
tamper: boolean
Tamper alarm:
tamperin the status. -
visitor: boolean
Doorbell active:
visitorin the status.
Usage
import * as mod from "protocol/event.ts";