- 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.
"""
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: