isy-nodejs 0.5.0-beta.56 → 0.5.0-beta.57
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/lib/Devices/ISYDevice.js +1 -2
- package/lib/ISY.d.ts +1 -0
- package/lib/ISY.js +16 -7
- package/lib/ISYNode.d.ts +2 -1
- package/lib/ISYNode.js +4 -3
- package/package.json +1 -1
package/lib/Devices/ISYDevice.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.ISYUpdateableLevelDevice = exports.ISYLevelDevice = exports.ISYUpdateableBinaryStateDevice = exports.ISYBinaryStateDevice = exports.ISYDevice = void 0;
|
|
3
|
-
const util_1 = require("util");
|
|
4
3
|
const ISY_1 = require("../ISY");
|
|
5
4
|
const ISYConstants_1 = require("../ISYConstants");
|
|
6
5
|
const ISYNode_1 = require("../ISYNode");
|
|
@@ -26,7 +25,7 @@ class ISYDevice extends ISYNode_1.ISYNode {
|
|
|
26
25
|
if (this.parentAddress !== this.address &&
|
|
27
26
|
this.parentAddress !== undefined) {
|
|
28
27
|
this._parentDevice = isy.getDevice(this.parentAddress);
|
|
29
|
-
if (
|
|
28
|
+
if (this._parentDevice != null) {
|
|
30
29
|
this._parentDevice.addChild(this);
|
|
31
30
|
}
|
|
32
31
|
}
|
package/lib/ISY.d.ts
CHANGED
|
@@ -110,6 +110,7 @@ export declare class ISY extends EventEmitter {
|
|
|
110
110
|
data: any;
|
|
111
111
|
}): void;
|
|
112
112
|
initializeWebSocket(): void;
|
|
113
|
+
shutdown(): void;
|
|
113
114
|
private closeWebSocket;
|
|
114
115
|
getDevice(address: string, parentsOnly?: boolean): ISYDevice<any>;
|
|
115
116
|
getScene(address: string | number): any;
|
package/lib/ISY.js
CHANGED
|
@@ -390,6 +390,9 @@ class ISY extends events_1.EventEmitter {
|
|
|
390
390
|
device = child;
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
+
if (device === null || device === undefined) {
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
393
396
|
if (Array.isArray(node.property)) {
|
|
394
397
|
for (let prop of node.property) {
|
|
395
398
|
device[prop.id] = device.convertFrom(prop.value, prop.uom);
|
|
@@ -552,30 +555,36 @@ class ISY extends events_1.EventEmitter {
|
|
|
552
555
|
})
|
|
553
556
|
.on('fail', (data, response) => {
|
|
554
557
|
that.logger(`Websocket subscription failure: ${data}`);
|
|
555
|
-
|
|
558
|
+
that.closeWebSocket();
|
|
556
559
|
})
|
|
557
560
|
.on('abort', () => {
|
|
558
561
|
that.logger('Websocket subscription aborted.');
|
|
559
|
-
|
|
562
|
+
that.closeWebSocket();
|
|
560
563
|
})
|
|
561
564
|
.on('timeout', (ms) => {
|
|
562
565
|
that.logger(`Websocket subscription timed out after ${ms} milliseconds.`);
|
|
563
|
-
|
|
566
|
+
that.closeWebSocket();
|
|
564
567
|
});
|
|
565
568
|
}
|
|
569
|
+
shutdown() {
|
|
570
|
+
if (this.guardianTimer) {
|
|
571
|
+
clearInterval(this.guardianTimer);
|
|
572
|
+
this.guardianTimer = undefined;
|
|
573
|
+
}
|
|
574
|
+
this.closeWebSocket();
|
|
575
|
+
}
|
|
566
576
|
closeWebSocket() {
|
|
567
577
|
if (!this.webSocket) {
|
|
568
578
|
return;
|
|
569
579
|
}
|
|
580
|
+
const webSocket = this.webSocket;
|
|
581
|
+
this.webSocket = undefined;
|
|
570
582
|
try {
|
|
571
|
-
|
|
583
|
+
webSocket.close();
|
|
572
584
|
}
|
|
573
585
|
catch (error) {
|
|
574
586
|
this.logger(`Websocket close failed: ${error}`);
|
|
575
587
|
}
|
|
576
|
-
finally {
|
|
577
|
-
this.webSocket = undefined;
|
|
578
|
-
}
|
|
579
588
|
}
|
|
580
589
|
getDevice(address, parentsOnly = false) {
|
|
581
590
|
let s = this.deviceList.get(address);
|
package/lib/ISYNode.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { Family } from './Families';
|
|
4
|
-
import {
|
|
4
|
+
import { NodeType } from './ISYConstants';
|
|
5
|
+
import type { ISY } from './ISY';
|
|
5
6
|
import { PropertyChangedEventEmitter } from './Utils';
|
|
6
7
|
export declare class ISYNode extends EventEmitter implements PropertyChangedEventEmitter {
|
|
7
8
|
readonly isy: ISY;
|
package/lib/ISYNode.js
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
2
2
|
exports.ISYNode = void 0;
|
|
3
3
|
const events_1 = require("events");
|
|
4
4
|
const Families_1 = require("./Families");
|
|
5
|
-
const
|
|
5
|
+
const ISYConstants_1 = require("./ISYConstants");
|
|
6
6
|
class ISYNode extends events_1.EventEmitter {
|
|
7
7
|
constructor(isy, node) {
|
|
8
8
|
var _a, _b;
|
|
@@ -24,7 +24,7 @@ class ISYNode extends events_1.EventEmitter {
|
|
|
24
24
|
//if (s.length > 1)
|
|
25
25
|
//s.shift();
|
|
26
26
|
this.baseDisplayName = s.join(' ').replace(/([A-Z])/g, ' $1').replace(' ', ' ').replace(' ', ' ').trim();
|
|
27
|
-
if (this.parentType ===
|
|
27
|
+
if (this.parentType === ISYConstants_1.NodeType.Folder) {
|
|
28
28
|
this.folder = isy.folderMap.get(this.parent._);
|
|
29
29
|
isy.logger(`${this.name} this node is in folder ${this.folder}`);
|
|
30
30
|
this.logger = (msg) => {
|
|
@@ -78,7 +78,8 @@ class ISYNode extends events_1.EventEmitter {
|
|
|
78
78
|
else {
|
|
79
79
|
// this.logger(event.control);
|
|
80
80
|
const e = event.control;
|
|
81
|
-
const
|
|
81
|
+
const { Controls } = require('./ISY');
|
|
82
|
+
const dispName = Controls[e];
|
|
82
83
|
if (dispName !== undefined && dispName !== null) {
|
|
83
84
|
this.logger(`Command ${dispName.label} (${e}) triggered.`);
|
|
84
85
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "isy-nodejs",
|
|
3
3
|
"description": "Javascript wrapper for ISY interface including websockets for change notifications. Fork of isy-js by Rod Toll. Designed to be used in a node.js application.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.5.0-beta.
|
|
5
|
+
"version": "0.5.0-beta.57",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Rod Toll & Pradeep Mouli",
|
|
8
8
|
"email": "rod_toll@hotmail.com"
|