homebridge-tasmota-control 1.6.3 → 1.6.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/package.json +1 -1
- package/src/sensors.js +93 -104
package/package.json
CHANGED
package/src/sensors.js
CHANGED
|
@@ -28,17 +28,6 @@ class Sensors extends EventEmitter {
|
|
|
28
28
|
|
|
29
29
|
//sensors
|
|
30
30
|
this.sensorsCount = 0;
|
|
31
|
-
this.sensorsTemperatureCount = 0;
|
|
32
|
-
this.sensorsReferenceTemperatureCount = 0;
|
|
33
|
-
this.sensorsObjTemperatureCount = 0;
|
|
34
|
-
this.sensorsAmbTemperatureCount = 0;
|
|
35
|
-
this.sensorsHumidityCount = 0;
|
|
36
|
-
this.sensorsDewPointTemperatureCount = 0;
|
|
37
|
-
this.sensorsPressureCount = 0;
|
|
38
|
-
this.sensorsGasCount = 0;
|
|
39
|
-
this.sensorsCarbonDioxydeCount = 0;
|
|
40
|
-
this.sensorsAmbientLightCount = 0;
|
|
41
|
-
this.sensorsMotionCount = 0;
|
|
42
31
|
|
|
43
32
|
//variable
|
|
44
33
|
this.startPrepareAccessory = true;
|
|
@@ -138,17 +127,17 @@ class Sensors extends EventEmitter {
|
|
|
138
127
|
|
|
139
128
|
//update characteristics
|
|
140
129
|
const servicesMap = [
|
|
141
|
-
[this.
|
|
142
|
-
[this.
|
|
143
|
-
[this.
|
|
144
|
-
[this.
|
|
145
|
-
[this.
|
|
146
|
-
[this.
|
|
147
|
-
[this.
|
|
148
|
-
[this.
|
|
149
|
-
[this.
|
|
150
|
-
[this.
|
|
151
|
-
[this.
|
|
130
|
+
[this.temperatureServices?.[i], Characteristic.CurrentTemperature, sensor.temperature],
|
|
131
|
+
[this.temperatureReferenceServices?.[i], Characteristic.CurrentTemperature, sensor.referenceTemperature],
|
|
132
|
+
[this.temperatureObjService?.[i], Characteristic.CurrentTemperature, sensor.objTemperature],
|
|
133
|
+
[this.temperatureAmbService?.[i], Characteristic.CurrentTemperature, sensor.ambTemperature],
|
|
134
|
+
[this.temperatureDewPointService?.[i], Characteristic.CurrentTemperature, sensor.dewPointTemperature],
|
|
135
|
+
[this.humidityService?.[i], Characteristic.CurrentRelativeHumidity, sensor.humidity],
|
|
136
|
+
[this.carbonDioxydeServices?.[i], Characteristic.CarbonDioxideDetected, sensor.carbonDioxyde > 1000],
|
|
137
|
+
[this.carbonDioxydeServices?.[i], Characteristic.CarbonDioxideLevel, sensor.carbonDioxyde],
|
|
138
|
+
[this.carbonDioxydeServices?.[i], Characteristic.CarbonDioxidePeakLevel, sensor.carbonDioxyde],
|
|
139
|
+
[this.ambientLightServices?.[i], Characteristic.CurrentAmbientLightLevel, sensor.ambientLight],
|
|
140
|
+
[this.motionServices?.[i], Characteristic.MotionDetected, sensor.motion],
|
|
152
141
|
];
|
|
153
142
|
|
|
154
143
|
for (const [service, charType, value] of servicesMap) {
|
|
@@ -162,17 +151,17 @@ class Sensors extends EventEmitter {
|
|
|
162
151
|
// energy
|
|
163
152
|
if (isEnergy) {
|
|
164
153
|
const energyMap = [
|
|
165
|
-
[this.
|
|
166
|
-
[this.
|
|
167
|
-
[this.
|
|
168
|
-
[this.
|
|
169
|
-
[this.
|
|
170
|
-
[this.
|
|
171
|
-
[this.
|
|
172
|
-
[this.
|
|
173
|
-
[this.
|
|
174
|
-
[this.
|
|
175
|
-
[this.
|
|
154
|
+
[this.powerAndEnergyServices?.[i], Characteristic.Power, sensor.power],
|
|
155
|
+
[this.powerAndEnergyServices?.[i], Characteristic.ApparentPower, sensor.apparentPower],
|
|
156
|
+
[this.powerAndEnergyServices?.[i], Characteristic.ReactivePower, sensor.reactivePower],
|
|
157
|
+
[this.powerAndEnergyServices?.[i], Characteristic.EnergyToday, sensor.energyToday],
|
|
158
|
+
[this.powerAndEnergyServices?.[i], Characteristic.EnergyLastDay, sensor.energyLastDay],
|
|
159
|
+
[this.powerAndEnergyServices?.[i], Characteristic.EnergyLifetime, sensor.energyLifetime],
|
|
160
|
+
[this.powerAndEnergyServices?.[i], Characteristic.Current, sensor.current],
|
|
161
|
+
[this.powerAndEnergyServices?.[i], Characteristic.Voltage, sensor.voltage],
|
|
162
|
+
[this.powerAndEnergyServices?.[i], Characteristic.Factor, sensor.factor],
|
|
163
|
+
[this.powerAndEnergyServices?.[i], Characteristic.Frequency, sensor.frequency],
|
|
164
|
+
[this.powerAndEnergyServices?.[i], Characteristic.ReadingTime, sensor.time],
|
|
176
165
|
];
|
|
177
166
|
|
|
178
167
|
for (const [service, charType, value] of energyMap) {
|
|
@@ -262,16 +251,16 @@ class Sensors extends EventEmitter {
|
|
|
262
251
|
//Prepare services
|
|
263
252
|
if (this.sensorsCount > 0) {
|
|
264
253
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Sensor Services`) : false;
|
|
265
|
-
this.
|
|
266
|
-
this.
|
|
267
|
-
this.
|
|
268
|
-
this.
|
|
269
|
-
this.
|
|
270
|
-
this.
|
|
271
|
-
this.
|
|
272
|
-
this.
|
|
273
|
-
this.
|
|
274
|
-
this.
|
|
254
|
+
this.emperatureServices = [];
|
|
255
|
+
this.temperatureReferenceServices = [];
|
|
256
|
+
this.temperatureObjService = [];
|
|
257
|
+
this.temperatureAmbService = [];
|
|
258
|
+
this.temperatureDewPointService = [];
|
|
259
|
+
this.humidityService = [];
|
|
260
|
+
this.carbonDioxydeServices = [];
|
|
261
|
+
this.ambientLightServices = [];
|
|
262
|
+
this.motionServices = [];
|
|
263
|
+
this.powerAndEnergyServices = [];
|
|
275
264
|
|
|
276
265
|
//temperature
|
|
277
266
|
let i = 0;
|
|
@@ -280,96 +269,96 @@ class Sensors extends EventEmitter {
|
|
|
280
269
|
if (sensor.temperature) {
|
|
281
270
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Temperature Sensor Services`) : false;
|
|
282
271
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Temperature` : `${sensorName} Temperature`;
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
272
|
+
const temperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Temperature Sensor ${i}`);
|
|
273
|
+
temperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
274
|
+
temperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
275
|
+
temperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
287
276
|
.onGet(async () => {
|
|
288
277
|
const value = sensor.temperature;
|
|
289
278
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${sensor.tempUnit}`);
|
|
290
279
|
return value;
|
|
291
280
|
});
|
|
292
|
-
this.
|
|
281
|
+
this.temperatureServices.push(temperatureService);
|
|
293
282
|
}
|
|
294
283
|
|
|
295
284
|
//reference temperature
|
|
296
285
|
if (sensor.referenceTemperature) {
|
|
297
286
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Reference Temperature Sensor Services`) : false;
|
|
298
287
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Reference Temperature` : `${sensorName} Reference Temperature`;
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
288
|
+
const temperatureReferenceService = accessory.addService(Service.TemperatureSensor, serviceName, `Reference Temperature Sensor ${i}`);
|
|
289
|
+
temperatureReferenceService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
290
|
+
temperatureReferenceService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
291
|
+
temperatureReferenceService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
303
292
|
.onGet(async () => {
|
|
304
293
|
const value = sensor.referenceTemperature;
|
|
305
294
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${sensor.tempUnit}`);
|
|
306
295
|
return value;
|
|
307
296
|
});
|
|
308
|
-
this.
|
|
297
|
+
this.temperatureReferenceServices.push(temperatureReferenceService);
|
|
309
298
|
}
|
|
310
299
|
|
|
311
300
|
//object temperature
|
|
312
301
|
if (sensor.objTemperature) {
|
|
313
302
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Obj Temperature Sensor Services`) : false;
|
|
314
303
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Obj Temperature` : `${sensorName} Obj Temperature`;
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
304
|
+
const temperatureObjService = accessory.addService(Service.TemperatureSensor, serviceName, `Obj Temperature Sensor ${i}`);
|
|
305
|
+
temperatureObjService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
306
|
+
temperatureObjService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
307
|
+
temperatureObjService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
319
308
|
.onGet(async () => {
|
|
320
309
|
const value = sensor.objTemperature;
|
|
321
310
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${sensor.tempUnit}`);
|
|
322
311
|
return value;
|
|
323
312
|
});
|
|
324
|
-
this.
|
|
313
|
+
this.temperatureObjService.push(temperatureObjService);
|
|
325
314
|
}
|
|
326
315
|
|
|
327
316
|
//ambient temperature
|
|
328
317
|
if (sensor.ambTemperature) {
|
|
329
318
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Amb Temperature Sensor Services`) : false;
|
|
330
319
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Amb Temperature` : `${sensorName} Amb Temperature`;
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
320
|
+
const temperatureAmbService = accessory.addService(Service.TemperatureSensor, serviceName, `Amb Temperature Sensor ${i}`);
|
|
321
|
+
temperatureAmbService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
322
|
+
temperatureAmbService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
323
|
+
temperatureAmbService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
335
324
|
.onGet(async () => {
|
|
336
325
|
const value = sensor.ambTemperature;
|
|
337
326
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${sensor.tempUnit}`);
|
|
338
327
|
return value;
|
|
339
328
|
});
|
|
340
|
-
this.
|
|
329
|
+
this.temperatureAmbService.push(temperatureAmbService);
|
|
341
330
|
}
|
|
342
331
|
|
|
343
332
|
//dew point temperature
|
|
344
333
|
if (sensor.dewPointTemperature) {
|
|
345
334
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Dew Point Temperature Sensor Services`) : false;
|
|
346
335
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Dew Point` : `${sensorName} Dew Point`;
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
336
|
+
const temperatureDewPointService = accessory.addService(Service.TemperatureSensor, serviceName, `Dew Point Temperature Sensor ${i}`);
|
|
337
|
+
temperatureDewPointService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
338
|
+
temperatureDewPointService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
339
|
+
temperatureDewPointService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
351
340
|
.onGet(async () => {
|
|
352
341
|
const value = sensor.dewPointTemperature;
|
|
353
342
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${sensor.tempUnit}`);
|
|
354
343
|
return value;
|
|
355
344
|
});
|
|
356
|
-
this.
|
|
345
|
+
this.temperatureDewPointService.push(temperatureDewPointService);
|
|
357
346
|
}
|
|
358
347
|
|
|
359
348
|
//humidity
|
|
360
349
|
if (sensor.humidity) {
|
|
361
350
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Humidity Sensor Services`) : false;
|
|
362
351
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Humidity` : `${sensorName} Humidity`;
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
352
|
+
const humidityService = accessory.addService(Service.HumiditySensor, serviceName, `Humidity Sensor ${i}`);
|
|
353
|
+
humidityService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
354
|
+
humidityService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
355
|
+
humidityService.getCharacteristic(Characteristic.CurrentRelativeHumidity)
|
|
367
356
|
.onGet(async () => {
|
|
368
357
|
const value = sensor.humidity;
|
|
369
358
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} humidity: ${value} %`);
|
|
370
359
|
return value;
|
|
371
360
|
});
|
|
372
|
-
this.
|
|
361
|
+
this.humidityService.push(humidityService);
|
|
373
362
|
}
|
|
374
363
|
|
|
375
364
|
//pressure
|
|
@@ -380,70 +369,70 @@ class Sensors extends EventEmitter {
|
|
|
380
369
|
if (sensor.carbonDioxyde) {
|
|
381
370
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Carbon Dioxyde Sensor Services`) : false;
|
|
382
371
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Carbon Dioxyde` : `${sensorName} Carbon Dioxyde`;
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
372
|
+
const carbonDioxydeService = accessory.addService(Service.CarbonDioxideSensor, serviceName, `Carbon Dioxyde Sensor ${i}`);
|
|
373
|
+
carbonDioxydeService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
374
|
+
carbonDioxydeService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
375
|
+
carbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideDetected)
|
|
387
376
|
.onGet(async () => {
|
|
388
377
|
const state = sensor.carbonDioxyde > 1000;
|
|
389
378
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde detected: ${state ? 'Yes' : 'No'}`);
|
|
390
379
|
return state;
|
|
391
380
|
});
|
|
392
|
-
|
|
381
|
+
carbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideLevel)
|
|
393
382
|
.onGet(async () => {
|
|
394
383
|
const value = sensor.carbonDioxyde;
|
|
395
384
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde level: ${value} ppm`);
|
|
396
385
|
return value;
|
|
397
386
|
});
|
|
398
|
-
|
|
387
|
+
carbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxidePeakLevel)
|
|
399
388
|
.onGet(async () => {
|
|
400
389
|
const value = sensor.carbonDioxyde;
|
|
401
390
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde peak level: ${value} ppm`);
|
|
402
391
|
return value;
|
|
403
392
|
});
|
|
404
|
-
this.
|
|
393
|
+
this.carbonDioxydeServices.push(carbonDioxydeService);
|
|
405
394
|
}
|
|
406
395
|
|
|
407
396
|
//ambient light
|
|
408
397
|
if (sensor.ambientLight) {
|
|
409
398
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Ambient Light Sensor Services`) : false;
|
|
410
399
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Ambient Light` : `${sensorName} Ambient Light`;
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
400
|
+
const ambientLightService = accessory.addService(Service.LightSensor, serviceName, `Ambient Light Sensor ${i}`);
|
|
401
|
+
ambientLightService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
402
|
+
ambientLightService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
403
|
+
ambientLightService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
|
|
415
404
|
.onGet(async () => {
|
|
416
405
|
const value = sensor.ambientLight;
|
|
417
406
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} ambient light: ${value} lx`);
|
|
418
407
|
return value;
|
|
419
408
|
});
|
|
420
|
-
this.
|
|
409
|
+
this.ambientLightServices.push(ambientLightService);
|
|
421
410
|
}
|
|
422
411
|
|
|
423
412
|
//motion
|
|
424
413
|
if (sensor.motion) {
|
|
425
414
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Motion Sensor Services`) : false;
|
|
426
415
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Motion` : `${sensorName} Motion`;
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
416
|
+
const motionService = accessory.addService(Service.MotionSensor, serviceName, `Motion Sensor ${i}`);
|
|
417
|
+
motionService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
418
|
+
motionService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
419
|
+
motionService.getCharacteristic(Characteristic.MotionDetected)
|
|
431
420
|
.onGet(async () => {
|
|
432
421
|
const state = sensor.motion;
|
|
433
422
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} motion: ${state ? 'ON' : 'OFF'}`);
|
|
434
423
|
return state;
|
|
435
424
|
});
|
|
436
|
-
this.
|
|
425
|
+
this.motionServices.push(motionService);
|
|
437
426
|
}
|
|
438
427
|
|
|
439
428
|
//energy
|
|
440
429
|
if (sensor.name === 'ENERGY') {
|
|
441
430
|
const debug4 = this.enableDebugMode ? this.emit('debug', `Prepare Power And Energy Service`) : false;
|
|
442
431
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName}` : `${sensorName}`;
|
|
443
|
-
const
|
|
444
|
-
|
|
432
|
+
const powerAndEnergyService = accessory.addService(Service.PowerAndEnergy, serviceName, `Energy Sensor ${i}`);
|
|
433
|
+
powerAndEnergyService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
445
434
|
if (sensor.power) {
|
|
446
|
-
|
|
435
|
+
powerAndEnergyService.getCharacteristic(Characteristic.Power)
|
|
447
436
|
.onGet(async () => {
|
|
448
437
|
const value = sensor.power;
|
|
449
438
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} power: ${value} W`);
|
|
@@ -451,7 +440,7 @@ class Sensors extends EventEmitter {
|
|
|
451
440
|
});
|
|
452
441
|
}
|
|
453
442
|
if (sensor.apparentPower) {
|
|
454
|
-
|
|
443
|
+
powerAndEnergyService.getCharacteristic(Characteristic.ApparentPower)
|
|
455
444
|
.onGet(async () => {
|
|
456
445
|
const value = sensor.apparentPower;
|
|
457
446
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} apparent power: ${value} VA`);
|
|
@@ -459,7 +448,7 @@ class Sensors extends EventEmitter {
|
|
|
459
448
|
});
|
|
460
449
|
}
|
|
461
450
|
if (sensor.reactivePower) {
|
|
462
|
-
|
|
451
|
+
powerAndEnergyService.getCharacteristic(Characteristic.ReactivePower)
|
|
463
452
|
.onGet(async () => {
|
|
464
453
|
const value = sensor.reactivePower;
|
|
465
454
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reactive power: ${value} VAr`);
|
|
@@ -467,7 +456,7 @@ class Sensors extends EventEmitter {
|
|
|
467
456
|
});
|
|
468
457
|
}
|
|
469
458
|
if (sensor.energyToday) {
|
|
470
|
-
|
|
459
|
+
powerAndEnergyService.getCharacteristic(Characteristic.EnergyToday)
|
|
471
460
|
.onGet(async () => {
|
|
472
461
|
const value = sensor.energyToday;
|
|
473
462
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} energy today: ${value} kWh`);
|
|
@@ -475,7 +464,7 @@ class Sensors extends EventEmitter {
|
|
|
475
464
|
});
|
|
476
465
|
}
|
|
477
466
|
if (sensor.energyLastDay) {
|
|
478
|
-
|
|
467
|
+
powerAndEnergyService.getCharacteristic(Characteristic.EnergyLastDay)
|
|
479
468
|
.onGet(async () => {
|
|
480
469
|
const value = sensor.energyLastDay;
|
|
481
470
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} energy last day: ${value} kWh`);
|
|
@@ -483,7 +472,7 @@ class Sensors extends EventEmitter {
|
|
|
483
472
|
});
|
|
484
473
|
}
|
|
485
474
|
if (sensor.energyLifetime) {
|
|
486
|
-
|
|
475
|
+
powerAndEnergyService.getCharacteristic(Characteristic.EnergyLifetime)
|
|
487
476
|
.onGet(async () => {
|
|
488
477
|
const value = sensor.energyLifetime;
|
|
489
478
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} energy lifetime: ${value} kWh`);
|
|
@@ -491,7 +480,7 @@ class Sensors extends EventEmitter {
|
|
|
491
480
|
});
|
|
492
481
|
}
|
|
493
482
|
if (sensor.current) {
|
|
494
|
-
|
|
483
|
+
powerAndEnergyService.getCharacteristic(Characteristic.Current)
|
|
495
484
|
.onGet(async () => {
|
|
496
485
|
const value = sensor.current;
|
|
497
486
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} current: ${value} A`);
|
|
@@ -499,7 +488,7 @@ class Sensors extends EventEmitter {
|
|
|
499
488
|
});
|
|
500
489
|
}
|
|
501
490
|
if (sensor.voltage) {
|
|
502
|
-
|
|
491
|
+
powerAndEnergyService.getCharacteristic(Characteristic.Voltage)
|
|
503
492
|
.onGet(async () => {
|
|
504
493
|
const value = sensor.voltage;
|
|
505
494
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} voltage: ${value} V`);
|
|
@@ -507,7 +496,7 @@ class Sensors extends EventEmitter {
|
|
|
507
496
|
});
|
|
508
497
|
}
|
|
509
498
|
if (sensor.factor) {
|
|
510
|
-
|
|
499
|
+
powerAndEnergyService.getCharacteristic(Characteristic.Factor)
|
|
511
500
|
.onGet(async () => {
|
|
512
501
|
const value = sensor.factor;
|
|
513
502
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} power factor: ${value} cos φ`);
|
|
@@ -515,7 +504,7 @@ class Sensors extends EventEmitter {
|
|
|
515
504
|
});
|
|
516
505
|
}
|
|
517
506
|
if (sensor.frequency) {
|
|
518
|
-
|
|
507
|
+
powerAndEnergyService.getCharacteristic(Characteristic.Freqency)
|
|
519
508
|
.onGet(async () => {
|
|
520
509
|
const value = sensor.frequency;
|
|
521
510
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} frequency: ${value} Hz`);
|
|
@@ -523,14 +512,14 @@ class Sensors extends EventEmitter {
|
|
|
523
512
|
});
|
|
524
513
|
}
|
|
525
514
|
if (sensor.time) {
|
|
526
|
-
|
|
515
|
+
powerAndEnergyService.getCharacteristic(Characteristic.ReadingTime)
|
|
527
516
|
.onGet(async () => {
|
|
528
517
|
const value = sensor.time;
|
|
529
518
|
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} last report: ${value}`);
|
|
530
519
|
return value;
|
|
531
520
|
});
|
|
532
521
|
}
|
|
533
|
-
this.
|
|
522
|
+
this.powerAndEnergyServices.push(powerAndEnergyService);
|
|
534
523
|
}
|
|
535
524
|
i++;
|
|
536
525
|
}
|