cremalink.parsing.monitor.profile module

This module defines the data structures for a “Monitor Profile”. A profile is a declarative configuration that describes how to interpret the raw bytes of a monitor frame for a specific device model.

class cremalink.parsing.monitor.profile.FlagDefinition(source: str, byte: int, bit: int, invert: bool = False, description: str | None = None)[source]

Bases: object

Defines how to extract a boolean flag from a specific bit in a byte array. This is used for parsing the ‘alarms’ and ‘switches’ byte fields.

bit: int
byte: int
description: str | None = None
invert: bool = False
source: str
validate() None[source]

Checks if the definition is valid.

class cremalink.parsing.monitor.profile.MonitorProfile(flags: Dict[str, ~cremalink.parsing.monitor.profile.FlagDefinition]=<factory>, enums: Dict[str, ~typing.Dict[int, str]]=<factory>, predicates: Dict[str, ~cremalink.parsing.monitor.profile.PredicateDefinition]=<factory>)[source]

Bases: object

A complete profile for parsing a device’s monitor frame.

This class holds all the definitions needed to translate the raw bytes of a monitor frame into meaningful, human-readable data. It is typically loaded from a device-specific JSON file.

available_fields() list[str][source]

Returns a sorted list of all defined flag and predicate names.

enums: Dict[str, Dict[int, str]]
flags: Dict[str, FlagDefinition]
classmethod from_dict(data: dict | None) MonitorProfile[source]

Constructs a MonitorProfile from a dictionary (e.g., from a JSON file).

predicates: Dict[str, PredicateDefinition]
summary() dict[str, Any][source]

Provides a brief summary of the profile’s contents.

class cremalink.parsing.monitor.profile.PredicateDefinition(kind: str, source: str | None = None, value: Any = None, values: Iterable[Any] | None = None, flag: str | None = None, byte: int | None = None, bit: int | None = None)[source]

Bases: object

Defines a logical condition to be evaluated against the monitor frame data. Predicates are used to create higher-level boolean states, like “is_on” or “is_making_coffee”.

bit: int | None = None
byte: int | None = None
flag: str | None = None
kind: str
source: str | None = None
uses_bit_address() bool[source]

Returns True if the predicate directly addresses a bit.

uses_flag() bool[source]

Returns True if the predicate depends on a named flag.

validate() None[source]

Checks if the predicate definition is valid.

value: Any = None
values: Iterable[Any] | None = None