node-red-contrib-homekit-bridged 1.7.0-dev.4 → 1.7.0-dev.6

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,4 +1,3 @@
1
- /// <reference types="hap-nodejs/@types/bonjour-hap" />
2
1
  import { MulticastOptions } from 'bonjour-hap';
3
2
  import { Accessory, Categories } from 'hap-nodejs';
4
3
  import HAPHostConfigType from './HAPHostConfigType';
@@ -1,4 +1,4 @@
1
- import { Accessory, Characteristic, CharacteristicChange, CharacteristicGetCallback, CharacteristicProps, CharacteristicSetCallback, CharacteristicValue, Service } from 'hap-nodejs';
1
+ import { Accessory, AdaptiveLightingController, Characteristic, CharacteristicChange, CharacteristicGetCallback, CharacteristicProps, CharacteristicSetCallback, CharacteristicValue, Service } from 'hap-nodejs';
2
2
  import { HAPConnection } from 'hap-nodejs/dist/lib/util/eventedhttp';
3
3
  import { NodeAPI } from 'node-red';
4
4
  import { NodeStatusUtils } from '../utils/NodeStatusUtils';
@@ -32,5 +32,6 @@ type HAPServiceNodeType = NodeType & {
32
32
  uniqueIdentifier: string;
33
33
  reachable?: boolean;
34
34
  nodeStatusUtils: NodeStatusUtils;
35
+ adaptiveLightingController?: AdaptiveLightingController;
35
36
  };
