cremalink.parsing.monitor.frame module
This module defines the low-level structure of a “monitor” data frame. It handles the byte-level decoding of the raw payload from the device.
- class cremalink.parsing.monitor.frame.MonitorFrame(direction: int, request_id: int, answer_required: int, accessory: int, switches: bytes, alarms: bytes, status: int, action: int, progress: int, timestamp: bytes, extra: bytes, raw: bytes, raw_b64: str)[source]
Bases:
objectRepresents the decoded, low-level structure of a monitor data frame.
This class takes the raw bytes from a monitor update and parses them into their fundamental components according to the device’s binary protocol. This includes separating headers, payload, checksums, and timestamps.
- as_dict() dict[source]
Returns a dictionary representation of the frame’s contents. This is useful for serialization or debugging.
- classmethod from_b64(raw_b64: str) MonitorFrame[source]
Decodes a base64 string into a structured MonitorFrame.
This factory method performs the primary byte-level parsing, including: - Base64 decoding. - Length validation. - CRC-16 checksum verification. - Splitting the raw bytes into their respective fields (header, payload, etc.).
- Parameters:
raw_b64 – The base64-encoded monitor data string.
- Returns:
A populated MonitorFrame instance.
- Raises:
ValueError – If the data is malformed, too short, or fails the CRC check.