Class MqttPlugin new

The class MqttPlugin implements the base class of all smart-plugins that use MQTT. The implemented methods are described below.

In addition the methods implemented in lib.utils.Utils are inherited.

class lib.model.mqttplugin.MqttPlugin[source]

Bases: lib.model.smartplugin.SmartPlugin


Start subscription to all topics

Should be called from the run method of a plugin


Stop subscription to all topics

Should be called from the stop method of a plugin

add_subscription(topic, payload_type, bool_values=None, item=None, callback=None)[source]

Add mqtt subscription to subscribed_topics list

subscribing is done directly, if subscriptions have been started by self.start_subscriptions()

  • topic – topic to subscribe to

  • payload_type – payload type of the topic (for this subscription to the topic)

  • bool_values – bool values (for this subscription to the topic)

  • item – item that should receive the payload as value. Used by the standard handler (if no callback function is specified)

  • callback – a plugin can provide an own callback function, if special handling of the payload is needed


publish_topic(topic, payload, item=None, qos=None, retain=False, bool_values=None)[source]

Publish a topic to mqtt

  • topic – topic to publish

  • payload – payload to publish

  • item – item (if relevant)

  • qos – qos for this message (optional)

  • retain – retain flag for this message (optional)

  • bool_values – bool values (for publishing this topic, optional)


broker_config = {}
broker_monitoring = False

Return formatted uptime of broker


Dummy method - should not be called any more :return: Bool value True :rtype: bool