homebridge-tasmota-control 1.3.3 → 1.3.4

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 CHANGED
@@ -110,7 +110,7 @@ class tasmotaPlatform {
110
110
  const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
111
111
 
112
112
  //start impulse generator
113
- const startImpulseGenerator = startDone ? await tasmotaDevice.startImpulseGenerator() : false
113
+ const startImpulseGenerator = stopImpulseGenerator ? await tasmotaDevice.startImpulseGenerator() : false
114
114
  } catch (error) {
115
115
  const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
116
116
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.3.3",
4
+ "version": "1.3.4",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -34,7 +34,7 @@
34
34
  "node": "^18.20.4 || ^20.15.1 || ^22.7.0 || ^23.2.0"
35
35
  },
36
36
  "dependencies": {
37
- "axios": "^1.8.4"
37
+ "axios": "^1.9.0"
38
38
  },
39
39
  "keywords": [
40
40
  "homebridge",
@@ -43,21 +43,19 @@ class TasmotaDevice extends EventEmitter {
43
43
  const presets = miElHvac.presets || [];
44
44
  this.presetsConfigured = [];
45
45
  for (const preset of presets) {
46
- const presetName = preset.name ?? false;
47
- const presetDisplayType = preset.displayType ?? 0;
48
- const presetNamePrefix = preset.namePrefix ?? false;
49
- if (presetName && presetDisplayType > 0) {
50
- const presetyServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][presetDisplayType];
51
- const presetCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][presetDisplayType];
52
- preset.namePrefix = presetNamePrefix;
53
- preset.serviceType = presetyServiceType;
54
- preset.characteristicType = presetCharacteristicType;
55
- preset.state = false;
56
- preset.previousSettings = {};
57
- this.presetsConfigured.push(preset);
58
- } else {
59
- const log = presetDisplayType === 0 ? false : this.emit('warn', `Preset Name: ${preset ? preset : 'Missing'}`);
60
- };
46
+ const displayType = preset.displayType ?? 0;
47
+ if (displayType === 0) {
48
+ return;
49
+
50
+ }
51
+ const presetyServiceType = ['', Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][displayType];
52
+ const presetCharacteristicType = ['', Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][displayType];
53
+ preset.serviceType = presetyServiceType;
54
+ preset.characteristicType = presetCharacteristicType;
55
+ preset.name = preset.name || 'Preset';
56
+ preset.state = false;
57
+ preset.previousSettings = {};
58
+ this.presetsConfigured.push(preset);
61
59
  }
62
60
  this.presetsConfiguredCount = this.presetsConfigured.length || 0;
63
61
 
@@ -65,22 +63,20 @@ class TasmotaDevice extends EventEmitter {
65
63
  const buttons = miElHvac.buttons || [];
66
64
  this.buttonsConfigured = [];
67
65
  for (const button of buttons) {
68
- const buttonName = button.name ?? false;
69
- const buttonMode = button.mode ?? -1;
70
- const buttonDisplayType = button.displayType ?? 0;
71
- const buttonNamePrefix = button.namePrefix ?? false;
72
- if (buttonName && buttonMode >= 0 && buttonDisplayType > 0) {
73
- const buttonServiceType = ['', Service.Outlet, Service.Switch][buttonDisplayType];
74
- const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On][buttonDisplayType];
75
- button.namePrefix = buttonNamePrefix;
76
- button.serviceType = buttonServiceType;
77
- button.characteristicType = buttonCharacteristicType;
78
- button.state = false;
79
- button.previousValue = null;
80
- this.buttonsConfigured.push(button);
81
- } else {
82
- const log = buttonDisplayType === 0 ? false : this.emit('warn', `Button Name: ${buttonName ? buttonName : 'Missing'}, Mode: ${buttonMode ? buttonMode : 'Missing'}`);
83
- };
66
+ const displayType = button.displayType ?? 0;
67
+ if (displayType === 0) {
68
+ return;
69
+
70
+ }
71
+
72
+ const buttonServiceType = ['', Service.Outlet, Service.Switch][displayType];
73
+ const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On][displayType];
74
+ button.serviceType = buttonServiceType;
75
+ button.characteristicType = buttonCharacteristicType;
76
+ button.name = button.name || 'Button';
77
+ button.state = false;
78
+ button.previousValue = null;
79
+ this.buttonsConfigured.push(button);
84
80
  }
85
81
  this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
86
82
 
