node-red-contrib-homekit-bridged 1.7.0-dev.2 → 1.7.0-dev.3

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.
@@ -1,8 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ const util = __importStar(require("node:util"));
6
30
  const logger_1 = require("@nrchkb/logger");
7
31
  const hap_nodejs_1 = require("hap-nodejs");
8
32
  const NRCHKBError_1 = __importDefault(require("../NRCHKBError"));
@@ -32,7 +56,7 @@ module.exports = function (node) {
32
56
  };
33
57
  const onCharacteristicGet = function (callback, context, connection) {
34
58
  var _a, _b;
35
- log.debug(`onCharacteristicGet with status: ${this.statusCode}, value: ${this.value}, reachability is ${((_a = node.parentNode) !== null && _a !== void 0 ? _a : node).reachable} with context ${JSON.stringify(context)} on connection ${connection === null || connection === void 0 ? void 0 : connection.sessionID}`);
59
+ log.debug(`onCharacteristicGet with status: ${this.statusCode}, value: ${this.value}, reachability is ${((_a = node.parentNode) !== null && _a !== void 0 ? _a : node).reachable} with context ${util.inspect(context)} on connection ${connection === null || connection === void 0 ? void 0 : connection.sessionID}`);
36
60
  if (callback) {
37
61
  try {
38
62
  callback(((_b = node.parentNode) !== null && _b !== void 0 ? _b : node).reachable
@@ -92,7 +116,7 @@ module.exports = function (node) {
92
116
  const onCharacteristicSet = (allCharacteristics) => function (newValue, callback, context, connection) {
93
117
  var _a, _b;
94
118
  log.debug(`onCharacteristicSet with status: ${this.statusCode}, value: ${this.value}, reachability is ${((_a = node.parentNode) !== null && _a !== void 0 ? _a : node).reachable}
95
- with context ${JSON.stringify(context)} on connection ${connection === null || connection === void 0 ? void 0 : connection.sessionID}`);
119
+ with context ${util.inspect(context)} on connection ${connection === null || connection === void 0 ? void 0 : connection.sessionID}`);
96
120
  try {
97
121
  if (callback) {
98
122
  callback(((_b = node.parentNode) !== null && _b !== void 0 ? _b : node).reachable
@@ -110,7 +134,7 @@ module.exports = function (node) {
110
134
  var _a;
111
135
  const { oldValue, newValue, context, originator, reason } = change;
112
136
  log.debug(`onCharacteristicChange with reason: ${reason}, oldValue: ${oldValue}, newValue: ${newValue}, reachability is ${((_a = node.parentNode) !== null && _a !== void 0 ? _a : node).reachable}
113
- with context ${JSON.stringify(context)} on connection ${originator === null || originator === void 0 ? void 0 : originator.sessionID}`);
137
+ with context ${util.inspect(context)} on connection ${originator === null || originator === void 0 ? void 0 : originator.sessionID}`);
114
138
  if (oldValue != newValue) {
115
139
  onValueChange.call(this, allCharacteristics, 0, {
116
140
  oldValue,
@@ -276,19 +300,27 @@ module.exports = function (node) {
276
300
  }
277
301
  };
278
302
  const configureAdaptiveLightning = () => {
279
- var _a;
280
- if (node.service.name === 'Lightbulb' &&
303
+ if (node.service.UUID === Service.Lightbulb.UUID &&
281
304
  node.config.adaptiveLightingOptionsEnable) {
282
305
  try {
283
- const adaptiveLightingController = new hap_nodejs_1.AdaptiveLightingController(node.service, {
284
- controllerMode: (_a = node.config.adaptiveLightingOptionsMode) !== null && _a !== void 0 ? _a : 1,
306
+ node.service.getCharacteristic(Characteristic.Brightness);
307
+ node.service.getCharacteristic(Characteristic.ColorTemperature);
308
+ const options = {
309
+ controllerMode: node.config.adaptiveLightingOptionsMode
310
+ ? +node.config.adaptiveLightingOptionsMode
311
+ : 1,
285
312
  customTemperatureAdjustment: node.config
286
- .adaptiveLightingOptionsCustomTemperatureAdjustment,
287
- });
313
+ .adaptiveLightingOptionsCustomTemperatureAdjustment
314
+ ? +node.config
315
+ .adaptiveLightingOptionsCustomTemperatureAdjustment
316
+ : undefined,
317
+ };
318
+ log.trace(`Configuring Adaptive Lighting with options: ${options}`);
319
+ const adaptiveLightingController = new hap_nodejs_1.AdaptiveLightingController(node.service, options);
288
320
  node.accessory.configureController(adaptiveLightingController);
289
321
  }
290
322
  catch (error) {
291
- log.error(`Failed to configure adaptive lightning due to ${error}`);
323
+ log.error(`Failed to configure Adaptive Lightning due to ${error}`);
292
324
  }
293
325
  }
294
326
  };
@@ -203,13 +203,13 @@
203
203
  <div class="form-row">
204
204
  <label for="node-input-adaptiveLightingOptionsMode"><i class="fa fa-hand-o-up"></i> Mode</label>
205
205
  <select id="node-input-adaptiveLightingOptionsMode">
206
- <option value="0" selected="selected">AUTOMATIC</option>
207
- <option value="1" disabled>MANUAL</option>
206
+ <option value="1" selected="selected">AUTOMATIC</option>
207
+ <option value="2" disabled>MANUAL</option>
208
208
  </select>
209
209
  </div>
210
210
  <div class="form-row">
211
211
  <label for="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment"><i class="fa fa-thermometer-quarter"></i> Custom Temperature Adjustment</label>
212
- <input type="text" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment">
212
+ <input type="number" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment">
213
213
  </div>
214
214
  </div>
215
215
 
@@ -498,10 +498,12 @@
498
498
  value: false,
499
499
  },
500
500
  adaptiveLightingOptionsMode: {
501
- value: 0,
501
+ value: 1,
502
+ validate: RED.validators.number()
502
503
  },
503
504
  adaptiveLightingOptionsCustomTemperatureAdjustment: {
504
- value: undefined,
505
+ value: 0,
506
+ validate: RED.validators.number()
505
507
  },
506
508
  },
507
509
  inputs: 1,
@@ -203,13 +203,13 @@
203
203
  <div class="form-row">
204
204
  <label for="node-input-adaptiveLightingOptionsMode"><i class="fa fa-hand-o-up"></i> Mode</label>
205
205
  <select id="node-input-adaptiveLightingOptionsMode">
206
- <option value="0" selected="selected">AUTOMATIC</option>
207
- <option value="1" disabled>MANUAL</option>
206
+ <option value="1" selected="selected">AUTOMATIC</option>
207
+ <option value="2" disabled>MANUAL</option>
208
208
  </select>
209
209
  </div>
210
210
  <div class="form-row">
211
211
  <label for="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment"><i class="fa fa-thermometer-quarter"></i> Custom Temperature Adjustment</label>
212
- <input type="text" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment">
212
+ <input type="number" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment">
213
213
  </div>
214
214
  </div>
215
215
 
@@ -508,10 +508,12 @@ if (nrchkbExperimental) {
508
508
  value: false,
509
509
  },
510
510
  adaptiveLightingOptionsMode: {
511
- value: 0,
511
+ value: 1,
512
+ validate: RED.validators.number()
512
513
  },
513
514
  adaptiveLightingOptionsCustomTemperatureAdjustment: {
514
- value: undefined,
515
+ value: 0,
516
+ validate: RED.validators.number()
515
517
  },
516
518
  },
517
519
  inputs: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-homekit-bridged",
3
- "version": "1.7.0-dev.2",
3
+ "version": "1.7.0-dev.3",
4
4
  "description": "Node-RED nodes to simulate Apple HomeKit devices.",
5
5
  "main": "build/nodes/nrchkb.js",
6
6
  "scripts": {
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "homepage": "https://github.com/NRCHKB/node-red-contrib-homekit-bridged#readme",
44
44
  "dependencies": {
45
- "@nrchkb/logger": "^2.0.2",
45
+ "@nrchkb/logger": "^3.0.0",
46
46
  "hap-nodejs": "0.12.2",
47
47
  "node-persist": "^4.0.1",
48
48
  "semver": "^7.6.2",