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
package/test/testsuite.js DELETED
@@ -1,607 +0,0 @@
1
- // MOCHA TEST SUITE
2
- // Designed to work against a fake-isy-994i server (see github.com/rodtoll/fake-isy-994i). Will not run unmodified against a real server as test devices
3
- // won't be found on that server AND real servers can't have their state reset.
4
- //
5
- var restler = require('restler');
6
- var assert = require('assert');
7
- var ISY = require('../isy.js').ISY;
8
- var ISYLightDevice = require('../isydevice').ISYLightDevice;
9
- var ISYLockDevice = require('../isydevice').ISYLockDevice;
10
- var ISYOutletDevice = require('../isydevice').ISYOutletDevice;
11
- var ISYDoorWindowDevice = require('../isydevice').ISYDoorWindowDevice;
12
- var ISYFanDevice = require('../isydevice').ISYFanDevice;
13
- var ISYMotionSensorDevice = require('../isydevice').ISYMotionSensorDevice;
14
- var ISYScene = require('../isyscene').ISYScene;
15
- var ELKAlarmPanelDevice = require('../elkdevice').ELKAlarmPanelDevice;
16
- var ElkAlarmSensor = require('../elkdevice').ElkAlarmSensor;
17
- var ISYBaseDevice = require('../isydevice').ISYBaseDevice;
18
-
19
- var expectedDeviceCountWithElkWithScenes = 228;
20
- var expectedDeviceCountWithElkNoScenes = 179;
21
- var expectedDeviceCountWithoutElkWithScenes = 194;
22
- var expectedDeviceCountWithoutElkNoScenes = 145;
23
- var expectedDimmableLightCount = 78;
24
- var expectedLightCount = 102;
25
- var expectedLockCount = 3;
26
- var expectedDoorWindowCount = 7;
27
- var expectedMotionCount = 5;
28
- var expectedFanCount = 3;
29
- var expectedOutletCount = 4;
30
- var expectedSceneCount = 49;
31
- var expectedElkAlarmCount = 0;
32
- var expectedElkSensorCount = 34;
33
- var expectedGenericCount = 21;
34
- var expectedType1VariablesCount = 25;
35
- var expectedType2VariablesCount = 32;
36
- var sampleType1VariableId = '1';
37
- var sampleType1VariableName = 'OfficeMotionEnabled';
38
- var sampleType2VariableName = 'AlarmFrontDoorOpen';
39
- var sampleType2VariableId = '1';
40
- var sampleElkZone = 'ElkZone22';
41
- var sampleSceneId = '12627';
42
- var sampleDimmableLight = '33 9B DC 1';
43
- var sampleKeypadDimmableButton = '2B 99 34 8';
44
- var sampleZWaveLock = 'ZW002_1';
45
- var sampleMotionSensorSensor = '21 62 43 1';
46
- var sampleMorningLincLock = '29 3D E2 1';
47
- var sampleIOLincSensor = '17 79 81 1';
48
- var sampleFanLincFan = '14 A6 C5 2';
49
- var sampleFanLincLight = '14 A7 12 1';
50
- var sampleFanLincFanOffState = '14 A8 BC 2';
51
- var sampleOutletLinc = '19 C0 E4 1';
52
- var sampleDisabledDevice = '1F 42 F7 1';
53
- var sampleApplianceLinc = '1F 46 F0 1';
54
- var sampleOnOffLight = '18 36 B1 1';
55
- var sampleLightFromMotionLightKit = '17 15 6A 1';
56
- var sampleDoorWindowSensor = '14 47 41 1';
57
- var sampleSceneWithAllLightsOff = '27346';
58
- var sampleGenericDevice = '14 5C B2 2';
59
- var sampleSceneWithAllLightsOffAllImpacted = ['18 12 18 1', '19 53 90 1', /* The Scene itself */ '27346'];
60
- var testServerAddress = '127.0.0.1:3000';
61
- var testServerUserName = 'admin';
62
- var testServerPassword = 'password';
63
-
64
- var sampleBaseDeviceList = [
65
- {address: sampleDimmableLight, type: 'DimmableLight'},
66
- {address: sampleKeypadDimmableButton, type: 'DimmableLight'},
67
- {address: sampleZWaveLock, type: 'SecureLock'},
68
- {address: sampleMotionSensorSensor, type: 'MotionSensor'},
69
- {address: sampleMorningLincLock, type: 'DoorLock'},
70
- {address: sampleIOLincSensor, type: 'DoorWindowSensor'},
71
- {address: sampleFanLincFan, type: 'Fan'},
72
- {address: sampleFanLincLight, type: 'DimmableLight'},
73
- {address: sampleOutletLinc, type: 'Light'},
74
- {address: sampleOnOffLight, type: 'Light'},
75
- {address: sampleApplianceLinc, type: 'Outlet'},
76
- {address: sampleLightFromMotionLightKit, type: 'Light'},
77
- {address: sampleDoorWindowSensor, type: 'DoorWindowSensor'},
78
- {address: sampleGenericDevice, type: 'Unknown'}
79
- ];
80
-
81
- function countDevices(done, elkEnabled, scenesEnabled) {
82
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, true, function() {}, false, true);
83
- assert.doesNotThrow(function() {
84
- isy.initialize(function() {
85
- var deviceList = isy.getDeviceList();
86
- var lightCount = 0;
87
- var lockCount = 0;
88
- var doorWindowCount = 0;
89
- var motionCount = 0;
90
- var fanCount = 0;
91
- var outletCount = 0;
92
- var sceneCount = 0;
93
- var elkAlarmCount = 0;
94
- var elkSensorCount = 0;
95
- var genericCount = 0;
96
- var dimmableLightCount = 0;
97
- for(var deviceIndex = 0; deviceIndex < deviceList.length; deviceIndex++) {
98
- var device = deviceList[deviceIndex];
99
- assert(device.address != sampleDisabledDevice, 'Should not enumerate a disabled device');
100
- if(device instanceof ISYLightDevice) {
101
- lightCount++;
102
- if(device.isDimmable) {
103
- dimmableLightCount++;
104
- }
105
- } else if(device instanceof ISYLockDevice) {
106
- lockCount++;
107
- } else if(device instanceof ISYOutletDevice) {
108
- outletCount++;
109
- } else if(device instanceof ISYDoorWindowDevice) {
110
- doorWindowCount++;
111
- } else if(device instanceof ISYFanDevice) {
112
- fanCount++;
113
- } else if(device instanceof ISYMotionSensorDevice) {
114
- motionCount++;
115
- } else if(device instanceof ISYScene) {
116
- sceneCount++;
117
- } else if(device instanceof ELKAlarmPanelDevice) {
118
- elkAlarmCount++;
119
- } else if(device instanceof ElkAlarmSensor) {
120
- elkSensorCount++;
121
- } else if(device instanceof ISYBaseDevice) {
122
- genericCount++;
123
- }
124
- }
125
- assert.equal(lightCount, expectedLightCount, "Light count is incorrect");
126
- assert.equal(lockCount, expectedLockCount, "Lock count incorrect");
127
- assert.equal(doorWindowCount, expectedDoorWindowCount, "Door window sensor count is incorrect");
128
- assert.equal(motionCount, expectedMotionCount, "Motion sensor count is incorrect");
129
- assert.equal(fanCount, expectedFanCount, "Fan count is incorrect");
130
- assert.equal(outletCount, expectedOutletCount, "Outlet count is incorrect");
131
- assert.equal(sceneCount, (scenesEnabled) ? expectedSceneCount : 0, "Scene count is incorrect");
132
- assert.equal(elkAlarmCount, (elkEnabled) ? expectedElkAlarmCount : 0, "Elk alarm panel count is incorrect");
133
- assert.equal(elkSensorCount, (elkEnabled) ? expectedElkSensorCount : 0, "Elk sensor count is incorrect");
134
- assert.equal(genericCount, expectedGenericCount, 'Generic device count is incorrect');
135
- assert.equal(dimmableLightCount, expectedDimmableLightCount, 'Dimmable light count is incorrect');
136
- var panel = isy.getElkAlarmPanel();
137
- if(elkEnabled) {
138
- assert(panel instanceof ELKAlarmPanelDevice, "Should have a panel");
139
- } else {
140
- assert(panel == null, "Should have no panel when elk disabled");
141
- }
142
- if(scenesEnabled) {
143
- assert.equal(isy.getSceneList().length, sceneCount, 'Should have scenes in the scene list');
144
- }
145
- done();
146
- });
147
- });
148
- }
149
-
150
- function checkDevice(testParam, device) {
151
- assert(device != null && device != undefined, 'Should have found the specified device for address '+testParam.address);
152
- assert.equal(device.address, testParam.address, 'Should have expected address for address '+testParam.address);
153
- assert.equal(device.deviceType, testParam.type, 'Should have expected type for address '+testParam.address);
154
-
155
- }
156
-
157
- function checkForExpectedDevices(done, elkEnabled, scenesEnabled) {
158
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, true, function() {}, false, true);
159
- assert.doesNotThrow(function() {
160
- isy.initialize(function() {
161
- for(var addressIndex = 0; addressIndex < sampleBaseDeviceList.length; addressIndex++) {
162
- checkDevice(sampleBaseDeviceList[addressIndex], isy.getDevice(sampleBaseDeviceList[addressIndex].address));
163
- }
164
- if(elkEnabled) {
165
- checkDevice({address: sampleElkZone, type: 'AlarmDoorWindowSensor'}, isy.getDevice(sampleElkZone));
166
- }
167
- if(scenesEnabled) {
168
- checkDevice({address: sampleSceneId, type: 'Scene'}, isy.getDevice(sampleSceneId));
169
- }
170
- if(!elkEnabled) {
171
- assert(isy.getDevice(sampleElkZone)==null, "Elk disabled, shouldn't have an elk device");
172
- }
173
- if(!scenesEnabled) {
174
- assert(isy.getDevice(sampleSceneId)==null, 'Scenes disabled should not have scene in device list');
175
- }
176
- done();
177
- });
178
- });
179
- }
180
-
181
- function resetServerState(done) {
182
- restler.get('http://'+testServerAddress+'/config/reset').on('complete', function(result, response) { done(); });
183
- }
184
-
185
- function setVariableFailureMode(shouldFail,done) {
186
- restler.get('http://'+testServerAddress+'/config/failVariableCalls/'+shouldFail.toString()).on('complete', function(result, response) { done(); });
187
- }
188
-
189
- // Used to send set to on command for sensors. Doesn't work on real ISY.
190
- function sendServerOnCommand(isy, deviceAddress,done) {
191
- isy.sendRestCommand(deviceAddress, 'DON', null, function() { done(); });
192
- }
193
-
194
- function sendServerZoneCommand(isy, zoneId, command, done) {
195
- isy.sendRestCommand(zoneId, command, null, function() { done(); });
196
- }
197
-
198
- describe('ISY Device and scene Enumeration and Creation', function() {
199
- describe('Device enumeration (scenes=true,elk=true)', function() {
200
- it('Basic startup should work and right number of devices should be enumerated ', function(done) {
201
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, true, function() {}, false, true);
202
- assert.doesNotThrow(function() {
203
- isy.initialize(function() {
204
- assert.equal(isy.getDeviceList().length, expectedDeviceCountWithElkWithScenes, 'Device count incorrect');
205
- done();
206
- });
207
- });
208
- });
209
- it('Right device count and types are present', function(done) {
210
- countDevices(done,true,true);
211
- });
212
- it('Device lookup works and expected variety of devices present', function(done) {
213
- checkForExpectedDevices(done,true,true);
214
- });
215
- });
216
- describe('Device enumeration(scenes=true,elk=false)', function() {
217
- it('Basic startup should work and right number of devices should be enumerated ', function(done) {
218
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, false, function() {}, false, true);
219
- assert.doesNotThrow(function() {
220
- isy.initialize(function() {
221
- assert.equal(isy.getDeviceList().length, expectedDeviceCountWithoutElkWithScenes, 'Device count incorrect');
222
- done();
223
- });
224
- });
225
- });
226
- it('Right device count and types are present', function(done) {
227
- countDevices(done,true,true);
228
- });
229
- it('Device lookup works and expected variety of devices present', function(done) {
230
- checkForExpectedDevices(done,true,true);
231
- });
232
- });
233
- describe('Device enumeration (scenes=false,elk=false)', function() {
234
- it('Basic startup should work and right number of devices should be enumerated ', function(done) {
235
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, false, function() {}, false, false);
236
- assert.doesNotThrow(function() {
237
- isy.initialize(function() {
238
- assert.equal(isy.getDeviceList().length, expectedDeviceCountWithoutElkNoScenes, 'Device count incorrect');
239
- done();
240
- });
241
- });
242
- });
243
- it('Right device count and types are present', function(done) {
244
- countDevices(done,true,true);
245
- });
246
- it('Device lookup works and expected variety of devices present', function(done) {
247
- checkForExpectedDevices(done,true,true);
248
- });
249
- });
250
- describe('Device enumeration (scenes=false,elk=true)', function() {
251
- it('Basic startup should work and right number of devices should be enumerated ', function(done) {
252
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, true, function() {}, false, false);
253
- assert.doesNotThrow(function() {
254
- isy.initialize(function() {
255
- assert.equal(isy.getDeviceList().length, expectedDeviceCountWithElkNoScenes, 'Device count incorrect');
256
- done();
257
- });
258
- });
259
- });
260
- it('Right device count and types are present', function(done) {
261
- countDevices(done,true,true);
262
- });
263
- it('Device lookup works and expected variety of devices present', function(done) {
264
- checkForExpectedDevices(done,true,true);
265
- });
266
- });
267
- describe('#check scene indexing', function() {
268
- it('Basic scene lookup', function(done) {
269
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, true, function() {}, false, false);
270
- assert.doesNotThrow(function() {
271
- isy.initialize(function() {
272
- assert.equal(isy.getSceneList().length, expectedSceneCount, 'Scene count incorrect');
273
- assert(isy.getScene(sampleSceneId) instanceof ISYScene, 'Scene lookup working');
274
- assert.equal(isy.getScene(sampleSceneId).address, sampleSceneId, 'The right scene object is returned' )
275
- done();
276
- });
277
- });
278
- });
279
- });
280
- });
281
-
282
- function runTrueFalseTest(isy, deviceId, stateFunctionToTest, sendFunctionToTest, done) {
283
- var deviceToCheck = isy.getDevice(deviceId);
284
- var startingChangedTimestamp = deviceToCheck.lastChanged;
285
- var stateToExpect = !deviceToCheck[stateFunctionToTest]();
286
- var testRunIndex = 0;
287
- isy.changeCallback = function (isy, changedDevice) {
288
- if(changedDevice.address == deviceToCheck.address) {
289
- assert.equal(stateToExpect, deviceToCheck[stateFunctionToTest](), 'Should have expected state for device: '+deviceToCheck.address);
290
- assert(changedDevice.lastChanged > startingChangedTimestamp, 'lastChanged property should have changed.')
291
- if(testRunIndex == 0) {
292
- stateToExpect = !deviceToCheck[stateFunctionToTest]();
293
- deviceToCheck[sendFunctionToTest](stateToExpect, function() {});
294
- testRunIndex++;
295
- } else {
296
- done();
297
- }
298
- }
299
- }
300
- deviceToCheck[sendFunctionToTest](stateToExpect, function() {});
301
- }
302
-
303
- function runFanTest(isy, deviceId, fanSpeed, done) {
304
- var deviceToCheck = isy.getDevice(deviceId);
305
- var startingChangedTimestamp = deviceToCheck.lastChanged;
306
- isy.changeCallback = function (isy, changedDevice) {
307
- if (deviceId == changedDevice.address) {
308
- assert.equal(fanSpeed, deviceToCheck.getCurrentFanState(), 'Should have expected fan speed for device: ' + deviceToCheck.address);
309
- assert(changedDevice.lastChanged > startingChangedTimestamp, 'lastChanged property should have changed.')
310
- done();
311
- }
312
- }
313
- deviceToCheck.sendFanCommand(fanSpeed, function () {});
314
- }
315
-
316
-
317
- function runSensorTest(isy, deviceId, stateFunctionToTest, done) {
318
- var deviceToCheck = isy.getDevice(deviceId);
319
- var startingChangedDate = deviceToCheck.lastChanged;
320
- isy.changeCallback = function (isy, changedDevice) {
321
- if(changedDevice.address == deviceToCheck.address) {
322
- assert(deviceToCheck[stateFunctionToTest](), 'Sensor should show true state: '+deviceToCheck.address);
323
- assert(deviceToCheck.lastChanged > startingChangedDate, 'Sesnor last changed data should have updated');
324
- done();
325
- }
326
- }
327
- sendServerOnCommand(isy, deviceId, function() {});
328
- }
329
-
330
- function runSceneTest(isy, sceneId, lightStateToSet, impactedDeviceList, done) {
331
- var sceneToCheck = isy.getDevice(sceneId);
332
- var startingChangedDate = sceneToCheck.lastChanged;
333
- var devicesToCheck = [];
334
- var doneCalled = false;
335
- for(var index = 0; index < impactedDeviceList.length; index++) {
336
- devicesToCheck.push(impactedDeviceList[index]);
337
- }
338
- isy.changeCallback = function (isy,changedDevice) {
339
- for(var deviceIndex = 0; deviceIndex < devicesToCheck.length; deviceIndex++) {
340
- if(devicesToCheck[deviceIndex] == changedDevice.address) {
341
- if(sceneToCheck.address != devicesToCheck[deviceIndex]) {
342
- assert.equal(changedDevice.getCurrentLightState(), lightStateToSet, "Should be setting devices to the state we expect");
343
- }
344
- devicesToCheck.splice(deviceIndex, 1);
345
- break;
346
- }
347
- }
348
- if(devicesToCheck.length == 0) {
349
- if(!doneCalled) {
350
- assert.equal(sceneToCheck.getCurrentLightState(), lightStateToSet, 'Scene should now be set to the desired state');
351
- assert(sceneToCheck.getAreAllLightsInSpecifiedState(lightStateToSet), "Once all lights are accounted for getAreAllLightsInSpecifiedState() should be true" );
352
- assert(sceneToCheck.lastChanged > startingChangedDate, 'Scene last changed data should have updated');
353
- done();
354
- doneCalled = true;
355
- }
356
- } else if (devicesToCheck.length > 1) {
357
- assert(!sceneToCheck.getAreAllLightsInSpecifiedState(lightStateToSet), "Until all lights are accounted for getAreAllLightsInSpecifiedState() should be false" );
358
- }
359
- }
360
- sceneToCheck.sendLightCommand(lightStateToSet, function() {});
361
- }
362
-
363
- function runElkZoneTest(isy, zoneId, command, expectedCount, expectedResult, stateFunctionToTest, done) {
364
- var callbackCount = 0;
365
- var deviceId = "ElkZone"+zoneId;
366
- var deviceToCheck = isy.getDevice(deviceId);
367
- var startingChangedTimestamp = new Date();
368
- isy.changeCallback = function (isy, changedDevice) {
369
- if(changedDevice.address == deviceToCheck.address) {
370
- callbackCount++;
371
- if(callbackCount == expectedCount) {
372
- assert.equal(deviceToCheck[stateFunctionToTest](), expectedResult, 'Elk Sensor should show expected state: '+deviceToCheck.address);
373
- assert(deviceToCheck.lastChanged > startingChangedTimestamp, 'lastChanged property should have changed.')
374
- done();
375
- }
376
- }
377
- }
378
- sendServerZoneCommand(isy, zoneId, command, function() {});
379
- }
380
-
381
-
382
- describe('ISY Device change notifications', function() {
383
- var notifyFunc = null;
384
- function testChangeCallback(isy,device) {
385
- if(notifyFunc != null) {
386
- notifyFunc(device);
387
- }
388
- }
389
- var isy = null;
390
- beforeEach(function(done) {
391
- resetServerState(function() {
392
- isy = new ISY(testServerAddress, testServerUserName, testServerPassword, true, testChangeCallback, false, true);
393
- isy.initialize(done);
394
- });
395
- });
396
- describe('Dimmable light change notifications', function() {
397
- it('Light on and off state (non-dimmable)', function(done) {
398
- runTrueFalseTest(isy, sampleOnOffLight, 'getCurrentLightState', 'sendLightCommand', done);
399
- assert(!isy.getDevice(sampleOnOffLight).isDimmable, 'On off light should not be dimmable');
400
- });
401
- it('Light on and off state (dimmable)', function(done) {
402
- runTrueFalseTest(isy, sampleDimmableLight, 'getCurrentLightState', 'sendLightCommand', done);
403
- assert(isy.getDevice(sampleDimmableLight).isDimmable, 'On off light should not be dimmable');
404
- });
405
- it('Light on and off state (keybad dimmable button)', function(done) {
406
- runTrueFalseTest(isy, sampleKeypadDimmableButton, 'getCurrentLightState', 'sendLightCommand', done);
407
- });
408
- it('Light on and off state (fanlinc light)', function(done) {
409
- runTrueFalseTest(isy, sampleKeypadDimmableButton, 'getCurrentLightState', 'sendLightCommand', done);
410
- });
411
- it('Light on and off state (motion light)', function(done) {
412
- runTrueFalseTest(isy, sampleKeypadDimmableButton, 'getCurrentLightState', 'sendLightCommand', done);
413
- });
414
- it('Light dim state change notification to 50%', function(done) {
415
- var deviceToCheck = isy.getDevice(sampleDimmableLight);
416
- var dimStateToExpect = 50;
417
- deviceToCheck.sendLightCommand(false, function() {});
418
- notifyFunc = function (changedDevice) {
419
- if(changedDevice.address == deviceToCheck.address) {
420
- assert.equal(dimStateToExpect, deviceToCheck.getCurrentLightDimState(), 'Should have expected state for device: '+deviceToCheck.address);
421
- assert(deviceToCheck.getCurrentLightState(), 'Ensure light is on');
422
- done();
423
- }
424
- }
425
- deviceToCheck.sendLightDimCommand(dimStateToExpect, function() {});
426
- });
427
-
428
- it('Light dim state change notification to on has 100 dim level', function(done) {
429
- var deviceToCheck = isy.getDevice(sampleDimmableLight);
430
- notifyFunc = function (changedDevice) {
431
- if(changedDevice.address == deviceToCheck.address) {
432
- assert.equal(100, deviceToCheck.getCurrentLightDimState(), 'Should have expected state for device: '+deviceToCheck.address);
433
- assert(deviceToCheck.getCurrentLightState(), 'Ensure light is on');
434
- done();
435
- }
436
- }
437
- deviceToCheck.sendLightCommand(true, function() {});
438
- });
439
- it('Light dim state change notification to off has 0 dim level', function(done) {
440
- var deviceToCheck = isy.getDevice(sampleDimmableLight);
441
- var notifyCount = 0;
442
- notifyFunc = function (changedDevice) {
443
- if(changedDevice.address == deviceToCheck.address) {
444
- // Need to skip first notification as it is to turn the light on
445
- if(notifyCount > 0) {
446
- assert.equal(0, deviceToCheck.getCurrentLightDimState(), 'Should have expected state for device: '+deviceToCheck.address);
447
- assert(!deviceToCheck.getCurrentLightState(), 'Ensure light is on');
448
- done();
449
- } else {
450
- notifyCount++;
451
- }
452
- }
453
- }
454
- // Need to turn it on first as default state for this light is off
455
- deviceToCheck.sendLightCommand(true, function() {});
456
- deviceToCheck.sendLightCommand(false, function() {});
457
- });
458
- });
459
- describe('Locks', function() {
460
- it('Secure Lock locked and unlocked state', function(done) {
461
- runTrueFalseTest(isy, sampleZWaveLock, 'getCurrentLockState', 'sendLockCommand', done);
462
- });
463
- it('MorningLinc Lock locked and unlocked state', function(done) {
464
- runTrueFalseTest(isy, sampleMorningLincLock, 'getCurrentLockState', 'sendLockCommand', done);
465
- });
466
- });
467
- describe('Sensors', function() {
468
- it('Insteon Motion Sensor Triggered', function(done) {
469
- runSensorTest(isy, sampleMotionSensorSensor, 'getCurrentMotionSensorState', done);
470
- });
471
- it('Insteon Door Window Sensor from IOLinc', function(done) {
472
- runSensorTest(isy, sampleIOLincSensor, 'getCurrentDoorWindowState', done);
473
- });
474
- it('Insteon Door Window Sensor', function(done) {
475
- runSensorTest(isy, sampleDoorWindowSensor, 'getCurrentDoorWindowState', done);
476
- });
477
- });
478
- describe('Outlets on and off2', function() {
479
- it('ApplianceLinc on and off', function(done) {
480
- assert.equal(isy.getDevice(sampleApplianceLinc).deviceType, 'Outlet', 'ApplianceLinc Should be an outlet');
481
- runTrueFalseTest(isy, sampleApplianceLinc, 'getCurrentOutletState', 'sendOutletCommand', done);
482
- });
483
- });
484
- describe('Fan levels', function() {
485
- it('Set fan to low', function(done) {
486
- var deviceToCheck = isy.getDevice(sampleFanLincFan);
487
- runFanTest(isy, sampleFanLincFan, deviceToCheck.FAN_LEVEL_LOW, done);
488
- });
489
- it('Set fan to med', function(done) {
490
- var deviceToCheck = isy.getDevice(sampleFanLincFan);
491
- runFanTest(isy, sampleFanLincFan, deviceToCheck.FAN_LEVEL_MEDIUM, done);
492
- });
493
- it('Set fan to high', function(done) {
494
- var deviceToCheck = isy.getDevice(sampleFanLincFanOffState);
495
- runFanTest(isy, sampleFanLincFanOffState, deviceToCheck.FAN_LEVEL_HIGH, done);
496
- });
497
- });
498
- describe('Scenes', function() {
499
- it('Scene with all lights off turns them all on when scene is turned on and then turns them all off', function(done) {
500
- runSceneTest(isy, sampleSceneWithAllLightsOff, true, sampleSceneWithAllLightsOffAllImpacted, function() {
501
- runSceneTest(isy, sampleSceneWithAllLightsOff, false, sampleSceneWithAllLightsOffAllImpacted, done);
502
- });
503
- });
504
- });
505
- describe('Elk Sensors', function() {
506
- it('Logical state change when you open then close', function(done) {
507
- runElkZoneTest(isy, "1", "OPEN", 1, 2, 'getLogicalState', function() {
508
- runElkZoneTest(isy, "1", "CLOSE", 1, 0,'getLogicalState', done);
509
- });
510
-
511
- });
512
- it('Physical state change when you open then close', function(done) {
513
- runElkZoneTest(isy, "1", "OPEN", 1, 1, 'getPhysicalState', function() {
514
- runElkZoneTest(isy, "1", "CLOSE", 1, 2, 'getPhysicalState', done);
515
- });
516
- });
517
- });
518
- });
519
-
520
- function runVariableTest(variableType, variableId, variableValue, done) {
521
- var initialTimeStamp = new Date();
522
- function variableCheckCallback(isy, variable) {
523
- if(variable.id == variableId && variable.type == variableType) {
524
- assert.equal(variable.value, variableValue, "Variable should have been updated to expected value");
525
- assert(variable.lastChanged > initialTimeStamp, "Variable last changed should have changed. Before: "+initialTimeStamp.toString()+" lastChanged: "+variable.lastChanged);
526
- done();
527
- }
528
- }
529
- resetServerState(function() {
530
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, true, function () {
531
- }, false, true, false, variableCheckCallback);
532
- isy.initialize(function() {
533
- var variable = isy.getVariable(variableType, variableId);
534
- assert(variable != null, "Should have found expected variable");
535
- // Cheat and push back last changed date as this may run quick enough seconds haven't changed.
536
- variable.lastChanged.setFullYear(2012);
537
- initialTimeStamp = variable.lastChanged;
538
- setTimeout(function() {
539
- variable.sendSetValue(variableValue, function() {});
540
- }, 2);
541
-
542
- });
543
- });
544
- }
545
- describe('ISY Variables', function() {
546
- describe('Variable enumeration', function () {
547
- it('Basic startup should work and right number of variables should be enumerated ', function (done) {
548
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, true, function () {
549
- }, false, true);
550
- assert.doesNotThrow(function () {
551
- var type1Found = false;
552
- var type2Found = false;
553
- isy.initialize(function () {
554
- var type1Count = 0;
555
- var type2Count = 0;
556
- for(var index = 0; index < isy.getVariableList().length; index++) {
557
- var variable = isy.getVariableList()[index];
558
- if(variable.type == '1' && sampleType1VariableId == variable.id) {
559
- assert.equal(variable.name, sampleType1VariableName, "Type 1 variable should have expected name");
560
- type1Found = true;
561
- }
562
- if(variable.type == '2' && sampleType2VariableId == variable.id) {
563
- assert.equal(variable.name, sampleType2VariableName, "Type 2 variable name should have expected name");
564
- type2Found = true;
565
- }
566
- if(variable.type == '1') {
567
- type1Count++;
568
- } else if(variable.type == '2') {
569
- type2Count++;
570
- } else {
571
- assert(false, "Should not have any non type 1 or type 2 variables" );
572
- }
573
- }
574
- assert(type1Found, "Should have found expected type 1 variable");
575
- assert(type2Found, "Should have found expected type 2 variable");
576
- assert.equal(type1Count, expectedType1VariablesCount, "Variable type 1 count is not correct");
577
- assert.equal(type2Count, expectedType2VariablesCount, "Variable type 2 count is not correct");
578
- done();
579
- });
580
- });
581
- });
582
- });
583
- describe('Handle no variables', function () {
584
- it('Basic startup should still work when no variables defined ', function (done) {
585
- setVariableFailureMode(true, function () {
586
- var isy = new ISY(testServerAddress, testServerUserName, testServerPassword, true, function () {}, false, true);
587
- assert.doesNotThrow(function () {
588
- isy.initialize(function () {
589
- assert(isy.getVariableList().length == 0, "Should have empty variable list");
590
- setVariableFailureMode(false, function () {
591
- done();
592
- });
593
- });
594
- });
595
- });
596
-
597
- });
598
- });
599
- describe('Variable roundtrip + notifications', function () {
600
- it('Type 1 variable roundtrip + notifications', function (done) {
601
- runVariableTest('1', sampleType1VariableId, 5, done);
602
- });
603
- it('Type 2 variable roundtrip + notifications', function (done) {
604
- runVariableTest('2', sampleType1VariableId, 5, done);
605
- });
606
- });
607
- });
package/tsconfig.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "compileOnSave": true,
3
- "compilerOptions": {
4
- "target": "es2018",
5
- "module": "commonjs",
6
- "rootDir": "src",
7
- "noImplicitUseStrict": true,
8
- "lib":[
9
- "ES2018",
10
- "ES2017",
11
- "ES2016",
12
- "ES2015",
13
- "ES6",
14
- "ES5"
15
- ],
16
- //"allowJs": true,
17
- "outDir": "lib",
18
- "declaration": true,
19
- "declarationDir": "lib",
20
- "resolveJsonModule": true
21
- },
22
- "exclude": [
23
- "./lib/*",
24
- "./node_modules/*",
25
- "./test/*"
26
- ]
27
- }
package/tslint.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "defaultSeverity": "warning",
3
- "extends": [
4
- "tslint:recommended"
5
-
6
- ],
7
- "jsRules": {},
8
- "rules": {"no-return-await":true,
9
- "member-ordering":true,
10
- "variable-name":true,
11
- "triple-equals":true,
12
- "indent":[true,"tabs",2],
13
- "max-classes-per-file":false,
14
- "max-line-length":false,
15
- "quotemark":[true,"single"],
16
- "prefer-template": true,
17
- "interface-name": false,
18
- "trailing-comma": false,
19
- "semicolon":true,
20
- "align":true,
21
- "await-promise":true,
22
- "class-name": true,
23
- "prefer-function-over-method": true,
24
- "promise-function-async": true
25
- },
26
-
27
- "rulesDirectory": []
28
- }