isy-nodejs 0.5.0-beta.54 → 0.5.0-beta.56
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.d.ts +12 -12
- package/lib/Devices/Insteon/InsteonCOSensorDevice.d.ts +5 -5
- package/lib/Devices/Insteon/InsteonDevice.d.ts +136 -10
- package/lib/Devices/Insteon/InsteonDevice.js +10 -11
- package/lib/Devices/Insteon/InsteonDeviceFactory.d.ts +2 -2
- package/lib/Devices/Insteon/InsteonDeviceFactory.js +10 -10
- package/lib/Devices/Insteon/InsteonDimmerSwitchDevice.d.ts +67 -3
- package/lib/Devices/Insteon/InsteonDoorWindowSensorDevice.d.ts +5 -5
- package/lib/Devices/Insteon/InsteonFanDevice.d.ts +5 -5
- package/lib/Devices/Insteon/InsteonLeakSensorDevice.d.ts +5 -5
- package/lib/Devices/Insteon/InsteonLockDevice.d.ts +5 -5
- package/lib/Devices/Insteon/InsteonRelayDevice.d.ts +5 -5
- package/lib/Devices/Insteon/InsteonRelaySwitchDevice.d.ts +67 -3
- package/lib/Devices/Insteon/InsteonSmokeSensorDevice.d.ts +5 -5
- package/lib/ISY.d.ts +1 -0
- package/lib/ISY.js +16 -1
- package/package.json +9 -1
- package/.babelrc +0 -12
- package/.travis.yml +0 -8
- package/ISYNodesDump.json +0 -1368
- package/isySampleOutput/config.json +0 -1825
- package/scratch.js +0 -95
- package/src/Categories.ts +0 -19
- package/src/Devices/DeviceFactory.ts +0 -20
- package/src/Devices/Elk/ElkAlarmPanelDevice.ts +0 -190
- package/src/Devices/Elk/ElkAlarmSensorDevice.ts +0 -104
- package/src/Devices/ISYDevice.ts +0 -281
- package/src/Devices/Insteon/InsteonBallastDimmerDevice.ts +0 -6
- package/src/Devices/Insteon/InsteonBaseDevice.ts +0 -43
- package/src/Devices/Insteon/InsteonCOSensorDevice.ts +0 -12
- package/src/Devices/Insteon/InsteonDeviceFactory.ts +0 -823
- package/src/Devices/Insteon/InsteonDimmableDevice.ts +0 -16
- package/src/Devices/Insteon/InsteonDimmerOutletDevice.ts +0 -7
- package/src/Devices/Insteon/InsteonDimmerSwitchDevice.ts +0 -8
- package/src/Devices/Insteon/InsteonDoorWindowSensorDevice.ts +0 -12
- package/src/Devices/Insteon/InsteonFanDevice.ts +0 -73
- package/src/Devices/Insteon/InsteonKeypadDevice.ts +0 -10
- package/src/Devices/Insteon/InsteonKeypadDimmerDevice.ts +0 -10
- package/src/Devices/Insteon/InsteonKeypadRelayDevice.ts +0 -7
- package/src/Devices/Insteon/InsteonLeakSensorDevice.ts +0 -12
- package/src/Devices/Insteon/InsteonLockDevice.ts +0 -42
- package/src/Devices/Insteon/InsteonMotionSensorDevice.ts +0 -43
- package/src/Devices/Insteon/InsteonOnOffOutletDevice.ts +0 -22
- package/src/Devices/Insteon/InsteonRelayDevice.ts +0 -20
- package/src/Devices/Insteon/InsteonRelaySwitchDevice.ts +0 -8
- package/src/Devices/Insteon/InsteonSmokeSensorDevice.ts +0 -12
- package/src/Devices/Insteon/InsteonThermostatDevice.ts +0 -39
- package/src/Devices/Insteon/insteondevice.ts +0 -47
- package/src/Events/EventType.ts +0 -27
- package/src/Events/ISYEvent.ts +0 -9
- package/src/Events/NodeEvent.ts +0 -9
- package/src/Events/PropertyChangedEvent.ts +0 -11
- package/src/Families.ts +0 -30
- package/src/ISY.ts +0 -768
- package/src/ISYConstants.ts +0 -182
- package/src/ISYNode.ts +0 -195
- package/src/ISYScene.ts +0 -120
- package/src/ISYVariable.ts +0 -49
- package/src/isyproductinfo.json +0 -378
- package/src/utils.ts +0 -108
- package/test/testsuite.js +0 -607
- package/tsconfig.json +0 -27
- package/tslint.json +0 -28
package/src/ISYConstants.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const ISYConstants = {
|
|
3
|
-
|
|
4
|
-
States: {
|
|
5
|
-
Off: 0,
|
|
6
|
-
On: 100,
|
|
7
|
-
Lock: {
|
|
8
|
-
Locked: 100,
|
|
9
|
-
Unlocked: 0
|
|
10
|
-
},
|
|
11
|
-
SecureLock: {
|
|
12
|
-
Secured: 1,
|
|
13
|
-
NotSecured: 0
|
|
14
|
-
},
|
|
15
|
-
DoorWindow: {
|
|
16
|
-
Closed: 0,
|
|
17
|
-
Open: 100// 255
|
|
18
|
-
},
|
|
19
|
-
Siren:
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
Sensor:
|
|
24
|
-
{
|
|
25
|
-
Triggered: 100,
|
|
26
|
-
NotTriggered: 0
|
|
27
|
-
},
|
|
28
|
-
Level: {
|
|
29
|
-
Min: 0,
|
|
30
|
-
Max: 100
|
|
31
|
-
},
|
|
32
|
-
LeakSensor: {
|
|
33
|
-
Dry: 0,
|
|
34
|
-
Wet: 100,
|
|
35
|
-
Heartbeat: 'hb'
|
|
36
|
-
},
|
|
37
|
-
Fan: {
|
|
38
|
-
Low: 25, // 63,
|
|
39
|
-
Medium: 75, // 191,
|
|
40
|
-
High: 100// 255
|
|
41
|
-
},
|
|
42
|
-
Climate: {
|
|
43
|
-
FanMode: {
|
|
44
|
-
On: 7,
|
|
45
|
-
Auto: 8
|
|
46
|
-
},
|
|
47
|
-
Mode: {
|
|
48
|
-
Off: 0,
|
|
49
|
-
Heat: 1,
|
|
50
|
-
Cool: 2,
|
|
51
|
-
Auto: 3,
|
|
52
|
-
Fan: 4,
|
|
53
|
-
ProgramAuto: 5,
|
|
54
|
-
ProgramHeat: 6,
|
|
55
|
-
ProgramCool: 7
|
|
56
|
-
},
|
|
57
|
-
ScheduleMode: {
|
|
58
|
-
Hold: 0,
|
|
59
|
-
Run: 1,
|
|
60
|
-
Away: 2
|
|
61
|
-
},
|
|
62
|
-
OperatingMode: {
|
|
63
|
-
Idle: 0,
|
|
64
|
-
Heating: 1,
|
|
65
|
-
Cooling: 2
|
|
66
|
-
},
|
|
67
|
-
UnitOfMeasure: {
|
|
68
|
-
Celcius: 1,
|
|
69
|
-
Fahrenheit: 2
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
Cmds: {
|
|
75
|
-
On: 'DON',
|
|
76
|
-
Off: 'DOF',
|
|
77
|
-
Dimmable: {
|
|
78
|
-
FastOn: 'DFON',
|
|
79
|
-
FastOff: 'DFOF',
|
|
80
|
-
Brighten: 'BRT',
|
|
81
|
-
Dim: 'DIM',
|
|
82
|
-
FadeUp: 'FDUP',
|
|
83
|
-
FadeDown: 'FDDOWN',
|
|
84
|
-
FadeStop: 'FDSTOP'
|
|
85
|
-
},
|
|
86
|
-
Lock: {
|
|
87
|
-
Lock: 'DON',
|
|
88
|
-
Unlock: 'DOF'
|
|
89
|
-
},
|
|
90
|
-
Thermostat:
|
|
91
|
-
{
|
|
92
|
-
SetpointUp: 'BRT',
|
|
93
|
-
SetpointDown: 'DIM'
|
|
94
|
-
},
|
|
95
|
-
Query: 'ST'
|
|
96
|
-
},
|
|
97
|
-
Props: {
|
|
98
|
-
Status: 'ST',
|
|
99
|
-
RampRate: 'RR',
|
|
100
|
-
OnLevel: 'OL',
|
|
101
|
-
BatteryLevel: 'BATLVL',
|
|
102
|
-
SecureLock: {
|
|
103
|
-
Mode: 'SECMD'
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
ZWave: {
|
|
107
|
-
LockAlarm: 'ALARM',
|
|
108
|
-
LockAccess: 'USRNUM',
|
|
109
|
-
LockStatus: 'ST',
|
|
110
|
-
EnergyPowerFactor: 'PF',
|
|
111
|
-
EnergyPowerPolarizedPower: 'PPW',
|
|
112
|
-
EnergyPowerCurrent: 'CC',
|
|
113
|
-
EnergyPowerTotalPower: 'TPW',
|
|
114
|
-
EnergyPowerVoltage: 'CV'
|
|
115
|
-
},
|
|
116
|
-
Climate: {
|
|
117
|
-
Temperature: 'CLITEMP',
|
|
118
|
-
Humidity: 'CLIHUM',
|
|
119
|
-
OperatingMode: 'CLIHCS',
|
|
120
|
-
Mode: 'CLIMD',
|
|
121
|
-
FanMode: 'CLIFS',
|
|
122
|
-
FanState: 'CLIFRS',
|
|
123
|
-
CoolSetPoint: 'CLISPC',
|
|
124
|
-
HeatSetPoint: 'CLISPH',
|
|
125
|
-
ScheduleMode: 'CLISMD',
|
|
126
|
-
EnergyMode: 'CLIEMD',
|
|
127
|
-
|
|
128
|
-
},
|
|
129
|
-
Error: 'ERR',
|
|
130
|
-
UnitOfMeasure: 'UOM'
|
|
131
|
-
},
|
|
132
|
-
deviceTypes: {
|
|
133
|
-
lock: 'Lock',
|
|
134
|
-
secureLock: 'SecureLock',
|
|
135
|
-
light: 'Light',
|
|
136
|
-
dimmableLight: 'DimmableLight',
|
|
137
|
-
outlet: 'Outlet',
|
|
138
|
-
fan: 'Fan',
|
|
139
|
-
unknown: 'Unknown',
|
|
140
|
-
doorWindowSensor: 'DoorWindowSensor',
|
|
141
|
-
alarmDoorWindowSensor: 'AlarmDoorWindowSensor',
|
|
142
|
-
coSensor: 'CoSensor',
|
|
143
|
-
alarmPanel: 'AlarmPanel',
|
|
144
|
-
motionSensor: 'MotionSensor',
|
|
145
|
-
leakSensor: 'LeakSensor',
|
|
146
|
-
remote: 'Remote',
|
|
147
|
-
scene: 'Scene',
|
|
148
|
-
thermostat: 'Thermostat',
|
|
149
|
-
polyNode: 'PolyNode'
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
export const Properties =
|
|
158
|
-
{
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export enum VariableType {
|
|
163
|
-
Integer = 1,
|
|
164
|
-
State = 2
|
|
165
|
-
}
|
|
166
|
-
export enum NodeType {
|
|
167
|
-
Device = 1,
|
|
168
|
-
Scene = 2,
|
|
169
|
-
Folder = 3,
|
|
170
|
-
X10A10 = 4
|
|
171
|
-
}
|
|
172
|
-
export enum LinkType
|
|
173
|
-
{
|
|
174
|
-
Controller = 16,
|
|
175
|
-
Responder = 0
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
export default ISYConstants;
|
|
180
|
-
export const Props = ISYConstants.Props;
|
|
181
|
-
export const States = ISYConstants.States;
|
|
182
|
-
export const Commands = ISYConstants.Cmds;
|
package/src/ISYNode.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { isNullOrUndefined } from 'util';
|
|
3
|
-
|
|
4
|
-
import { Family } from './Families';
|
|
5
|
-
import { Categories, Controls, ISY, NodeType } from './ISY';
|
|
6
|
-
import { PropertyChangedEventEmitter } from './Utils';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export class ISYNode extends EventEmitter implements PropertyChangedEventEmitter {
|
|
10
|
-
|
|
11
|
-
public readonly isy: ISY;
|
|
12
|
-
public readonly flag: any;
|
|
13
|
-
public readonly nodeDefId: string;
|
|
14
|
-
public readonly address: string;
|
|
15
|
-
[x: string]: any;
|
|
16
|
-
public name: string;
|
|
17
|
-
public displayName: string;
|
|
18
|
-
public spokenName: string;
|
|
19
|
-
public location: string;
|
|
20
|
-
public isLoad: boolean;
|
|
21
|
-
|
|
22
|
-
public folder: string = '';
|
|
23
|
-
public parent: any;
|
|
24
|
-
public parentType: NodeType;
|
|
25
|
-
public readonly elkId: string;
|
|
26
|
-
public nodeType: number;
|
|
27
|
-
public readonly baseDisplayName: string;
|
|
28
|
-
public propsInitialized: boolean;
|
|
29
|
-
public logger: (msg: any) => void;
|
|
30
|
-
public lastChanged: Date;
|
|
31
|
-
public enabled: boolean;
|
|
32
|
-
constructor (isy: ISY, node: { flag?: any; nodeDefId?: string; address?: string; name?: string; family?: Family; parent?: any; enabled: boolean; ELK_ID?: string; }) {
|
|
33
|
-
super();
|
|
34
|
-
this.isy = isy;
|
|
35
|
-
this.nodeType = 0;
|
|
36
|
-
this.flag = node.flag;
|
|
37
|
-
this.nodeDefId = node.nodeDefId;
|
|
38
|
-
this.address = String(node.address);
|
|
39
|
-
this.name = node.name;
|
|
40
|
-
this.family = node.family ?? Family.Insteon;
|
|
41
|
-
|
|
42
|
-
this.parent = node.parent;
|
|
43
|
-
|
|
44
|
-
this.parentType = Number(this.parent?.type);
|
|
45
|
-
|
|
46
|
-
this.enabled = node.enabled;
|
|
47
|
-
this.elkId = node.ELK_ID;
|
|
48
|
-
|
|
49
|
-
this.propsInitialized = false;
|
|
50
|
-
const s = this.name.split('.');
|
|
51
|
-
//if (s.length > 1)
|
|
52
|
-
//s.shift();
|
|
53
|
-
this.baseDisplayName = s.join(' ').replace(/([A-Z])/g, ' $1').replace(' ', ' ').replace(' ',' ').trim();
|
|
54
|
-
if (this.parentType === NodeType.Folder) {
|
|
55
|
-
|
|
56
|
-
this.folder = isy.folderMap.get(this.parent._);
|
|
57
|
-
isy.logger(`${this.name} this node is in folder ${this.folder}`);
|
|
58
|
-
this.logger = (msg) => {
|
|
59
|
-
return isy.logger(`${this.folder} ${this.name} (${this.address}): ${msg}`);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
this.displayName = `${this.folder} ${this.baseName}`;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
this.displayName = this.baseDisplayName;
|
|
66
|
-
this.logger = (msg) => {
|
|
67
|
-
return isy.logger(`${this.name} (${this.address}): ${msg}`);
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
this.logger(this.nodeDefId);
|
|
72
|
-
this.lastChanged = new Date();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public handlePropertyChange(propertyName: string, value: any, formattedValue: string): boolean {
|
|
76
|
-
this.lastChanged = new Date();
|
|
77
|
-
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public handleControlTrigger(controlName: string): boolean {
|
|
82
|
-
//this.lastChanged = new Date();
|
|
83
|
-
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public on(event: 'PropertyChanged'|'ControlTriggered', listener: ((propertyName: string, newValue: any, oldValue: any, formattedValue: string) => any)|((controlName: string) => any)): this {
|
|
88
|
-
super.on(event, listener);
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public emit(event: 'PropertyChanged'|'ControlTriggered', propertyName?: string, newValue?: any, oldValue?: any, formattedValue?: string, controlName?: string) {
|
|
93
|
-
if('PropertyChanged')
|
|
94
|
-
return super.emit(event, propertyName, newValue, oldValue, formattedValue);
|
|
95
|
-
else if('ControlTriggered')
|
|
96
|
-
return super.emit(event,controlName);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
public handleEvent(event: any): boolean {
|
|
101
|
-
let actionValue = null;
|
|
102
|
-
if (event.action instanceof Object) {
|
|
103
|
-
actionValue = event.action._;
|
|
104
|
-
} else if (event.action instanceof Number || event.action instanceof String) {
|
|
105
|
-
actionValue = Number(event.action);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (event.control in this) {
|
|
109
|
-
// property not command
|
|
110
|
-
const formatted = 'fmtAct' in event ? event.fmtAct : actionValue;
|
|
111
|
-
return this.handlePropertyChange(event.control, actionValue, formatted);
|
|
112
|
-
}
|
|
113
|
-
else if(event.control === '_3')
|
|
114
|
-
{
|
|
115
|
-
this.logger(`Received Node Change Event: ${JSON.stringify(event)}. These are currently unsupported.`);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// this.logger(event.control);
|
|
119
|
-
const e = event.control;
|
|
120
|
-
const dispName = Controls[e];
|
|
121
|
-
if (dispName !== undefined && dispName !== null) {
|
|
122
|
-
this.logger(`Command ${dispName.label} (${e}) triggered.`);
|
|
123
|
-
} else {
|
|
124
|
-
this.logger(`Command ${e} triggered.`);
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
let controlName : string = e;
|
|
128
|
-
this.handleControlTrigger(controlName);
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
static _displayNameFunction: Function;
|
|
134
|
-
|
|
135
|
-
public setDisplayName(template: string): string {
|
|
136
|
-
// tslint:disable-next-line: only-arrow-functions
|
|
137
|
-
if (!ISYNode._displayNameFunction) {
|
|
138
|
-
// template = template.replace("{", "{this."};
|
|
139
|
-
const regex = /(?<op1>\w+) \?\? (?<op2>\w+)/g;
|
|
140
|
-
this.logger(`Display name format: ${template}`);
|
|
141
|
-
let newttemp = template.replace(regex, 'this.$<op1> === null || this.$<op1> === undefined || this.$<op1> === \'\' ? this.$<op2> : this.$<op1>');
|
|
142
|
-
this.logger(`Template format updated to: ${newttemp}`);
|
|
143
|
-
const s = { location: this.location ?? '', folder: this.folder ?? '', spokenName: this.spokenName ?? this.name, name: this.name ?? '' };
|
|
144
|
-
newttemp = newttemp.replace('this.name', 'this.baseDisplayName');
|
|
145
|
-
ISYNode._displayNameFunction = new Function(`return \`${newttemp}\`.trim();`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return ISYNode._displayNameFunction.call(this);
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
public async refreshNotes() {
|
|
154
|
-
const that = this;
|
|
155
|
-
try {
|
|
156
|
-
|
|
157
|
-
const result = await this.getNotes();
|
|
158
|
-
if (result !== null && result !== undefined) {
|
|
159
|
-
that.location = result.location ?? this.folder ?? '';
|
|
160
|
-
that.spokenName = result.spoken ?? this.folder ?? '';
|
|
161
|
-
// if(result.spoken)
|
|
162
|
-
|
|
163
|
-
} else {
|
|
164
|
-
that.logger('No notes found.');
|
|
165
|
-
}
|
|
166
|
-
that.displayName = that.setDisplayName.bind(that)(that.isy.displayNameFormat);
|
|
167
|
-
that.displayName = that.displayName ?? this.baseDisplayName;
|
|
168
|
-
that.logger(`The friendly name updated to: ${that.displayName}`);
|
|
169
|
-
} catch (e) {
|
|
170
|
-
|
|
171
|
-
that.logger(e);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
public async getNotes(): Promise<any> {
|
|
177
|
-
|
|
178
|
-
try {
|
|
179
|
-
const result = await this.isy.callISY(`nodes/${this.address}/notes`);
|
|
180
|
-
if (result !== null && result !== undefined) {
|
|
181
|
-
return result.NodeProperties;
|
|
182
|
-
} else {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
} catch (e) {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
package/src/ISYScene.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { InsteonDimmableDevice } from './Devices/Insteon/InsteonDimmableDevice';
|
|
2
|
-
import { Family } from './Families';
|
|
3
|
-
import { InsteonRelayDevice, ISY, ISYDevice } from './ISY';
|
|
4
|
-
import { Commands, LinkType } from './ISYConstants';
|
|
5
|
-
import { ISYNode } from './ISYNode';
|
|
6
|
-
|
|
7
|
-
export class ISYScene extends ISYNode {
|
|
8
|
-
public type: string;
|
|
9
|
-
public connectionType: string;
|
|
10
|
-
public batteryOperated: boolean;
|
|
11
|
-
public deviceType: any;
|
|
12
|
-
public deviceFriendlyName: string;
|
|
13
|
-
public members: Array<ISYDevice<any>>;
|
|
14
|
-
public isDimmable: boolean;
|
|
15
|
-
public typeCode: string;
|
|
16
|
-
constructor(isy: ISY, scene: { members?: { link: any; }; flag?: any; nodeDefId?: string; address?: string; name?: string; family?: Family; parent?: any; enabled: boolean; ELK_ID?: string; }) {
|
|
17
|
-
super(isy, scene);
|
|
18
|
-
// this.logger(JSON.stringify(scene));
|
|
19
|
-
this.typeCode = '';
|
|
20
|
-
this.connectionType = 'Insteon Wired';
|
|
21
|
-
this.batteryOperated = false;
|
|
22
|
-
|
|
23
|
-
this.deviceFriendlyName = 'ISY Scene';
|
|
24
|
-
this.members = [];
|
|
25
|
-
this.isDimmable = false;
|
|
26
|
-
if (Array.isArray(scene.members?.link)) {
|
|
27
|
-
for (const node of scene.members.link) {
|
|
28
|
-
if ('_' in node) {
|
|
29
|
-
// childDevices.push(node._);
|
|
30
|
-
// childDevices.push(object)
|
|
31
|
-
const s = node._;
|
|
32
|
-
const d = isy.getDevice(s);
|
|
33
|
-
|
|
34
|
-
if (d !== null && d !== undefined) { d.addLink(this); }
|
|
35
|
-
|
|
36
|
-
if (d instanceof InsteonDimmableDevice && node.type !== LinkType.Controller) { this.isDimmable = true; }
|
|
37
|
-
this.members[s] = d;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} else if (scene.members?.link) {
|
|
41
|
-
if ('_' in scene.members.link) {
|
|
42
|
-
const node = scene.members.link._;
|
|
43
|
-
this.logger(JSON.stringify(node));
|
|
44
|
-
// childDevices.push(node._);
|
|
45
|
-
// childDevices.push(object)
|
|
46
|
-
const s = scene.members.link._;
|
|
47
|
-
const d = isy.getDevice(s);
|
|
48
|
-
if (d) { d.addLink(this);
|
|
49
|
-
// tslint:disable-next-line: triple-equals
|
|
50
|
-
if ((d.isDimmable && node.type != LinkType.Controller) || this.isDimmable) { this.isDimmable = true; }
|
|
51
|
-
this.members[s] = d;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// check dimmability this.dimmable = Array.apply(p => p.dimmable);
|
|
56
|
-
this.recalculateState();
|
|
57
|
-
}
|
|
58
|
-
// Get the current light state
|
|
59
|
-
get isOn() {
|
|
60
|
-
for (const device of this.members) {
|
|
61
|
-
if (device instanceof InsteonRelayDevice) {
|
|
62
|
-
if (device.isOn) {
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
get brightnessLevel() {
|
|
71
|
-
let lightDeviceCount = 0;
|
|
72
|
-
let blevel = 0;
|
|
73
|
-
for (const device of this.members) {
|
|
74
|
-
if (device instanceof InsteonDimmableDevice) {
|
|
75
|
-
lightDeviceCount++;
|
|
76
|
-
blevel += device.brightnessLevel;
|
|
77
|
-
} else if (device instanceof InsteonRelayDevice) {
|
|
78
|
-
lightDeviceCount++;
|
|
79
|
-
blevel += device.isOn ? 100 : 0;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (lightDeviceCount > 0) {
|
|
83
|
-
return Math.floor(blevel / lightDeviceCount);
|
|
84
|
-
} else {
|
|
85
|
-
return 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Current light dim state is always calculated
|
|
89
|
-
public recalculateState() {
|
|
90
|
-
this.markAsChanged();
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
public markAsChanged() {
|
|
94
|
-
this.lastChanged = new Date();
|
|
95
|
-
this.emit('PropertyChanged', 'isOn', this.isOn, this.isOn, this.isOn ? 'on' : 'off');
|
|
96
|
-
|
|
97
|
-
if (this.isDimmable) {
|
|
98
|
-
this.emit('PropertyChanged', 'brightnesslevel', this.brightnessLevel, this.brightnessLevel, this.brightnessLevel + '%');
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
public async updateIsOn(lightState: boolean) {
|
|
103
|
-
return this.isy.sendNodeCommand(this, lightState ? Commands.On : Commands.Off);
|
|
104
|
-
}
|
|
105
|
-
public async updateBrightnessLevel(level) {
|
|
106
|
-
return this.isy.sendNodeCommand(this, level > 0 ? Commands.On : Commands.Off, level);
|
|
107
|
-
}
|
|
108
|
-
public getAreAllLightsInSpecifiedState(state) {
|
|
109
|
-
for (const device of this.members) {
|
|
110
|
-
if (device instanceof InsteonRelayDevice) {
|
|
111
|
-
if (device.isOn !== state) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
package/src/ISYVariable.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { ISY } from './ISY';
|
|
3
|
-
import { VariableType } from './ISYConstants';
|
|
4
|
-
|
|
5
|
-
export class ISYVariable extends EventEmitter {
|
|
6
|
-
public isy: ISY;
|
|
7
|
-
public id: number;
|
|
8
|
-
public name: string;
|
|
9
|
-
public value: any;
|
|
10
|
-
public init: any;
|
|
11
|
-
public type: VariableType;
|
|
12
|
-
public lastChanged: Date;
|
|
13
|
-
constructor(isy: ISY, id: number, name: string, type: any) {
|
|
14
|
-
super();
|
|
15
|
-
this.isy = isy;
|
|
16
|
-
this.id = id;
|
|
17
|
-
this.name = name;
|
|
18
|
-
this.value = undefined;
|
|
19
|
-
this.init = undefined;
|
|
20
|
-
this.type = type;
|
|
21
|
-
this.lastChanged = new Date();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public handleEvent(event: { eventInfo: { var: any }; })
|
|
25
|
-
{
|
|
26
|
-
const varNode = event.eventInfo.var;
|
|
27
|
-
if (varNode !== null) {
|
|
28
|
-
const id = varNode.id;
|
|
29
|
-
const type = varNode.type;
|
|
30
|
-
const priorVal = this.value;
|
|
31
|
-
this.value = parseInt(varNode.val);
|
|
32
|
-
const year = parseInt(varNode.ts.substr(0, 4));
|
|
33
|
-
const month = parseInt(varNode.ts.substr(4, 2));
|
|
34
|
-
const day = parseInt(varNode.ts.substr(6, 2));
|
|
35
|
-
const hour = parseInt(varNode.ts.substr(9, 2));
|
|
36
|
-
const min = parseInt(varNode.ts.substr(12, 2));
|
|
37
|
-
const sec = parseInt(varNode.ts.substr(15, 2));
|
|
38
|
-
this.lastChanged = new Date(year, month, day, hour, min, sec);
|
|
39
|
-
this.emit('ValueChanged',this.value, priorVal);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public async updateValue(value: any): Promise<void> {
|
|
44
|
-
const p = await this.isy.callISY(`vars\\${this.type}\\${this.id}\\${value}`);
|
|
45
|
-
this.value = value;
|
|
46
|
-
return p;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}
|