@@ -88,22 +84,19 @@ class TasmotaDevice extends EventEmitter {
88
84
  const sensors = miElHvac.sensors || [];
89
85
  this.sensorsConfigured = [];
90
86
  for (const sensor of sensors) {
91
- const sensorName = sensor.name ?? false;
92
- const sensorMode = sensor.mode ?? -1;
93
- const sensorDisplayType = sensor.displayType ?? 0;
94
- const sensorNamePrefix = sensor.namePrefix ?? false;
95
- if (sensorName && sensorMode >= 0 && sensorDisplayType > 0) {
96
- const sensorServiceType = ['', Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][sensorDisplayType];
97
- const sensorCharacteristicType = ['', Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][sensorDisplayType];
98
- sensor.namePrefix = sensorNamePrefix;
99
- sensor.serviceType = sensorServiceType;
100
- sensor.characteristicType = sensorCharacteristicType;
101
- sensor.state = false;
102
- sensor.previousValue = null;
103
- this.sensorsConfigured.push(sensor);
104
- } else {
105
- const log = sensorDisplayType === 0 ? false : this.emit('warn', `Sensor Name: ${sensorName ? sensorName : 'Missing'}, Mode: ${sensorMode ? sensorMode : 'Missing'}`);
106
- };
87
+ const displayType = sensor.displayType ?? 0;
88
+ if (displayType === 0) {
89
+ return;
90
+
91
+ }
92
+ const sensorServiceType = ['', Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][displayType];
93
+ const sensorCharacteristicType = ['', Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][displayType];
94
+ sensor.serviceType = sensorServiceType;
95
+ sensor.characteristicType = sensorCharacteristicType;
96
+ sensor.name = sensor.name || 'Sensor';
97
+ sensor.state = false;
98
+ sensor.previousValue = null;
99
+ this.sensorsConfigured.push(sensor);
107
100
  }
108
101
  this.sensorsConfiguredCount = this.sensorsConfigured.length || 0;
109
102
 
@@ -1498,19 +1491,19 @@ class TasmotaDevice extends EventEmitter {
1498
1491
  minStep: this.accessory.temperatureIncrement
1499
1492
  })
1500
1493
  .onGet(async () => {
1501
- const value = this.accessory.operationMode === 'auto' ? this.accessory.defaultCoolingSetTemperature : this.accessory.setTemperature;
1494
+ const value = this.accessory.targetOperationMode === 2 ? this.accessory.setTemperature : this.accessory.defaultCoolingSetTemperature;
1502
1495
  return value;
1503
1496
  })
1504
1497
  .onSet(async (value) => {
1505
1498
  try {
1506
- if (this.accessory.operationMode === 'auto') {
1499
+ if (this.accessory.targetOperationMode === 0) {
1507
1500
  await this.saveData(this.defaultCoolingSetTemperatureFile, value);
1508
1501
  value = (value + this.accessory.defaultHeatingSetTemperature) / 2;
1509
1502
  }
1510
1503
 
1511
1504
  const temp = `${MiElHVAC.SetTemp}${value}`
1512
1505
  await this.axiosInstance(temp);
1513
- const info = this.disableLogInfo ? false : this.emit('message', `Set ${this.accessory.operationMode === 'auto' ? 'cooling threshold temperature' : 'temperature'}: ${value}${this.accessory.temperatureUnit}`);
1506
+ const info = this.disableLogInfo ? false : this.emit('message', `Set ${this.accessory.targetOperationMode === 2 ? 'temperature' : 'cooling threshold temperature'}: ${value}${this.accessory.temperatureUnit}`);
1514
1507
  } catch (error) {
1515
1508
  this.emit('warn', `Set cooling threshold temperature error: ${error}`);
1516
1509
  };
@@ -1523,19 +1516,19 @@ class TasmotaDevice extends EventEmitter {
1523
1516
  minStep: this.accessory.temperatureIncrement
1524
1517
  })
1525
1518
  .onGet(async () => {
1526
- const value = this.accessory.operationMode === 'auto' ? this.accessory.defaultHeatingSetTemperature : this.accessory.setTemperature;
1519
+ const value = this.accessory.targetOperationMode === 1 ? this.accessory.setTemperature : this.accessory.defaultHeatingSetTemperature;
1527
1520
  return value;
1528
1521
  })
1529
1522
  .onSet(async (value) => {
1530
1523
  try {
1531
- if (this.accessory.operationMode === 'auto') {
1524
+ if (this.accessory.targetOperationMode === 0) {
1532
1525
  await this.saveData(this.defaultHeatingSetTemperatureFile, value);
1533
1526
  value = (value + this.accessory.defaultCoolingSetTemperature) / 2;
1534
1527
  }
1535
1528
 
1536
1529
  const temp = `${MiElHVAC.SetTemp}${value}`
1537
1530
  await this.axiosInstance(temp);
1538
- const info = this.disableLogInfo ? false : this.emit('message', `Set ${this.accessory.operationMode === 'auto' ? 'heating threshold temperature' : 'temperature'}: ${value}${this.accessory.temperatureUnit}`);
1531
+ const info = this.disableLogInfo ? false : this.emit('message', `Set ${this.accessory.targetOperationMode === 1 ? 'temperature' : 'heating threshold temperature'}: ${value}${this.accessory.temperatureUnit}`);
1539
1532
  } catch (error) {
1540
1533
  this.emit('warn', `Set heating threshold temperature error: ${error}`);
1541
1534
  };