function parseAlarmEvents
parseAlarmEvents(xml: string): AlarmEvent[]

Reads every <AlarmEvent> from a decrypted cmd 33 push.

Elements other than <AlarmEvent>, such as <DayNightEvent>, are ignored, and so is an <AlarmEvent> without a <channelId>.

Examples

Parse a push with AI detections

import { assertEquals } from "@std/assert";
import { parseAlarmEvents } from "@hertzg/reolink-api/protocol/event";

const [event] = parseAlarmEvents(
  "<body><AlarmEventList><AlarmEvent>" +
    "<channelId>0</channelId><status>MD</status>" +
    "<AItype>people,vehicle</AItype>" +
    "</AlarmEvent></AlarmEventList></body>",
);

assertEquals(event.motion, true);
assertEquals(event.ai, ["people", "vehicle"]);

Parameters

xml: string

The decrypted push body.

Return Type

One AlarmEvent per <AlarmEvent> element, in document order.

Usage

import { parseAlarmEvents } from "protocol/event.ts";