MQTT
- class core.modules.mqtt_client.MQTTClient
Main communication module to interface with a MQTT Broker
- connect()
Connect to the MQTT broker using the database entry with the highest primary key. If no setup is available None is returned else a mqtt.Client instance is returned. In case of failure during the initialization of the connection the database entry connected is set to
Falsewhich isTruein case of a success.
- publish(topic: str, data: dict)
Send data to broker.
- Parameters:
topic (str) – UTF-8 string used by brokers to filter messages.
data (dict) – Payload send to broker.
- Returns:
None
- class measurement_server.models.measurement.MQTTModel(*args, **kwargs)
This model is used as a base model for this project. All models which are indended to broadcast updates to a MQTT broker shall inherit from this abstract model. While preserving all attributes of its children this class extends the save method such that data written to the database will also be published to a MQTTClient instance .
- forms.mqttSettingsForm(files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)
Interface to submit MQTT broker connection data. See
measurement_server/views/settings.pyfor a implementation reference.