summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lpmqtt/daemon.py15
1 files changed, 11 insertions, 4 deletions
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
23 23
24class PushMQTT(object): 24class PushMQTT(object):
25 def __init__(self, hostname, port=1883, client_id=None, 25 def __init__(self, hostname, port=1883, client_id=None,
26 keepalive=60, will=None, auth=None, tls=None): 26 keepalive=60, will=None, auth=None, tls=None, qos=0):
27 self.hostname = hostname 27 self.hostname = hostname
28 self.port = port 28 self.port = port
29 self.client_id = client_id 29 self.client_id = client_id
@@ -31,18 +31,19 @@ class PushMQTT(object):
31 self.will = will 31 self.will = will
32 self.auth = auth 32 self.auth = auth
33 self.tls = tls 33 self.tls = tls
34 self.qos = qos
34 35
35 def publish_single(self, topic, msg): 36 def publish_single(self, topic, msg):
36 publish.single(topic, msg, hostname=self.hostname, 37 publish.single(topic, msg, hostname=self.hostname,
37 port=self.port, client_id=self.client_id, 38 port=self.port, client_id=self.client_id,
38 keepalive=self.keepalive, will=self.will, 39 keepalive=self.keepalive, will=self.will,
39 auth=self.auth, tls=self.tls) 40 auth=self.auth, tls=self.tls, qos=self.qos)
40 41
41 def publish_multiple(self, topic, msg): 42 def publish_multiple(self, topic, msg):
42 publish.multiple(topic, msg, hostname=self.hostname, 43 publish.multiple(topic, msg, hostname=self.hostname,
43 port=self.port, client_id=self.client_id, 44 port=self.port, client_id=self.client_id,
44 keepalive=self.keepalive, will=self.will, 45 keepalive=self.keepalive, will=self.will,
45 auth=self.auth, tls=self.tls) 46 auth=self.auth, tls=self.tls, qos=self.qos)
46 47
47 48
48def process_event(event, base_topic): 49def process_event(event, base_topic):
@@ -86,12 +87,18 @@ def main():
86 if mqtt_password: 87 if mqtt_password:
87 auth['password'] = mqtt_password 88 auth['password'] = mqtt_password
88 base_topic = config.get('mqtt', 'base_topic') 89 base_topic = config.get('mqtt', 'base_topic')
90 # Max QOS
91 if config.has_option('mqtt', 'qos'):
92 mqtt_qos = config.getint('mqtt', 'qos')
93 else:
94 mqtt_qos = 0
89 95
90 mqttqueue = PushMQTT( 96 mqttqueue = PushMQTT(
91 config.get('mqtt', 'hostname'), 97 config.get('mqtt', 'hostname'),
92 port=mqtt_port, 98 port=mqtt_port,
93 keepalive=keepalive, 99 keepalive=keepalive,
94 auth=auth) 100 auth=auth,
101 qos=mqtt_qos)
95 102
96 # IMAP email settings 103 # IMAP email settings
97 imap_server = config.get('imap', 'hostname') 104 imap_server = config.get('imap', 'hostname')