pybragerone.models.param

Runtime-light parameter store.

This module intentionally contains only the minimal structures and logic needed to store and update raw parameter values (e.g. P5.s0).

All asset-driven behavior (mappings, menu grouping, i18n, computed STATUS rule evaluation, and rich “describe” helpers) is implemented in pybragerone.models.param_resolver.ParamResolver.

Classes

ParamFamilyModel(**data)

One parameter "family" (e.g., P4 index 1) collecting channels: v/s/u/n/x...

ParamStore(**data)

Store of live parameter values.

class pybragerone.models.param.ParamFamilyModel(**data: Any)[source]

Bases: BaseModel

One parameter “family” (e.g., P4 index 1) collecting channels: v/s/u/n/x…

Parameters:
channels: dict[str, Any]
get(chan: str, default: Any = None)[source]

Get raw channel value, or default if not present.

Return type:

Any

Parameters:
idx: int
model_config: ClassVar[ConfigDict] = {'frozen': False, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

pool: str
set(chan: str, value: Any)[source]

Set raw channel value.

Return type:

None

Parameters:
property status_raw: Any

Raw status channel, if any.

property unit_code: Any

Raw unit code channel, if any.

property value: Any

Raw value channel, if any.

class pybragerone.models.param.ParamStore(**data: Any)[source]

Bases: BaseModel

Store of live parameter values.

Notes

Keys use the BragerOne addressing format: P<n>.<chan><idx> (e.g. P5.s0, P4.v1, P4.u1).

This class is designed to be safe and fast for HA runtime.

Parameters:

families (dict[str, ParamFamilyModel])

families: dict[str, ParamFamilyModel]
flatten()[source]

Flattened view of all parameters as { 'P4.v1': value, ... }.

Return type:

dict[str, Any]

get_family(pool: str, idx: int)[source]

Get ParamFamilyModel by (pool, idx) address, or None if not found.

Return type:

ParamFamilyModel | None

Parameters:
ingest_prime_payload(payload: Mapping[str, Any])[source]

Ingest REST prime payload (modules/parameters) into the store.

Return type:

None

Parameters:

payload (Mapping[str, Any])

model_config: ClassVar[ConfigDict] = {'frozen': False, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

async run_with_bus(bus: EventBus)[source]

Consume ParamUpdate events from EventBus and upsert into ParamStore.

Return type:

None

Parameters:

bus (EventBus)

upsert(key: str, value: Any)[source]

Upsert a single parameter value by full key, e.g. P4.v1.

Return type:

ParamFamilyModel | None

Parameters:
async upsert_async(key: str, value: Any)[source]

Async upsert wrapper for convenience in async code.

Return type:

ParamFamilyModel | None

Parameters: