diff --git a/packages/zwave-js/src/lib/controller/Controller.ts b/packages/zwave-js/src/lib/controller/Controller.ts index 5b2fbac08a3..4428f417056 100644 --- a/packages/zwave-js/src/lib/controller/Controller.ts +++ b/packages/zwave-js/src/lib/controller/Controller.ts @@ -3867,23 +3867,32 @@ supported CCs: ${ private async handleSerialAPIStartedUnexpectedly( msg: SerialAPIStartedRequest, ): Promise { - // Normally, the soft reset command includes waiting for this message. If we end up here, it is unexpected. + // Normally, the soft reset command includes waiting for this message. + // If we end up here, it is unexpected. + + switch (msg.wakeUpReason) { + // All wakeup reasons that indicate a reset of the Serial API + // need to be handled here, so we interpret node IDs correctly. + case SerialAPIWakeUpReason.Reset: + case SerialAPIWakeUpReason.WatchdogReset: + case SerialAPIWakeUpReason.SoftwareReset: + case SerialAPIWakeUpReason.EmergencyWatchdogReset: + case SerialAPIWakeUpReason.BrownoutCircuit: { + // The Serial API restarted unexpectedly + if (this._nodeIdType === NodeIDType.Long) { + this.driver.controllerLog.print( + `Serial API restarted unexpectedly.`, + "warn", + ); - if (msg.wakeUpReason === SerialAPIWakeUpReason.SoftwareReset) { - // The Serial API restarted - if (this._nodeIdType === NodeIDType.Long) { - this.driver.controllerLog.print( - `Serial API restarted unexpectedly.`, - "warn", - ); + // We previously used 16 bit node IDs, but the controller was reset. + // Remember this and try to go back to 16 bit. + this._nodeIdType = NodeIDType.Short; + await this.trySetNodeIDType(NodeIDType.Long); + } - // We previously used 16 bit node IDs, but the controller was reset. - // Remember this and try to go back to 16 bit. - this._nodeIdType = NodeIDType.Short; - await this.trySetNodeIDType(NodeIDType.Long); + return true; // Don't invoke any more handlers } - - return true; // Don't invoke any more handlers } return false; // Not handled diff --git a/packages/zwave-js/src/lib/serialapi/application/SerialAPIStartedRequest.ts b/packages/zwave-js/src/lib/serialapi/application/SerialAPIStartedRequest.ts index 93a1229ef7b..3fffcdbd9b5 100644 --- a/packages/zwave-js/src/lib/serialapi/application/SerialAPIStartedRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/application/SerialAPIStartedRequest.ts @@ -29,7 +29,7 @@ export enum SerialAPIWakeUpReason { WatchdogReset = 0x03, /** The Z-Wave API Module has been woken up by an external interrupt. */ ExternalInterrupt = 0x04, - /** The Z-Wave API Module has been woken up by a powering up. */ + /** The Z-Wave API Module has been woken up by powering up. */ PowerUp = 0x05, /** The Z-Wave API Module has been woken up by USB Suspend. */ USBSuspend = 0x06,