diff --git a/lpmqtt/daemon.py b/lpmqtt/daemon.py index 304c956..0104407 100644 --- a/lpmqtt/daemon.py +++ b/lpmqtt/daemon.py @@ -23,7 +23,7 @@ from lpmqtt import lp class PushMQTT(object): def __init__(self, hostname, port=1883, client_id=None, - keepalive=60, will=None, auth=None, tls=None): + keepalive=60, will=None, auth=None, tls=None, qos=0): self.hostname = hostname self.port = port self.client_id = client_id @@ -31,18 +31,19 @@ class PushMQTT(object): self.will = will self.auth = auth self.tls = tls + self.qos = qos def publish_single(self, topic, msg): publish.single(topic, msg, hostname=self.hostname, port=self.port, client_id=self.client_id, keepalive=self.keepalive, will=self.will, - auth=self.auth, tls=self.tls) + auth=self.auth, tls=self.tls, qos=self.qos) def publish_multiple(self, topic, msg): publish.multiple(topic, msg, hostname=self.hostname, port=self.port, client_id=self.client_id, keepalive=self.keepalive, will=self.will, - auth=self.auth, tls=self.tls) + auth=self.auth, tls=self.tls, qos=self.qos) def process_event(event, base_topic): @@ -86,12 +87,18 @@ def main(): if mqtt_password: auth['password'] = mqtt_password base_topic = config.get('mqtt', 'base_topic') + # Max QOS + if config.has_option('mqtt', 'qos'): + mqtt_qos = config.getint('mqtt', 'qos') + else: + mqtt_qos = 0 mqttqueue = PushMQTT( config.get('mqtt', 'hostname'), port=mqtt_port, keepalive=keepalive, - auth=auth) + auth=auth, + qos=mqtt_qos) # IMAP email settings imap_server = config.get('imap', 'hostname')