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

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/build/lib/api.js CHANGED
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const logger_1 = require("@nrchkb/logger");
27
27
  const hap_nodejs_1 = require("hap-nodejs");
28
+ const EveCharacteristics_1 = __importDefault(require("./hap/eve-app/EveCharacteristics"));
28
29
  const Storage_1 = require("./Storage");
29
30
  const HapCategories_1 = __importDefault(require("./types/hap-nodejs/HapCategories"));
30
31
  const version = require('../../package.json').version.trim();
@@ -127,9 +128,9 @@ module.exports = function (RED) {
127
128
  });
128
129
  };
129
130
  const _initNRCHKBCustomCharacteristicsAPI = () => __awaiter(this, void 0, void 0, function* () {
130
- const getCustomCharacteristics = () => {
131
- return Storage_1.Storage.loadCustomCharacteristics()
132
- .then((value) => {
131
+ const getCustomCharacteristics = () => __awaiter(this, void 0, void 0, function* () {
132
+ try {
133
+ const value = yield Storage_1.Storage.loadCustomCharacteristics();
133
134
  log.trace('loadCustomCharacteristics()');
134
135
  log.trace(value);
135
136
  if (Array.isArray(value)) {
@@ -137,14 +138,14 @@ module.exports = function (RED) {
137
138
  }
138
139
  else {
139
140
  log.debug('customCharacteristics is not Array, returning empty value');
140
- return [];
141
+ return EveCharacteristics_1.default;
141
142
  }
142
- })
143
- .catch((error) => {
143
+ }
144
+ catch (error) {
144
145
  log.error(`Failed to get customCharacteristics in nrchkbStorage due to ${error}`);
145
- return [];
146
- });
147
- };
146
+ return EveCharacteristics_1.default;
147
+ }
148
+ });
148
149
  const characteristicNameToKey = (name) => {
149
150
  return name.replace(' ', '');
150
151
  };
@@ -260,7 +261,7 @@ module.exports = function (RED) {
260
261
  });
261
262
  }));
