Merge pull request #47 from jalim/hotfix/message-event-bus-patch

Change to notification to use message event bus
This commit is contained in:
Manuel83
2017-06-28 09:32:44 +02:00
committed by GitHub
2 changed files with 4 additions and 7 deletions
+1 -3
View File
@@ -224,9 +224,7 @@ class CraftBeerPi(ActorAPI, SensorAPI):
def notify(self, headline, message, type="success", timeout=5000): def notify(self, headline, message, type="success", timeout=5000):
self.beep() self.beep()
msg = {"id": str(uuid.uuid1()), "type": type, "headline": headline, "message": message, "timeout": timeout} msg = {"id": str(uuid.uuid1()), "type": type, "headline": headline, "message": message, "timeout": timeout}
if timeout is None: self.emit_message(msg)
self.cache["messages"].append(msg)
self.emit("NOTIFY", msg)
def beep(self): def beep(self):
if self.buzzer is not None: if self.buzzer is not None:
+3 -4
View File
@@ -32,10 +32,9 @@ def messageEvent(message, **kwargs):
:param kwargs: other parameter :param kwargs: other parameter
:return: None :return: None
""" """
if message["timeout"] is None:
msg = {"id": len(cbpi.cache["messages"]), "type": "info", "message": message, "read": False} cbpi.cache["messages"].append(message)
cbpi.cache["messages"].append(msg) cbpi.emit("NOTIFY", message)
cbpi.emit('MESSAGE', msg,)
@cbpi.initalizer(order=2) @cbpi.initalizer(order=2)
def init(cbpi): def init(cbpi):