mirror of
https://github.com/koush/scrypted.git
synced 2026-02-03 06:03:27 +00:00
zwave: update to latest zwave-js
This commit is contained in:
1
plugins/zwave/.vscode/settings.json
vendored
1
plugins/zwave/.vscode/settings.json
vendored
@@ -1,4 +1,3 @@
|
||||
|
||||
{
|
||||
"scrypted.debugHost": "scrypted-server",
|
||||
}
|
||||
3933
plugins/zwave/package-lock.json
generated
3933
plugins/zwave/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/zwave",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.8",
|
||||
"description": "Z-Wave USB Controller for Scrypted",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache",
|
||||
@@ -40,6 +40,6 @@
|
||||
"@types/node": "^18.15.11"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"zwave-js": "^10.14.1"
|
||||
"zwave-js": "^12.12.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class ZwaveControllerProvider extends ScryptedDeviceBase implements Devic
|
||||
driver: Driver;
|
||||
controller: ZWaveController;
|
||||
driverReady: Promise<void>;
|
||||
dskDeferred: {reject: any, resolve: any};
|
||||
dskDeferred: { reject: any, resolve: any };
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -92,6 +92,11 @@ export class ZwaveControllerProvider extends ScryptedDeviceBase implements Devic
|
||||
this.console.log(process.cwd());
|
||||
|
||||
const driver = new Driver(this.storage.getItem('serialPort'), {
|
||||
features: {
|
||||
softReset: this.storage.getItem('softReset') === 'true',
|
||||
unresponsiveControllerRecovery: false,
|
||||
watchdog: false,
|
||||
},
|
||||
securityKeys: {
|
||||
S2_Unauthenticated: Buffer.from(s2UnauthenticatedKey, 'hex'),
|
||||
S2_Authenticated: Buffer.from(s2AuthenticatedKey, 'hex'),
|
||||
@@ -106,7 +111,7 @@ export class ZwaveControllerProvider extends ScryptedDeviceBase implements Devic
|
||||
console.log(driver.cacheDir);
|
||||
|
||||
driver.on("error", (e) => {
|
||||
driver.destroy().catch(() => {});
|
||||
driver.destroy().catch(() => { });
|
||||
console.error('driver error', e);
|
||||
reject(e);
|
||||
});
|
||||
@@ -204,7 +209,7 @@ export class ZwaveControllerProvider extends ScryptedDeviceBase implements Devic
|
||||
title: 'Healing State',
|
||||
key: 'healingState',
|
||||
readonly: true,
|
||||
value: this.controller?.isHealNetworkActive ? 'Healing' : 'Not Healing',
|
||||
value: this.controller?.isRebuildingRoutes ? 'Healing' : 'Not Healing',
|
||||
},
|
||||
{
|
||||
group: 'Network',
|
||||
@@ -213,6 +218,14 @@ export class ZwaveControllerProvider extends ScryptedDeviceBase implements Devic
|
||||
type: 'button',
|
||||
description: 'Heal the Z-Wave Network. This operation may take a long time and the network may become unreponsive while in progress.',
|
||||
},
|
||||
{
|
||||
group: 'Adapter',
|
||||
title: 'Soft Reset',
|
||||
key: 'softReset',
|
||||
type: 'boolean',
|
||||
value: this.storage.getItem('softReset') === 'true',
|
||||
description: 'Soft Reset the adapter on startup.',
|
||||
},
|
||||
{
|
||||
group: 'Adapter',
|
||||
title: 'Serial Port',
|
||||
@@ -253,7 +266,7 @@ export class ZwaveControllerProvider extends ScryptedDeviceBase implements Devic
|
||||
}
|
||||
|
||||
async stopOperations() {
|
||||
this.controller.stopHealingNetwork();
|
||||
// this.controller.stopHealingNetwork();
|
||||
await this.controller.stopExclusion();
|
||||
await this.controller.stopInclusion();
|
||||
}
|
||||
@@ -303,34 +316,39 @@ export class ZwaveControllerProvider extends ScryptedDeviceBase implements Devic
|
||||
|
||||
async healNetwork() {
|
||||
await this.stopOperations();
|
||||
const healing = this.controller.beginHealingNetwork();
|
||||
const healing = this.controller.beginRebuildingRoutes();
|
||||
this.console.log('healing network', healing);
|
||||
}
|
||||
|
||||
async putSetting(key: string, value: string | number | boolean) {
|
||||
if (key === 'inclusion') {
|
||||
this.inclusion();
|
||||
return;
|
||||
}
|
||||
if (key === 'exclusion') {
|
||||
this.exclusion();
|
||||
return;
|
||||
}
|
||||
if (key === 'confirmPin') {
|
||||
this.dskDeferred?.resolve(value.toString());
|
||||
this.dskDeferred = undefined;
|
||||
return;
|
||||
}
|
||||
if (key === 'heal') {
|
||||
this.healNetwork();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (key === 'inclusion') {
|
||||
this.inclusion();
|
||||
return;
|
||||
}
|
||||
if (key === 'exclusion') {
|
||||
this.exclusion();
|
||||
return;
|
||||
}
|
||||
if (key === 'confirmPin') {
|
||||
this.dskDeferred?.resolve(value.toString());
|
||||
this.dskDeferred = undefined;
|
||||
return;
|
||||
}
|
||||
if (key === 'heal') {
|
||||
this.healNetwork();
|
||||
return;
|
||||
}
|
||||
|
||||
this.storage.setItem(key, value as string);
|
||||
this.storage.setItem(key, value as string);
|
||||
|
||||
await this.driver?.destroy();
|
||||
this.driver = undefined;
|
||||
this.startDriver();
|
||||
await this.driver?.destroy();
|
||||
this.driver = undefined;
|
||||
this.startDriver();
|
||||
}
|
||||
finally {
|
||||
this.onDeviceEvent(ScryptedInterface.Settings, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
async discoverDevices(duration: number) {
|
||||
|
||||
Reference in New Issue
Block a user