cremalink.parsing.monitor.decode module

This module contains the primary functions for decoding a raw monitor payload into a structured MonitorSnapshot.

cremalink.parsing.monitor.decode.build_monitor_snapshot(payload: dict[str, Any], source: str = 'local', device_id: str | None = None) MonitorSnapshot[source]

Constructs a MonitorSnapshot from a raw payload dictionary.

This function orchestrates the decoding process: 1. It extracts the base64-encoded monitor string from the input payload. 2. It decodes the base64 string into raw bytes. 3. It calls extract_fields_from_b64 to parse the raw bytes into a

low-level dictionary and a MonitorFrame.

  1. It bundles all this information into a MonitorSnapshot object.

Parameters:
  • payload – The raw dictionary payload, typically from the local server or cloud API.

  • source – The origin of the data (e.g., ‘local’, ‘cloud’).

  • device_id – The identifier of the device.

Returns:

A populated MonitorSnapshot instance.

cremalink.parsing.monitor.decode.decode_monitor_b64(raw_b64: str) bytes[source]

A simple wrapper for base64 decoding that provides a more specific error message.