Class MqttPlugin new

Die Klasse MqttPlugin implementiert die Basisklasse aller SmartPlugins die MQTT nutzen. Die vorhandenen Methoden sind im Folgenden beschrieben

Zusätzlich werden die Methoden der Klasse lib.utils.Utils vererbt.

class lib.model.mqttplugin.MqttPlugin(*args, **kargs)[Quellcode]

Bases: lib.model.smartplugin.SmartPlugin

start_subscriptions()[Quellcode]

Start subscription to all topics

Should be called from the run method of a plugin

stop_subscriptions()[Quellcode]

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)[Quellcode]

Add mqtt subscription to subscribed_topics list

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

Parameter
  • 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

Rückgabe

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

Publish a topic to mqtt

Parameter
  • 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)

Rückgabe

broker_config = {}
broker_monitoring = False
get_broker_info()[Quellcode]
broker_uptime()[Quellcode]

Return formatted uptime of broker

mqtt_init()[Quellcode]

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