homebridge-tasmota-control 1.4.1-beta.10 → 1.4.1-beta.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/sensors.js +22 -22
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.4.1-beta.10",
4
+ "version": "1.4.1-beta.12",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/sensors.js CHANGED
@@ -111,7 +111,6 @@ class Sensors extends EventEmitter {
111
111
  carbonDioxyde: sensorData.CarbonDioxyde,
112
112
  ambientLight: sensorData.Ambient,
113
113
  motion: sensorData === 'ON',
114
-
115
114
  //energy
116
115
  energyTotalStartTime: sensorData.TotalStartTime ?? '',
117
116
  energyTotal: sensorData.Total ?? 0,
@@ -124,16 +123,15 @@ class Sensors extends EventEmitter {
124
123
  factor: sensorData.Factor ?? 0,
125
124
  voltage: sensorData.Voltage ?? 0,
126
125
  current: sensorData.Current ?? 0,
127
- load: sensorData.Load ?? 0
126
+ load: sensorData.Load ?? 0,
127
+ time: sensorStatus.Time ?? '',
128
+ tempUnit: sensorStatus.TempUnit === 'C' ? '°C' : 'F',
129
+ pressureUnit: sensorStatus.PressureUnit ?? 'hPa'
128
130
  }
129
131
 
130
132
  //push to array
131
133
  this.sensors.push(obj);
132
134
  }
133
-
134
- this.time = sensorStatus.Time ?? '';
135
- this.tempUnit = sensorStatus.TempUnit === 'C' ? '°C' : 'F';
136
- this.pressureUnit = sensorStatus.PressureUnit ?? 'hPa';
137
135
  this.sensorsCount = this.sensors.length;
138
136
 
139
137
  //update characteristics
@@ -229,6 +227,7 @@ class Sensors extends EventEmitter {
229
227
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare Sensor Services`) : false;
230
228
 
231
229
  //temperature
230
+ let i = 0;
232
231
  for (const sensor of this.sensors) {
233
232
  const sensorName = sensor.name;
234
233
  if (sensor.temperature !== undefined) {
@@ -240,8 +239,8 @@ class Sensors extends EventEmitter {
240
239
  sensorTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
241
240
  sensorTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
242
241
  .onGet(async () => {
243
- const value = this.sensorsTemperature[i];
244
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${this.tempUnit}`);
242
+ const value = sensor.temperature;
243
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${sensor.tempUnit}`);
245
244
  return value;
246
245
  });
247
246
  this.sensorTemperatureServices.push(sensorTemperatureService);
@@ -257,8 +256,8 @@ class Sensors extends EventEmitter {
257
256
  sensorReferenceTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
258
257
  sensorReferenceTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
259
258
  .onGet(async () => {
260
- const value = this.sensorsReferenceTemperature[i];
261
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${this.tempUnit}`);
259
+ const value = sensor.referenceTemperature;
260
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${sensor.tempUnit}`);
262
261
  return value;
263
262
  });
264
263
  this.sensorReferenceTemperatureServices.push(sensorReferenceTemperatureService);
@@ -274,8 +273,8 @@ class Sensors extends EventEmitter {
274
273
  sensorObjTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
275
274
  sensorObjTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
276
275
  .onGet(async () => {
277
- const value = this.sensorsObjTemperature[i];
278
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${this.tempUnit}`);
276
+ const value = sensor.objTemperature;
277
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${sensor.tempUnit}`);
279
278
  return value;
280
279
  });
281
280
  this.sensorObjTemperatureServices.push(sensorObjTemperatureService);
@@ -291,8 +290,8 @@ class Sensors extends EventEmitter {
291
290
  sensorAmbTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
292
291
  sensorAmbTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
293
292
  .onGet(async () => {
294
- const value = this.sensorsAmbTemperature[i];
295
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${this.tempUnit}`);
293
+ const value = sensor.ambTemperature;
294
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${sensor.tempUnit}`);
296
295
  return value;
297
296
  });
298
297
  this.sensorAmbTemperatureServices.push(sensorAmbTemperatureService);
@@ -308,8 +307,8 @@ class Sensors extends EventEmitter {
308
307
  sensorDewPointTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
309
308
  sensorDewPointTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
310
309
  .onGet(async () => {
311
- const value = this.sensorsDewPointTemperature[i];
312
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${this.tempUnit}`);
310
+ const value = sensor.dewPointTemperature;
311
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${sensor.tempUnit}`);
313
312
  return value;
314
313
  });
315
314
  this.sensorDewPointTemperatureServices.push(sensorDewPointTemperatureService);
@@ -325,7 +324,7 @@ class Sensors extends EventEmitter {
325
324
  sensorHumidityService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
326
325
  sensorHumidityService.getCharacteristic(Characteristic.CurrentRelativeHumidity)
327
326
  .onGet(async () => {
328
- const value = this.sensorsHumidity[i];
327
+ const value = sensor.humidity;
329
328
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} humidity: ${value} %`);
330
329
  return value;
331
330
  });
@@ -346,19 +345,19 @@ class Sensors extends EventEmitter {
346
345
  sensorCarbonDioxydeService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
347
346
  sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideDetected)
348
347
  .onGet(async () => {
349
- const state = this.sensorsCarbonDioxyde[i] > 1000;
348
+ const state = sensor.carbonDioxyde > 1000;
350
349
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde detected: ${state ? 'Yes' : 'No'}`);
351
350
  return state;
352
351
  });
353
352
  sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideLevel)
354
353
  .onGet(async () => {
355
- const value = this.sensorsCarbonDioxyde[i];
354
+ const value = sensor.carbonDioxyde;
356
355
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde level: ${value} ppm`);
357
356
  return value;
358
357
  });
359
358
  sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxidePeakLevel)
360
359
  .onGet(async () => {
361
- const value = this.sensorsCarbonDioxyde[i];
360
+ const value = sensor.carbonDioxyde;
362
361
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde peak level: ${value} ppm`);
363
362
  return value;
364
363
  });
@@ -375,7 +374,7 @@ class Sensors extends EventEmitter {
375
374
  sensorAmbientLightService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
376
375
  sensorAmbientLightService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
377
376
  .onGet(async () => {
378
- const value = this.sensorsAmbientLight[i];
377
+ const value = sensor.ambientLight;
379
378
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} ambient light: ${value} lx`);
380
379
  return value;
381
380
  });
@@ -392,12 +391,13 @@ class Sensors extends EventEmitter {
392
391
  sensorMotionService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
393
392
  sensorMotionService.getCharacteristic(Characteristic.MotionDetected)
394
393
  .onGet(async () => {
395
- const state = this.sensorsMotion[i];
394
+ const state = sensor.motion;
396
395
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} motion: ${state ? 'ON' : 'OFF'}`);
397
396
  return state;
398
397
  });
399
398
  this.sensorMotionServices.push(sensorMotionService);
400
399
  }
400
+ i++;
401
401
  }
402
402
  }
403
403