zwave-js 10.20.0 → 10.21.0
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.
- package/build/lib/driver/Driver.d.ts +75 -4
- package/build/lib/driver/Driver.d.ts.map +1 -1
- package/build/lib/driver/Driver.js +115 -60
- package/build/lib/driver/Driver.js.map +1 -1
- package/build/lib/driver/ZWaveOptions.d.ts +16 -0
- package/build/lib/driver/ZWaveOptions.d.ts.map +1 -1
- package/build/lib/node/Node.d.ts.map +1 -1
- package/build/lib/node/Node.js +50 -5
- package/build/lib/node/Node.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { CommandClass, ICommandClassContainer } from "@zwave-js/cc";
|
|
4
|
-
import { ConfigManager } from "@zwave-js/config";
|
|
5
|
-
import { CommandClasses, ICommandClass, LogConfig, SendCommandOptions, SendCommandReturnType, SendMessageOptions } from "@zwave-js/core";
|
|
6
|
-
import type { ZWaveApplicationHost } from "@zwave-js/host";
|
|
4
|
+
import { ConfigManager, DeviceConfig } from "@zwave-js/config";
|
|
5
|
+
import { CommandClasses, ControllerLogger, ICommandClass, LogConfig, Maybe, SecurityClass, SecurityManager, SecurityManager2, SendCommandOptions, SendCommandReturnType, SendMessageOptions, ValueDB, ValueID } from "@zwave-js/core";
|
|
6
|
+
import type { NodeSchedulePollOptions, ZWaveApplicationHost } from "@zwave-js/host";
|
|
7
7
|
import { BootloaderChunk, FunctionType, Message, ZWaveSerialPortImplementation } from "@zwave-js/serial";
|
|
8
|
-
import { DeepPartial, TypedEventEmitter } from "@zwave-js/shared";
|
|
8
|
+
import { DeepPartial, ReadonlyThrowingMap, TypedEventEmitter } from "@zwave-js/shared";
|
|
9
9
|
import * as util from "util";
|
|
10
10
|
import { ZWaveController } from "../controller/Controller";
|
|
11
11
|
import type { Endpoint } from "../node/Endpoint";
|
|
@@ -74,6 +74,12 @@ export declare class Driver extends TypedEventEmitter<DriverEventCallbacks> impl
|
|
|
74
74
|
private _logContainer;
|
|
75
75
|
private _driverLog;
|
|
76
76
|
private _controllerLog;
|
|
77
|
+
/**
|
|
78
|
+
* **!!! INTERNAL !!!**
|
|
79
|
+
*
|
|
80
|
+
* Not intended to be used by applications
|
|
81
|
+
*/
|
|
82
|
+
get controllerLog(): ControllerLogger;
|
|
77
83
|
private _controller;
|
|
78
84
|
/** Encapsulates information about the Z-Wave controller and provides access to its nodes */
|
|
79
85
|
get controller(): ZWaveController;
|
|
@@ -81,9 +87,66 @@ export declare class Driver extends TypedEventEmitter<DriverEventCallbacks> impl
|
|
|
81
87
|
private _bootloader;
|
|
82
88
|
isInBootloader(): boolean;
|
|
83
89
|
private _securityManager;
|
|
90
|
+
/**
|
|
91
|
+
* **!!! INTERNAL !!!**
|
|
92
|
+
*
|
|
93
|
+
* Not intended to be used by applications
|
|
94
|
+
*/
|
|
95
|
+
get securityManager(): SecurityManager | undefined;
|
|
84
96
|
private _securityManager2;
|
|
97
|
+
/**
|
|
98
|
+
* **!!! INTERNAL !!!**
|
|
99
|
+
*
|
|
100
|
+
* Not intended to be used by applications
|
|
101
|
+
*/
|
|
102
|
+
get securityManager2(): SecurityManager2 | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* **!!! INTERNAL !!!**
|
|
105
|
+
*
|
|
106
|
+
* Not intended to be used by applications. Use `controller.homeId` instead!
|
|
107
|
+
*/
|
|
108
|
+
get homeId(): number;
|
|
109
|
+
/**
|
|
110
|
+
* **!!! INTERNAL !!!**
|
|
111
|
+
*
|
|
112
|
+
* Not intended to be used by applications. Use `controller.ownNodeId` instead!
|
|
113
|
+
*/
|
|
114
|
+
get ownNodeId(): number;
|
|
115
|
+
/**
|
|
116
|
+
* **!!! INTERNAL !!!**
|
|
117
|
+
*
|
|
118
|
+
* Not intended to be used by applications. Use `controller.nodes` instead!
|
|
119
|
+
*/
|
|
120
|
+
get nodes(): ReadonlyThrowingMap<number, ZWaveNode>;
|
|
85
121
|
getNodeUnsafe(msg: Message): ZWaveNode | undefined;
|
|
86
122
|
tryGetEndpoint(cc: CommandClass): Endpoint | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* **!!! INTERNAL !!!**
|
|
125
|
+
*
|
|
126
|
+
* Not intended to be used by applications
|
|
127
|
+
*/
|
|
128
|
+
getValueDB(nodeId: number): ValueDB;
|
|
129
|
+
/**
|
|
130
|
+
* **!!! INTERNAL !!!**
|
|
131
|
+
*
|
|
132
|
+
* Not intended to be used by applications
|
|
133
|
+
*/
|
|
134
|
+
tryGetValueDB(nodeId: number): ValueDB | undefined;
|
|
135
|
+
getDeviceConfig(nodeId: number): DeviceConfig | undefined;
|
|
136
|
+
getHighestSecurityClass(nodeId: number): SecurityClass | undefined;
|
|
137
|
+
hasSecurityClass(nodeId: number, securityClass: SecurityClass): Maybe<boolean>;
|
|
138
|
+
/**
|
|
139
|
+
* **!!! INTERNAL !!!**
|
|
140
|
+
*
|
|
141
|
+
* Not intended to be used by applications
|
|
142
|
+
*/
|
|
143
|
+
setSecurityClass(nodeId: number, securityClass: SecurityClass, granted: boolean): void;
|
|
144
|
+
/**
|
|
145
|
+
* **!!! INTERNAL !!!**
|
|
146
|
+
*
|
|
147
|
+
* Not intended to be used by applications. Use `node.isControllerNode` instead!
|
|
148
|
+
*/
|
|
149
|
+
isControllerNode(nodeId: number): boolean;
|
|
87
150
|
/** Updates the logging configuration without having to restart the driver. */
|
|
88
151
|
updateLogConfig(config: DeepPartial<LogConfig>): void;
|
|
89
152
|
/** Returns the current logging configuration. */
|
|
@@ -94,6 +157,8 @@ export declare class Driver extends TypedEventEmitter<DriverEventCallbacks> impl
|
|
|
94
157
|
static enumerateSerialPorts(): Promise<string[]>;
|
|
95
158
|
/** Updates a subset of the driver options on the fly */
|
|
96
159
|
updateOptions(options: DeepPartial<EditableZWaveOptions>): void;
|
|
160
|
+
private _options;
|
|
161
|
+
get options(): Readonly<ZWaveOptions>;
|
|
97
162
|
private _wasStarted;
|
|
98
163
|
private _isOpen;
|
|
99
164
|
/** Start the driver */
|
|
@@ -215,6 +280,12 @@ export declare class Driver extends TypedEventEmitter<DriverEventCallbacks> impl
|
|
|
215
280
|
* @param endpointIndex The endpoint for which the CC security should be determined
|
|
216
281
|
*/
|
|
217
282
|
isCCSecure(ccId: CommandClasses, nodeId: number, endpointIndex?: number): boolean;
|
|
283
|
+
/**
|
|
284
|
+
* **!!! INTERNAL !!!**
|
|
285
|
+
*
|
|
286
|
+
* Not intended to be used by applications
|
|
287
|
+
*/
|
|
288
|
+
schedulePoll(nodeId: number, valueId: ValueID, options: NodeSchedulePollOptions): boolean;
|
|
218
289
|
private isSoftResetting;
|
|
219
290
|
private maySoftReset;
|
|
220
291
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Driver.d.ts","sourceRoot":"","sources":["../../../src/lib/driver/Driver.ts"],"names":[],"mappings":";;AAEA,OAAO,EAEN,YAAY,EAMZ,sBAAsB,EA4BtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,aAAa,
|
|
1
|
+
{"version":3,"file":"Driver.d.ts","sourceRoot":"","sources":["../../../src/lib/driver/Driver.ts"],"names":[],"mappings":";;AAEA,OAAO,EAEN,YAAY,EAMZ,sBAAsB,EA4BtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,aAAa,EACb,YAAY,EAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,cAAc,EACd,gBAAgB,EAKhB,aAAa,EAEb,SAAS,EAGT,KAAK,EAKL,aAAa,EAEb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EASlB,OAAO,EACP,OAAO,EAKP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACX,uBAAuB,EACvB,oBAAoB,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,eAAe,EAEf,YAAY,EAMZ,OAAO,EAOP,6BAA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GAAG,qBAAqB,GAClE,MAAM;IAeT,uEAAuE;IAChE,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAW7C,gFAAgF;IACzE,gCAAgC,IACpC,OAAO,eAAe,GACtB,OAAO,qBAAqB;IAQ/B,+EAA+E;IACxE,+BAA+B,IACnC,OAAO,wBAAwB,GAC/B,OAAO,8BAA8B;IASjC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM;IAItC;;;OAGG;IACU,qBAAqB,CACjC,MAAM,GAAE,OAAe,GACrB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAwB9B;;;;;OAKG;IACU,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;IA8CpD,OAAO,CAAC,mBAAmB,CAAkB;IAC7C,OAAO,CAAC,uBAAuB,CAAoC;IAgDnE,OAAO,CAAC,uBAAuB;IAwC/B,OAAO,CAAC,2BAA2B;IAgDnC;;;;OAIG;IACI,sBAAsB,CAAC,CAAC,SAAS,eAAe,EACtD,SAAS,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,EAC9C,OAAO,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,CAAC;IAgCb,OAAO,CAAC,uBAAuB,CAA6B;IAC5D,OAAO,CAAC,2BAA2B,CAAK;IAExC,OAAO,CAAC,0BAA0B;CA8BlC"}
|
|
@@ -282,9 +282,9 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
282
282
|
throw new core_1.ZWaveError(`The port must be a string or a valid custom serial port implementation!`, core_1.ZWaveErrorCodes.Driver_InvalidOptions);
|
|
283
283
|
}
|
|
284
284
|
// merge given options with defaults
|
|
285
|
-
this.
|
|
285
|
+
this._options = (0, shared_1.mergeDeep)(options, defaultOptions);
|
|
286
286
|
// And make sure they contain valid values
|
|
287
|
-
checkOptions(this.
|
|
287
|
+
checkOptions(this._options);
|
|
288
288
|
if (options?.userAgent) {
|
|
289
289
|
if (!(0, typeguards_1.isObject)(options.userAgent)) {
|
|
290
290
|
throw new core_1.ZWaveError(`The userAgent property must be an object!`, core_1.ZWaveErrorCodes.Driver_InvalidOptions);
|
|
@@ -292,15 +292,15 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
292
292
|
this.updateUserAgent(options.userAgent);
|
|
293
293
|
}
|
|
294
294
|
// Initialize logging
|
|
295
|
-
this._logContainer = new core_1.ZWaveLogContainer(this.
|
|
295
|
+
this._logContainer = new core_1.ZWaveLogContainer(this._options.logConfig);
|
|
296
296
|
this._driverLog = new Driver_1.DriverLogger(this, this._logContainer);
|
|
297
297
|
this._controllerLog = new core_1.ControllerLogger(this._logContainer);
|
|
298
298
|
// Initialize the cache
|
|
299
|
-
this.cacheDir = this.
|
|
299
|
+
this.cacheDir = this._options.storage.cacheDir;
|
|
300
300
|
// Initialize config manager
|
|
301
301
|
this.configManager = new config_1.ConfigManager({
|
|
302
302
|
logContainer: this._logContainer,
|
|
303
|
-
deviceConfigPriorityDir: this.
|
|
303
|
+
deviceConfigPriorityDir: this._options.storage.deviceConfigPriorityDir,
|
|
304
304
|
});
|
|
305
305
|
// And initialize but don't start the send thread machine
|
|
306
306
|
const sendThreadMachine = (0, SendThreadMachine_1.createSendThreadMachine)({
|
|
@@ -397,7 +397,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
397
397
|
},
|
|
398
398
|
log: this.driverLog.print.bind(this.driverLog),
|
|
399
399
|
logQueue: this.driverLog.sendQueue.bind(this.driverLog),
|
|
400
|
-
}, (0, shared_1.pick)(this.
|
|
400
|
+
}, (0, shared_1.pick)(this._options, ["timeouts", "attempts"]));
|
|
401
401
|
this.sendThread = (0, xstate_1.interpret)(sendThreadMachine);
|
|
402
402
|
this._sendThreadIdle = false;
|
|
403
403
|
this.sendThread.onTransition((state) => {
|
|
@@ -471,7 +471,11 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
471
471
|
get driverLog() {
|
|
472
472
|
return this._driverLog;
|
|
473
473
|
}
|
|
474
|
-
/**
|
|
474
|
+
/**
|
|
475
|
+
* **!!! INTERNAL !!!**
|
|
476
|
+
*
|
|
477
|
+
* Not intended to be used by applications
|
|
478
|
+
*/
|
|
475
479
|
get controllerLog() {
|
|
476
480
|
return this._controllerLog;
|
|
477
481
|
}
|
|
@@ -492,24 +496,47 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
492
496
|
isInBootloader() {
|
|
493
497
|
return this._bootloader != undefined;
|
|
494
498
|
}
|
|
495
|
-
/**
|
|
499
|
+
/**
|
|
500
|
+
* **!!! INTERNAL !!!**
|
|
501
|
+
*
|
|
502
|
+
* Not intended to be used by applications
|
|
503
|
+
*/
|
|
496
504
|
get securityManager() {
|
|
497
505
|
return this._securityManager;
|
|
498
506
|
}
|
|
499
|
-
/**
|
|
507
|
+
/**
|
|
508
|
+
* **!!! INTERNAL !!!**
|
|
509
|
+
*
|
|
510
|
+
* Not intended to be used by applications
|
|
511
|
+
*/
|
|
500
512
|
get securityManager2() {
|
|
501
513
|
return this._securityManager2;
|
|
502
514
|
}
|
|
503
|
-
/**
|
|
515
|
+
/**
|
|
516
|
+
* **!!! INTERNAL !!!**
|
|
517
|
+
*
|
|
518
|
+
* Not intended to be used by applications. Use `controller.homeId` instead!
|
|
519
|
+
*/
|
|
504
520
|
get homeId() {
|
|
521
|
+
// This is needed for the ZWaveHost interface
|
|
505
522
|
return this.controller.homeId;
|
|
506
523
|
}
|
|
507
|
-
/**
|
|
524
|
+
/**
|
|
525
|
+
* **!!! INTERNAL !!!**
|
|
526
|
+
*
|
|
527
|
+
* Not intended to be used by applications. Use `controller.ownNodeId` instead!
|
|
528
|
+
*/
|
|
508
529
|
get ownNodeId() {
|
|
530
|
+
// This is needed for the ZWaveHost interface
|
|
509
531
|
return this.controller.ownNodeId;
|
|
510
532
|
}
|
|
511
|
-
/**
|
|
533
|
+
/**
|
|
534
|
+
* **!!! INTERNAL !!!**
|
|
535
|
+
*
|
|
536
|
+
* Not intended to be used by applications. Use `controller.nodes` instead!
|
|
537
|
+
*/
|
|
512
538
|
get nodes() {
|
|
539
|
+
// This is needed for the ZWaveHost interface
|
|
513
540
|
return this.controller.nodes;
|
|
514
541
|
}
|
|
515
542
|
getNodeUnsafe(msg) {
|
|
@@ -524,37 +551,57 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
524
551
|
?.getEndpoint(cc.endpointIndex);
|
|
525
552
|
}
|
|
526
553
|
}
|
|
527
|
-
/**
|
|
554
|
+
/**
|
|
555
|
+
* **!!! INTERNAL !!!**
|
|
556
|
+
*
|
|
557
|
+
* Not intended to be used by applications
|
|
558
|
+
*/
|
|
528
559
|
getValueDB(nodeId) {
|
|
560
|
+
// This is needed for the ZWaveHost interface
|
|
529
561
|
const node = this.controller.nodes.getOrThrow(nodeId);
|
|
530
562
|
return node.valueDB;
|
|
531
563
|
}
|
|
532
|
-
/**
|
|
564
|
+
/**
|
|
565
|
+
* **!!! INTERNAL !!!**
|
|
566
|
+
*
|
|
567
|
+
* Not intended to be used by applications
|
|
568
|
+
*/
|
|
533
569
|
tryGetValueDB(nodeId) {
|
|
570
|
+
// This is needed for the ZWaveHost interface
|
|
534
571
|
const node = this.controller.nodes.get(nodeId);
|
|
535
572
|
return node?.valueDB;
|
|
536
573
|
}
|
|
537
|
-
/** @internal This is needed for the ZWaveHost interface */
|
|
538
574
|
getDeviceConfig(nodeId) {
|
|
575
|
+
// This is needed for the ZWaveHost interface
|
|
539
576
|
return this.controller.nodes.get(nodeId)?.deviceConfig;
|
|
540
577
|
}
|
|
541
|
-
/** @internal This is needed for the ZWaveHost interface */
|
|
542
578
|
getHighestSecurityClass(nodeId) {
|
|
579
|
+
// This is needed for the ZWaveHost interface
|
|
543
580
|
const node = this.controller.nodes.getOrThrow(nodeId);
|
|
544
581
|
return node.getHighestSecurityClass();
|
|
545
582
|
}
|
|
546
|
-
/** @internal This is needed for the ZWaveHost interface */
|
|
547
583
|
hasSecurityClass(nodeId, securityClass) {
|
|
584
|
+
// This is needed for the ZWaveHost interface
|
|
548
585
|
const node = this.controller.nodes.getOrThrow(nodeId);
|
|
549
586
|
return node.hasSecurityClass(securityClass);
|
|
550
587
|
}
|
|
551
|
-
/**
|
|
588
|
+
/**
|
|
589
|
+
* **!!! INTERNAL !!!**
|
|
590
|
+
*
|
|
591
|
+
* Not intended to be used by applications
|
|
592
|
+
*/
|
|
552
593
|
setSecurityClass(nodeId, securityClass, granted) {
|
|
594
|
+
// This is needed for the ZWaveHost interface
|
|
553
595
|
const node = this.controller.nodes.getOrThrow(nodeId);
|
|
554
596
|
node.setSecurityClass(securityClass, granted);
|
|
555
597
|
}
|
|
556
|
-
/**
|
|
598
|
+
/**
|
|
599
|
+
* **!!! INTERNAL !!!**
|
|
600
|
+
*
|
|
601
|
+
* Not intended to be used by applications. Use `node.isControllerNode` instead!
|
|
602
|
+
*/
|
|
557
603
|
isControllerNode(nodeId) {
|
|
604
|
+
// This is needed for the ZWaveHost interface
|
|
558
605
|
return nodeId === this.ownNodeId;
|
|
559
606
|
}
|
|
560
607
|
/** Updates the logging configuration without having to restart the driver. */
|
|
@@ -567,7 +614,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
567
614
|
}
|
|
568
615
|
/** Updates the preferred sensor scales to use for node queries */
|
|
569
616
|
setPreferredScales(scales) {
|
|
570
|
-
this.
|
|
617
|
+
this._options.preferences.scales = (0, shared_1.mergeDeep)(defaultOptions.preferences.scales, scales);
|
|
571
618
|
}
|
|
572
619
|
/** Enumerates all existing serial ports */
|
|
573
620
|
static async enumerateSerialPorts() {
|
|
@@ -588,13 +635,13 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
588
635
|
]);
|
|
589
636
|
// Create a new deep-merged copy of the options so we can check them for validity
|
|
590
637
|
// without affecting our own options
|
|
591
|
-
const newOptions = (0, shared_1.mergeDeep)((0, shared_1.cloneDeep)(this.
|
|
638
|
+
const newOptions = (0, shared_1.mergeDeep)((0, shared_1.cloneDeep)(this._options), safeOptions, true);
|
|
592
639
|
checkOptions(newOptions);
|
|
593
640
|
if (options.userAgent && !(0, typeguards_1.isObject)(options.userAgent)) {
|
|
594
641
|
throw new core_1.ZWaveError(`The userAgent property must be an object!`, core_1.ZWaveErrorCodes.Driver_InvalidOptions);
|
|
595
642
|
}
|
|
596
643
|
// All good, update the options
|
|
597
|
-
this.
|
|
644
|
+
this._options = newOptions;
|
|
598
645
|
if (options.logConfig) {
|
|
599
646
|
this.updateLogConfig(options.logConfig);
|
|
600
647
|
}
|
|
@@ -602,6 +649,9 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
602
649
|
this.updateUserAgent(options.userAgent);
|
|
603
650
|
}
|
|
604
651
|
}
|
|
652
|
+
get options() {
|
|
653
|
+
return this._options;
|
|
654
|
+
}
|
|
605
655
|
/** Start the driver */
|
|
606
656
|
async start() {
|
|
607
657
|
// avoid starting twice
|
|
@@ -612,7 +662,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
612
662
|
return Promise.resolve();
|
|
613
663
|
this._wasStarted = true;
|
|
614
664
|
// Enforce that an error handler is attached, except for testing with a mocked serialport
|
|
615
|
-
if (!this.
|
|
665
|
+
if (!this._options.testingHooks &&
|
|
616
666
|
this.listenerCount("error") === 0) {
|
|
617
667
|
throw new core_1.ZWaveError(`Before starting the driver, a handler for the "error" event must be attached.`, core_1.ZWaveErrorCodes.Driver_NoErrorHandler);
|
|
618
668
|
}
|
|
@@ -635,7 +685,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
635
685
|
}
|
|
636
686
|
else {
|
|
637
687
|
this.driverLog.print(`opening serial port ${this.port}`);
|
|
638
|
-
this.serial = new serial_1.ZWaveSerialPort(this.port, this._logContainer, this.
|
|
688
|
+
this.serial = new serial_1.ZWaveSerialPort(this.port, this._logContainer, this._options.testingHooks?.serialPortBinding);
|
|
639
689
|
}
|
|
640
690
|
}
|
|
641
691
|
else {
|
|
@@ -678,16 +728,16 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
678
728
|
this.driverLog.print("serial port opened");
|
|
679
729
|
this._isOpen = true;
|
|
680
730
|
spOpenPromise.resolve();
|
|
681
|
-
if (typeof this.
|
|
731
|
+
if (typeof this._options.testingHooks?.onSerialPortOpen ===
|
|
682
732
|
"function") {
|
|
683
|
-
await this.
|
|
733
|
+
await this._options.testingHooks.onSerialPortOpen(this.serial);
|
|
684
734
|
}
|
|
685
735
|
// Perform initialization sequence
|
|
686
736
|
await this.writeHeader(serial_1.MessageHeaders.NAK);
|
|
687
737
|
// Per the specs, this should be followed by a soft-reset but we need to be able
|
|
688
738
|
// to handle sticks that don't support the soft reset command. Therefore we do it
|
|
689
739
|
// after opening the value DBs
|
|
690
|
-
if (!this.
|
|
740
|
+
if (!this._options.testingHooks?.skipBootloaderCheck) {
|
|
691
741
|
// After an incomplete firmware upgrade, we might be stuck in the bootloader
|
|
692
742
|
// Therefore wait a short amount of time to see if the serialport detects bootloader mode.
|
|
693
743
|
// If we are, the bootloader will reply with its menu.
|
|
@@ -698,7 +748,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
698
748
|
// Wait a short time again. If we're in bootloader mode again, we're stuck
|
|
699
749
|
await (0, async_1.wait)(1000);
|
|
700
750
|
if (this._bootloader) {
|
|
701
|
-
if (this.
|
|
751
|
+
if (this._options.allowBootloaderOnly) {
|
|
702
752
|
this.driverLog.print("Failed to recover from bootloader. Staying in bootloader mode as requested.", "warn");
|
|
703
753
|
// Needed for the OTW feature to be available
|
|
704
754
|
this._controller = new Controller_1.ZWaveController(this, true);
|
|
@@ -716,7 +766,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
716
766
|
}
|
|
717
767
|
// Try to create the cache directory. This can fail, in which case we should expose a good error message
|
|
718
768
|
try {
|
|
719
|
-
await this.
|
|
769
|
+
await this._options.storage.driver.ensureDir(this.cacheDir);
|
|
720
770
|
}
|
|
721
771
|
catch (e) {
|
|
722
772
|
let message;
|
|
@@ -732,7 +782,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
732
782
|
return;
|
|
733
783
|
}
|
|
734
784
|
// Load the necessary configuration
|
|
735
|
-
if (this.
|
|
785
|
+
if (this._options.testingHooks?.loadConfiguration !== false) {
|
|
736
786
|
this.driverLog.print("loading configuration...");
|
|
737
787
|
try {
|
|
738
788
|
await this.configManager.loadAll();
|
|
@@ -769,7 +819,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
769
819
|
async openSerialport() {
|
|
770
820
|
let lastError;
|
|
771
821
|
// After a reset, the serial port may need a few seconds until we can open it - try a few times
|
|
772
|
-
for (let attempt = 1; attempt <= this.
|
|
822
|
+
for (let attempt = 1; attempt <= this._options.attempts.openSerialPort; attempt++) {
|
|
773
823
|
try {
|
|
774
824
|
await this.serial.open();
|
|
775
825
|
return;
|
|
@@ -777,7 +827,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
777
827
|
catch (e) {
|
|
778
828
|
lastError = e;
|
|
779
829
|
}
|
|
780
|
-
if (attempt < this.
|
|
830
|
+
if (attempt < this._options.attempts.openSerialPort) {
|
|
781
831
|
await (0, async_1.wait)(1000);
|
|
782
832
|
}
|
|
783
833
|
}
|
|
@@ -792,11 +842,11 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
792
842
|
getJsonlDBOptions() {
|
|
793
843
|
const options = {
|
|
794
844
|
ignoreReadErrors: true,
|
|
795
|
-
...ThrottlePresets_1.throttlePresets[this.
|
|
845
|
+
...ThrottlePresets_1.throttlePresets[this._options.storage.throttle],
|
|
796
846
|
};
|
|
797
|
-
if (this.
|
|
847
|
+
if (this._options.storage.lockDir) {
|
|
798
848
|
options.lockfile = {
|
|
799
|
-
directory: this.
|
|
849
|
+
directory: this._options.storage.lockDir,
|
|
800
850
|
};
|
|
801
851
|
}
|
|
802
852
|
return options;
|
|
@@ -849,7 +899,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
849
899
|
// version the cache format, so migrations in the future are easier
|
|
850
900
|
this._networkCache.set("cacheFormat", 1);
|
|
851
901
|
try {
|
|
852
|
-
await (0, NetworkCache_1.migrateLegacyNetworkCache)(this, this.controller.homeId, this._networkCache, this._valueDB, this.
|
|
902
|
+
await (0, NetworkCache_1.migrateLegacyNetworkCache)(this, this.controller.homeId, this._networkCache, this._valueDB, this._options.storage.driver, this.cacheDir);
|
|
853
903
|
// Go through the value DB and remove all keys referencing commandClass -1, which used to be a
|
|
854
904
|
// hacky way to store non-CC specific values
|
|
855
905
|
for (const key of this._valueDB.keys()) {
|
|
@@ -876,7 +926,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
876
926
|
.on("node added", this.onNodeAdded.bind(this))
|
|
877
927
|
.on("node removed", this.onNodeRemoved.bind(this));
|
|
878
928
|
}
|
|
879
|
-
if (!this.
|
|
929
|
+
if (!this._options.testingHooks?.skipControllerIdentification) {
|
|
880
930
|
// Determine controller IDs to open the Value DBs
|
|
881
931
|
// We need to do this first because some older controllers, especially the UZB1 and
|
|
882
932
|
// some 500-series sticks in virtualized environments don't respond after a soft reset
|
|
@@ -885,11 +935,11 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
885
935
|
// Identify the controller and determine if it supports soft reset
|
|
886
936
|
await this.controller.identify();
|
|
887
937
|
await this.initNetworkCache(this.controller.homeId);
|
|
888
|
-
if (this.
|
|
938
|
+
if (this._options.enableSoftReset && !this.maySoftReset()) {
|
|
889
939
|
this.driverLog.print(`Soft reset is enabled through config, but this stick does not support it.`, "warn");
|
|
890
|
-
this.
|
|
940
|
+
this._options.enableSoftReset = false;
|
|
891
941
|
}
|
|
892
|
-
if (this.
|
|
942
|
+
if (this._options.enableSoftReset) {
|
|
893
943
|
try {
|
|
894
944
|
await this.softResetInternal(false);
|
|
895
945
|
}
|
|
@@ -908,7 +958,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
908
958
|
// There are situations where a controller claims it has the ID 0,
|
|
909
959
|
// which isn't valid. In this case try again after having soft-reset the stick
|
|
910
960
|
if (this.controller.ownNodeId === 0 &&
|
|
911
|
-
this.
|
|
961
|
+
this._options.enableSoftReset) {
|
|
912
962
|
this.driverLog.print(`Controller identification returned invalid node ID 0 - trying again...`, "warn");
|
|
913
963
|
// We might end up with a different home ID, so close the cache before re-identifying the controller
|
|
914
964
|
await this._networkCache?.close();
|
|
@@ -935,22 +985,22 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
935
985
|
}
|
|
936
986
|
// Set up the S0 security manager. We can only do that after the controller
|
|
937
987
|
// interview because we need to know the controller node id.
|
|
938
|
-
const S0Key = this.
|
|
988
|
+
const S0Key = this._options.securityKeys?.S0_Legacy;
|
|
939
989
|
if (S0Key) {
|
|
940
990
|
this.driverLog.print("Network key for S0 configured, enabling S0 security manager...");
|
|
941
991
|
this._securityManager = new core_1.SecurityManager({
|
|
942
992
|
networkKey: S0Key,
|
|
943
993
|
ownNodeId: this._controller.ownNodeId,
|
|
944
|
-
nonceTimeout: this.
|
|
994
|
+
nonceTimeout: this._options.timeouts.nonce,
|
|
945
995
|
});
|
|
946
996
|
}
|
|
947
997
|
else {
|
|
948
998
|
this.driverLog.print("No network key for S0 configured, communication with secure (S0) devices won't work!", "warn");
|
|
949
999
|
}
|
|
950
1000
|
// The S2 security manager could be initialized earlier, but we do it here for consistency
|
|
951
|
-
if (this.
|
|
1001
|
+
if (this._options.securityKeys &&
|
|
952
1002
|
// Only set it up if we have security keys for at least one S2 security class
|
|
953
|
-
Object.keys(this.
|
|
1003
|
+
Object.keys(this._options.securityKeys).some((key) => key.startsWith("S2_") &&
|
|
954
1004
|
key in core_1.SecurityClass &&
|
|
955
1005
|
(0, core_1.securityClassIsS2)(core_1.SecurityClass[key]))) {
|
|
956
1006
|
this.driverLog.print("At least one network key for S2 configured, enabling S2 security manager...");
|
|
@@ -962,7 +1012,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
962
1012
|
"S2_AccessControl",
|
|
963
1013
|
"S0_Legacy",
|
|
964
1014
|
]) {
|
|
965
|
-
const key = this.
|
|
1015
|
+
const key = this._options.securityKeys[secClass];
|
|
966
1016
|
if (key) {
|
|
967
1017
|
this._securityManager2.setKey(core_1.SecurityClass[secClass], key);
|
|
968
1018
|
}
|
|
@@ -982,7 +1032,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
982
1032
|
// Before interviewing nodes reset our knowledge about their ready state
|
|
983
1033
|
this._nodesReady.clear();
|
|
984
1034
|
this._nodesReadyEventEmitted = false;
|
|
985
|
-
if (!this.
|
|
1035
|
+
if (!this._options.testingHooks?.skipNodeInterview) {
|
|
986
1036
|
// Now interview all nodes
|
|
987
1037
|
// First complete the controller interview
|
|
988
1038
|
const controllerNode = this._controller.nodes.get(this._controller.ownNodeId);
|
|
@@ -1046,7 +1096,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
1046
1096
|
this.rejectTransactions((t) => t.message.getNodeId() === node.id &&
|
|
1047
1097
|
(t.priority === core_1.MessagePriority.NodeQuery ||
|
|
1048
1098
|
t.tag === "interview"), "The interview was restarted", core_1.ZWaveErrorCodes.Controller_InterviewRestarted);
|
|
1049
|
-
const maxInterviewAttempts = this.
|
|
1099
|
+
const maxInterviewAttempts = this._options.attempts.nodeInterview;
|
|
1050
1100
|
try {
|
|
1051
1101
|
if (!(await node.interviewInternal())) {
|
|
1052
1102
|
// Find out if we may retry the interview
|
|
@@ -1372,9 +1422,9 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
1372
1422
|
/** This is called when a new node has been added to the network */
|
|
1373
1423
|
onNodeAdded(node) {
|
|
1374
1424
|
this.addNodeEventHandlers(node);
|
|
1375
|
-
if (this.
|
|
1425
|
+
if (this._options.interview?.disableOnNodeAdded)
|
|
1376
1426
|
return;
|
|
1377
|
-
if (this.
|
|
1427
|
+
if (this._options.testingHooks?.skipNodeInterview)
|
|
1378
1428
|
return;
|
|
1379
1429
|
// Interview the node
|
|
1380
1430
|
// don't await the interview, because it may take a very long time
|
|
@@ -1593,8 +1643,13 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
1593
1643
|
// We shouldn't be here
|
|
1594
1644
|
return false;
|
|
1595
1645
|
}
|
|
1596
|
-
/**
|
|
1646
|
+
/**
|
|
1647
|
+
* **!!! INTERNAL !!!**
|
|
1648
|
+
*
|
|
1649
|
+
* Not intended to be used by applications
|
|
1650
|
+
*/
|
|
1597
1651
|
schedulePoll(nodeId, valueId, options) {
|
|
1652
|
+
// Needed for ZWaveApplicationHost
|
|
1598
1653
|
const node = this.controller.nodes.getOrThrow(nodeId);
|
|
1599
1654
|
return node.schedulePoll(valueId, options);
|
|
1600
1655
|
}
|
|
@@ -1631,7 +1686,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
1631
1686
|
* Soft-resets the controller if the feature is enabled
|
|
1632
1687
|
*/
|
|
1633
1688
|
async trySoftReset() {
|
|
1634
|
-
if (this.
|
|
1689
|
+
if (this._options.enableSoftReset && this.maySoftReset()) {
|
|
1635
1690
|
await this.softReset();
|
|
1636
1691
|
}
|
|
1637
1692
|
else {
|
|
@@ -1647,7 +1702,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
1647
1702
|
* **Warning:** This call will throw if soft-reset is not enabled.
|
|
1648
1703
|
*/
|
|
1649
1704
|
async softReset() {
|
|
1650
|
-
if (!this.
|
|
1705
|
+
if (!this._options.enableSoftReset) {
|
|
1651
1706
|
const message = `The soft reset feature has been disabled with a config option or the ZWAVEJS_DISABLE_SOFT_RESET environment variable.`;
|
|
1652
1707
|
this.controllerLog.print(message, "error");
|
|
1653
1708
|
throw new core_1.ZWaveError(message, core_1.ZWaveErrorCodes.Driver_FeatureDisabled);
|
|
@@ -1736,7 +1791,7 @@ class Driver extends shared_1.TypedEventEmitter {
|
|
|
1736
1791
|
this.controllerLog.print("Waiting for the Serial API to start...");
|
|
1737
1792
|
waitResult = await this.waitForMessage((msg) => {
|
|
1738
1793
|
return msg.functionType === serial_1.FunctionType.SerialAPIStarted;
|
|
1739
|
-
}, this.
|
|
1794
|
+
}, this._options.timeouts.serialAPIStarted).catch(() => false);
|
|
1740
1795
|
if (waitResult) {
|
|
1741
1796
|
// Serial API did start, maybe do something with the information?
|
|
1742
1797
|
this.controllerLog.print("Serial API started");
|
|
@@ -3193,13 +3248,13 @@ ${handlers.length} left`);
|
|
|
3193
3248
|
// Prioritize Bridge commands when they are supported
|
|
3194
3249
|
msg = new SendDataBridgeMessages_1.SendDataBridgeRequest(this, {
|
|
3195
3250
|
command,
|
|
3196
|
-
maxSendAttempts: this.
|
|
3251
|
+
maxSendAttempts: this._options.attempts.sendData,
|
|
3197
3252
|
});
|
|
3198
3253
|
}
|
|
3199
3254
|
else {
|
|
3200
3255
|
msg = new SendDataMessages_1.SendDataRequest(this, {
|
|
3201
3256
|
command,
|
|
3202
|
-
maxSendAttempts: this.
|
|
3257
|
+
maxSendAttempts: this._options.attempts.sendData,
|
|
3203
3258
|
});
|
|
3204
3259
|
}
|
|
3205
3260
|
}
|
|
@@ -3208,13 +3263,13 @@ ${handlers.length} left`);
|
|
|
3208
3263
|
// Prioritize Bridge commands when they are supported
|
|
3209
3264
|
msg = new SendDataBridgeMessages_1.SendDataMulticastBridgeRequest(this, {
|
|
3210
3265
|
command,
|
|
3211
|
-
maxSendAttempts: this.
|
|
3266
|
+
maxSendAttempts: this._options.attempts.sendData,
|
|
3212
3267
|
});
|
|
3213
3268
|
}
|
|
3214
3269
|
else {
|
|
3215
3270
|
msg = new SendDataMessages_1.SendDataMulticastRequest(this, {
|
|
3216
3271
|
command,
|
|
3217
|
-
maxSendAttempts: this.
|
|
3272
|
+
maxSendAttempts: this._options.attempts.sendData,
|
|
3218
3273
|
});
|
|
3219
3274
|
}
|
|
3220
3275
|
}
|
|
@@ -3630,7 +3685,7 @@ ${handlers.length} left`);
|
|
|
3630
3685
|
// If the node has a compat flag to override the timeout, use that,
|
|
3631
3686
|
// otherwise use the driver option
|
|
3632
3687
|
return (node?.deviceConfig?.compat?.reportTimeout ??
|
|
3633
|
-
this.
|
|
3688
|
+
this._options.timeouts.report);
|
|
3634
3689
|
}
|
|
3635
3690
|
/** Returns the preferred constructor to use for singlecast SendData commands */
|
|
3636
3691
|
getSendDataSinglecastConstructor() {
|
|
@@ -3690,7 +3745,7 @@ ${handlers.length} left`);
|
|
|
3690
3745
|
if (this.configManager.useExternalConfig && extConfigDir) {
|
|
3691
3746
|
// 1. external config dir, leave node_modules alone
|
|
3692
3747
|
await (0, UpdateConfig_1.installConfigUpdateInDocker)(newVersion, {
|
|
3693
|
-
cacheDir: this.
|
|
3748
|
+
cacheDir: this._options.storage.cacheDir,
|
|
3694
3749
|
configDir: extConfigDir,
|
|
3695
3750
|
});
|
|
3696
3751
|
}
|