Add logger and better exception handling

This commit is contained in:
zewelor
2017-11-24 08:53:21 +01:00
parent d463345707
commit 09d1332b92
3 changed files with 49 additions and 12 deletions
+8 -1
View File
@@ -1,11 +1,12 @@
from logger import _LOGGER
import paho.mqtt.publish as publish
class MqttClient:
def __init__(self, config):
self._config = config
def publish(self, messages):
_LOGGER.debug(messages)
publish.multiple(list(map(lambda m: m.as_dict, messages)),
hostname=self.hostname,
auth={'username': self.username, 'password': self.password})
@@ -46,3 +47,9 @@ class MqttMessage:
'topic': self.topic,
'payload': self.payload
}
def __repr__(self):
return self.as_dict.__str__()
def __str__(self):
return self.__repr__()