isy-nodejs 0.5.0-beta.55 → 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.
Files changed (52) hide show
  1. package/lib/Devices/ISYDevice.js +1 -2
  2. package/lib/ISY.d.ts +2 -0
  3. package/lib/ISY.js +28 -4
  4. package/lib/ISYNode.d.ts +2 -1
  5. package/lib/ISYNode.js +4 -3
  6. package/package.json +9 -1
  7. package/.babelrc +0 -12
  8. package/.travis.yml +0 -8
  9. package/ISYNodesDump.json +0 -1368
  10. package/isySampleOutput/config.json +0 -1825
  11. package/scratch.js +0 -95
  12. package/src/Categories.ts +0 -19
  13. package/src/Devices/DeviceFactory.ts +0 -20
  14. package/src/Devices/Elk/ElkAlarmPanelDevice.ts +0 -190
  15. package/src/Devices/Elk/ElkAlarmSensorDevice.ts +0 -104
  16. package/src/Devices/ISYDevice.ts +0 -282
  17. package/src/Devices/Insteon/InsteonBallastDimmerDevice.ts +0 -6
  18. package/src/Devices/Insteon/InsteonBaseDevice.ts +0 -43
  19. package/src/Devices/Insteon/InsteonCOSensorDevice.ts +0 -12
  20. package/src/Devices/Insteon/InsteonDeviceFactory.ts +0 -823
  21. package/src/Devices/Insteon/InsteonDimmableDevice.ts +0 -16
  22. package/src/Devices/Insteon/InsteonDimmerOutletDevice.ts +0 -7
  23. package/src/Devices/Insteon/InsteonDimmerSwitchDevice.ts +0 -8
  24. package/src/Devices/Insteon/InsteonDoorWindowSensorDevice.ts +0 -12
  25. package/src/Devices/Insteon/InsteonFanDevice.ts +0 -73
  26. package/src/Devices/Insteon/InsteonKeypadDevice.ts +0 -9
  27. package/src/Devices/Insteon/InsteonKeypadDimmerDevice.ts +0 -10
  28. package/src/Devices/Insteon/InsteonKeypadRelayDevice.ts +0 -7
  29. package/src/Devices/Insteon/InsteonLeakSensorDevice.ts +0 -12
  30. package/src/Devices/Insteon/InsteonLockDevice.ts +0 -42
  31. package/src/Devices/Insteon/InsteonMotionSensorDevice.ts +0 -43
  32. package/src/Devices/Insteon/InsteonOnOffOutletDevice.ts +0 -22
  33. package/src/Devices/Insteon/InsteonRelayDevice.ts +0 -21
  34. package/src/Devices/Insteon/InsteonRelaySwitchDevice.ts +0 -8
  35. package/src/Devices/Insteon/InsteonSmokeSensorDevice.ts +0 -12
  36. package/src/Devices/Insteon/InsteonThermostatDevice.ts +0 -39
  37. package/src/Devices/Insteon/insteondevice.ts +0 -41
  38. package/src/Events/EventType.ts +0 -27
  39. package/src/Events/ISYEvent.ts +0 -9
  40. package/src/Events/NodeEvent.ts +0 -9
  41. package/src/Events/PropertyChangedEvent.ts +0 -11
  42. package/src/Families.ts +0 -30
  43. package/src/ISY.ts +0 -768
  44. package/src/ISYConstants.ts +0 -182
  45. package/src/ISYNode.ts +0 -195
  46. package/src/ISYScene.ts +0 -120
  47. package/src/ISYVariable.ts +0 -49
  48. package/src/isyproductinfo.json +0 -378
  49. package/src/utils.ts +0 -108
  50. package/test/testsuite.js +0 -607
  51. package/tsconfig.json +0 -27
  52. package/tslint.json +0 -28
