node-alarm-dot-com 1.11.0-beta.7 → 2.0.0-beta.1

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/dist/index.d.ts CHANGED
@@ -86,9 +86,10 @@ export declare function disarm(partitionID: string, authOpts: AuthOpts): Promise
86
86
  * @param {string} lightID Light ID string.
87
87
  * @param {number} brightness An integer, 1-100, indicating brightness.
88
88
  * @param {Object} authOpts Authentication object returned from the login.
89
+ * @param {boolean} isDimmer Indicates whether or not light is dimmable.
89
90
  * @returns {Promise}
90
91
  */
91
- export declare function setLightOn(lightID: string, authOpts: AuthOpts, brightness: number): Promise<any>;
92
+ export declare function setLightOn(lightID: string, authOpts: AuthOpts, brightness: number, isDimmer: boolean): Promise<any>;
92
93
  /**
93
94
  * Convenience Method:
94
95
  * Sets a light to OFF. The brightness level is ignored.
@@ -96,9 +97,10 @@ export declare function setLightOn(lightID: string, authOpts: AuthOpts, brightne
96
97
  * @param {string} lightID Light ID string.
97
98
  * @param {number} brightness An integer, 1-100, indicating brightness. Ignored.
98
99
  * @param {Object} authOpts Authentication object returned from the login.
100
+ * @param {boolean} isDimmer Indicates whether or not light is dimmable.
99
101
  * @returns {Promise}
100
102
  */
101
- export declare function setLightOff(lightID: string, authOpts: AuthOpts, brightness: number): Promise<any>;
103
+ export declare function setLightOff(lightID: string, authOpts: AuthOpts, brightness: number, isDimmer: boolean): Promise<any>;
102
104
  /**
103
105
  * Convenience Method:
104
106
  * Sets a lock to "locked" (SECURED).
package/dist/index.js CHANGED
@@ -71,7 +71,7 @@ async function login(username, password, existingMfaToken) {
71
71
  .catch(err => {
72
72
  throw new Error(`GET ${ADCLOGIN_URL} failed: ${err.message || err}`);
73
73
  });
74
- await node_fetch_1.default(ADCFORMLOGIN_URL, {
74
+ await (0, node_fetch_1.default)(ADCFORMLOGIN_URL, {
75
75
  method: 'POST',
76
76
  headers: {
77
77
  'Content-Type': 'application/x-www-form-urlencoded',
@@ -262,14 +262,30 @@ exports.disarm = disarm;
262
262
  // about any of the components, sensors included.
263
263
  // Light methods ///////////////////////////////////////////////////////////////
264
264
  /**
265
- * Perform light actions, e.g., turn on, turn off, change brightness level.
265
+ * Perform non-dimmable light actions, i.e. turn on, turn off
266
+ *
267
+ * @param {string} lightID Light ID string.
268
+ * @param {string} action Action (verb) to perform on the light.
269
+ * @param {Object} authOpts Authentication object returned from the login.
270
+ */
271
+ function lightAction(lightID, authOpts, action) {
272
+ const url = `${LIGHTS_URL}${lightID}/${action}`;
273
+ const postOpts = Object.assign({}, authOpts, {
274
+ body: {
275
+ statePollOnly: false
276
+ }
277
+ });
278
+ return authenticatedPost(url, postOpts);
279
+ }
280
+ /**
281
+ * Perform dimmable light actions, e.g., turn on, turn off, change brightness level.
266
282
  *
267
283
  * @param {string} lightID Light ID string.
268
284
  * @param {string} action Action (verb) to perform on the light.
269
285
  * @param {Object} authOpts Authentication object returned from the login.
270
286
  * @param {number} brightness An integer, 1-100, indicating brightness.
271
287
  */
