powermon.libs.apicoordinator module

apicoordinator.py

class powermon.libs.apicoordinator.ApiCoordinator(adhoc_topic_format: str, announce_topic: str, enabled: bool, refresh_interval: int)

Bases: object

apicoordinator coordinates the api / mqtt interface

addcommand_callback(client, userdata, msg)

add a callback

announce(obj)

Announce jsonised obj dto to api

classmethod from_config(config=None)

build apicoordinator object from config dict

get_addcommand_topic()

get the adhoc topic

initialize()

initialize the apicoordinator

run()

regular processing function, ensures that the announce isnt too frequent

set_device(device: Device)

store the device in the apicoordinator

set_mqtt_broker(mqtt_broker)

store the mqtt broker in the apicoordinator

to_dto()

convert object to data transfer object

class powermon.libs.apicoordinator.ApiCoordinatorDTO(*, name: str, description: str | None)

Bases: BaseModel

data transfer model for ApiCoordinator class

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

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

model_fields: ClassVar[Dict[str, FieldInfo]] = {'description': FieldInfo(annotation=Union[str, NoneType], required=True), 'name': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.