MqttTransport

class compas_eve.mqtt.MqttTransport[source]

Bases: Transport, EventEmitterMixin

MQTT transport allows sending and receiving messages using an MQTT broker.

Parameters:
hoststr

Host name for the MQTT broker, e.g. broker.hivemq.com or localhost if you are running a local broker on your machine.

portint

MQTT broker port, defaults to 1883.

client_idstr, optional

Client ID for the MQTT connection. If not provided, a unique ID will be generated.

Methods

advertise

Announce this code will publish messages to the specified topic.

close

Close the connection to the MQTT broker.

on_ready

Allows to hook-up to the event triggered when the connection to MQTT broker is ready.

publish

Publish a message to a topic.

subscribe

Subscribe to a topic.

unadvertise

Announce that this code will stop publishing messages to the specified topic.

unsubscribe

Unsubscribe from the specified topic.

unsubscribe_by_id

Unsubscribe from the specified topic based on the subscription id.

Inherited Methods

emit

Emit event, passing *args and **kwargs to each attached function.

listeners

Returns a list of all listeners registered to the event.

off

Removes the function f from event.

on

Registers the function (or optionally an asyncio coroutine function) f to the event name event.

once

The same as ee.on, except that the listener is automatically removed after being called.

remove_all_listeners

Remove all listeners attached to event.

remove_listener

Removes the function f from event.