MQTT Device Template

class festivalgrid.device_templates.mqtt_device.MQTTDevice(device)[source]

The base class for MQTT based devices.


Tasmota is a good reference for implementing new MQTT based device templates.


Pings both the worker and mqtt_broker services that they should reload the setup.

send_mqtt_message(topic, message)[source]

Use this to send a message to the mqtt broker.

  • topic (str.) – The topic this message should be published under.

  • message (str.) – The message that should be published.

festivalgrid.device_templates.mqtt_device.init_mqtt(client_id=None, on_message=False, on_connect=False, on_disconnect=False)[source]

This will open a connection to the mqtt broker and register any callbacks you pass in as parameters.

  • client_id (str.) – The name this connection should register as with the broker.

  • on_message (function.) – Callback function that gets called when a new message is received.

  • on_connect (function.) – Callback function that gets called when the connection to the broker is successful.

  • on_disconnect (function.) – Callback function that gets called when the broker disconnects.


paho.Client – the paho Client object instance