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.
- package/lib/Devices/ISYDevice.js +1 -2
- package/lib/ISY.d.ts +2 -0
- package/lib/ISY.js +28 -4
- package/lib/ISYNode.d.ts +2 -1
- package/lib/ISYNode.js +4 -3
- 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 -282
- 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 -9
- 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 -21
- 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 -41
- 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/scratch.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// File for scratch testing. Will be removed in the future at is for my own internal purposes
|
|
2
|
-
|
|
3
|
-
var ISY = require('./isy');
|
|
4
|
-
var ISYDevice = require('./isydevice');
|
|
5
|
-
|
|
6
|
-
function handleInitialized() {
|
|
7
|
-
var deviceList = isy.getDeviceList();
|
|
8
|
-
console.log("Device count: "+deviceList.length);
|
|
9
|
-
if(deviceList == null) {
|
|
10
|
-
console.log("No device list returned!");
|
|
11
|
-
} else {
|
|
12
|
-
console.log("Got device list. Device count: "+deviceList.length);
|
|
13
|
-
for(var index = 0; index < deviceList.length; index++ ) {
|
|
14
|
-
console.log("Device: "+deviceList[index].name+", "+deviceList[index].deviceType+", "+deviceList[index].address+", "+deviceList[index].deviceFriendlyName);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
var fanDevice = isy.getDevice('14 A8 BC 2');
|
|
18
|
-
var fanSpeed = fanDevice.getCurrentFanState();
|
|
19
|
-
console.log('Current fan speed '+fanSpeed);
|
|
20
|
-
fanDevice.sendFanCommand(fanDevice.FAN_LEVEL_MEDIUM, function() {});
|
|
21
|
-
setTimeout(function() {
|
|
22
|
-
console.log('Fan state (should be medium): '+fanDevice.getCurrentFanState());
|
|
23
|
-
fanDevice.sendFanCommand(fanDevice.FAN_LEVEL_HIGH, function() {});
|
|
24
|
-
setTimeout(function() {
|
|
25
|
-
console.log('Fan state (should be high): '+fanDevice.getCurrentFanState());
|
|
26
|
-
fanDevice.sendFanCommand((fanDevice.FAN_OFF), function() {});
|
|
27
|
-
}, 4000)
|
|
28
|
-
},4000);
|
|
29
|
-
//runBasicSceneTest(deviceList);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function handleChanged(isy, device) {
|
|
33
|
-
var logMessage = 'From isy: '+isy.address+' device changed: '+device.name;
|
|
34
|
-
if(device.deviceType == isy.DEVICE_TYPE_FAN) {
|
|
35
|
-
logMessage += ' fan state: '+device.getCurrentFanState();
|
|
36
|
-
} else if(device.deviceType == isy.DEVICE_TYPE_LIGHT) {
|
|
37
|
-
logMessage += ' light state: '+device.getCurrentLightState();
|
|
38
|
-
} else if(device.deviceType == isy.DEVICE_TYPE_DIMMABLE_LIGHT) {
|
|
39
|
-
logMessage += ' dimmable light state: '+device.getCurrentLightState()+' dimm Level: '+device.getCurrentLightDimState();
|
|
40
|
-
} else if(device.deviceType == isy.DEVICE_TYPE_LOCK || device.deviceType == isy.DEVICE_TYPE_SECURE_LOCK) {
|
|
41
|
-
logMessage += ' lock state: '+device.getCurrentLockState();
|
|
42
|
-
} else if(device.deviceType == isy.DEVICE_TYPE_OUTLET) {
|
|
43
|
-
logMessage += ' outlet state: '+device.getCurrentOutletState();
|
|
44
|
-
} else if(device.deviceType == isy.DEVICE_TYPE_ALARM_DOOR_WINDOW_SENSOR) {
|
|
45
|
-
logMessage += ' door window sensor state: '+device.getCurrentDoorWindowState()+' logical: '+device.getLogicalState()+' physical: '+device.getPhysicalState();
|
|
46
|
-
} else if(device.deviceType == isy.DEVICE_TYPE_DOOR_WINDOW_SENSOR) {
|
|
47
|
-
logMessage += ' door window sensor state: '+device.getCurrentDoorWindowState();
|
|
48
|
-
} else if(device.deviceType == isy.DEVICE_TYPE_ALARM_PANEL) {
|
|
49
|
-
logMessage += ' alarm panel state: '+device.getAlarmStatusAsText();
|
|
50
|
-
} else if(device.deviceType == isy.DEVICE_TYPE_MOTION_SENSOR) {
|
|
51
|
-
logMessage += ' motion sensor state: '+device.getCurrentMotionSensorState();
|
|
52
|
-
} else if(device.deviceType == isy.DEVICE_TYPE_SCENE) {
|
|
53
|
-
logMessage += ' scene. light state: '+device.getCurrentLightState()+' dimm Level: '+device.getCurrentLightDimState();
|
|
54
|
-
} else {
|
|
55
|
-
logMessage += ' unknown device, cannot parse state';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
console.log(logMessage);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
//var isy = new ISY.ISY('10.0.1.19', 'admin', 'password', true, handleChanged, false, true,true);
|
|
62
|
-
var isy = new ISY.ISY('127.0.0.1:3000', 'admin', 'password', true, handleChanged, false, true,true);
|
|
63
|
-
|
|
64
|
-
isy.initialize(handleInitialized);
|
|
65
|
-
console.log('initialize completed');
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function runBasicSceneTest(devices) {
|
|
70
|
-
for(var index = 0; index < devices.length; index++) {
|
|
71
|
-
var device = devices[index];
|
|
72
|
-
if(device.deviceType == isy.DEVICE_TYPE_SCENE && device.childDevices.length > 0 && device.childDevices.length < 5) {
|
|
73
|
-
console.log('Using scene: '+device.name);
|
|
74
|
-
console.log('Contains devices: ');
|
|
75
|
-
for(var childIndex = 0; childIndex < device.childDevices.length; childIndex++) {
|
|
76
|
-
console.log('Device: name='+device.childDevices[childIndex].name+' type='+device.childDevices[childIndex].deviceType);
|
|
77
|
-
}
|
|
78
|
-
console.log('Light state: '+devices[index].getCurrentLightState());
|
|
79
|
-
device.sendLightCommand(true, function() {
|
|
80
|
-
console.log('Turned them off to start so we make sure to get an on');
|
|
81
|
-
device.sendLightCommand(true, function() {
|
|
82
|
-
console.log('SHould have seen them all turn on');
|
|
83
|
-
device.sendLightCommand(false, function() {
|
|
84
|
-
console.log('Should have seen them all turn off');
|
|
85
|
-
device.sendLightDimCommand(50, function() {
|
|
86
|
-
console.log('Should have seen them all set to 50%');
|
|
87
|
-
device.sendLightCommand(false, function() {});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
package/src/Categories.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export enum Categories {
|
|
2
|
-
Controller = 0,
|
|
3
|
-
DimmableControl = 1,
|
|
4
|
-
RelayControl = 2,
|
|
5
|
-
NetworkBridge = 3,
|
|
6
|
-
IrrigationControl = 4,
|
|
7
|
-
ClimateControl = 5,
|
|
8
|
-
PoolControl = 6,
|
|
9
|
-
SensorActuator = 7,
|
|
10
|
-
HomeEntertainment = 8,
|
|
11
|
-
EnergyManagement = 9,
|
|
12
|
-
ApplianceControl = 10,
|
|
13
|
-
WindowShadeControl = 14,
|
|
14
|
-
AccessControl = 15,
|
|
15
|
-
SecurityHealthSafety = 16,
|
|
16
|
-
A10X10 = 113,
|
|
17
|
-
Virtual = 127,
|
|
18
|
-
Unknown = 254
|
|
19
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Family, ISYDevice } from '../ISY';
|
|
3
|
-
import { InsteonDeviceFactory } from './Insteon/InsteonDeviceFactory';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export class DeviceFactory {
|
|
7
|
-
|
|
8
|
-
public static getDeviceDetails(node: { family?: any; type?: any; address?: any; nodeDefId: any; }): { name: string; modelNumber?: string; version?: string; class?: typeof ISYDevice; unsupported?: true } {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// tslint:disable-next-line: triple-equals
|
|
12
|
-
if ((node.family ?? Family.Insteon) == Family.Insteon) {
|
|
13
|
-
|
|
14
|
-
return InsteonDeviceFactory.getInsteonDeviceDetails(node.type, node);
|
|
15
|
-
|
|
16
|
-
} else { return {name: 'Unsupported Device', class: ISYDevice, unsupported: true} }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { timingSafeEqual } from 'crypto';
|
|
2
|
-
import { Family } from '../../Families';
|
|
3
|
-
import { ISY } from '../../ISY';
|
|
4
|
-
import { ISYDevice } from '../ISYDevice';
|
|
5
|
-
import { ElkAlarmSensorDevice } from './ElkAlarmSensorDevice';
|
|
6
|
-
|
|
7
|
-
/////////////////////////////
|
|
8
|
-
// ELKAlarmPanelDevice
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
export class ELKAlarmPanelDevice extends ISYDevice<Family.Elk> {
|
|
12
|
-
|
|
13
|
-
public alarmTripState: AlarmTripState;
|
|
14
|
-
public alarmState: AlarmState;
|
|
15
|
-
public alarmMode: AlarmMode;
|
|
16
|
-
public area: number;
|
|
17
|
-
|
|
18
|
-
public deviceFriendlyName: string;
|
|
19
|
-
public deviceType: any;
|
|
20
|
-
public connectionType: string;
|
|
21
|
-
public batteryOperated: boolean;
|
|
22
|
-
public voltage: number;
|
|
23
|
-
|
|
24
|
-
constructor(isy: ISY, area: number) {
|
|
25
|
-
|
|
26
|
-
super(isy, { family: Family.Elk, type: '0.0.0.0', enabled: true, address: `ElkAlarmPanel_${area}`, name: `Elk Alarm Panel ${area}` });
|
|
27
|
-
|
|
28
|
-
this.area = area;
|
|
29
|
-
this.alarmTripState = AlarmTripState.DISARMED;
|
|
30
|
-
this.alarmState = AlarmState.NOT_READY_TO_ARM;
|
|
31
|
-
this.alarmMode = AlarmMode.DISARMED;
|
|
32
|
-
|
|
33
|
-
this.deviceFriendlyName = 'Elk Alarm Panel ' + area;
|
|
34
|
-
|
|
35
|
-
this.connectionType = 'Elk Network Module';
|
|
36
|
-
this.batteryOperated = false;
|
|
37
|
-
this.voltage = 71;
|
|
38
|
-
this
|
|
39
|
-
.lastChanged = new Date();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public async sendCommand(command: string): Promise<any> {
|
|
43
|
-
|
|
44
|
-
return this.isy.sendISYCommand(`elk/area/${this.area}/cmd/${command}`);
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public async sendSetAlarmModeCommand(alarmMode: string) {
|
|
49
|
-
if (alarmMode === 'disarm') {
|
|
50
|
-
return this.sendCommand('disarm');
|
|
51
|
-
} else {
|
|
52
|
-
return this.sendCommand(`arm?armType=${alarmMode}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
public async clearAllBypasses() {
|
|
56
|
-
return this.sendCommand('unbypass');
|
|
57
|
-
}
|
|
58
|
-
public getAlarmStatusAsText() {
|
|
59
|
-
return `AM [${this.alarmMode}] AS [${this.alarmState}] ATS [${this.alarmTripState}]`;
|
|
60
|
-
}
|
|
61
|
-
public getAlarmTripState() {
|
|
62
|
-
return this.alarmTripState;
|
|
63
|
-
}
|
|
64
|
-
public getAlarmState() {
|
|
65
|
-
return this.alarmState;
|
|
66
|
-
}
|
|
67
|
-
public getAlarmMode() {
|
|
68
|
-
return this.alarmMode;
|
|
69
|
-
}
|
|
70
|
-
public handleEvent(event: { control?: string; data?: any; node?: any; eventInfo?: any; }) {
|
|
71
|
-
const areaUpdate = event.eventInfo.ae;
|
|
72
|
-
const areaId = areaUpdate.attr.area;
|
|
73
|
-
const updateType = areaUpdate.attr.type;
|
|
74
|
-
const valueToSet = Number(areaUpdate.attr.val);
|
|
75
|
-
let valueChanged = false;
|
|
76
|
-
if (areaId === this.area) {
|
|
77
|
-
if (updateType === AlarmPanelProperty.AlarmTripState) {
|
|
78
|
-
if (this.alarmTripState !== valueToSet) {
|
|
79
|
-
const oldVal = this.alarmTripState;
|
|
80
|
-
this.alarmTripState = valueToSet;
|
|
81
|
-
this.emit('PropertyChanged', 'alarmTripState', this.alarmTripState, oldVal, AlarmTripState[this.alarmTripState]);
|
|
82
|
-
valueChanged = true;
|
|
83
|
-
}
|
|
84
|
-
} else if (updateType === AlarmPanelProperty.AlarmState) {
|
|
85
|
-
if (this.alarmState !== valueToSet) {
|
|
86
|
-
const oldVal = this.alarmState;
|
|
87
|
-
this.alarmState = valueToSet;
|
|
88
|
-
this.emit('PropertyChanged', 'alarmState', this.alarmState, oldVal, AlarmState[this.alarmState]);
|
|
89
|
-
valueChanged = true;
|
|
90
|
-
}
|
|
91
|
-
} else if (updateType === AlarmPanelProperty.AlarmMode) {
|
|
92
|
-
if (this.alarmMode !== valueToSet) {
|
|
93
|
-
const oldVal = this.alarmMode;
|
|
94
|
-
this.alarmMode = valueToSet;
|
|
95
|
-
this.emit('PropertyChanged', 'alarmMode', this.alarmState, oldVal, AlarmMode[this.alarmMode]);
|
|
96
|
-
valueChanged = true;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (valueChanged) {
|
|
101
|
-
this.lastChanged = new Date();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return valueChanged;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export enum AlarmPanelProperty {
|
|
110
|
-
AlarmMode = 3,
|
|
111
|
-
AlarmState = 2,
|
|
112
|
-
AlarmTripState = 1
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export enum AlarmMode {
|
|
116
|
-
DISARMED = 0,
|
|
117
|
-
AWAY = 1,
|
|
118
|
-
STAY = 2,
|
|
119
|
-
STAY_INSTANT = 3,
|
|
120
|
-
NIGHT = 4,
|
|
121
|
-
NIGHT_INSTANT = 5,
|
|
122
|
-
VACATION = 6
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export enum AlarmTripState {
|
|
126
|
-
DISARMED = 0,
|
|
127
|
-
EXIT_DELAY = 1,
|
|
128
|
-
TRIPPED = 2
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export enum AlarmState {
|
|
133
|
-
NOT_READY_TO_ARM = 0,
|
|
134
|
-
READY_TO_ARM = 1,
|
|
135
|
-
READY_TO_ARM_VIOLATION = 2,
|
|
136
|
-
ARMED_WITH_TIMER = 3,
|
|
137
|
-
ARMED_FULLY = 4,
|
|
138
|
-
FORCE_ARMED_VIOLATION = 5,
|
|
139
|
-
ARMED_WITH_BYPASS = 6
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Alarm mode constanrs
|
|
144
|
-
ELKAlarmPanelDevice.prototype.ALARM_MODE_DISARMED = 0;
|
|
145
|
-
ELKAlarmPanelDevice.prototype.ALARM_MODE_AWAY = 1;
|
|
146
|
-
ELKAlarmPanelDevice.prototype.ALARM_MODE_STAY = 2;
|
|
147
|
-
ELKAlarmPanelDevice.prototype.ALARM_MODE_STAY_INSTANT = 3;
|
|
148
|
-
ELKAlarmPanelDevice.prototype.ALARM_MODE_NIGHT = 4;
|
|
149
|
-
ELKAlarmPanelDevice.prototype.ALARM_MODE_NIGHT_INSTANT = 5;
|
|
150
|
-
ELKAlarmPanelDevice.prototype.ALARM_MODE_VACATION = 6;
|
|
151
|
-
|
|
152
|
-
// Alarm trip state
|
|
153
|
-
ELKAlarmPanelDevice.prototype.ALARM_TRIP_STATE_DISARMED = 0;
|
|
154
|
-
ELKAlarmPanelDevice.prototype.ALARM_TRIP_STATE_EXIT_DELAY = 1;
|
|
155
|
-
ELKAlarmPanelDevice.prototype.ALARM_TRIP_STATE_TRIPPED = 2;
|
|
156
|
-
|
|
157
|
-
// Alarm state
|
|
158
|
-
ELKAlarmPanelDevice.prototype.ALARM_STATE_NOT_READY_TO_ARM = 0;
|
|
159
|
-
ELKAlarmPanelDevice.prototype.ALARM_STATE_READY_TO_ARM = 1;
|
|
160
|
-
ELKAlarmPanelDevice.prototype.ALARM_STATE_READY_TO_ARM_VIOLATION = 2;
|
|
161
|
-
ELKAlarmPanelDevice.prototype.ALARM_STATE_ARMED_WITH_TIMER = 3;
|
|
162
|
-
ELKAlarmPanelDevice.prototype.ALARM_STATE_ARMED_FULLY = 4;
|
|
163
|
-
ELKAlarmPanelDevice.prototype.ALARM_STATE_FORCE_ARMED_VIOLATION = 5;
|
|
164
|
-
ELKAlarmPanelDevice.prototype.ALARM_STATE_ARMED_WITH_BYPASS = 6;
|
|
165
|
-
|
|
166
|
-
// Logical Status for sensors
|
|
167
|
-
export enum AlarmSensorPhysicalState {
|
|
168
|
-
NOT_CONFIGURED = 0,
|
|
169
|
-
OPEN = 1,
|
|
170
|
-
EOL = 2,
|
|
171
|
-
SHORT = 3
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
ElkAlarmSensorDevice.prototype.SENSOR_STATE_PHYSICAL_NOT_CONFIGURED = 0;
|
|
175
|
-
ElkAlarmSensorDevice.prototype.SENSOR_STATE_PHYSICAL_OPEN = 1;
|
|
176
|
-
ElkAlarmSensorDevice.prototype.SENSOR_STATE_PHYSICAL_EOL = 2;
|
|
177
|
-
ElkAlarmSensorDevice.prototype.SENSOR_STATE_PHYSICAL_SHORT = 3;
|
|
178
|
-
|
|
179
|
-
export enum AlarmSensorLogicalState {
|
|
180
|
-
NORMAL = 0,
|
|
181
|
-
TROUBLE = 1,
|
|
182
|
-
VIOLATED = 2,
|
|
183
|
-
BYPASSED = 3
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Physical status for sensors
|
|
187
|
-
ElkAlarmSensorDevice.prototype.SENSOR_STATE_LOGICAL_NORMAL = 0;
|
|
188
|
-
ElkAlarmSensorDevice.prototype.SENSOR_STATE_LOGICAL_TROUBLE = 1;
|
|
189
|
-
ElkAlarmSensorDevice.prototype.SENSOR_STATE_LOGICAL_VIOLATED = 2;
|
|
190
|
-
ElkAlarmSensorDevice.prototype.SENSOR_STATE_LOGICAL_BYPASSED = 3;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { Family } from '../../Families';
|
|
2
|
-
import { ISY } from '../../ISY';
|
|
3
|
-
import { ISYDevice } from '../ISYDevice';
|
|
4
|
-
import { AlarmSensorPhysicalState, AlarmSensorLogicalState } from './ElkAlarmPanelDevice';
|
|
5
|
-
/////////////////////////////
|
|
6
|
-
// ELKAlarmSensor
|
|
7
|
-
//
|
|
8
|
-
export class ElkAlarmSensorDevice extends ISYDevice<Family.Elk> {
|
|
9
|
-
public area: number;
|
|
10
|
-
public zone: string;
|
|
11
|
-
public deviceFriendlyName: string;
|
|
12
|
-
public deviceType: any;
|
|
13
|
-
public connectionType: string;
|
|
14
|
-
public batteryOperated: boolean;
|
|
15
|
-
public physicalState: AlarmSensorPhysicalState;
|
|
16
|
-
public logicalState: AlarmSensorLogicalState;
|
|
17
|
-
public voltage: number;
|
|
18
|
-
constructor (isy: ISY, name: string, area: number, zone: string) {
|
|
19
|
-
super(isy, { family: Family.Elk, name, address: `ElkZone_${zone}`, enabled: true });
|
|
20
|
-
this.area = area;
|
|
21
|
-
this.zone = zone;
|
|
22
|
-
// this.name = name;
|
|
23
|
-
// this.address = "ElkZone" + zone;
|
|
24
|
-
this.displayName = `Elk Connected Sensor ${zone}`;
|
|
25
|
-
this.deviceFriendlyName = `Elk Connected Sensor ${zone}`;
|
|
26
|
-
this.connectionType = 'Elk Network';
|
|
27
|
-
this.batteryOperated = false;
|
|
28
|
-
this.physicalState = AlarmSensorPhysicalState.NOT_CONFIGURED;
|
|
29
|
-
this.logicalState = AlarmSensorLogicalState.NORMAL;
|
|
30
|
-
this.lastChanged = new Date();
|
|
31
|
-
}
|
|
32
|
-
public async sendCommand(command: string): Promise<any> {
|
|
33
|
-
return this.isy.sendISYCommand(`elk/zone/${this.zone}/cmd/${command}`);
|
|
34
|
-
}
|
|
35
|
-
public async sendBypassToggleCommand() {
|
|
36
|
-
return this.sendCommand(`toggle/bypass`);
|
|
37
|
-
}
|
|
38
|
-
public getPhysicalState() {
|
|
39
|
-
return this.physicalState;
|
|
40
|
-
}
|
|
41
|
-
public isBypassed() {
|
|
42
|
-
return (this.logicalState === 3);
|
|
43
|
-
}
|
|
44
|
-
public getLogicalState() {
|
|
45
|
-
return this.logicalState;
|
|
46
|
-
}
|
|
47
|
-
public getCurrentDoorWindowState() {
|
|
48
|
-
return (this.physicalState === this.SENSOR_STATE_PHYSICAL_OPEN || this.logicalState === this.SENSOR_STATE_LOGICAL_VIOLATED);
|
|
49
|
-
}
|
|
50
|
-
public getSensorStatus() {
|
|
51
|
-
return 'PS [' + this.physicalState + '] LS [' + this.logicatState + ']';
|
|
52
|
-
}
|
|
53
|
-
public isPresent() {
|
|
54
|
-
if (this.voltage < 65 || this.voltage > 80) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
public handleEvent(event: {
|
|
62
|
-
control?: string;
|
|
63
|
-
data?: any;
|
|
64
|
-
node?: any;
|
|
65
|
-
eventInfo?: any;
|
|
66
|
-
}) {
|
|
67
|
-
const zoneUpdate = event.eventInfo.ze;
|
|
68
|
-
const zone = zoneUpdate.attr.zone;
|
|
69
|
-
const updateType = zoneUpdate.attr.type;
|
|
70
|
-
const valueToSet = zoneUpdate.attr.val;
|
|
71
|
-
let valueChanged = false;
|
|
72
|
-
if (zone === this.zone) {
|
|
73
|
-
if (updateType === 51) {
|
|
74
|
-
if (this.logicalState !== valueToSet) {
|
|
75
|
-
const temp = this.logicalState;
|
|
76
|
-
this.logicalState = valueToSet;
|
|
77
|
-
this.emit('PropertyChanged', 'logicalState', this.logicalState, temp, this.voltage.toString());
|
|
78
|
-
// Not triggering change update on logical state because physical always follows and don't want double notify.
|
|
79
|
-
// valueChanged = true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else if (updateType === 52) {
|
|
83
|
-
if (this.physicalState !== valueToSet) {
|
|
84
|
-
const temp = this.physicalState;
|
|
85
|
-
this.physicalState = valueToSet;
|
|
86
|
-
this.emit('PropertyChanged', 'physicalState', this.physicalState, temp, this.voltage.toString());
|
|
87
|
-
valueChanged = true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else if (updateType === 53) {
|
|
91
|
-
if (this.voltage !== valueToSet) {
|
|
92
|
-
const temp = this.voltage;
|
|
93
|
-
this.voltage = valueToSet;
|
|
94
|
-
this.emit('PropertyChanged', 'voltage', this.voltage, temp, this.voltage.toString());
|
|
95
|
-
valueChanged = true;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (valueChanged) {
|
|
100
|
-
this.lastChanged = new Date();
|
|
101
|
-
}
|
|
102
|
-
return valueChanged;
|
|
103
|
-
}
|
|
104
|
-
}
|