homebridge-tasmota-control 1.7.1 → 1.7.3
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/index.js +1 -1
- package/package.json +1 -1
- package/src/fans.js +6 -8
- package/src/lights.js +9 -19
- package/src/mielhvac.js +11 -40
- package/src/sensors.js +30 -32
- package/src/switches.js +5 -9
package/index.js
CHANGED
|
@@ -160,7 +160,7 @@ class tasmotaPlatform {
|
|
|
160
160
|
i++;
|
|
161
161
|
}
|
|
162
162
|
} catch (error) {
|
|
163
|
-
if (logLevel.error)
|
|
163
|
+
if (logLevel.error) throw new Error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
});
|
package/package.json
CHANGED
package/src/fans.js
CHANGED
|
@@ -132,14 +132,12 @@ class Fans extends EventEmitter {
|
|
|
132
132
|
this.fans.push(fan);
|
|
133
133
|
|
|
134
134
|
//update characteristics
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
.updateCharacteristic(Characteristic.RotationSpeed, speed);
|
|
142
|
-
}
|
|
135
|
+
const serviceName = this.fansNamePrefix ? `${this.info.deviceName} ${friendlyName}` : friendlyName;
|
|
136
|
+
this.fanServices?.[i]
|
|
137
|
+
?.setCharacteristic(Characteristic.ConfiguredName, serviceName)
|
|
138
|
+
.updateCharacteristic(Characteristic.On, powerFan)
|
|
139
|
+
// .updateCharacteristic(Characteristic.Direction, direction)
|
|
140
|
+
.updateCharacteristic(Characteristic.RotationSpeed, speed);
|
|
143
141
|
|
|
144
142
|
|
|
145
143
|
//log info
|
package/src/lights.js
CHANGED
|
@@ -125,25 +125,15 @@ class Lights extends EventEmitter {
|
|
|
125
125
|
this.lights.push(light);
|
|
126
126
|
|
|
127
127
|
//update characteristics
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (colorTemperature !== false) {
|
|
138
|
-
service.updateCharacteristic(Characteristic.ColorTemperature, colorTemperature);
|
|
139
|
-
}
|
|
140
|
-
if (hue !== false) {
|
|
141
|
-
service.updateCharacteristic(Characteristic.Hue, hue);
|
|
142
|
-
}
|
|
143
|
-
if (saturation !== false) {
|
|
144
|
-
service.updateCharacteristic(Characteristic.Saturation, saturation);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
128
|
+
const serviceName = this.lightsNamePrefix ? `${this.info.deviceName} ${friendlyName}` : friendlyName;
|
|
129
|
+
this.lightServices?.[i]
|
|
130
|
+
?.setCharacteristic(Characteristic.ConfiguredName, serviceName)
|
|
131
|
+
.updateCharacteristic(Characteristic.On, power);
|
|
132
|
+
|
|
133
|
+
if (brightnessType > 0) this.lightServices?.[i]?.updateCharacteristic(Characteristic.Brightness, bright);
|
|
134
|
+
if (colorTemperature !== false) this.lightServices?.[i]?.updateCharacteristic(Characteristic.ColorTemperature, colorTemperature);
|
|
135
|
+
if (hue !== false) this.lightServices?.[i]?.updateCharacteristic(Characteristic.Hue, hue);
|
|
136
|
+
if (saturation !== false) this.lightServices?.[i]?.updateCharacteristic(Characteristic.Saturation, saturation);
|
|
147
137
|
|
|
148
138
|
|
|
149
139
|
//log info
|
package/src/mielhvac.js
CHANGED
|
@@ -414,23 +414,9 @@ class MiElHvac extends EventEmitter {
|
|
|
414
414
|
.updateCharacteristic(Characteristic.TemperatureDisplayUnits, useFahrenheit)
|
|
415
415
|
.updateCharacteristic(Characteristic.SwingMode, swingMode);
|
|
416
416
|
|
|
417
|
-
if (obj.targetOperationMode === 0 || obj.targetOperationMode === 2)
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
obj.targetOperationMode === 0 ? defaultCoolingSetTemperature : setTemperature
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
if (obj.targetOperationMode === 0 || obj.targetOperationMode === 1) {
|
|
425
|
-
svc.updateCharacteristic(
|
|
426
|
-
Characteristic.HeatingThresholdTemperature,
|
|
427
|
-
obj.targetOperationMode === 0 ? defaultHeatingSetTemperature : setTemperature
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (modelSupportsFanSpeed) {
|
|
432
|
-
svc.updateCharacteristic(Characteristic.RotationSpeed, obj.fanSpeed);
|
|
433
|
-
}
|
|
417
|
+
if (obj.targetOperationMode === 0 || obj.targetOperationMode === 2) svc.updateCharacteristic(Characteristic.CoolingThresholdTemperature, obj.targetOperationMode === 0 ? defaultCoolingSetTemperature : setTemperature);
|
|
418
|
+
if (obj.targetOperationMode === 0 || obj.targetOperationMode === 1) svc.updateCharacteristic(Characteristic.HeatingThresholdTemperature, obj.targetOperationMode === 0 ? defaultHeatingSetTemperature : setTemperature);
|
|
419
|
+
if (modelSupportsFanSpeed) svc.updateCharacteristic(Characteristic.RotationSpeed, obj.fanSpeed);
|
|
434
420
|
|
|
435
421
|
if (this.frostProtectEnable) {
|
|
436
422
|
if (roomTemperature <= this.frostProtectLowTemp && !power) {
|
|
@@ -462,11 +448,7 @@ class MiElHvac extends EventEmitter {
|
|
|
462
448
|
const sameMode = preset.mode === iseeMode;
|
|
463
449
|
|
|
464
450
|
preset.state = power ? (sameMode && sameTemp && sameFan && sameSwingV && sameSwingH) : false;
|
|
465
|
-
|
|
466
|
-
if (this.presetsServices) {
|
|
467
|
-
this.presetsServices[index]
|
|
468
|
-
.updateCharacteristic(preset.characteristicType, preset.state);
|
|
469
|
-
}
|
|
451
|
+
this.presetsServices?.[index]?.updateCharacteristic(preset.characteristicType, preset.state);
|
|
470
452
|
});
|
|
471
453
|
}
|
|
472
454
|
|
|
@@ -563,11 +545,8 @@ class MiElHvac extends EventEmitter {
|
|
|
563
545
|
|
|
564
546
|
button.state = state;
|
|
565
547
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
this.buttonsServices[index]
|
|
569
|
-
.updateCharacteristic(characteristicType, state);
|
|
570
|
-
}
|
|
548
|
+
const characteristicType = button.characteristicType;
|
|
549
|
+
this.buttonsServices?.[index]?.updateCharacteristic(characteristicType, state);
|
|
571
550
|
});
|
|
572
551
|
}
|
|
573
552
|
|
|
@@ -656,25 +635,17 @@ class MiElHvac extends EventEmitter {
|
|
|
656
635
|
this.emit('warn', `Unknown sensor mode: ${mode} detected`);
|
|
657
636
|
}
|
|
658
637
|
|
|
659
|
-
// Update characteristic
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
this.sensorsServices[index]?.updateCharacteristic(characteristicType, sensor.state);
|
|
663
|
-
}
|
|
638
|
+
// Update characteristic{
|
|
639
|
+
const characteristicType = sensor.characteristicType;
|
|
640
|
+
this.sensorsServices?.[index]?.updateCharacteristic(characteristicType, sensor.state);
|
|
664
641
|
});
|
|
665
642
|
}
|
|
666
643
|
|
|
667
644
|
//update room temperature sensor
|
|
668
|
-
|
|
669
|
-
this.roomTemperatureSensorService
|
|
670
|
-
.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
|
|
671
|
-
}
|
|
645
|
+
this.roomTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
|
|
672
646
|
|
|
673
647
|
//update outdoor temperature sensor
|
|
674
|
-
|
|
675
|
-
this.outdoorTemperatureSensorService
|
|
676
|
-
.updateCharacteristic(Characteristic.CurrentTemperature, outdoorTemperature);
|
|
677
|
-
}
|
|
648
|
+
this.outdoorTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, outdoorTemperature);
|
|
678
649
|
|
|
679
650
|
//log current state
|
|
680
651
|
if (!this.disableLogInfo) {
|
package/src/sensors.js
CHANGED
|
@@ -135,49 +135,47 @@ class Sensors extends EventEmitter {
|
|
|
135
135
|
|
|
136
136
|
//update characteristics
|
|
137
137
|
const servicesMap = [
|
|
138
|
-
[this.temperatureServices
|
|
139
|
-
[this.temperatureReferenceServices
|
|
140
|
-
[this.temperatureObjServices
|
|
141
|
-
[this.temperatureAmbServices
|
|
142
|
-
[this.temperatureDewPointServices
|
|
143
|
-
[this.humidityServices
|
|
144
|
-
[this.carbonDioxydeServices
|
|
145
|
-
[this.carbonDioxydeServices
|
|
146
|
-
[this.carbonDioxydeServices
|
|
147
|
-
[this.ambientLightServices
|
|
148
|
-
[this.motionServices
|
|
138
|
+
[this.temperatureServices, Characteristic.CurrentTemperature, sensor.temperature],
|
|
139
|
+
[this.temperatureReferenceServices, Characteristic.CurrentTemperature, sensor.referenceTemperature],
|
|
140
|
+
[this.temperatureObjServices, Characteristic.CurrentTemperature, sensor.objTemperature],
|
|
141
|
+
[this.temperatureAmbServices, Characteristic.CurrentTemperature, sensor.ambTemperature],
|
|
142
|
+
[this.temperatureDewPointServices, Characteristic.CurrentTemperature, sensor.dewPointTemperature],
|
|
143
|
+
[this.humidityServices, Characteristic.CurrentRelativeHumidity, sensor.humidity],
|
|
144
|
+
[this.carbonDioxydeServices, Characteristic.CarbonDioxideDetected, sensor.carbonDioxyde > 1000],
|
|
145
|
+
[this.carbonDioxydeServices, Characteristic.CarbonDioxideLevel, sensor.carbonDioxyde],
|
|
146
|
+
[this.carbonDioxydeServices, Characteristic.CarbonDioxidePeakLevel, sensor.carbonDioxyde],
|
|
147
|
+
[this.ambientLightServices, Characteristic.CurrentAmbientLightLevel, sensor.ambientLight],
|
|
148
|
+
[this.motionServices, Characteristic.MotionDetected, sensor.motion],
|
|
149
149
|
];
|
|
150
150
|
|
|
151
151
|
for (const [service, charType, value] of servicesMap) {
|
|
152
|
-
const characteristic = service?.getCharacteristic(charType);
|
|
153
|
-
if (!characteristic)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
service.updateCharacteristic(charType, value);
|
|
152
|
+
const characteristic = service?.[i]?.getCharacteristic(charType);
|
|
153
|
+
if (!characteristic) continue;
|
|
154
|
+
|
|
155
|
+
service?.[i]?.updateCharacteristic(charType, value);
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
// energy
|
|
160
159
|
if (isEnergy) {
|
|
161
160
|
const energyMap = [
|
|
162
|
-
[this.powerAndEnergyServices
|
|
163
|
-
[this.powerAndEnergyServices
|
|
164
|
-
[this.powerAndEnergyServices
|
|
165
|
-
[this.powerAndEnergyServices
|
|
166
|
-
[this.powerAndEnergyServices
|
|
167
|
-
[this.powerAndEnergyServices
|
|
168
|
-
[this.powerAndEnergyServices
|
|
169
|
-
[this.powerAndEnergyServices
|
|
170
|
-
[this.powerAndEnergyServices
|
|
171
|
-
[this.powerAndEnergyServices
|
|
172
|
-
[this.powerAndEnergyServices
|
|
161
|
+
[this.powerAndEnergyServices, Characteristic.Power, sensor.power],
|
|
162
|
+
[this.powerAndEnergyServices, Characteristic.ApparentPower, sensor.apparentPower],
|
|
163
|
+
[this.powerAndEnergyServices, Characteristic.ReactivePower, sensor.reactivePower],
|
|
164
|
+
[this.powerAndEnergyServices, Characteristic.EnergyToday, sensor.energyToday],
|
|
165
|
+
[this.powerAndEnergyServices, Characteristic.EnergyLastDay, sensor.energyLastDay],
|
|
166
|
+
[this.powerAndEnergyServices, Characteristic.EnergyLifetime, sensor.energyLifetime],
|
|
167
|
+
[this.powerAndEnergyServices, Characteristic.Current, sensor.current],
|
|
168
|
+
[this.powerAndEnergyServices, Characteristic.Voltage, sensor.voltage],
|
|
169
|
+
[this.powerAndEnergyServices, Characteristic.Factor, sensor.factor],
|
|
170
|
+
[this.powerAndEnergyServices, Characteristic.Frequency, sensor.frequency],
|
|
171
|
+
[this.powerAndEnergyServices, Characteristic.ReadingTime, sensor.time],
|
|
173
172
|
];
|
|
174
173
|
|
|
175
174
|
for (const [service, charType, value] of energyMap) {
|
|
176
|
-
const characteristic = service?.getCharacteristic(charType);
|
|
177
|
-
if (!characteristic)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
service.updateCharacteristic(charType, value);
|
|
175
|
+
const characteristic = service?.[i]?.getCharacteristic(charType);
|
|
176
|
+
if (!characteristic) continue;
|
|
177
|
+
|
|
178
|
+
service?.[i]?.updateCharacteristic(charType, value);
|
|
181
179
|
}
|
|
182
180
|
}
|
|
183
181
|
|
package/src/switches.js
CHANGED
|
@@ -92,17 +92,13 @@ class Switches extends EventEmitter {
|
|
|
92
92
|
this.switchesOutlets.push(switchOutlet);
|
|
93
93
|
|
|
94
94
|
//update characteristics
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
service.updateCharacteristic(Characteristic.On, power);
|
|
100
|
-
}
|
|
95
|
+
const serviceName = this.relaysNamePrefix ? `${this.info.deviceName} ${friendlyName}` : friendlyName;
|
|
96
|
+
this.lightServices?.[i]
|
|
97
|
+
?.setCharacteristic(Characteristic.ConfiguredName, serviceName)
|
|
98
|
+
.updateCharacteristic(Characteristic.On, power);
|
|
101
99
|
|
|
102
100
|
//log info
|
|
103
|
-
if (!this.disableLogInfo) {
|
|
104
|
-
this.emit('info', `${friendlyName}, state: ${power ? 'ON' : 'OFF'}`);
|
|
105
|
-
}
|
|
101
|
+
if (!this.disableLogInfo) this.emit('info', `${friendlyName}, state: ${power ? 'ON' : 'OFF'}`);
|
|
106
102
|
}
|
|
107
103
|
}
|
|
108
104
|
|