class documentation

class MQTTHandler(object):

Known subclasses: acme.plugins.bindings.MQTTClient.MQTTClientHandler

View In Hierarchy

This base class defines the interface for an MQTT handler class. The abstract methods defined here must be implemented by the implementing class.

The implementing class acts as a handler for various callbacks when dealing with the MQTT handler. To receive messages a client implementation must register topics and the callbacks for them in the onConnect() method.

Method logging This method is called when a log message should be handled.
Method onConnect This method is called after the MQTT client connected to the MQTT broker. Usually, an MQTT client should subscribe to topics and register the callback methods here.
Method onDisconnect This method is called after the MQTT client disconnected from the MQTT broker.
Method onError This method is called when receiving an error when communicating with the MQTT broker.
Method onShutdown This method is called after the `connection` was shut down.
Method onSubscribed This method is called after the MQTT client successfully subsribed to a topic.
Method onUnsubscribed This method is called after the MQTT client successfully unsubsribed from a topic.
def logging(self, connection: MQTTConnection | None, level: int, message: str) -> bool:

This method is called when a log message should be handled.

Parameters
connection:MQTTConnection | NoneThe MQTT connection.
level:intThe log level.
message:strThe log message.
Returns
boolTrue if successful, False otherwise.
def onConnect(self, connection: MQTTConnection) -> bool:

This method is called after the MQTT client connected to the MQTT broker. Usually, an MQTT client should subscribe to topics and register the callback methods here.

Parameters
connection:MQTTConnectionThe MQTT connection.
Returns
boolTrue if successful, False otherwise.
def onDisconnect(self, connection: MQTTConnection) -> bool:

This method is called after the MQTT client disconnected from the MQTT broker.

Parameters
connection:MQTTConnectionThe MQTT connection.
Returns
boolTrue if successful, False otherwise.
def onError(self, connection: MQTTConnection, rc: int) -> bool:

This method is called when receiving an error when communicating with the MQTT broker.

Parameters
connection:MQTTConnectionThe MQTT connection.
rc:intThe error code.
Returns
boolTrue if successful, False otherwise.
def onShutdown(self, connection: MQTTConnection):

This method is called after the `connection` was shut down.

Parameters
connection:MQTTConnectionThe MQTT connection.
def onSubscribed(self, connection: MQTTConnection, topic: str) -> bool:

This method is called after the MQTT client successfully subsribed to a topic.

Parameters
connection:MQTTConnectionThe MQTT connection.
topic:strThe topic that was subscribed to.
Returns
boolTrue if successful, False otherwise.
def onUnsubscribed(self, connection: MQTTConnection, topic: str) -> bool:

This method is called after the MQTT client successfully unsubsribed from a topic.

Parameters
connection:MQTTConnectionThe MQTT connection.
topic:strThe topic that was unsubscribed from.
Returns
boolTrue if successful, False otherwise.