262
263
  RED.httpAdmin.post('/nrchkb/config', RED.auth.needsPermission('nrchkb.write'), (req, res) => __awaiter(this, void 0, void 0, function* () {
263
- const customCharacteristics = req.body.customCharacteristics || [];
264
+ const customCharacteristics = req.body.customCharacteristics || EveCharacteristics_1.default;
264
265
  Storage_1.Storage.saveCustomCharacteristics(customCharacteristics)
265
266
  .then(() => {
266
267
  res.sendStatus(200);
@@ -0,0 +1,9 @@
1
+ import { Characteristic } from 'hap-nodejs';
2
+ import { EveS2R1, EveS2R2, EveS2W1, EveS2W2 } from './eve-app/EveCharacteristics';
3
+ declare class HAPCharacteristic extends Characteristic {
4
+ static EveS2R1: typeof EveS2R1;
5
+ static EveS2R2: typeof EveS2R2;
6
+ static EveS2W1: typeof EveS2W1;
7
+ static EveS2W2: typeof EveS2W2;
8
+ }
9
+ export default HAPCharacteristic;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hap_nodejs_1 = require("hap-nodejs");
4
+ class HAPCharacteristic extends hap_nodejs_1.Characteristic {
5
+ }
6
+ exports.default = HAPCharacteristic;
@@ -0,0 +1,6 @@
1
+ import { Service } from 'hap-nodejs';
2
+ import { EveHistoryData } from './eve-app/EveServices';
3
+ declare class HAPService extends Service {
4
+ static EveHistoryData: typeof EveHistoryData;
5
+ }
6
+ export default HAPService;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hap_nodejs_1 = require("hap-nodejs");
4
+ class HAPService extends hap_nodejs_1.Service {
5
+ }
6
+ exports.default = HAPService;
@@ -0,0 +1,20 @@
1
+ import CustomCharacteristicType from '../../types/CustomCharacteristicType';
2
+ import HAPCharacteristic from '../HAPCharacteristic';
3
+ declare const EveCharacteristics: CustomCharacteristicType[];
4
+ export declare class EveS2R1 extends HAPCharacteristic {
5
+ static readonly UUID: string;
6
+ constructor();
7
+ }
8
+ export declare class EveS2R2 extends HAPCharacteristic {
9
+ static readonly UUID: string;
10
+ constructor();
11
+ }
12
+ export declare class EveS2W1 extends HAPCharacteristic {
13
+ static readonly UUID: string;
14
+ constructor();
15
+ }
16
+ export declare class EveS2W2 extends HAPCharacteristic {
17
+ static readonly UUID: string;
18
+ constructor();
19
+ }
20
+ export default EveCharacteristics;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EveS2W2 = exports.EveS2W1 = exports.EveS2R2 = exports.EveS2R1 = void 0;
7
+ const HAPCharacteristic_1 = __importDefault(require("../HAPCharacteristic"));
8
+ const EveCharacteristics = [
9
+ {
10
+ UUID: 'E863F10A-079E-48FF-8F27-9C2605A29F52',
11
+ name: 'Eve-Volt',
12
+ format: "float",
13
+ perms: ["pr"],
14
+ description: 'Volt (V) value. Used by Eve.app.',
15
+ },
16
+ {
17
+ UUID: 'E863F126-079E-48FF-8F27-9C2605A29F52',
18
+ name: 'Eve-Ampere',
19
+ format: "float",
20
+ perms: ["pr"],
21
+ description: 'Ampere (A) value. Used by Eve.app.',
22
+ },
23
+ {
24
+ UUID: 'E863F10D-079E-48FF-8F27-9C2605A29F52',
25
+ name: 'Eve-Watt',
26
+ format: "float",
27
+ perms: ["pr"],
28
+ description: 'Watt (W) value. Used by Eve.app, reported as "Consumption".',
29
+ },
30
+ {
31
+ UUID: 'E863F10C-079E-48FF-8F27-9C2605A29F52',
32
+ name: 'Eve-Kilowatt-hour',
33
+ format: "float",
34
+ perms: ["pr"],
35
+ description: 'Kilowatt-hour (kWh) value. Used by Eve.app, reported as Total Consumption.',
36
+ },
37
+ {
38
+ UUID: 'E863F110-079E-48FF-8F27-9C2605A29F52',
39
+ name: 'Eve-Volt-Ampere',
40
+ format: "uint16",
41
+ perms: ["pr"],
42
+ description: 'Volt-Ampere (VA) value. Used by Eve.app.',
43
+ },
44
+ ];
45
+ class EveS2R1 extends HAPCharacteristic_1.default {
46
+ constructor() {
47
+ super('Eve-S2R1', EveS2R1.UUID, {
48
+ format: "data",
49
+ perms: ["pr", "ev", "hd"],
50
+ });
51
+ }
52
+ }
53
+ exports.EveS2R1 = EveS2R1;
54
+ EveS2R1.UUID = 'E863F116-079E-48FF-8F27-9C2605A29F52';
55
+ HAPCharacteristic_1.default.EveS2R1 = EveS2R1;
56
+ class EveS2R2 extends HAPCharacteristic_1.default {
57
+ constructor() {
58
+ super('Eve-S2R2', EveS2R2.UUID, {
59
+ format: "data",
60
+ perms: ["pr", "ev", "hd"],
61
+ });
62
+ }
63
+ }
64
+ exports.EveS2R2 = EveS2R2;
65
+ EveS2R2.UUID = 'E863F117-079E-48FF-8F27-9C2605A29F52';
66
+ HAPCharacteristic_1.default.EveS2R2 = EveS2R2;
67
+ class EveS2W1 extends HAPCharacteristic_1.default {
68
+ constructor() {
69
+ super('Eve-S2W1', EveS2W1.UUID, {
70
+ format: "data",
71
+ perms: ["pw", "hd"],
72
+ });
73
+ }
74
+ }
75
+ exports.EveS2W1 = EveS2W1;
76
+ EveS2W1.UUID = 'E863F11C-079E-48FF-8F27-9C2605A29F52';
77
+ HAPCharacteristic_1.default.EveS2W1 = EveS2W1;
78
+ class EveS2W2 extends HAPCharacteristic_1.default {
79
+ constructor() {
80
+ super('Eve-S2W2', EveS2W2.UUID, {
81
+ format: "data",
82
+ perms: ["pw", "hd"],
83
+ });
84
+ }
85
+ }
86
+ exports.EveS2W2 = EveS2W2;
87
+ EveS2W2.UUID = 'E863F121-079E-48FF-8F27-9C2605A29F52';
88
+ HAPCharacteristic_1.default.EveS2W2 = EveS2W2;
89
+ exports.default = EveCharacteristics;
@@ -0,0 +1,5 @@
1
+ import HAPService from '../HAPService';
2
+ export declare class EveHistoryData extends HAPService {
3
+ static readonly UUID: string;
4
+ constructor();
5
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EveHistoryData = void 0;
7
+ const HAPCharacteristic_1 = __importDefault(require("../HAPCharacteristic"));
8
+ const HAPService_1 = __importDefault(require("../HAPService"));
9
+ class EveHistoryData extends HAPService_1.default {
10
+ constructor() {
11
+ super('EveHistoryData', EveHistoryData.UUID);
12
+ this.addCharacteristic(HAPCharacteristic_1.default.EveS2R1);
13
+ this.addCharacteristic(HAPCharacteristic_1.default.EveS2R2);
14
+ this.addCharacteristic(HAPCharacteristic_1.default.EveS2W1);
15
+ this.addCharacteristic(HAPCharacteristic_1.default.EveS2W2);
16
+ }
17
+ }
18
+ exports.EveHistoryData = EveHistoryData;
19
+ EveHistoryData.UUID = 'E863F007-079E-48FF-8F27-9C2605A29F52';
20
+ HAPService_1.default.EveHistoryData = EveHistoryData;
@@ -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.4",
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",