zwave-js 15.1.0 → 15.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- export declare const PACKAGE_VERSION = "15.1.0";
1
+ export declare const PACKAGE_VERSION = "15.1.1";
2
2
  export declare const PACKAGE_NAME = "zwave-js";
3
3
  //# sourceMappingURL=_version.d.ts.map
@@ -22,7 +22,7 @@ __export(version_exports, {
22
22
  PACKAGE_VERSION: () => PACKAGE_VERSION
23
23
  });
24
24
  module.exports = __toCommonJS(version_exports);
25
- const PACKAGE_VERSION = "15.1.0";
25
+ const PACKAGE_VERSION = "15.1.1";
26
26
  const PACKAGE_NAME = "zwave-js";
27
27
  // Annotate the CommonJS export names for ESM import in node:
28
28
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/_version.ts"],
4
- "sourcesContent": ["// This file is auto-generated by the codegen maintenance script\nexport const PACKAGE_VERSION = \"15.1.0\";\nexport const PACKAGE_NAME = \"zwave-js\";\n"],
4
+ "sourcesContent": ["// This file is auto-generated by the codegen maintenance script\nexport const PACKAGE_VERSION = \"15.1.1\";\nexport const PACKAGE_NAME = \"zwave-js\";\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;;AACO,MAAM,kBAAkB;AACxB,MAAM,eAAe;",
6
6
  "names": []
7
7
  }
@@ -224,6 +224,7 @@ export declare class Driver extends TypedEventTarget<DriverEventCallbacks> imple
224
224
  private _controllerInterviewed;
225
225
  private _nodesReady;
226
226
  private _nodesReadyEventEmitted;
227
+ private _isOpeningSerialPort;
227
228
  private openSerialport;
228
229
  /** Indicates whether all nodes are ready, i.e. the "all nodes ready" event has been emitted */
229
230
  get allNodesReady(): boolean;
@@ -287,6 +288,8 @@ export declare class Driver extends TypedEventTarget<DriverEventCallbacks> imple
287
288
  private compileAndSendStatistics;
288
289
  /** Is called when a node interview is completed */
289
290
  private onNodeInterviewCompleted;
291
+ /** This is called when a new node was found and is being added to the network */
292
+ private onNodeFound;
290
293
  /** This is called when a new node has been added to the network */
291
294
  private onNodeAdded;
292
295
  /** This is called when a node was removed from the network */
@@ -810,7 +810,9 @@ class Driver extends import_shared.TypedEventTarget {
810
810
  }
