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 +1 -1
- package/src/constans.json +2 -0
- package/src/tasmotadevice.js +25 -40
package/package.json
CHANGED
package/src/constans.json
CHANGED
package/src/tasmotadevice.js
CHANGED
|
@@ -123,7 +123,7 @@ class TasmotaDevice {
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
//status fwr
|
|
126
|
-
|
|
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.
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
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
|
-
|
|
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(
|
|
220
|
-
this.
|
|
221
|
-
|
|
222
|
-
this.
|
|
223
|
-
|
|
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,
|
|
219
|
+
.updateCharacteristic(Characteristic.On, powerStase);
|
|
233
220
|
|
|
234
221
|
if (deviceType === 1) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (brightnessSupported) {
|
|
222
|
+
if (brightness !== false) {
|
|
238
223
|
this.switchOutletLightServices[i].updateCharacteristic(Characteristic.Brightness, brightness);
|
|
239
224
|
};
|
|
240
|
-
if (
|
|
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 (
|
|
229
|
+
if (hue !== false) {
|
|
245
230
|
this.switchOutletLightServices[i].updateCharacteristic(Characteristic.Hue, hue);
|
|
246
231
|
};
|
|
247
|
-
if (
|
|
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.
|
|
396
|
+
if (this.brightness[i] !== false) {
|
|
412
397
|
switchOutletLightService.getCharacteristic(Characteristic.Brightness)
|
|
413
398
|
.onGet(async () => {
|
|
414
|
-
const value = this.
|
|
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.
|
|
413
|
+
if (this.colorTemperatue[i] !== false) {
|
|
429
414
|
switchOutletLightService.getCharacteristic(Characteristic.ColorTemperature)
|
|
430
415
|
.onGet(async () => {
|
|
431
|
-
const value = this.
|
|
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.
|
|
431
|
+
if (this.hue[i] !== false) {
|
|
447
432
|
switchOutletLightService.getCharacteristic(Characteristic.Hue)
|
|
448
433
|
.onGet(async () => {
|
|
449
|
-
const value = this.
|
|
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.
|
|
448
|
+
if (this.saturation[i] !== false) {
|
|
464
449
|
switchOutletLightService.getCharacteristic(Characteristic.Saturation)
|
|
465
450
|
.onGet(async () => {
|
|
466
|
-
const value = this.
|
|
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
|
})
|