Skip to content

Commit

Permalink
feat: show controller status (#3294)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Sep 21, 2023
1 parent 653913c commit a43e74f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ControllerFirmwareUpdateResult,
ControllerFirmwareUpdateStatus,
ControllerStatistics,
ControllerStatus,
DataRate,
Driver,
ExclusionOptions,
Expand Down Expand Up @@ -4181,6 +4182,10 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
'firmware update finished',
this._onControllerFirmwareUpdateFinished.bind(this)
)
.on(
'status changed',
this._onControllerStatusChanged.bind(this)
)
} catch (error) {
// Fixes freak error in "driver ready" handler #1309
logger.error(error.message)
Expand Down Expand Up @@ -4380,6 +4385,27 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
this.emit('event', EventSource.CONTROLLER, 'statistics updated', stats)
}

private _onControllerStatusChanged(status: ControllerStatus) {
let message = ''

if (status === ControllerStatus.Unresponsive) {
this._error = 'Controller is unresponsive'
message = this._error
} else if (status === ControllerStatus.Jammed) {
this._error = 'Controller is unable to transmit'
message = this._error
} else {
message = `Controller is ${getEnumMemberName(
ControllerStatus,
status
)}`
this._error = undefined
}

this._updateControllerStatus(message)
this.emit('event', EventSource.CONTROLLER, 'status changed', status)
}

private _onBootLoaderReady() {
this._updateControllerStatus('Bootloader is READY')

Expand Down

0 comments on commit a43e74f

Please sign in to comment.