homebridge-tasmota-control 1.7.1 → 1.7.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": "1.7.1",
4
+ "version": "1.7.2",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
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 fanService = this.fanServices?.[i];
136
- if (fanService) {
137
- const serviceName = this.fansNamePrefix ? `${this.info.deviceName} ${friendlyName}` : friendlyName;
138
- fanService.updateCharacteristic(Characteristic.ConfiguredName, serviceName)
139
- .updateCharacteristic(Characteristic.On, powerFan)
140
- // .updateCharacteristic(Characteristic.Direction, direction)
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 service = this.lightServices?.[i];
129
- if (service) {
130
- const serviceName = this.lightsNamePrefix ? `${this.info.deviceName} ${friendlyName}` : friendlyName;
131
- service.updateCharacteristic(Characteristic.ConfiguredName, serviceName);
132
- service.updateCharacteristic(Characteristic.On, power);
133
-
134
- if (brightnessType > 0) {
135
- service.updateCharacteristic(Characteristic.Brightness, bright);
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
- svc.updateCharacteristic(
419
- Characteristic.CoolingThresholdTemperature,
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
- if (this.buttonsServices) {
567
- const characteristicType = button.characteristicType;
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
- if (this.sensorsServices) {
661
- const characteristicType = sensor.characteristicType;
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
- if (this.roomTemperatureSensorService) {
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
- if (this.outdoorTemperatureSensorService) {
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?.[i], Characteristic.CurrentTemperature, sensor.temperature],
139
- [this.temperatureReferenceServices?.[i], Characteristic.CurrentTemperature, sensor.referenceTemperature],
140
- [this.temperatureObjServices?.[i], Characteristic.CurrentTemperature, sensor.objTemperature],
141
- [this.temperatureAmbServices?.[i], Characteristic.CurrentTemperature, sensor.ambTemperature],
142
- [this.temperatureDewPointServices?.[i], Characteristic.CurrentTemperature, sensor.dewPointTemperature],
143
- [this.humidityServices?.[i], Characteristic.CurrentRelativeHumidity, sensor.humidity],
144
- [this.carbonDioxydeServices?.[i], Characteristic.CarbonDioxideDetected, sensor.carbonDioxyde > 1000],
145
- [this.carbonDioxydeServices?.[i], Characteristic.CarbonDioxideLevel, sensor.carbonDioxyde],
146
- [this.carbonDioxydeServices?.[i], Characteristic.CarbonDioxidePeakLevel, sensor.carbonDioxyde],
147
- [this.ambientLightServices?.[i], Characteristic.CurrentAmbientLightLevel, sensor.ambientLight],
148
- [this.motionServices?.[i], Characteristic.MotionDetected, sensor.motion],
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
- continue;
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?.[i], Characteristic.Power, sensor.power],
163
- [this.powerAndEnergyServices?.[i], Characteristic.ApparentPower, sensor.apparentPower],
164
- [this.powerAndEnergyServices?.[i], Characteristic.ReactivePower, sensor.reactivePower],
165
- [this.powerAndEnergyServices?.[i], Characteristic.EnergyToday, sensor.energyToday],
166
- [this.powerAndEnergyServices?.[i], Characteristic.EnergyLastDay, sensor.energyLastDay],
167
- [this.powerAndEnergyServices?.[i], Characteristic.EnergyLifetime, sensor.energyLifetime],
168
- [this.powerAndEnergyServices?.[i], Characteristic.Current, sensor.current],
169
- [this.powerAndEnergyServices?.[i], Characteristic.Voltage, sensor.voltage],
170
- [this.powerAndEnergyServices?.[i], Characteristic.Factor, sensor.factor],
171
- [this.powerAndEnergyServices?.[i], Characteristic.Frequency, sensor.frequency],
172
- [this.powerAndEnergyServices?.[i], Characteristic.ReadingTime, sensor.time],
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
- continue;
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 service = this.lightServices?.[i];
96
- if (service) {
97
- const serviceName = this.relaysNamePrefix ? `${this.info.deviceName} ${friendlyName}` : friendlyName;
98
- service.updateCharacteristic(Characteristic.ConfiguredName, serviceName);
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