MQTT bridging¶
dataClay includes support for client communication via MQTT.
In order to use this functionality, the client class has to inherit the MQTTMixin class. The client will be able to specify how the messages should be handled, which topics will be subscribed to, and send messages with a topic.
- class dataclay.contrib.mqtt.MQTTMixin[source]¶
MQTT mechanisms
- message_handling(client, userdata, msg)[source]¶
Placeholder for function message_handling. This function describes how the client will handle a message.
- Parameters:
client (paho.mqtt.client.Client) – The client instance for this callback.
userdata – The private user data as set in Client() or user_data_set().
msg (MQTTMessage) – The received message. This is a class with members topic, payload, qos, retain.
- Raises:
NotImplementedError – If the message_handling function has not been implemented, an error is raised.
- produce_mqtt_msg(data: dict[str, Any], topic: str = 'dataclay', **more)[source]¶
The client is connected to the broker, and it sends the message to the chosen topic.
- Parameters:
data (dict[str, Any]) – Message.
topic (str, optional) – Topic of the message. Defaults to “dataclay”.