811
811
  if (this._options.testingHooks?.skipFirmwareIdentification) {
812
812
  await this.writeHeader(import_serial.MessageHeaders.NAK);
813
- await (0, import_async.wait)(1e3);
813
+ if ((0, import_shared.getenv)("NODE_ENV") !== "test") {
814
+ await (0, import_async.wait)(1e3);
815
+ }
814
816
  } else {
815
817
  const mode = await this.detectMode();
816
818
  if (mode === import_DriverMode.DriverMode.CLI) {
@@ -897,13 +899,21 @@ class Driver extends import_shared.TypedEventTarget {
897
899
  _controllerInterviewed = false;
898
900
  _nodesReady = /* @__PURE__ */ new Set();
899
901
  _nodesReadyEventEmitted = false;
902
+ _isOpeningSerialPort = false;
900
903
  async openSerialport() {
901
904
  let lastError;
905
+ this._isOpeningSerialPort = true;
902
906
  for (let attempt = 1; attempt <= this._options.attempts.openSerialPort; attempt++) {
903
907
  try {
904
908
  this.serial = await this.serialFactory.createStream();
905
909
  void this.handleSerialData(this.serial);
906
- return;
910
+ if ((0, import_shared.getenv)("NODE_ENV") !== "test") {
911
+ await (0, import_async.wait)(250);
912
+ }
913
+ if (this.serial.isOpen) {
914
+ this._isOpeningSerialPort = false;
915
+ return;
916
+ }
907
917
  } catch (e) {
908
918
  lastError = e;
909
919
  }
@@ -911,6 +921,7 @@ class Driver extends import_shared.TypedEventTarget {
911
921
  await (0, import_async.wait)(1e3);
912
922
  }
913
923
  }
924
+ this._isOpeningSerialPort = false;
914
925
  const message = `Failed to open the serial port: ${(0, import_shared.getErrorMessage)(lastError)}`;
915
926
  this.driverLog.print(message, "error");
916
927
  throw new import_core.ZWaveError(message, import_core.ZWaveErrorCodes.Driver_Failed);
@@ -999,7 +1010,7 @@ class Driver extends import_shared.TypedEventTarget {
999
1010
  async initializeControllerAndNodes() {
1000
1011
  if (this._controller == void 0) {
1001
1012
  this._controller = new import_Controller.ZWaveController(this);
1002
- this._controller.on("node added", this.onNodeAdded.bind(this)).on("node removed", this.onNodeRemoved.bind(this)).on("status changed", this.onControllerStatusChanged.bind(this)).on("network found", this.onNetworkFound.bind(this)).on("network joined", this.onNetworkJoined.bind(this)).on("network left", this.onNetworkLeft.bind(this));
1013
+ this._controller.on("node found", this.onNodeFound.bind(this)).on("node added", this.onNodeAdded.bind(this)).on("node removed", this.onNodeRemoved.bind(this)).on("status changed", this.onControllerStatusChanged.bind(this)).on("network found", this.onNetworkFound.bind(this)).on("network joined", this.onNetworkJoined.bind(this)).on("network left", this.onNetworkLeft.bind(this));
1003
1014
  }
1004
1015
  if (!this._options.testingHooks?.skipControllerIdentification) {
1005
1016
  const { nodeIds } = await this.controller.queryCapabilities();
@@ -1473,6 +1484,21 @@ class Driver extends import_shared.TypedEventTarget {
1473
1484
  onNodeInterviewCompleted(node) {
1474
1485
  this.debounceSendNodeToSleep(node);
1475
1486
  }
1487
+ /** This is called when a new node was found and is being added to the network */
1488
+ onNodeFound(node) {
1489
+ const prefix = `{"nodeId":${node.id},`;
1490
+ for (const key of this.valueDB.keys()) {
1491
+ if (key.startsWith(prefix)) {
1492
+ this.valueDB.delete(key);
1493
+ }
1494
+ }
1495
+ for (const key of this.metadataDB.keys()) {
1496
+ if (key.startsWith(prefix)) {
1497
+ this.metadataDB.delete(key);
1498
+ }
1499
+ }
1500
+ this.cachePurge(import_NetworkCache.cacheKeys.node(node.id)._baseKey);
1501
+ }
1476
1502
  /** This is called when a new node has been added to the network */
1477
1503
  onNodeAdded(node) {
1478
1504
  this.addNodeEventHandlers(node);
@@ -1780,8 +1806,10 @@ class Driver extends import_shared.TypedEventTarget {
1780
1806
  });
1781
1807
  } catch (e) {
1782
1808
  this.controllerLog.print(`Soft reset failed: ${(0, import_shared.getErrorMessage)(e)}`, "error");
1783
- if ((0, import_core.isMissingControllerACK)(e))
1809
+ if ((0, import_core.isMissingControllerACK)(e)) {
1810
+ this.isSoftResetting = false;
1784
1811
  throw e;
1812
+ }
1785
1813
  }
1786
1814
  if (this._controller) {
1787
1815
  this._controller["_nodeIdType"] = import_core.NodeIDType.Short;
@@ -2074,7 +2102,7 @@ class Driver extends import_shared.TypedEventTarget {
2074
2102
  if ((0, import_shared.isAbortError)(e)) {
2075
2103
  return;
2076
2104
  } else if ((0, import_core.isZWaveError)(e) && e.code === import_core.ZWaveErrorCodes.Driver_Failed) {
2077
- if (this.isSoftResetting)
2105
+ if (this.isSoftResetting || this._isOpeningSerialPort)
2078
2106
  return;
2079
2107
  void this.destroyWithMessage(e.message);
2080
2108
  return;