- 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
This commit is contained in:
Fabio Manganiello 2023-01-21 16:56:27 +01:00
parent fb562bb415
commit 3923a09831
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
2 changed files with 19 additions and 45 deletions

View File

@ -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 }

View File

@ -46,24 +46,18 @@ class ZwaveNetworkStoppedEvent(ZwaveEvent):
Triggered when a Z-Wave network is stopped. Triggered when a Z-Wave network is stopped.
""" """
pass
class ZwaveNetworkErrorEvent(ZwaveEvent): class ZwaveNetworkErrorEvent(ZwaveEvent):
""" """
Triggered when an error occurs on the Z-Wave network. Triggered when an error occurs on the Z-Wave network.
""" """
pass
class ZwaveNetworkResetEvent(ZwaveEvent): class ZwaveNetworkResetEvent(ZwaveEvent):
""" """
Triggered when a Z-Wave network is reset. Triggered when a Z-Wave network is reset.
""" """
pass
class ZwaveNodeEvent(ZwaveEvent): class ZwaveNodeEvent(ZwaveEvent):
""" """
@ -79,48 +73,36 @@ class ZwaveNodeAddedEvent(ZwaveNodeEvent):
Triggered when a node is added to the network. Triggered when a node is added to the network.
""" """
pass
class ZwaveNodeRemovedEvent(ZwaveNodeEvent): class ZwaveNodeRemovedEvent(ZwaveNodeEvent):
""" """
Triggered when a node is removed from the network. Triggered when a node is removed from the network.
""" """
pass
class ZwaveNodeRenamedEvent(ZwaveNodeEvent): class ZwaveNodeRenamedEvent(ZwaveNodeEvent):
""" """
Triggered when a node is renamed. Triggered when a node is renamed.
""" """
pass
class ZwaveNodeReadyEvent(ZwaveNodeEvent): class ZwaveNodeReadyEvent(ZwaveNodeEvent):
""" """
Triggered when a node is ready. Triggered when a node is ready.
""" """
pass
class ZwaveNodeAsleepEvent(ZwaveNodeEvent): class ZwaveNodeAsleepEvent(ZwaveNodeEvent):
""" """
Triggered when a node goes in sleep mode. Triggered when a node goes in sleep mode.
""" """
pass
class ZwaveNodeAwakeEvent(ZwaveNodeEvent): class ZwaveNodeAwakeEvent(ZwaveNodeEvent):
""" """
Triggered when a node goes back into awake mode. Triggered when a node goes back into awake mode.
""" """
pass
class ZwaveNodeGroupEvent(ZwaveNodeEvent): class ZwaveNodeGroupEvent(ZwaveNodeEvent):
""" """
@ -148,48 +130,36 @@ class ZwaveNodePollingEnabledEvent(ZwaveNodeEvent):
Triggered when the polling of a node is successfully turned on. Triggered when the polling of a node is successfully turned on.
""" """
pass
class ZwaveNodePollingDisabledEvent(ZwaveNodeEvent): class ZwaveNodePollingDisabledEvent(ZwaveNodeEvent):
""" """
Triggered when the polling of a node is successfully turned off. Triggered when the polling of a node is successfully turned off.
""" """
pass
class ZwaveButtonCreatedEvent(ZwaveNodeEvent): class ZwaveButtonCreatedEvent(ZwaveNodeEvent):
""" """
Triggered when a button is added to the network. Triggered when a button is added to the network.
""" """
pass
class ZwaveButtonRemovedEvent(ZwaveNodeEvent): class ZwaveButtonRemovedEvent(ZwaveNodeEvent):
""" """
Triggered when a button is removed from the network. Triggered when a button is removed from the network.
""" """
pass
class ZwaveButtonOnEvent(ZwaveNodeEvent): class ZwaveButtonOnEvent(ZwaveNodeEvent):
""" """
Triggered when a button is pressed. Triggered when a button is pressed.
""" """
pass
class ZwaveButtonOffEvent(ZwaveNodeEvent): class ZwaveButtonOffEvent(ZwaveNodeEvent):
""" """
Triggered when a button is released. Triggered when a button is released.
""" """
pass
class ZwaveValueEvent(ZwaveEvent): class ZwaveValueEvent(ZwaveEvent):
""" """
@ -208,40 +178,30 @@ class ZwaveValueAddedEvent(ZwaveValueEvent):
Triggered when a value is added to a node on the network. Triggered when a value is added to a node on the network.
""" """
pass
class ZwaveValueChangedEvent(ZwaveValueEvent): class ZwaveValueChangedEvent(ZwaveValueEvent):
""" """
Triggered when a value of a node on the network changes. Triggered when a value of a node on the network changes.
""" """
pass
class ZwaveValueRefreshedEvent(ZwaveValueEvent): class ZwaveValueRefreshedEvent(ZwaveValueEvent):
""" """
Triggered when a value of a node on the network is refreshed. Triggered when a value of a node on the network is refreshed.
""" """
pass
class ZwaveValueRemovedEvent(ZwaveValueEvent): class ZwaveValueRemovedEvent(ZwaveValueEvent):
""" """
Triggered when a value of a node on the network is removed. Triggered when a value of a node on the network is removed.
""" """
pass
class ZwaveNodeQueryCompletedEvent(ZwaveEvent): class ZwaveNodeQueryCompletedEvent(ZwaveEvent):
""" """
Triggered when all the nodes on the network have been queried. Triggered when all the nodes on the network have been queried.
""" """
pass
class ZwaveCommandEvent(ZwaveEvent): class ZwaveCommandEvent(ZwaveEvent):
""" """
@ -274,7 +234,5 @@ class ZwaveCommandWaitingEvent(ZwaveCommandEvent):
Triggered when a command is waiting for a message to proceed. Triggered when a command is waiting for a message to proceed.
""" """
pass
# vim:sw=4:ts=4:et: # vim:sw=4:ts=4:et: