ViewtronEvent & Event Classes (Node.js)
Functions
getText() Extract text from a fast-xml-parser value. Handles both direct strings and objects with #text property.
asArray() Normalize a value to an array. Handles xmltodict/fast-xml-parser single-item quirk.
extractBase64() Extract base64 image data, filtering out placeholder values.
parseEvent(postBody) ⇒ ViewtronEvent | null
Parse an HTTP POST body from a Viewtron camera or NVR.
Returns a ViewtronEvent for recognized events, or null for keepalives,
alarm status messages, and unrecognized payloads. Parsed events include
configVersion (the config version attribute) and format (v1 or v2).
A config version of 2.x selects the v2 envelope. A 2.x post with no
messageType and a v1 smartType is parsed with the v1 layout instead.
Within each layout, smartType matching is case-insensitive.
eventTime is the camera time. currentTime is read as seconds,
milliseconds, or microseconds based on its magnitude.
getText()
Extract text from a fast-xml-parser value. Handles both direct strings and objects with #text property.
Kind: global function
asArray()
Normalize a value to an array. Handles xmltodict/fast-xml-parser single-item quirk.
Kind: global function
extractBase64()
Extract base64 image data, filtering out placeholder values.
Kind: global function
parseEvent(postBody) ⇒ ViewtronEvent | null
Parse an HTTP POST body from a Viewtron camera or NVR.
Returns a ViewtronEvent for recognized events, or null for keepalives,
alarm status messages, and unrecognized payloads. Parsed events include
configVersion (the config version attribute) and format (v1 or v2).
A config version of 2.x selects the v2 envelope. A 2.x post with no
messageType and a v1 smartType is parsed with the v1 layout instead.
Within each layout, smartType matching is case-insensitive.
eventTime is the camera time. currentTime is read as seconds,
milliseconds, or microseconds based on its magnitude.
Kind: global function
| Param | Type | Description |
|---|---|---|
| postBody | string | Raw XML string from camera HTTP POST |