MQTT Device Template¶
The base class for MQTT based devices.
Tasmotais a good reference for implementing new MQTT based device templates.
Pings both the worker and mqtt_broker services that they should reload the setup.
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.
init_mqtt(client_id=None, on_message=False, on_connect=False, on_disconnect=False)¶
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