homebridge-tasmota-control 1.8.0-beta.1 → 1.8.0-beta.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/src/lights.js CHANGED
@@ -21,9 +21,9 @@ class Lights extends EventEmitter {
21
21
 
22
22
  //other config
23
23
  this.lightsNamePrefix = config.lightsNamePrefix || false;
24
- this.enableDebugMode = config.enableDebugMode || false;
25
- this.disableLogInfo = config.disableLogInfo || false;
26
- this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
24
+ this.logDeviceInfo = config.log?.deviceInfo || false;
25
+ this.logInfo = config.log?.info || false;
26
+ this.logDebug = config.log?.debug || false;
27
27
  this.functions = new Functions();
28
28
 
29
29
  //axios instance
@@ -54,17 +54,17 @@ class Lights extends EventEmitter {
54
54
  }
55
55
 
56
56
  async checkState() {
57
- if (this.enableDebugMode) this.emit('debug', `Requesting status`);
57
+ if (this.logDebug) this.emit('debug', `Requesting status`);
58
58
  try {
59
59
  //power status
60
60
  const powerStatusData = await this.client(ApiCommands.PowerStatus);
61
61
  const powerStatus = powerStatusData.data ?? {};
62
- if (this.enableDebugMode) this.emit('debug', `Power status: ${JSON.stringify(powerStatus, null, 2)}`);
62
+ if (this.logDebug) this.emit('debug', `Power status: ${JSON.stringify(powerStatus, null, 2)}`);
63
63
 
64
64
  //sensor status
65
65
  const sensorStatusData = await this.client(ApiCommands.Status);
66
66
  const sensorStatus = sensorStatusData.data ?? {};
67
- if (this.enableDebugMode) this.emit('debug', `Sensors status: ${JSON.stringify(sensorStatus, null, 2)}`);
67
+ if (this.logDebug) this.emit('debug', `Sensors status: ${JSON.stringify(sensorStatus, null, 2)}`);
68
68
 
69
69
  //sensor status keys
70
70
  const sensorStatusKeys = Object.keys(sensorStatus);
@@ -126,7 +126,7 @@ class Lights extends EventEmitter {
126
126
 
127
127
 
128
128
  //log info
129
- if (!this.disableLogInfo) {
129
+ if (this.logInfo) {
130
130
  this.emit('info', `${friendlyName}, state: ${power ? 'ON' : 'OFF'}`);
131
131
  if (brightnessType !== 0) this.emit('info', `${friendlyName}, brightness: ${bright} %`);
132
132
  if (colorTemperature) this.emit('info', `${friendlyName}, color temperatur: ${colorTemperature}`);
@@ -165,7 +165,7 @@ class Lights extends EventEmitter {
165
165
 
166
166
  //prepare accessory
167
167
  async prepareAccessory() {
168
- if (this.enableDebugMode) this.emit('debug', `Prepare Accessory`);
168
+ if (this.logDebug) this.emit('debug', `Prepare Accessory`);
169
169
 
170
170
  try {
171
171
  //accessory
@@ -175,7 +175,7 @@ class Lights extends EventEmitter {
175
175
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
176
176
 
177
177
  //Prepare information service
178
- if (this.enableDebugMode) this.emit('debug', `Prepare Information Service`);
178
+ if (this.logDebug) this.emit('debug', `Prepare Information Service`);
179
179
  accessory.getService(Service.AccessoryInformation)
180
180
  .setCharacteristic(Characteristic.Manufacturer, 'Tasmota')
181
181
  .setCharacteristic(Characteristic.Model, this.info.modelName ?? 'Model Name')
@@ -184,9 +184,9 @@ class Lights extends EventEmitter {
184
184
  .setCharacteristic(Characteristic.ConfiguredName, accessoryName);
185
185
 
186
186
  //Prepare services
187
- if (this.enableDebugMode) this.emit('debug', `Prepare Services`);
187
+ if (this.logDebug) this.emit('debug', `Prepare Services`);
188
188
  if (this.lights.length > 0) {
189
- if (this.enableDebugMode) this.emit('debug', `Prepare Light Services`);
189
+ if (this.logDebug) this.emit('debug', `Prepare Light Services`);
190
190
  this.lightServices = [];
191
191
 
192
192
  for (let i = 0; i < this.lights.length; i++) {
@@ -209,7 +209,7 @@ class Lights extends EventEmitter {
209
209
  state = state ? powerOn : powerOff;
210
210
 
211
211
  await this.client.get(state);
212
- if (!this.disableLogInfo) this.emit('info', `${friendlyName}, set state: ${state ? 'ON' : 'OFF'}`);
212
+ if (this.logInfo) this.emit('info', `${friendlyName}, set state: ${state ? 'ON' : 'OFF'}`);
213
213
  } catch (error) {
214
214
  this.emit('warn', `${friendlyName}, set state error: ${error}`);
215
215
  }
@@ -224,7 +224,7 @@ class Lights extends EventEmitter {
224
224
  try {
225
225
  const brightness = ['', `${ApiCommands.Dimmer}${value}`, `${ApiCommands.HSBBrightness}${value}`][this.lights[i].brightnessType]; //0..100
226
226
  await this.client.get(brightness);
227
- if (!this.disableLogInfo) this.emit('info', `${friendlyName}, set brightness: ${value} %`);
227
+ if (this.logInfo) this.emit('info', `${friendlyName}, set brightness: ${value} %`);
228
228
  } catch (error) {
229
229
  this.emit('warn', `set brightness error: ${error}`);
230
230
  }
@@ -241,7 +241,7 @@ class Lights extends EventEmitter {
241
241
  value = await this.functions.scaleValue(value, 140, 500, 153, 500);
242
242
  const colorTemperature = `${ApiCommands.ColorTemperature}${value}`; //153..500
243
243
  await this.client.get(colorTemperature);
244
- if (!this.disableLogInfo) this.emit('info', `${friendlyName}, set color temperatur: ${value}`);
244
+ if (this.logInfo) this.emit('info', `${friendlyName}, set color temperatur: ${value}`);
245
245
  } catch (error) {
246
246
  this.emit('warn', `set color temperatur error: ${error}`);
247
247
  }
@@ -257,7 +257,7 @@ class Lights extends EventEmitter {
257
257
  try {
258
258
  const hue = `${ApiCommands.HSBHue}${value}`; //0..360
259
259
  await this.client.get(hue);
260
- if (!this.disableLogInfo) this.emit('info', `${friendlyName}, set hue: ${value}`);
260
+ if (this.logInfo) this.emit('info', `${friendlyName}, set hue: ${value}`);
261
261
  } catch (error) {
262
262
  this.emit('warn', `set hue error: ${error}`);
263
263
  }
@@ -273,7 +273,7 @@ class Lights extends EventEmitter {
273
273
  try {
274
274
  const saturation = `${ApiCommands.HSBSaturation}${value}`; //0..100
275
275
  await this.client.get(saturation);
276
- if (!this.disableLogInfo) this.emit('info', `set saturation: ${value}`);
276
+ if (this.logInfo) this.emit('info', `set saturation: ${value}`);
277
277
  } catch (error) {
278
278
  this.emit('warn', `set saturation error: ${error}`);
279
279
  }
@@ -299,7 +299,7 @@ class Lights extends EventEmitter {
299
299
  this.emit('success', `Connect Success`)
300
300
 
301
301
  //check device info
302
- if (!this.disableLogDeviceInfo) await this.deviceInfo();
302
+ if (!this.logDeviceInfo) await this.deviceInfo();
303
303
 
304
304
  //start prepare accessory
305
305
  const accessory = await this.prepareAccessory();
package/src/mielhvac.js CHANGED
@@ -77,9 +77,9 @@ class MiElHvac extends EventEmitter {
77
77
 
78
78
  //other config
79
79
  this.sensorsNamePrefix = config.sensorsNamePrefix || false;
80
- this.enableDebugMode = config.enableDebugMode || false;
81
- this.disableLogInfo = config.disableLogInfo || false;
82
- this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
80
+ this.logDeviceInfo = config.log?.deviceInfo || false;
81
+ this.logInfo = config.log?.info || false;
82
+ this.logDebug = config.log?.debug || false;
83
83
 
84
84
  //mielhvac
85
85
  this.mielHvac = {};
@@ -134,17 +134,17 @@ class MiElHvac extends EventEmitter {
134
134
  }
135
135
 
136
136
  async checkState() {
137
- if (this.enableDebugMode) this.emit('debug', `Requesting status`);
137
+ if (this.logDebug) this.emit('debug', `Requesting status`);
138
138
  try {
139
139
  //power status
140
140
  const powerStatusData = await this.client.get(ApiCommands.PowerStatus);
141
141
  const powerStatus = powerStatusData.data ?? {};
142
- if (this.enableDebugMode) this.emit('debug', `Power status: ${JSON.stringify(powerStatus, null, 2)}`);
142
+ if (this.logDebug) this.emit('debug', `Power status: ${JSON.stringify(powerStatus, null, 2)}`);
143
143
 
144
144
  //sensor status
145
145
  const sensorStatusData = await this.client.get(ApiCommands.Status);
146
146
  const sensorStatus = sensorStatusData.data ?? {};
147
- if (this.enableDebugMode) this.emit('debug', `Sensors status: ${JSON.stringify(sensorStatus, null, 2)}`);
147
+ if (this.logDebug) this.emit('debug', `Sensors status: ${JSON.stringify(sensorStatus, null, 2)}`);
148
148
 
149
149
  //sensor status keys
150
150
  const sensorStatusKeys = Object.keys(sensorStatus);
@@ -606,7 +606,7 @@ class MiElHvac extends EventEmitter {
606
606
  this.outdoorTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, outdoorTemperature);
607
607
 
608
608
  //log current state
609
- if (!this.disableLogInfo) {
609
+ if (this.logInfo) {
610
610
  this.emit('info', `Power: ${power ? 'ON' : 'OFF'}`);
611
611
  const info = power ? this.emit('info', `Target operation mode: ${operationMode.toUpperCase()}`) : false;
612
612
  const info1 = power ? this.emit('info', `Current operation mode: ${operationModeStatus.toUpperCase()}`) : false;
@@ -637,7 +637,7 @@ class MiElHvac extends EventEmitter {
637
637
  //get remote temp
638
638
  const rmoteTempData = await this.axiosInstanceRemoteTemp.get();
639
639
  const remoteTemp = rmoteTempData.data ?? false;
640
- if (this.enableDebugMode) this.emit('debug', `Remote temp: ${JSON.stringify(remoteTemp, null, 2)}`);
640
+ if (this.logDebug) this.emit('debug', `Remote temp: ${JSON.stringify(remoteTemp, null, 2)}`);
641
641
 
642
642
  //set remote temp
643
643
  const temp = `${MiElHVAC.SetRemoteTemp}${remoteTemp}`
@@ -662,7 +662,7 @@ class MiElHvac extends EventEmitter {
662
662
 
663
663
  //prepare accessory
664
664
  async prepareAccessory() {
665
- if (this.enableDebugMode) this.emit('debug', `Prepare Accessory`);
665
+ if (this.logDebug) this.emit('debug', `Prepare Accessory`);
666
666
 
667
667
  try {
668
668
  //accessory
@@ -672,7 +672,7 @@ class MiElHvac extends EventEmitter {
672
672
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
673
673
 
674
674
  //Prepare information service
675
- if (this.enableDebugMode) this.emit('debug', `Prepare Information Service`);
675
+ if (this.logDebug) this.emit('debug', `Prepare Information Service`);
676
676
  accessory.getService(Service.AccessoryInformation)
677
677
  .setCharacteristic(Characteristic.Manufacturer, 'Tasmota')
678
678
  .setCharacteristic(Characteristic.Model, this.info.modelName ?? 'Model Name')
@@ -681,8 +681,8 @@ class MiElHvac extends EventEmitter {
681
681
  .setCharacteristic(Characteristic.ConfiguredName, accessoryName);
682
682
 
683
683
  //Prepare services
684
- if (this.enableDebugMode) this.emit('debug', `Prepare Services`);
685
- if (this.enableDebugMode) this.emit('debug', `Prepare mitsubishi hvac service`);
684
+ if (this.logDebug) this.emit('debug', `Prepare Services`);
685
+ if (this.logDebug) this.emit('debug', `Prepare mitsubishi hvac service`);
686
686
  const autoDryFanMode = [MiElHVAC.SetMode.auto, MiElHVAC.SetMode.auto, MiElHVAC.SetMode.dry, MiElHVAC.SetMode.fan][this.autoDryFanMode]; //NONE, AUTO, DRY, FAN
687
687
  const heatDryFanMode = [MiElHVAC.SetMode.heat, MiElHVAC.SetMode.heat, MiElHVAC.SetMode.dry, MiElHVAC.SetMode.fan][this.heatDryFanMode]; //NONE, HEAT, DRY, FAN
688
688
  const coolDryFanMode = [MiElHVAC.SetMode.cool, MiElHVAC.SetMode.cool, MiElHVAC.SetMode.dry, MiElHVAC.SetMode.fan][this.coolDryFanMode]; //NONE, COOL, DRY, FAN
@@ -701,7 +701,7 @@ class MiElHvac extends EventEmitter {
701
701
  try {
702
702
  const power = [MiElHVAC.PowerOff, MiElHVAC.PowerOn][state];
703
703
  await this.client.get(power);
704
- if (!this.disableLogInfo) this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
704
+ if (this.logInfo) this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
705
705
  } catch (error) {
706
706
  this.emit('warn', `Set power error: ${error}`);
707
707
  }
@@ -735,7 +735,7 @@ class MiElHvac extends EventEmitter {
735
735
  break;
736
736
  };
737
737
 
738
- if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${MiElHVAC.OperationMode[value]}`);
738
+ if (this.logInfo) this.emit('info', `Set operation mode: ${MiElHVAC.OperationMode[value]}`);
739
739
  } catch (error) {
740
740
  this.emit('warn', `Set operation mode error: ${error}`);
741
741
  }
@@ -782,7 +782,7 @@ class MiElHvac extends EventEmitter {
782
782
  //fan speed mode
783
783
  const fanSpeedMap = ['auto', 'quiet', '1', '2', '3', '4'][fanSpeed];
784
784
  await this.client.get(MiElHVAC.SetFanSpeed[fanSpeedMap]);
785
- if (!this.disableLogInfo) this.emit('info', `Set fan speed mode: ${MiElHVAC.FanSpeed[fanSpeedModeText]}`);
785
+ if (this.logInfo) this.emit('info', `Set fan speed mode: ${MiElHVAC.FanSpeed[fanSpeedModeText]}`);
786
786
  } catch (error) {
787
787
  this.emit('warn', `Set fan speed mode error: ${error}`);
788
788
  }
@@ -811,7 +811,7 @@ class MiElHvac extends EventEmitter {
811
811
  await this.client.get(MiElHVAC.SetSwingH.swing);
812
812
  break;
813
813
  }
814
- if (!this.disableLogInfo) this.emit('info', `Set air direction mode: ${MiElHVAC.SwingMode[value]}`);
814
+ if (this.logInfo) this.emit('info', `Set air direction mode: ${MiElHVAC.SwingMode[value]}`);
815
815
  } catch (error) {
816
816
  this.emit('warn', `Set vane swing mode error: ${error}`);
817
817
  }
@@ -836,7 +836,7 @@ class MiElHvac extends EventEmitter {
836
836
 
837
837
  const temp = `${MiElHVAC.SetTemp}${value}`
838
838
  await this.client.get(temp);
839
- if (!this.disableLogInfo) this.emit('info', `Set ${this.mielHvac.targetOperationMode === 2 ? 'temperature' : 'cooling threshold temperature'}: ${value}${this.mielHvac.temperatureUnit}`);
839
+ if (this.logInfo) this.emit('info', `Set ${this.mielHvac.targetOperationMode === 2 ? 'temperature' : 'cooling threshold temperature'}: ${value}${this.mielHvac.temperatureUnit}`);
840
840
  } catch (error) {
841
841
  this.emit('warn', `Set cooling threshold temperature error: ${error}`);
842
842
  }
@@ -861,7 +861,7 @@ class MiElHvac extends EventEmitter {
861
861
 
862
862
  const temp = `${MiElHVAC.SetTemp}${value}`
863
863
  await this.client.get(temp);
864
- if (!this.disableLogInfo) this.emit('info', `Set ${this.mielHvac.targetOperationMode === 1 ? 'temperature' : 'heating threshold temperature'}: ${value}${this.mielHvac.temperatureUnit}`);
864
+ if (this.logInfo) this.emit('info', `Set ${this.mielHvac.targetOperationMode === 1 ? 'temperature' : 'heating threshold temperature'}: ${value}${this.mielHvac.temperatureUnit}`);
865
865
  } catch (error) {
866
866
  this.emit('warn', `Set heating threshold temperature error: ${error}`);
867
867
  }
@@ -876,7 +876,7 @@ class MiElHvac extends EventEmitter {
876
876
  try {
877
877
  const lock = [MiElHVAC.SetProhibit.off, MiElHVAC.SetProhibit.all][value];
878
878
  await this.client.get(lock);
879
- if (!this.disableLogInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
879
+ if (this.logInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
880
880
  } catch (error) {
881
881
  this.emit('warn', `Set lock physical controls error: ${error}`);
882
882
  }
@@ -890,7 +890,7 @@ class MiElHvac extends EventEmitter {
890
890
  try {
891
891
  const unit = [MiElHVAC.SetDisplayUnit.c, MiElHVAC.SetDisplayUnit.f][value];
892
892
  //await this.client.get(unit);
893
- if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
893
+ if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
894
894
  } catch (error) {
895
895
  this.emit('warn', `Set temperature display unit error: ${error}`);
896
896
  }
@@ -899,7 +899,7 @@ class MiElHvac extends EventEmitter {
899
899
 
900
900
  //presets services
901
901
  if (this.presets.length > 0) {
902
- if (this.enableDebugMode) this.emit('debug', 'Prepare presets services');
902
+ if (this.logDebug) this.emit('debug', 'Prepare presets services');
903
903
  this.presetsServices = [];
904
904
 
905
905
  this.presets.forEach((preset, index) => {
@@ -933,7 +933,7 @@ class MiElHvac extends EventEmitter {
933
933
  await this.client.get(cmd);
934
934
  }
935
935
 
936
- if (!this.disableLogInfo) {
936
+ if (this.logInfo) {
937
937
  this.emit('info', `Set: ${presetName}`);
938
938
  }
939
939
 
@@ -951,7 +951,7 @@ class MiElHvac extends EventEmitter {
951
951
 
952
952
 
953
953
  if (this.buttons.length > 0) {
954
- if (this.enableDebugMode) this.emit('debug', 'Prepare buttons services');
954
+ if (this.logDebug) this.emit('debug', 'Prepare buttons services');
955
955
  this.buttonsServices = [];
956
956
 
957
957
  this.buttons.forEach((button, index) => {
@@ -1057,7 +1057,7 @@ class MiElHvac extends EventEmitter {
1057
1057
 
1058
1058
  await this.client.get(data);
1059
1059
 
1060
- if (!this.disableLogInfo) {
1060
+ if (this.logInfo) {
1061
1061
  const action = state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`;
1062
1062
  if (mode > 0) this.emit('info', action);
1063
1063
  }
@@ -1075,7 +1075,7 @@ class MiElHvac extends EventEmitter {
1075
1075
 
1076
1076
  //sensors services
1077
1077
  if (this.sensors.length > 0) {
1078
- if (this.enableDebugMode) this.emit('debug', `Prepare sensors services`);
1078
+ if (this.logDebug) this.emit('debug', `Prepare sensors services`);
1079
1079
  this.sensorsServices = [];
1080
1080
 
1081
1081
  this.sensors.forEach((sensor, index) => {
@@ -1103,7 +1103,7 @@ class MiElHvac extends EventEmitter {
1103
1103
 
1104
1104
  //room temperature sensor service
1105
1105
  if (this.temperatureSensor && this.mielHvac.roomTemperature !== null) {
1106
- if (this.enableDebugMode) this.emit('debug', `Prepare room temperature sensor service`);
1106
+ if (this.logDebug) this.emit('debug', `Prepare room temperature sensor service`);
1107
1107
  this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor`);
1108
1108
  this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1109
1109
  this.roomTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Room`);
@@ -1122,7 +1122,7 @@ class MiElHvac extends EventEmitter {
1122
1122
 
1123
1123
  //outdoor temperature sensor service
1124
1124
  if (this.temperatureSensorOutdoor && this.mielHvac.hasOutdoorTemperature && this.mielHvac.outdoorTemperature !== null) {
1125
- if (this.enableDebugMode) this.emit('debug', `Prepare outdoor temperature sensor service`);
1125
+ if (this.logDebug) this.emit('debug', `Prepare outdoor temperature sensor service`);
1126
1126
  this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor`);
1127
1127
  this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1128
1128
  this.outdoorTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Outdoor`);
@@ -1156,7 +1156,7 @@ class MiElHvac extends EventEmitter {
1156
1156
  this.emit('success', `Connect Success`)
1157
1157
 
1158
1158
  //check device info
1159
- if (!this.disableLogDeviceInfo) await this.deviceInfo();
1159
+ if (!this.logDeviceInfo) await this.deviceInfo();
1160
1160
 
1161
1161
  //start prepare accessory
1162
1162
  const accessory = await this.prepareAccessory();