added timeout parameter to notificartion controller for potential later usage in UI

This commit is contained in:
avollkopf 2023-01-20 21:26:40 +01:00
parent 2429ea63d1
commit 4ddc9690ef

View file

@ -49,7 +49,7 @@ class NotificationController:
asyncio.create_task(method(self.cbpi, title, message, type, action ))
def notify(self, title, message: str, type: NotificationType = NotificationType.INFO, action=[]) -> None:
def notify(self, title, message: str, type: NotificationType = NotificationType.INFO, action=[], timeout: int=5000) -> None:
'''
This is a convinience method to send notification to the client
@ -66,8 +66,8 @@ class NotificationController:
actions = list(map(lambda item: prepare_action(item), action))
self.callback_cache[notifcation_id] = action
self.cbpi.ws.send(dict(id=notifcation_id, topic="notifiaction", type=type.value, title=title, message=message, action=actions))
data = dict(type=type.value, title=title, message=message, action=actions)
self.cbpi.ws.send(dict(id=notifcation_id, topic="notifiaction", type=type.value, title=title, message=message, action=actions, timeout=timeout))
data = dict(type=type.value, title=title, message=message, action=actions, timeout=timeout)
self.cbpi.push_update(topic="cbpi/notification", data=data)
asyncio.create_task(self._call_listener(title, message, type, action))