@@ -1,282 +0,0 @@
1
- import { timingSafeEqual } from 'crypto';
2
- import { isNullOrUndefined } from 'util';
3
-
4
- import { stringify } from 'querystring';
5
- import { threadId } from 'worker_threads';
6
- import { Family } from '../Families';
7
- import { Controls, ISY } from '../ISY';
8
- import { Commands, States } from '../ISYConstants';
9
- import { ISYNode } from '../ISYNode';
10
- import { ISYScene } from '../ISYScene';
11
- import { NodeEvent } from '../Events/NodeEvent';
12
-
13
- export class ISYDevice<T extends Family> extends ISYNode {
14
- public family: T;
15
-
16
- public readonly typeCode: string;
17
- public readonly deviceClass: any;
18
- public readonly parentAddress: any;
19
- public readonly category: number;
20
- public readonly subCategory: number;
21
- public readonly type: any;
22
- public _parentDevice: ISYDevice<T>;
23
- public readonly children: Array<ISYDevice<T>> = [];
24
- public readonly scenes: ISYScene[] = [];
25
- public readonly formatted: any[string] = {};
26
- public readonly uom: any[string] = {};
27
- public readonly pending: any[string] = {};
28
- public hidden: boolean = false;
29
- public location: string;
30
-
31
- constructor(isy: ISY, node: { family: any; type?: string; enabled: any; deviceClass?: any; pnode?: any; property?: any; flag?: any; nodeDefId?: string; address?: any; name?: string; parent?: any; ELK_ID?: string; }) {
32
- super(isy, node);
33
-
34
- this.family = node.family as T;
35
- this.nodeType = 1;
36
- this.type = node.type;
37
- this._enabled = node.enabled;
38
- this.deviceClass = node.deviceClass;
39
- this.parentAddress = node.pnode;
40
- const s = this.type.split('.');
41
- this.category = Number(s[0]);
42
- this.subCategory = Number(s[1]);
43
-
44
- // console.log(nodeDetail);
45
- if (
46
- this.parentAddress !== this.address &&
47
- this.parentAddress !== undefined
48
- ) {
49
- this._parentDevice = isy.getDevice(this.parentAddress);
50
- if (!isNullOrUndefined(this._parentDevice)) {
51
- this._parentDevice.addChild(this);
52
- }
53
-
54
- }
55
- if (Array.isArray(node.property)) {
56
- for (const prop of node.property) {
57
- this[prop.id] = this.convertFrom(prop.value, prop.uom);
58
- this.formatted[prop.id] = prop.formatted;
59
- this.uom[prop.id] = prop.uom;
60
- this.logger(
61
- `Property ${Controls[prop.id].label} (${prop.id}) initialized to: ${
62
- this[prop.id]
63
- } (${this.formatted[prop.id]})`
64
- );
65
- }
66
- } else if (node.property) {
67
- this[node.property.id] = this.convertFrom(
68
- node.property.value,
69
- node.property.uom
70
- );
71
- this.formatted[node.property.id] = node.property.formatted;
72
- this.uom[node.property.id] = node.property.uom;
73
- this.logger(
74
- `Property ${Controls[node.property.id].label} (${
75
- node.property.id
76
- }) initialized to: ${this[node.property.id]} (${
77
- this.formatted[node.property.id]
78
- })`
79
- );
80
- }
81
-
82
- }
83
-
84
- public convertTo(value: any, uom: number): any {
85
- return value;
86
- }
87
-
88
- public convertFrom(value: any, uom: number): any {
89
- return value;
90
- }
91
-
92
- public addLink(isyScene: ISYScene) {
93
- this.scenes.push(isyScene);
94
- }
95
-
96
- public addChild(childDevice: ISYDevice<T>) {
97
- this.children.push(childDevice);
98
- }
99
-
100
- get parentDevice(): ISYDevice<T> {
101
- if (this._parentDevice === undefined) {
102
- if (
103
- this.parentAddress !== this.address &&
104
- this.parentAddress !== null &&
105
- this.parentAddress !== undefined
106
- ) {
107
- this._parentDevice = this.isy.getDevice(this.parentAddress);
108
- if (this._parentDevice !== null) {
109
- this._parentDevice.addChild(this);
110
- }
111
- }
112
- this._parentDevice = null;
113
- }
114
- return this._parentDevice;
115
- }
116
-
117
- public async refreshProperty(propertyName: string): Promise<any> {
118
- return this.isy.callISY(`nodes/${this.address}/status/${propertyName}`);
119
- }
120
-
121
- public async updateProperty(propertyName: string, value: string): Promise<any> {
122
- const val = this.convertTo(Number(value), Number(this.uom[propertyName]));
123
- this.logger(
124
- `Updating property ${Controls[propertyName].label}. incoming value: ${value} outgoing value: ${val}`
125
- );
126
- this.pending[propertyName] = value;
127
- return this.isy
128
- .sendISYCommand(`nodes/${this.address}/set/${propertyName}/${val}`)
129
- .then((p) => {
130
- this[propertyName] = value;
131
- this.pending[propertyName] = null;
132
- });
133
- }
134
-
135
- public async sendCommand(command, ...parameters: any[]): Promise<any> {
136
- return this.isy.sendNodeCommand(this, command, ...parameters);
137
- }
138
-
139
- public async refresh(): Promise<any> {
140
- const device = this;
141
- const result = await this.isy.callISY(`nodes/${this.address}/status`);
142
- const node = result.node;
143
- // this.logger(node);
144
-
145
- if (Array.isArray(node.property)) {
146
- for (const prop of node.property) {
147
- device[prop.id] = prop.value;
148
- device.formatted[prop.id] = prop.formatted;
149
- device.uom[prop.id] = prop.uom;
150
- device.logger(
151
- `Property ${Controls[prop.id].label} (${prop.id}) refreshed to: ${
152
- device[prop.id]
153
- } (${device.formatted[prop.id]})`
154
- );
155
- }
156
- } else if (node.property) {
157
- device[node.property.id] = node.property.value;
158
- device.formatted[node.property.id] = node.property.formatted;
159
- device.uom[node.property.id] = node.property.uom;
160
- device.logger(
161
- `Property ${Controls[node.property.id].label} (${node.property.id}) refreshed to: ${device[node.property.id]} (${device.formatted[node.property.id]})`
162
- );
163
- }
164
- return result;
165
- }
166
-
167
-
168
-
169
- public handleControlTrigger(controlName) {
170
- return this.emit('ControlTriggered', controlName);
171
- }
172
-
173
- public handlePropertyChange(propertyName: string, value: any, formattedValue: string) {
174
- let changed = false;
175
- const priorVal = this[propertyName];
176
- try {
177
- const val = this.convertFrom(
178
- value,
179
- this.uom[propertyName]
180
- );
181
-
182
- if (this[propertyName] !== val) {
183
-
184
- this.logger(
185
- `Property ${
186
- Controls[propertyName].label
187
- } (${propertyName}) updated to: ${val} (${formattedValue})`
188
- );
189
- this[propertyName] = val;
190
- this.formatted[propertyName] = formattedValue;
191
- this.lastChanged = new Date();
192
- changed = true;
193
- } else {
194
- this.logger(
195
- `Update event triggered, property ${
196
- Controls[propertyName].label
197
- } (${propertyName}) is unchanged.`
198
- );
199
- }
200
- if (changed) {
201
- this.emit('PropertyChanged', propertyName, val, priorVal, formattedValue);
202
-
203
- this.scenes.forEach((element) => {
204
- this.logger(`Recalulating ${element.name}`);
205
- element.recalculateState();
206
- });
207
- }
208
- } finally {
209
- return changed;
210
- }
211
- }
212
- }
213
-
214
- export type Constructor<T> = new (...args: any[]) => T;
215
-
216
- export const ISYBinaryStateDevice = <K extends Family, T extends Constructor<ISYDevice<K>>>(Base: T) => {
217
- return class extends Base {
218
- get state(): boolean {
219
- return this.ST > 0;
220
- }
221
- };
222
- };
223
-
224
- export const ISYUpdateableBinaryStateDevice = <K extends Family,T extends Constructor<ISYDevice<K>>>(
225
- Base: T
226
- ) => {
227
- return class extends Base {
228
- get state(): boolean {
229
-
230
- return this.ST > 0;
231
- }
232
-
233
- public async updateState(state: boolean): Promise<any> {
234
- if (state !== this.state || this.pending.ST > 0 !== this.state) {
235
- this.pending.ST = state ? States.On : States.Off;
236
- return this.sendCommand(state ? Commands.On : Commands.Off).then((p) => {
237
- this.ST = this.pending.ST;
238
- this.pending.ST = null;
239
- });
240
- }
241
- return Promise.resolve();
242
- }
243
- };
244
- };
245
-
246
- export const ISYLevelDevice = <T extends Constructor<ISYDevice<any>>>(base: T) =>
247
- class extends base {
248
- get level(): number {
249
- return this.ST;
250
- }
251
- };
252
-
253
- // tslint:disable-next-line: variable-name
254
-
255
- export const ISYUpdateableLevelDevice = <T extends Constructor<ISYDevice<any>>>(base: T) =>
256
- class extends base {
257
- get level(): number {
258
- return this.ST;
259
- }
260
-
261
- public async updateLevel(level: number): Promise<any> {
262
- if (level != this.ST && level !== (this.pending.ST ?? this.ST)) {
263
-
264
- this.pending.ST = level;
265
- if (level > 0) {
266
- return this.sendCommand(
267
- Commands.On,
268
- this.convertTo(level, this.uom.ST)
269
- ).then((p) => {
270
- this.ST = this.pending.ST;
271
- this.pending.ST = null;
272
- });
273
- } else {
274
- return this.sendCommand(Commands.Off).then((p) => {
275
- this.ST = this.pending.ST;
276
- this.pending.ST = null;
277
- });
278
- }
279
- }
280
- return Promise.resolve();
281
- }
282
- };
@@ -1,6 +0,0 @@
1
- import { InsteonDimmableDevice } from './InsteonDimmableDevice';
2
- export class InsteonBallastDimmerDevice extends InsteonDimmableDevice {
3
- constructor (isy: any, deviceNode: any) {
4
- super(isy, deviceNode);
5
- }
6
- }
@@ -1,43 +0,0 @@
1
- import { Family, Insteon } from '../../Families';
2
- import { ISY } from '../../ISY';
3
- import { byteToDegree, byteToPct, pctToByte } from '../../Utils';
4
- import { ISYDevice } from '../ISYDevice';
5
-
6
- // import { InsteonNLS } from './insteonfam'
7
- export class InsteonBaseDevice extends ISYDevice<Family.Insteon> {
8
- constructor(isy: ISY, deviceNode: { family: any; type?: string; enabled: any; deviceClass?: any; pnode?: any; property?: any; flag?: any; nodeDefId?: string; address?: string; name?: string; parent?: any; ELK_ID?: string; }) {
9
-
10
- super(isy, deviceNode);
11
- this.family = Family.Insteon;
12
- //// this.productName = InsteonNLS.getDeviceDescription(String.fromCharCode(category,device,version));
13
- this.childDevices = {};
14
- }
15
- public convertFrom(value: any, uom: number): any {
16
- switch (uom) {
17
- case 101:
18
- return byteToDegree(value);
19
- case 100:
20
- return byteToPct(value);
21
- case 17:
22
- return value / 10;
23
- default:
24
- return super.convertFrom(value, uom);
25
- }
26
- }
27
- public convertTo(value: any, uom: number): any {
28
- const nuom = super.convertTo(value, uom);
29
- switch (uom) {
30
- case 101:
31
- return nuom * 2;
32
- case 100:
33
- return pctToByte(nuom);
34
- case 17:
35
- return Math.round(value * 10);
36
- default:
37
- return nuom;
38
- }
39
- }
40
- public async sendBeep(level: number = 100): Promise<any> {
41
- return this.sendCommand(this, 'BEEP');
42
- }
43
- }
@@ -1,12 +0,0 @@
1
- import { ISY } from '../../ISY';
2
- import { ISYUpdateableBinaryStateDevice, ISYBinaryStateDevice } from '../ISYDevice';
3
- import { InsteonBaseDevice } from './InsteonBaseDevice';
4
-
5
- export class InsteonCOSensorDevice extends ISYBinaryStateDevice(InsteonBaseDevice) {
6
- constructor (isy: ISY, deviceNode: { family: any; type?: string; enabled: any; deviceClass?: any; pnode?: any; property?: any; flag?: any; nodeDefId?: string; address?: string; name?: string; parent?: any; ELK_ID?: string; }) {
7
- super(isy, deviceNode);
8
- }
9
- get monoxideDetected() {
10
- return this.state;
11
- }
12
- }