272
- function lightAction(lightID, authOpts, brightness, action) {
288
+ function dimmerAction(lightID, authOpts, brightness, action) {
273
289
  const url = `${LIGHTS_URL}${lightID}/${action}`;
274
290
  const postOpts = Object.assign({}, authOpts, {
275
291
  body: {
@@ -286,10 +302,16 @@ function lightAction(lightID, authOpts, brightness, action) {
286
302
  * @param {string} lightID Light ID string.
287
303
  * @param {number} brightness An integer, 1-100, indicating brightness.
288
304
  * @param {Object} authOpts Authentication object returned from the login.
305
+ * @param {boolean} isDimmer Indicates whether or not light is dimmable.
289
306
  * @returns {Promise}
290
307
  */
291
- function setLightOn(lightID, authOpts, brightness) {
292
- return lightAction(lightID, authOpts, brightness, 'turnOn');
308
+ function setLightOn(lightID, authOpts, brightness, isDimmer) {
309
+ if (isDimmer) {
310
+ return dimmerAction(lightID, authOpts, brightness, 'turnOn');
311
+ }
312
+ else {
313
+ return lightAction(lightID, authOpts, 'turnOn');
314
+ }
293
315
  }
294
316
  exports.setLightOn = setLightOn;
295
317
  /**
@@ -299,10 +321,16 @@ exports.setLightOn = setLightOn;
299
321
  * @param {string} lightID Light ID string.
300
322
  * @param {number} brightness An integer, 1-100, indicating brightness. Ignored.
301
323
  * @param {Object} authOpts Authentication object returned from the login.
324
+ * @param {boolean} isDimmer Indicates whether or not light is dimmable.
302
325
  * @returns {Promise}
303
326
  */
304
- function setLightOff(lightID, authOpts, brightness) {
305
- return lightAction(lightID, authOpts, brightness, 'turnOff');
327
+ function setLightOff(lightID, authOpts, brightness, isDimmer) {
328
+ if (isDimmer) {
329
+ return dimmerAction(lightID, authOpts, brightness, 'turnOff');
330
+ }
331
+ else {
332
+ return lightAction(lightID, authOpts, 'turnOff');
333
+ }
306
334
  }
307
335
  exports.setLightOff = setLightOff;
308
336
  // Lock methods ////////////////////////////////////////////////////////////////
@@ -438,7 +466,7 @@ async function get(url, opts) {
438
466
  let status;
439
467
  let resHeaders;
440
468
  try {
441
- const res = await node_fetch_1.default(url, {
469
+ const res = await (0, node_fetch_1.default)(url, {
442
470
  method: 'GET',
443
471
  redirect: 'manual',
444
472
  headers: opts.headers
@@ -468,7 +496,7 @@ async function post(url, opts) {
468
496
  let status;
469
497
  let resHeaders;
470
498
  try {
471
- const res = await node_fetch_1.default(url, {
499
+ const res = await (0, node_fetch_1.default)(url, {
472
500
  method: 'POST',
473
501
  redirect: 'manual',
474
502
  body: opts.body ? JSON.stringify(opts.body) : undefined,
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "node-alarm-dot-com",
3
- "version": "1.11.0-beta.7",
4
- "betaVersion": "1.11.0",
3
+ "version": "2.0.0-beta.1",
4
+ "betaVersion": "2.0.0",
5
5
  "description": "An interface module written in node.js to arm and disarm Alarm.com security systems.",
6
6
  "author": {
7
- "name": "Mike Kormendy",
8
- "email": "mike@somethinginteractive.com"
7
+ "name": "Chase Lau",
8
+ "url": "https://github.com/chase9"
9
9
  },
10
10
  "license": "MIT",
11
11
  "keywords": [
@@ -45,17 +45,18 @@
45
45
  "test": "echo \"Error: no test specified\" && exit 1"
46
46
  },
47
47
  "engines": {
48
- "node": ">=0.12.0"
48
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
49
49
  },
50
50
  "dependencies": {
51
- "@types/node-fetch": "^2.5.12",
52
- "node-fetch": "^3.0.0-beta.10",
51
+ "@types/node-fetch": "^3.0.2",
52
+ "@types/node": "^17.0.16",
53
+ "node-fetch": "^2.6.1",
53
54
  "semver": "^7.3.5"
54
55
  },
55
56
  "devDependencies": {
56
57
  "rimraf": "^3.0.2",
57
- "ts-node": "^10.2.0",
58
- "typescript": "^4.3.5",
59
- "yargs": "^17.1.0"
58
+ "ts-node": "^10.5.0",
59
+ "typescript": "^4.5.5",
60
+ "yargs": "^17.3.1"
60
61
  }
61
62
  }