homebridge-tasmota-control 0.6.2-beta.0 → 0.6.2-beta.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "0.6.2-beta.0",
4
+ "version": "0.6.2-beta.2",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -104,9 +104,14 @@ class TasmotaDevice {
104
104
  //status sns
105
105
  this.statusSNSSupported = deviceInfoKeys.includes('StatusSNS');
106
106
  CONSTANS.StatusSNS.forEach(sensor => {
107
- const subSensor = sensor.substring(0, 7);
108
- const sensorData = deviceInfo.StatusSNS[subSensor] ?? false;
109
- const push = sensorData ? this.sensors.push(sensorData) : false;
107
+ const sensorName = sensor.substring(0, 7);
108
+ const sensorData = deviceInfo.StatusSNS[sensorName] ?? false;
109
+
110
+ const obj = {
111
+ 'name': sensorName,
112
+ 'data': sensorData
113
+ }
114
+ const push = sensorData !== false && sensorData !== undefined && sensorData !== null ? this.sensors.push(obj) : false;
110
115
  });
111
116
  const sensorsCount = this.sensors.length
112
117
 
@@ -164,6 +169,7 @@ class TasmotaDevice {
164
169
  //sensors
165
170
  const sensorsCount = this.sensorsCount;
166
171
  if (sensorsCount > 0) {
172
+ this.sensorsName = [];
167
173
  this.sensorsTemperature = [];
168
174
  this.sensorsHumidity = [];
169
175
  this.sensorsDewPoint = [];
@@ -175,20 +181,20 @@ class TasmotaDevice {
175
181
  const debug = this.enableDebugMode ? this.log(`Device: ${this.host} ${this.name}, debug ${sensorsCount === 1 ? 'sensor' : 'sensors'} status: ${JSON.stringify(sensorsStatus, null, 2)}`) : false;
176
182
 
177
183
  for (let i = 0; i < sensorsCount; i++) {
178
- const sensor = this.sensors[i];
179
- const temperature = sensor.Temperature ?? false;
180
- const humidity = sensor.Humidity ?? false;
181
- const dewPoint = sensor.DewPoint ?? false;
182
- const pressure = sensor.Pressure ?? false;
183
- const gas = sensor.Gas ?? false;
184
-
185
- const debug = this.enableDebugMode ? this.log(`Device: ${this.host} ${this.name}, debug temperature: ${temperature}`) : false;
186
-
187
- const push = !temperature ? false : this.sensorsTemperature.push(temperature);
188
- const push1 = !humidity ? false : this.sensorsHumidity.push(humidity);
189
- const push2 = !dewPoint ? false : this.sensorsDewPoint.push(dewPoint);
190
- const push3 = !pressure ? false : this.sensorsPressure.push(pressure);
191
- const push4 = !gas ? false : this.sensorsGas.push(gas);
184
+ const sensorName = this.sensors[i].name;
185
+ const sensorData = this.sensors[i].data;
186
+ const temperature = sensorData.Temperature ?? false;
187
+ const humidity = sensorData.Humidity ?? false;
188
+ const dewPoint = sensorData.DewPoint ?? false;
189
+ const pressure = sensorData.Pressure ?? false;
190
+ const gas = sensorData.Gas ?? false;
191
+
192
+ const push = sensorName !== false && sensorName !== undefined && sensorName !== null ? this.sensorsName.push(sensorName) : false;
193
+ const push1 = temperature !== false && temperature !== undefined && temperature !== null ? this.sensorsTemperature.push(temperature) : false;
194
+ const push2 = humidity !== false && temperature !== undefined && temperature !== null ? this.sensorsHumidity.push(humidity) : false;
195
+ const push3 = dewPoint !== false && temperature !== undefined && temperature !== null ? this.sensorsDewPoint.push(dewPoint) : false;
196
+ const push4 = pressure !== false && temperature !== undefined && temperature !== null ? this.sensorsPressure.push(pressure) : false;
197
+ const push5 = gas !== false && temperature !== undefined && temperature !== null ? this.sensorsGas.push(gas) : false;
192
198
  };
193
199
 
194
200
  this.sensorsTemperatureCount = this.sensorsTemperature.length;
@@ -313,14 +319,15 @@ class TasmotaDevice {
313
319
  const debug = this.enableDebugMode ? this.log('Prepare Temperature Sensor Services') : false;
314
320
  this.sensorTemperatureServices = [];
315
321
  for (let i = 0; i < sensorsTemperatureCount; i++) {
316
- const serviceName = `${accessoryName} Temperature`;
322
+ const sensorName = this.sensorsName[i];
323
+ const serviceName = `${accessoryName} ${sensorName} Temperature`;
317
324
  const sensorTemperatureService = new Service.TemperatureSensor(serviceName, `Temperature Sensor${i}`);
318
325
  sensorTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
319
326
  sensorTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
320
327
  sensorTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
321
328
  .onGet(async () => {
322
329
  const value = this.sensorsTemperature[i];
323
- const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host}, ${accessoryName}, temperature: ${value} °${this.tempUnit}`);
330
+ const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host}, ${accessoryName}, sensor:${sensorName} temperature: ${value} °${this.tempUnit}`);
324
331
  return value;
325
332
  });
326
333
  this.sensorTemperatureServices.push(sensorTemperatureService);
@@ -334,14 +341,15 @@ class TasmotaDevice {
334
341
  const debug = this.enableDebugMode ? this.log('Prepare Humidity Sensor Services') : false;
335
342
  this.sensorHumidityServices = [];
336
343
  for (let i = 0; i < sensorsHumidityCount; i++) {
337
- const serviceName = `${accessoryName} Humidity`;
344
+ const sensorName = this.sensorsName[i];
345
+ const serviceName = `${accessoryName} ${sensorName} Humidity`;
338
346
  const sensorHumidityService = new Service.HumiditySensor(serviceName, `Humidity Sensor${i}`);
339
347
  sensorHumidityService.addOptionalCharacteristic(Characteristic.ConfiguredName);
340
348
  sensorHumidityService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
341
349
  sensorHumidityService.getCharacteristic(Characteristic.CurrentRelativeHumidity)
342
350
  .onGet(async () => {
343
351
  const value = this.sensorsHumidity[i];
344
- const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host}, ${accessoryName}, humidity: ${value} %`);
352
+ const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host}, ${accessoryName}, sensor: ${sensorName} humidity: ${value} %`);
345
353
  return value;
346
354
  });
347
355
  this.sensorHumidityServices.push(sensorHumidityService);
@@ -355,14 +363,15 @@ class TasmotaDevice {
355
363
  const debug = this.enableDebugMode ? this.log('Prepare Dew Point Sensor Services') : false;
356
364
  this.sensorDewPointServices = [];
357
365
  for (let i = 0; i < sensorsDewPointCount; i++) {
358
- const serviceName = `${accessoryName} Dew Point`;
366
+ const sensorName = this.sensorsName[i];
367
+ const serviceName = `${accessoryName} ${sensorName} Dew Point`;
359
368
  const sensorDewPointService = new Service.TemperatureSensor(serviceName, `Dew Point Sensor${i}`);
360
369
  sensorDewPointService.addOptionalCharacteristic(Characteristic.ConfiguredName);
361
370
  sensorDewPointService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
362
371
  sensorDewPointService.getCharacteristic(Characteristic.CurrentTemperature)
363
372
  .onGet(async () => {
364
373
  const value = this.sensorsDewPoint[i];
365
- const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host}, ${accessoryName}, dew point: ${value} °${this.tempUnit}`);
374
+ const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host}, ${accessoryName}, sensor:${sensorName} dew point: ${value} °${this.tempUnit}`);
366
375
  return value;
367
376
  });
368
377
  this.sensorDewPointServices.push(sensorDewPointService);
@@ -373,7 +382,7 @@ class TasmotaDevice {
373
382
  //pressure
374
383
 
375
384
  //gas
376
- }
385
+ };
377
386
 
378
387
  resolve(accessory);
379
388
  } catch (error) {