From 3923a098313964b509c41f7f1ef5359f988a77d8 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 21 Jan 2023 16:56:27 +0100 Subject: [PATCH] - Expose methods on the bus module to publish/subscribe to notifications and entity updates - Removed some redundant `pass` statements in Z-Wave derived event classes --- platypush/backend/http/webapp/src/bus.js | 22 +++++++++++-- platypush/message/event/zwave.py | 42 ------------------------ 2 files changed, 19 insertions(+), 45 deletions(-) diff --git a/platypush/backend/http/webapp/src/bus.js b/platypush/backend/http/webapp/src/bus.js index 02a87039c..9bb98042f 100644 --- a/platypush/backend/http/webapp/src/bus.js +++ b/platypush/backend/http/webapp/src/bus.js @@ -1,5 +1,21 @@ -import mitt from 'mitt'; +import mitt from 'mitt' -const bus = mitt(); +const bus = mitt() -export { bus }; +bus.publishEntity = (entity) => { + bus.emit('entity-update', entity) +} + +bus.onEntity = (callback) => { + bus.on('entity-update', callback) +} + +bus.publishNotification = (notification) => { + bus.emit('notification-create', notification) +} + +bus.onNotification = (callback) => { + bus.on('notification-create', callback) +} + +export { bus } diff --git a/platypush/message/event/zwave.py b/platypush/message/event/zwave.py index 2654f5e2f..953dae7e4 100644 --- a/platypush/message/event/zwave.py +++ b/platypush/message/event/zwave.py @@ -46,24 +46,18 @@ class ZwaveNetworkStoppedEvent(ZwaveEvent): Triggered when a Z-Wave network is stopped. """ - pass - class ZwaveNetworkErrorEvent(ZwaveEvent): """ Triggered when an error occurs on the Z-Wave network. """ - pass - class ZwaveNetworkResetEvent(ZwaveEvent): """ Triggered when a Z-Wave network is reset. """ - pass - class ZwaveNodeEvent(ZwaveEvent): """ @@ -79,48 +73,36 @@ class ZwaveNodeAddedEvent(ZwaveNodeEvent): Triggered when a node is added to the network. """ - pass - class ZwaveNodeRemovedEvent(ZwaveNodeEvent): """ Triggered when a node is removed from the network. """ - pass - class ZwaveNodeRenamedEvent(ZwaveNodeEvent): """ Triggered when a node is renamed. """ - pass - class ZwaveNodeReadyEvent(ZwaveNodeEvent): """ Triggered when a node is ready. """ - pass - class ZwaveNodeAsleepEvent(ZwaveNodeEvent): """ Triggered when a node goes in sleep mode. """ - pass - class ZwaveNodeAwakeEvent(ZwaveNodeEvent): """ Triggered when a node goes back into awake mode. """ - pass - class ZwaveNodeGroupEvent(ZwaveNodeEvent): """ @@ -148,48 +130,36 @@ class ZwaveNodePollingEnabledEvent(ZwaveNodeEvent): Triggered when the polling of a node is successfully turned on. """ - pass - class ZwaveNodePollingDisabledEvent(ZwaveNodeEvent): """ Triggered when the polling of a node is successfully turned off. """ - pass - class ZwaveButtonCreatedEvent(ZwaveNodeEvent): """ Triggered when a button is added to the network. """ - pass - class ZwaveButtonRemovedEvent(ZwaveNodeEvent): """ Triggered when a button is removed from the network. """ - pass - class ZwaveButtonOnEvent(ZwaveNodeEvent): """ Triggered when a button is pressed. """ - pass - class ZwaveButtonOffEvent(ZwaveNodeEvent): """ Triggered when a button is released. """ - pass - class ZwaveValueEvent(ZwaveEvent): """ @@ -208,40 +178,30 @@ class ZwaveValueAddedEvent(ZwaveValueEvent): Triggered when a value is added to a node on the network. """ - pass - class ZwaveValueChangedEvent(ZwaveValueEvent): """ Triggered when a value of a node on the network changes. """ - pass - class ZwaveValueRefreshedEvent(ZwaveValueEvent): """ Triggered when a value of a node on the network is refreshed. """ - pass - class ZwaveValueRemovedEvent(ZwaveValueEvent): """ Triggered when a value of a node on the network is removed. """ - pass - class ZwaveNodeQueryCompletedEvent(ZwaveEvent): """ Triggered when all the nodes on the network have been queried. """ - pass - class ZwaveCommandEvent(ZwaveEvent): """ @@ -274,7 +234,5 @@ class ZwaveCommandWaitingEvent(ZwaveCommandEvent): Triggered when a command is waiting for a message to proceed. """ - pass - # vim:sw=4:ts=4:et: