5.3.1.17.5.1. cli.com.mqtt_com.MQTT
- class cli.com.mqtt_com.MQTT(name: str, parameter: MQTTParameter)
Bases:
ComInterfaceCommunication interface for sending and receiving messages via MQTT protocol. Initializes and manages a background process for MQTT communication.
- read(block: bool = False, timeout: float | None = None) dict | None
Read an incoming MQTT message from the output queue.
- Parameters:
block (bool) – Whether to block if the queue is empty.
timeout (float | None) – Timeout for blocking (in seconds).
- Returns:
Dictionary with ‘topic’ and ‘data’ if available, otherwise None.
- Return type:
dict | None
- write(msg: dict) None
Publish a message to a specific MQTT topic via the input queue.
- Parameters:
msg (dict) – The MQTT message as dict
- Raises:
RuntimeError – If the related MQTT process is not running.