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

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.
@@ -161,6 +161,7 @@ module.exports = (RED) => {
161
161
  config: self.config,
162
162
  }, self.parentService);
163
163
  self.characteristicProperties = CharacteristicUtils.load(self.service, self.config);
164
+ ServiceUtils.configureAdaptiveLightning();
164
165
  if (self.config.isParent) {
165
166
  BridgeUtils.delayedPublish(self);
166
167
  }
@@ -161,6 +161,7 @@ module.exports = (RED) => {
161
161
  config: self.config,
162
162
  }, self.parentService);
163
163
  self.characteristicProperties = CharacteristicUtils.load(self.service, self.config);
164
+ ServiceUtils.configureAdaptiveLightning();
164
165
  if (self.config.isParent) {
165
166
  BridgeUtils.delayedPublish(self);
166
167
  }
@@ -120,7 +120,8 @@ module.exports = function (node) {
120
120
  }
121
121
  };
122
122
  const onInput = function (msg) {
123
- if (msg.hasOwnProperty('payload')) {
123
+ var _a, _b;
124
+ if (msg.payload) {
124
125
  const type = typeof msg.payload;
125
126
  if (type !== 'object') {
126
127
  log.error(`Invalid payload type: ${type}`);
@@ -131,17 +132,17 @@ module.exports = function (node) {
131
132
  log.error('Invalid message (payload missing)');
132
133
  return;
133
134
  }
134
- const topic = node.config.topic ? node.config.topic : node.name;
135
+ const topic = (_a = node.config.topic) !== null && _a !== void 0 ? _a : node.name;
135
136
  if (node.config.filter && msg.topic !== topic) {
136
137
  log.debug("msg.topic doesn't match configured value and filter is enabled. Dropping message.");
137
138
  return;
138
139
  }
139
140
  let context = null;
140
- if (msg.payload.hasOwnProperty('Context')) {
141
+ if (msg.payload.Context) {
141
142
  context = msg.payload.Context;
142
143
  delete msg.payload.Context;
143
144
  }
144
- node.topic_in = msg.topic ? msg.topic : '';
145
+ node.topic_in = (_b = msg.topic) !== null && _b !== void 0 ? _b : '';
145
146
  Object.keys(msg.payload).map((key) => {
146
147
  var _a, _b;
147
148
  if (node.supported.indexOf(key) < 0) {
@@ -153,7 +154,7 @@ module.exports = function (node) {
153
154
  parentNode.reachable = value !== NO_RESPONSE_MSG;
154
155
  const characteristic = node.service.getCharacteristic(Characteristic[key]);
155
156
  if (context !== null) {
156
- characteristic.setValue(value, context);
157
+ characteristic.setValue(value, undefined, context);
157
158
  }
158
159
  else {
159
160
  characteristic.setValue(value);
@@ -184,7 +185,6 @@ module.exports = function (node) {
184
185
  done();
185
186
  };
186
187
  const getOrCreate = function (accessory, serviceInformation, parentService) {
187
- var _a;
188
188
  const newService = new Service[serviceInformation.serviceName](serviceInformation.name, serviceInformation.UUID);
189
189
  log.debug(`Looking for service with UUID ${serviceInformation.UUID} ...`);
190
190
  let service = accessory.services.find((service) => {
@@ -203,21 +203,6 @@ module.exports = function (node) {
203
203
  }
204
204
  else {
205
205
  service = accessory.addService(newService);
206
- if (serviceInformation.serviceName === 'Lightbulb' &&
207
- serviceInformation.config.adaptiveLightingOptionsEnable) {
208
- try {
209
- const adaptiveLightingController = new hap_nodejs_1.AdaptiveLightingController(service, {
210
- controllerMode: (_a = serviceInformation.config
211
- .adaptiveLightingOptionsMode) !== null && _a !== void 0 ? _a : 1,
212
- customTemperatureAdjustment: serviceInformation.config
213
- .adaptiveLightingOptionsCustomTemperatureAdjustment,
214
- });
215
- accessory.configureController(adaptiveLightingController);
216
- }
217
- catch (error) {
218
- log.error(`Failed to configure adaptive lightning due to ${error}`);
219
- }
220
- }
221
206
  }
222
207
  }
223
208
  else {
@@ -290,6 +275,23 @@ module.exports = function (node) {
290
275
  log.error('Invalid message (required {"payload":{"nrchkb":{"setup":{}}}})');
291
276
  }
292
277
  };
278
+ const configureAdaptiveLightning = () => {
279
+ var _a;
280
+ if (node.service.name === 'Lightbulb' &&
281
+ node.config.adaptiveLightingOptionsEnable) {
282
+ try {
283
+ const adaptiveLightingController = new hap_nodejs_1.AdaptiveLightingController(node.service, {
284
+ controllerMode: (_a = node.config.adaptiveLightingOptionsMode) !== null && _a !== void 0 ? _a : 1,
285
+ customTemperatureAdjustment: node.config
286
+ .adaptiveLightingOptionsCustomTemperatureAdjustment,
287
+ });
288
+ node.accessory.configureController(adaptiveLightingController);
289
+ }
290
+ catch (error) {
291
+ log.error(`Failed to configure adaptive lightning due to ${error}`);
292
+ }
293
+ }
294
+ };
293
295
  return {
294
296
  getOrCreate,
295
297
  onCharacteristicGet,
@@ -299,5 +301,6 @@ module.exports = function (node) {
299
301
  onClose,
300
302
  waitForParent,
301
303
  handleWaitForSetup,
304
+ configureAdaptiveLightning,
302
305
  };
303
306
  };
@@ -9,6 +9,7 @@ const NRCHKBError_1 = __importDefault(require("../NRCHKBError"));
9
9
  const Storage_1 = require("../Storage");
10
10
  module.exports = function (node) {
11
11
  const log = (0, logger_1.logger)('NRCHKB', 'ServiceUtils2', node.config.name, node);
12
+ const ServiceUtilsLegacy = require('./ServiceUtils')(node);
12
13
  const HapNodeJS = require('hap-nodejs');
13
14
  const Service = HapNodeJS.Service;
14
15
  const Characteristic = HapNodeJS.Characteristic;
@@ -127,7 +128,7 @@ module.exports = function (node) {
127
128
  }
128
129
  };
129
130
  const onInput = function (msg) {
130
- var _a;
131
+ var _a, _b;
131
132
  if (msg.payload) {
132
133
  const type = typeof msg.payload;
133
134
  if (type !== 'object') {
@@ -139,7 +140,7 @@ module.exports = function (node) {
139
140
  log.error('Invalid message (payload missing)');
140
141
  return;
141
142
  }
142
- const topic = node.config.topic ? node.config.topic : node.name;
143
+ const topic = (_a = node.config.topic) !== null && _a !== void 0 ? _a : node.name;
143
144
  if (node.config.filter && msg.topic !== topic) {
144
145
  log.debug("msg.topic doesn't match configured value and filter is enabled. Dropping message.");
145
146
  return;
@@ -149,7 +150,7 @@ module.exports = function (node) {
149
150
  context = msg.payload.Context;
150
151
  delete msg.payload.Context;
151
152
  }
152
- node.topic_in = (_a = msg.topic) !== null && _a !== void 0 ? _a : '';
153
+ node.topic_in = (_b = msg.topic) !== null && _b !== void 0 ? _b : '';
153
154
  Object.keys(msg.payload).map((key) => {
154
155
  var _a, _b, _c;
155
156
  if (node.supported.indexOf(key) < 0) {
@@ -176,7 +177,7 @@ module.exports = function (node) {
176
177
  parentNode.reachable = value !== NO_RESPONSE_MSG;
177
178
  const characteristic = node.service.getCharacteristic(Characteristic[key]);
178
179
  if (context !== null) {
179
- characteristic.setValue(value, context);
180
+ characteristic.setValue(value, undefined, context);
180
181
  }
181
182
  else {
182
183
  characteristic.setValue(value);
@@ -207,7 +208,6 @@ module.exports = function (node) {
207
208
  done();
208
209
  };
209
210
  const getOrCreate = function (accessory, serviceInformation, parentService) {
210
- var _a;
211
211
  const newService = new Service[serviceInformation.serviceName](serviceInformation.name, serviceInformation.UUID);
212
212
  log.debug(`Looking for service with UUID ${serviceInformation.UUID} ...`);
213
213
  let service = accessory.services.find((service) => {
@@ -226,21 +226,6 @@ module.exports = function (node) {
226
226
  }
227
227
  else {
228
228
  service = accessory.addService(newService);
229
- if (serviceInformation.serviceName === 'Lightbulb' &&
230
- serviceInformation.config.adaptiveLightingOptionsEnable) {
231
- try {
232
- const adaptiveLightingController = new hap_nodejs_1.AdaptiveLightingController(service, {
233
- controllerMode: (_a = serviceInformation.config
234
- .adaptiveLightingOptionsMode) !== null && _a !== void 0 ? _a : 1,
235
- customTemperatureAdjustment: serviceInformation.config
236
- .adaptiveLightingOptionsCustomTemperatureAdjustment,
237
- });
238
- accessory.configureController(adaptiveLightingController);
239
- }
240
- catch (error) {
241
- log.error(`Failed to configure adaptive lightning due to ${error}`);
242
- }
243
- }
244
229
  }
245
230
  }
246
231
  else {
@@ -322,5 +307,6 @@ module.exports = function (node) {
322
307
  onClose,
323
308
  waitForParent,
324
309
  handleWaitForSetup,
310
+ configureAdaptiveLightning: ServiceUtilsLegacy.configureAdaptiveLightning,
325
311
  };
326
312
  };
@@ -204,7 +204,7 @@
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
206
  <option value="0" selected="selected">AUTOMATIC</option>
207
- <option value="1">MANUAL</option>
207
+ <option value="1" disabled>MANUAL</option>
208
208
  </select>
209
209
  </div>
210
210
  <div class="form-row">
@@ -204,7 +204,7 @@
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
206
  <option value="0" selected="selected">AUTOMATIC</option>
207
- <option value="1">MANUAL</option>
207
+ <option value="1" disabled>MANUAL</option>
208
208
  </select>
209
209
  </div>
210
210
  <div class="form-row">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-homekit-bridged",
3
- "version": "1.7.0-dev.1",
3
+ "version": "1.7.0-dev.2",
4
4
  "description": "Node-RED nodes to simulate Apple HomeKit devices.",
5
5
  "main": "build/nodes/nrchkb.js",
6
6
  "scripts": {
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@homebridge/ciao": "^1.2.0",
53
- "@node-red/registry": "^3.1.10",
53
+ "@node-red/registry": "^3.1.11",
54
54
  "@types/mocha": "^10.0.6",
55
55
  "@types/node": "^18",
56
56
  "@types/node-persist": "^3.1.8",
@@ -58,8 +58,8 @@
58
58
  "@types/node-red-node-test-helper": "^0.3.4",
59
59
  "@types/semver": "^7.5.8",
60
60
  "@types/uuid": "^9.0.8",
61
- "@typescript-eslint/eslint-plugin": "^7.13.0",
62
- "@typescript-eslint/parser": "^7.13.0",
61
+ "@typescript-eslint/eslint-plugin": "^7.13.1",
62
+ "@typescript-eslint/parser": "^7.13.1",
63
63
  "babel-eslint": "^10.1.0",
64
64
  "del-cli": "^5.1.0",
65
65
  "eslint": "^8",
@@ -68,7 +68,7 @@
68
68
  "eslint-plugin-simple-import-sort": "^12.1.0",
69
69
  "husky": "^9.0.11",
70
70
  "mocha": "^10.4.0",
71
- "node-red": "^3.1.10",
71
+ "node-red": "^3.1.11",
72
72
  "node-red-node-test-helper": "^0.3.4",
73
73
  "prettier": "^3.3.2",
74
74
  "ts-node": "^10.9.2",