MQTT

Provide MQTT support.

class mauzr.platform.pycom.mqtt.Client(core, cfgbase='mqtt', **kwargs)

Bases: object

Provide MQTT support.

Parameters:
  • core (mauzr.core.Core) – Core instance.
  • cfgbase (str) – Configuration entry for this unit.
  • kwargs (dict) – Keyword arguments that will be merged into the config.

Configuration (mqtt section):

  • base (str): Topic base of the suit.
publish(topic, value, qos, retain)

Publish to a topic.

Parameters:
  • topic (str) – Topic to publish to.
  • value (bytes) – Value to publish.
  • qos (int) – QoS to use (May be 0 or 1).
  • retain (bool) – Retain if set to True.
Returns:

Return value from the client.

Return type:

object

Raises:

ValueError – If QoS is invalid.

set_host(**kwargs)

Set host to connect to.

Parameters:kwargs (dict) – Host Configuration
subscribe(topic, qos)

Subscribe to a topic.

Parameters:
  • topic (str) – Topic to subscribe to.
  • qos (int) – QoS to use (May be 0 or 1).
Returns:

Return value from the client.

Return type:

object

Raises:

ValueError – If QoS is invalid.