36
37
  export default HAPServiceNodeType;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  type PublishTimersType = {
3
2
  [key: string]: NodeJS.Timeout;
4
3
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="node-red__registry" />
2
1
  import { NodeStatus } from '@node-red/registry';
3
2
  import NodeType from '../types/NodeType';
4
3
  type StatusType = 'NO_RESPONSE' | 'MSG';
@@ -168,13 +168,20 @@ module.exports = function (node) {
168
168
  }
169
169
  node.topic_in = (_b = msg.topic) !== null && _b !== void 0 ? _b : '';
170
170
  Object.keys(msg.payload).map((key) => {
171
- var _a, _b;
171
+ var _a, _b, _c, _d;
172
172
  if (node.supported.indexOf(key) < 0) {
173
+ if (key === 'AdaptiveLightingController') {
174
+ const value = (_a = msg.payload) === null || _a === void 0 ? void 0 : _a[key];
175
+ const event = value === null || value === void 0 ? void 0 : value.event;
176
+ if (event === 'disable') {
177
+ (_b = node.adaptiveLightingController) === null || _b === void 0 ? void 0 : _b.disableAdaptiveLighting();
178
+ }
179
+ }
173
180
  log.error(`Instead of '${key}' try one of these characteristics: '${node.supported.join("', '")}'`);
174
181
  }
175
182
  else {
176
- const value = (_a = msg.payload) === null || _a === void 0 ? void 0 : _a[key];
177
- const parentNode = (_b = node.parentNode) !== null && _b !== void 0 ? _b : node;
183
+ const value = (_c = msg.payload) === null || _c === void 0 ? void 0 : _c[key];
184
+ const parentNode = (_d = node.parentNode) !== null && _d !== void 0 ? _d : node;
178
185
  parentNode.reachable = value !== NO_RESPONSE_MSG;
179
186
  const characteristic = node.service.getCharacteristic(Characteristic[key]);
180
187
  if (context !== null) {
@@ -317,7 +324,35 @@ module.exports = function (node) {
317
324
  };
318
325
  log.trace(`Configuring Adaptive Lighting with options: ${options}`);
319
326
  const adaptiveLightingController = new hap_nodejs_1.AdaptiveLightingController(node.service, options);
327
+ adaptiveLightingController.on('update', () => {
328
+ const activeAdaptiveLightingTransition = {
329
+ transitionStartMillis: adaptiveLightingController.getAdaptiveLightingStartTimeOfTransition(),
330
+ timeMillisOffset: adaptiveLightingController.getAdaptiveLightingTimeOffset(),
331
+ transitionCurve: adaptiveLightingController.getAdaptiveLightingTransitionCurve(),
332
+ brightnessAdjustmentRange: adaptiveLightingController.getAdaptiveLightingBrightnessMultiplierRange(),
333
+ updateInterval: adaptiveLightingController.getAdaptiveLightingUpdateInterval(),
334
+ notifyIntervalThreshold: adaptiveLightingController.getAdaptiveLightingNotifyIntervalThreshold(),
335
+ };
336
+ node.send({
337
+ payload: {
338
+ AdaptiveLightingController: {
339
+ event: 'update',
340
+ data: activeAdaptiveLightingTransition,
341
+ },
342
+ },
343
+ });
344
+ });
345
+ adaptiveLightingController.on('disable', () => {
346
+ node.send({
347
+ payload: {
348
+ AdaptiveLightingController: {
349
+ event: 'disable',
350
+ },
351
+ },
352
+ });
353
+ });
320
354
  node.accessory.configureController(adaptiveLightingController);
355
+ node.adaptiveLightingController = adaptiveLightingController;
321
356
  }
322
357
  catch (error) {
323
358
  log.error(`Failed to configure Adaptive Lightning due to ${error}`);
@@ -203,13 +203,14 @@
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="1" selected="selected">AUTOMATIC</option>
207
- <option value="2" disabled>MANUAL</option>
206
+ <option value="" selected hidden disabled>AUTOMATIC</option>
207
+ <option value="1">AUTOMATIC</option>
208
+ <option value="2">MANUAL</option>
208
209
  </select>
209
210
  </div>
210
211
  <div class="form-row">
211
212
  <label for="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment"><i class="fa fa-thermometer-quarter"></i> Custom Temperature Adjustment</label>
212
- <input type="number" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment">
213
+ <input type="number" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment" placeholder="0">
213
214
  </div>
214
215
  </div>
215
216
 
@@ -498,12 +499,10 @@
498
499
  value: false,
499
500
  },
500
501
  adaptiveLightingOptionsMode: {
501
- value: 1,
502
- validate: RED.validators.number()
502
+ validate: RED.validators.number(true)
503
503
  },
504
504
  adaptiveLightingOptionsCustomTemperatureAdjustment: {
505
- value: 0,
506
- validate: RED.validators.number()
505
+ validate: RED.validators.number(true)
507
506
  },
508
507
  },
509
508
  inputs: 1,
@@ -203,13 +203,14 @@
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="1" selected="selected">AUTOMATIC</option>
207
- <option value="2" disabled>MANUAL</option>
206
+ <option value="" selected hidden disabled>AUTOMATIC</option>
207
+ <option value="1">AUTOMATIC</option>
208
+ <option value="2">MANUAL</option>
208
209
  </select>
209
210
  </div>
210
211
  <div class="form-row">
211
212
  <label for="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment"><i class="fa fa-thermometer-quarter"></i> Custom Temperature Adjustment</label>
212
- <input type="number" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment">
213
+ <input type="number" id="node-input-adaptiveLightingOptionsCustomTemperatureAdjustment" placeholder="0">
213
214
  </div>
214
215
  </div>
215
216
 
@@ -508,12 +509,10 @@ if (nrchkbExperimental) {
508
509
  value: false,
509
510
  },
510
511
  adaptiveLightingOptionsMode: {
511
- value: 1,
512
- validate: RED.validators.number()
512
+ validate: RED.validators.number(true)
513
513
  },
514
514
  adaptiveLightingOptionsCustomTemperatureAdjustment: {
515
- value: 0,
516
- validate: RED.validators.number()
515
+ validate: RED.validators.number(true)
517
516
  },
518
517
  },
519
518
  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.4",
3
+ "version": "1.7.0-dev.6",
4
4
  "description": "Node-RED nodes to simulate Apple HomeKit devices.",
5
5
  "main": "build/nodes/nrchkb.js",
6
6
  "scripts": {
@@ -50,14 +50,14 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@homebridge/ciao": "^1.2.0",
53
- "@node-red/registry": "^3.1.11",
54
- "@types/mocha": "^10.0.6",
53
+ "@node-red/registry": "^4.0.0",
54
+ "@types/mocha": "^10.0.7",
55
55
  "@types/node": "^18",
56
56
  "@types/node-persist": "^3.1.8",
57
57
  "@types/node-red": "^1.3.5",
58
58
  "@types/node-red-node-test-helper": "^0.3.4",
59
59
  "@types/semver": "^7.5.8",
60
- "@types/uuid": "^9.0.8",
60
+ "@types/uuid": "^10.0.0",
61
61
  "@typescript-eslint/eslint-plugin": "^7.13.1",
62
62
  "@typescript-eslint/parser": "^7.13.1",
63
63
  "babel-eslint": "^10.1.0",
@@ -68,11 +68,11 @@
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.11",
71
+ "node-red": "^4.0.0",
72
72
  "node-red-node-test-helper": "^0.3.4",
73
73
  "prettier": "^3.3.2",
74
74
  "ts-node": "^10.9.2",
75
- "typescript": "^5.4.5"
75
+ "typescript": "^5.5.2"
76
76
  },
77
77
  "engines": {
78
78
  "node": ">=18"