Skip to content

Commit

Permalink
fix(mqtt): always send zwaveNode to node event as first arg (#2790)
Browse files Browse the repository at this point in the history
Fixes #2789
  • Loading branch information
robertsLando authored Nov 8, 2022
1 parent 1e86168 commit c254a86
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 47 deletions.
1 change: 1 addition & 0 deletions lib/Gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import MqttClient from './MqttClient'
import ZwaveClient, {
AllowedApis,
CallAPIResult,
EventSource,
HassDevice,
ZUINode,
ZUIValueId,
Expand Down
69 changes: 22 additions & 47 deletions lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3396,12 +3396,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {

this._onNodeStatus(zwaveNode)

this.emit(
'event',
EventSource.NODE,
'node ready',
this._nodes.get(zwaveNode.id)
)
this.emit('event', EventSource.NODE, 'node ready', zwaveNode)

logger.info(
`Node ${node.id} ready: ${node.manufacturer} - ${
Expand All @@ -3419,7 +3414,12 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {

logger.info(`Node ${zwaveNode.id}: interview started`)

this.emit('event', EventSource.NODE, 'node interview started', node)
this.emit(
'event',
EventSource.NODE,
'node interview started',
zwaveNode
)
}

/**
Expand All @@ -3444,7 +3444,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'node interview stage completed',
node
zwaveNode
)
}

Expand All @@ -3470,7 +3470,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'node interview completed',
this._nodes.get(zwaveNode.id)
zwaveNode
)
}

Expand All @@ -3488,12 +3488,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {

this._onNodeStatus(zwaveNode, true)

this.emit(
'event',
EventSource.NODE,
'node interview failed',
this._nodes.get(zwaveNode.id)
)
this.emit('event', EventSource.NODE, 'node interview failed', zwaveNode)
}

/**
Expand All @@ -3508,12 +3503,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
)

this._onNodeStatus(zwaveNode, true)
this.emit(
'event',
EventSource.NODE,
'node wakeup',
this._nodes.get(zwaveNode.id)
)
this.emit('event', EventSource.NODE, 'node wakeup', zwaveNode)
}

/**
Expand All @@ -3527,12 +3517,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
}asleep`
)
this._onNodeStatus(zwaveNode, true)
this.emit(
'event',
EventSource.NODE,
'node sleep',
this._nodes.get(zwaveNode.id)
)
this.emit('event', EventSource.NODE, 'node sleep', zwaveNode)
}

/**
Expand All @@ -3547,12 +3532,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
logger.info(`Node ${zwaveNode.id} is alive`)
}

this.emit(
'event',
EventSource.NODE,
'node alive',
this._nodes.get(zwaveNode.id)
)
this.emit('event', EventSource.NODE, 'node alive', zwaveNode)
}

/**
Expand All @@ -3567,12 +3547,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
}dead`
)

this.emit(
'event',
EventSource.NODE,
'node dead',
this._nodes.get(zwaveNode.id)
)
this.emit('event', EventSource.NODE, 'node dead', zwaveNode)
}

/**
Expand All @@ -3598,7 +3573,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'node value added',
this._nodes.get(zwaveNode.id),
zwaveNode,
args
)
}
Expand Down Expand Up @@ -3649,7 +3624,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'node value updated',
this._nodes.get(zwaveNode.id),
zwaveNode,
args
)
}
Expand All @@ -3670,7 +3645,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'node value removed',
this._nodes.get(zwaveNode.id),
zwaveNode,
args
)
}
Expand All @@ -3693,7 +3668,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'node metadata updated',
this._nodes.get(zwaveNode.id),
zwaveNode,
args
)
}
Expand Down Expand Up @@ -3767,7 +3742,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'node notification',
node,
zwaveNode,
ccId,
args
)
Expand All @@ -3794,7 +3769,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'statistics updated',
node.id,
zwaveNode,
stats
)
}
Expand Down Expand Up @@ -3823,7 +3798,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'node firmware update progress',
this._nodes.get(zwaveNode.id),
zwaveNode,
progress
)
}
Expand Down Expand Up @@ -3868,7 +3843,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'event',
EventSource.NODE,
'node firmware update finished',
this._nodes.get(zwaveNode.id),
zwaveNode,
result
)
}
Expand Down

0 comments on commit c254a86

Please sign in to comment.