homebridge-tasmota-control 0.9.0 → 0.9.1

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.9.0",
4
+ "version": "0.9.1",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/constans.json CHANGED
@@ -24,10 +24,12 @@
24
24
  },
25
25
  "LightKeys": [
26
26
  "Dimmer",
27
+ "Color",
27
28
  "HSBColor",
28
29
  "HSBColor1",
29
30
  "HSBColor2",
30
31
  "HSBColor3",
32
+ "White",
31
33
  "CT"
32
34
  ],
33
35
  "SensorKeys": [
@@ -123,7 +123,7 @@ class TasmotaDevice {
123
123
  };
124
124
 
125
125
  //status fwr
126
- this.statusFWRSupported = deviceInfoKeys.includes('StatusFWR');
126
+ const statusFWRSupported = deviceInfoKeys.includes('StatusFWR');
127
127
  const firmwareRevision = deviceInfo.StatusFWR.Version ?? 'unknown';
128
128
  const modelName = deviceInfo.StatusFWR.Hardware ?? '';
129
129
 
@@ -186,15 +186,10 @@ class TasmotaDevice {
186
186
  if (relaysCount > 0) {
187
187
  this.devicesType = [];
188
188
  this.powersStete = [];
189
-
190
- this.lightsBrightnessSupported = [];
191
- this.lightsBrightness = [];
192
- this.lightsColorTemperatueSupported = [];
193
- this.lightsColorTemperatue = [];
194
- this.lightsHueSupported = [];
195
- this.lightsHue = [];
196
- this.lightsSaturationSupported = [];
197
- this.lightsSaturation = [];
189
+ this.brightness = [];
190
+ this.colorTemperatue = [];
191
+ this.hue = [];
192
+ this.saturation = [];
198
193
 
199
194
  const powersStatusData = await this.axiosInstance(CONSTANS.ApiCommands.PowerStatus);
200
195
  const powersStatus = powersStatusData.data;
@@ -204,47 +199,37 @@ class TasmotaDevice {
204
199
  const powerKeys = Object.keys(powersStatus);
205
200
  const deviceType = powerKeys.some(key => CONSTANS.LightKeys.includes(key)) ? 1 : 0; //0 - switch/outlet, 1 - light
206
201
  const powerKey = relaysCount === 1 ? 'POWER' : 'POWER' + (i + 1);
207
- const status = powersStatus[powerKey] === 'ON' ?? false;
208
-
209
- const brightnessSupported = powerKeys.includes('Dimmer');
202
+
203
+ const powerStase = powersStatus[powerKey] === 'ON' ?? false;
210
204
  const brightness = powersStatus.Dimmer ?? false;
211
- const colorTemperatureSupported = powerKeys.includes('CT');
212
205
  const colorTemperature = powersStatus.CT ?? false;
213
- const hueSupported = powerKeys.includes('HSBColor1');
214
206
  const hue = powersStatus.HSBColor1 ?? false;
215
- const saturationSupported = powerKeys.includes('HSBColor2');
216
207
  const saturation = powersStatus.HSBColor2 ?? false;
217
208
 
218
209
  this.devicesType.push(deviceType);
219
- this.powersStete.push(status);
220
- this.lightsBrightnessSupported.push(brightnessSupported)
221
- const push = brightnessSupported ? this.lightsBrightness.push(brightness) : false;
222
- this.lightsColorTemperatueSupported.push(colorTemperatureSupported)
223
- const push1 = colorTemperatureSupported ? this.lightsColorTemperatue.push(colorTemperature) : false;
224
- this.lightsHueSupported.push(hueSupported)
225
- const push2 = hueSupported ? this.lightsHue.push(hue) : false;
226
- this.lightsSaturationSupported.push(saturationSupported)
227
- const push3 = saturationSupported ? this.lightsHue.push(saturation) : false;
210
+ this.powersStete.push(powerStase);
211
+ this.brightness.push(brightness);
212
+ this.colorTemperatue.push(colorTemperature);
213
+ this.hue.push(hue);
214
+ this.saturation.push(saturation);
228
215
 
229
216
  //update characteristics
230
217
  if (this.switchOutletLightServices) {
231
218
  this.switchOutletLightServices[i]
232
- .updateCharacteristic(Characteristic.On, status);
219
+ .updateCharacteristic(Characteristic.On, powerStase);
233
220
 
234
221
  if (deviceType === 1) {
235
- this.switchOutletLightServices[i].updateCharacteristic(Characteristic.On, status);
236
-
237
- if (brightnessSupported) {
222
+ if (brightness !== false) {
238
223
  this.switchOutletLightServices[i].updateCharacteristic(Characteristic.Brightness, brightness);
239
224
  };
240
- if (colorTemperatureSupported) {
225
+ if (colorTemperature !== false) {
241
226
  const value = colorTemperature > 153 ? colorTemperature : 140;
242
227
  this.switchOutletLightServices[i].updateCharacteristic(Characteristic.ColorTemperature, value);
243
228
  };
244
- if (hueSupported) {
229
+ if (hue !== false) {
245
230
  this.switchOutletLightServices[i].updateCharacteristic(Characteristic.Hue, hue);
246
231
  };
247
- if (saturationSupported) {
232
+ if (saturation !== false) {
248
233
  this.switchOutletLightServices[i].updateCharacteristic(Characteristic.Saturation, saturation);
249
234
  };
250
235
  };
@@ -408,10 +393,10 @@ class TasmotaDevice {
408
393
  }
409
394
  });
410
395
  if (deviceType === 1) {
411
- if (this.lightsBrightnessSupported[i]) {
396
+ if (this.brightness[i] !== false) {
412
397
  switchOutletLightService.getCharacteristic(Characteristic.Brightness)
413
398
  .onGet(async () => {
414
- const value = this.lightsBrightness[i] ?? 0;
399
+ const value = this.brightness[i] ?? 0;
415
400
  const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, brightness: ${value} %`);
416
401
  return value;
417
402
  })
@@ -425,10 +410,10 @@ class TasmotaDevice {
425
410
  }
426
411
  });
427
412
  };
428
- if (this.lightsColorTemperatueSupported[i]) {
413
+ if (this.colorTemperatue[i] !== false) {
429
414
  switchOutletLightService.getCharacteristic(Characteristic.ColorTemperature)
430
415
  .onGet(async () => {
431
- const value = this.lightsColorTemperatue[i] > 153 ? this.lightsColorTemperatue[i] : 140;
416
+ const value = this.colorTemperatue[i] > 153 ? this.colorTemperatue[i] : 140;
432
417
  const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, color temperatur: ${value}`);
433
418
  return value;
434
419
  })
@@ -443,10 +428,10 @@ class TasmotaDevice {
443
428
  }
444
429
  });
445
430
  };
446
- if (this.lightsHueSupported[i]) {
431
+ if (this.hue[i] !== false) {
447
432
  switchOutletLightService.getCharacteristic(Characteristic.Hue)
448
433
  .onGet(async () => {
449
- const value = this.lightsHue[i] ?? 0;
434
+ const value = this.hue[i] ?? 0;
450
435
  const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, hue: ${value} %`);
451
436
  return value;
452
437
  })
@@ -460,10 +445,10 @@ class TasmotaDevice {
460
445
  }
461
446
  });
462
447
  };
463
- if (this.lightsSaturationSupported[i]) {
448
+ if (this.saturation[i] !== false) {
464
449
  switchOutletLightService.getCharacteristic(Characteristic.Saturation)
465
450
  .onGet(async () => {
466
- const value = this.lightsSaturation[i] ?? 0;
451
+ const value = this.saturation[i] ?? 0;
467
452
  const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, saturation: ${value} %`);
468
453
  return value;
469
454
  })