esppy.connectors.MQTTSubscriber

class esppy.connectors.MQTTSubscriber(mqtthost=None, mqttclientid=None, mqtttopic=None, mqttqos=None, mqttmsgtype=None, name=None, is_active=None, snapshot=None, mqttuserid=None, mqttpassword=None, mqttport=None, mqttretainmsg=None, mqttdonotcleansession=None, mqttkeepaliveinterval=None, mqttmsgmaxdeliveryattempts=None, mqttmsgdelaydeliveryattempts=None, mqttmsgwaitbeforeretry=None, mqttmaxinflightmsg=None, collapse=None, rmretdel=None, dateformat=None, protofile=None, protomsg=None, mqttssl=None, mqttsslcafile=None, mqttsslcapath=None, mqttsslcertfile=None, mqttsslkeyfile=None, mqttsslpassword=None, csvincludeschema=None, configfilesection=None, mqttpasswordencrypted=None, addcsvopcode=None, addcsvflags=None, csvmsgperevent=None, csvmsgpereventblock=None)

Bases: esppy.connectors.base.Connector

Subscribe to MQ Telemetry Transport (MQTT)

Parameters
mqtthoststring

Specifies the MQTT server host name

mqttclientidstring

Specifies the string to use as the MQTT Client ID. If empty, a random client ID is generated. If NULL, mqttdonotcleansession must be false. Must be unique among all clients connected to the MQTT server.

mqtttopicstring

Specifies the string to use as an MQTT topic to publish events to.

mqttqosstring

Specifies the requested Quality of Service. Values can be 0, 1 or 2.

mqttmsgtypestring

Specifies binary, CSV, JSON, or the name of a string field in the subscribed window schema.

snapshotboolean, optional

Specifies whether to send snapshot data

mqttuseridstring, optional

Specifies the user name required to authenticate the connector’s session with the MQTT server.

mqttpasswordstring, optional

Specifies the password associated with mqttuserid

mqttportint, optional

Specifies the MQTT server port. Default is 1883.

mqttretainmsgboolean, optional

Sets to true to make the published message retained in the MQTT Server. Default is false.

mqttdonotcleansessionboolean, optional

Instructs the MQTT Server to keep all messages and subscriptions on disconnect, instead of keeping them. Default is false.

mqttkeepaliveintervalint, optional

Specifies the number of seconds after which the broker should send a PING message to the client if no other messages have been exchanged in that time. Default is 10.

mqttmsgmaxdeliveryattemptsint, optional

Specifies the number of times the connector tries to resend the message in case of failure. Default is 20.

mqttmsgdelaydeliveryattemptsint, optional

Specifies the delay in milliseconds between delivery attempts specified with mqttmsgmaxdeliveryattempts. Default is 500.

mqttmsgwaitbeforeretryint, optional

Specifies the number of seconds to wait before retrying to send messages to the MQTT broker. This applies to publish messages with QoS > 0. Default is 20.

mqttmaxinflightmsgint, optional

Specifies the number of QoS 1 and 2 messages that can be simultaneously in flight. Default is 20.

collapsestring, optional

Enables conversion of UPDATE_BLOCK events to make subscriber output publishable. The default value is disabled.

rmretdelboolean, optional

Specifies to remove all delete events from event blocks received by a subscriber that were introduced by a window retention policy.

dateformatstring, optional

Specifies the format of ESP_DATETIME and ESP_TIMESTAMP fields in CSV events. The default behavior is these fields are interpreted as an integer number of seconds (ESP_DATETIME) or microseconds (ESP_TIMESTAMP) since epoch.

protofilestring, optional

Specifies the .proto file that contains the Google Protocol Buffers message definition used to convert event blocks to protobuf messages. When you specify this parameter, you must also specify the protomsg parameter.

protomsgstring, optional

Specifies the name of a Google Protocol Buffers message in the .proto file that you specified with the protofile parameter. Event blocks are converted into this message.

mqttsslboolean, optional

Specifies to use SSL/TLS to connect to the MQTT broker. Default is false. In order to use SSL/TLS, the ESP encryption overlay must be installed.

mqttsslcafilestring, optional

If mqttssl=true, specifies the path to a file containing the PEM encoded trusted CA certificate files. Either mqttsslcafile or mqttsslcapath must be specified.

mqttsslcapathstring, optional

If mqttssl=true, specifies the path to a directory containing the PEM encoded trusted CA certificate files. See mosquitto.conf for more details about configuring this directory. Either mqttsslcafile or mqttsslcapath must be specified.

mqttsslcertfilestring, optional

If mqttssl=true, specifies the path to a file containing the PEM encoded certificate file for this client. Both mqttsslcertfile and mqttsslkeyfile must be provided if one of them is.

mqttsslkeyfilestring, optional

If mqttssl=true, specifies the path to a file containing the PEM encoded private key for this client. Both mqttsslcertfile and mqttsslkeyfile must be provided if one of them is.

mqttsslpasswordboolean, optional

If mqttssl=true, and if key file is encrypted, specifies the password for decryption.

csvincludeschemastring, optional

Specifies “never”, “once”, or “pereventblock”. The default value is “never”. When mqttmsgtype = CSV, prepend output CSV with the window’s serialized schema.

configfilesectionstring, optional

Specifies the name of the section in the config file to parse for configuration parameters. Specify the value as [configfilesection].

mqttpasswordencryptedboolean, optional

Specifies that mqttpassword is encrypted

addcsvopcodeboolean, optional

Prepends an opcode and comma to input CSV events. The opcode is Insert unless publishwithupsert is enabled.

addcsvflagsstring, optional

Specifies the event type to insert into input CSV events (with a comma). Valid values are “normal” and “partialupdate”.

csvmsgpereventint, optional

For CSV, specifies to send one message per event. The default is one message per transactional event block or else one message per event.

csvmsgpereventblockint, optional

For CSV, specifies to send one message per event block. The default is one message per transactional event block or else one message per event.

Returns
MQTTSubscriber
__init__(self, mqtthost=None, mqttclientid=None, mqtttopic=None, mqttqos=None, mqttmsgtype=None, name=None, is_active=None, snapshot=None, mqttuserid=None, mqttpassword=None, mqttport=None, mqttretainmsg=None, mqttdonotcleansession=None, mqttkeepaliveinterval=None, mqttmsgmaxdeliveryattempts=None, mqttmsgdelaydeliveryattempts=None, mqttmsgwaitbeforeretry=None, mqttmaxinflightmsg=None, collapse=None, rmretdel=None, dateformat=None, protofile=None, protomsg=None, mqttssl=None, mqttsslcafile=None, mqttsslcapath=None, mqttsslcertfile=None, mqttsslkeyfile=None, mqttsslpassword=None, csvincludeschema=None, configfilesection=None, mqttpasswordencrypted=None, addcsvopcode=None, addcsvflags=None, csvmsgperevent=None, csvmsgpereventblock=None)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self[, mqtthost, mqttclientid, …])

Initialize self.

clear(self)

copy(self[, deep])

Return a copy of the object

from_element(data[, session])

Construct connector from XML definition

from_parameters(conncls[, type, name, …])

from_xml(data[, session])

Construct connector from XML definition

get(self, key[, default])

items(self)

keys(self)

pop(self, key[, default])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem(self)

as a 2-tuple; but raise KeyError if D is empty.

set_properties(self, \*\*kwargs)

Set connector properties

setdefault(self, key[, default])

to_element(self)

Export connector definition to ElementTree.Element

to_xml(self[, pretty])

Export connector definition to XML

update(\*args, \*\*kwds)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values(self)

Attributes

connector_key

property_defs