function parsePtzPosition
parsePtzPosition(xml: string): PtzPosition

Reads the current position from the reply to a cmd 433 request.

Examples

Read a position

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

const position = parsePtzPosition(
  "<body><ptzCurPos><channelId>0</channelId>" +
    "<pPos>1520</pPos><tPos>310</tPos></ptzCurPos></body>",
);

assertEquals(position, { pan: 1520, tilt: 310 });

Parameters

xml: string

The decrypted reply body.

Return Type

The pan and tilt position.

Throws

Error

When the reply lacks <pPos> or <tPos>.

Usage

import { parsePtzPosition } from "protocol/ptz.ts";