homebridge-tasmota-control 1.3.3 → 1.3.5

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.5",
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'}`);
46
+ const displayType = preset.displayType ?? 0;
47
+ if (displayType === 0) {
48
+ continue;
60
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,19 @@ 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'}`);
66
+ const displayType = button.displayType ?? 0;
67
+ if (displayType === 0) {
68
+ continue;
83
69
  };
70
+
71
+ const buttonServiceType = ['', Service.Outlet, Service.Switch][displayType];
72
+ const buttonCharacteristicType = ['', Characteristic.On, Characteristic.On][displayType];
73
+ button.serviceType = buttonServiceType;
74
+ button.characteristicType = buttonCharacteristicType;
75
+ button.name = button.name || 'Button';
76
+ button.state = false;
77
+ button.previousValue = null;
78
+ this.buttonsConfigured.push(button);
84
79
  }
85
80
  this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
86
81
 
@@ -88,22 +83,19 @@ class TasmotaDevice extends EventEmitter {
88
83
  const sensors = miElHvac.sensors || [];
89
84
  this.sensorsConfigured = [];
90
85
  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'}`);
86
+ const displayType = sensor.displayType ?? 0;
87
+ if (displayType === 0) {
88
+ continue;
106
89
  };
90
+
91
+ const sensorServiceType = ['', Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][displayType];
92
+ const sensorCharacteristicType = ['', Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][displayType];
93
+ sensor.serviceType = sensorServiceType;
94
+ sensor.characteristicType = sensorCharacteristicType;
95
+ sensor.name = sensor.name || 'Sensor';
96
+ sensor.state = false;
97
+ sensor.previousValue = null;
98
+ this.sensorsConfigured.push(sensor);
107
99
  }
108
100
  this.sensorsConfiguredCount = this.sensorsConfigured.length || 0;
109
101
 
@@ -1498,19 +1490,19 @@ class TasmotaDevice extends EventEmitter {
1498
1490
  minStep: this.accessory.temperatureIncrement
1499
1491
  })
1500
1492
  .onGet(async () => {
1501
- const value = this.accessory.operationMode === 'auto' ? this.accessory.defaultCoolingSetTemperature : this.accessory.setTemperature;
1493
+ const value = this.accessory.targetOperationMode === 2 ? this.accessory.setTemperature : this.accessory.defaultCoolingSetTemperature;
1502
1494
  return value;
1503
1495
  })
1504
1496
  .onSet(async (value) => {
1505
1497
  try {
1506
- if (this.accessory.operationMode === 'auto') {
1498
+ if (this.accessory.targetOperationMode === 0) {
1507
1499
  await this.saveData(this.defaultCoolingSetTemperatureFile, value);
1508
1500
  value = (value + this.accessory.defaultHeatingSetTemperature) / 2;
1509
1501
  }
1510
1502
 
1511
1503
  const temp = `${MiElHVAC.SetTemp}${value}`
1512
1504
  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}`);
1505
+ const info = this.disableLogInfo ? false : this.emit('message', `Set ${this.accessory.targetOperationMode === 2 ? 'temperature' : 'cooling threshold temperature'}: ${value}${this.accessory.temperatureUnit}`);
1514
1506
  } catch (error) {
1515
1507
  this.emit('warn', `Set cooling threshold temperature error: ${error}`);
1516
1508
  };
@@ -1523,19 +1515,19 @@ class TasmotaDevice extends EventEmitter {
1523
1515
  minStep: this.accessory.temperatureIncrement
1524
1516
  })
1525
1517
  .onGet(async () => {
1526
- const value = this.accessory.operationMode === 'auto' ? this.accessory.defaultHeatingSetTemperature : this.accessory.setTemperature;
1518
+ const value = this.accessory.targetOperationMode === 1 ? this.accessory.setTemperature : this.accessory.defaultHeatingSetTemperature;
1527
1519
  return value;
1528
1520
  })
1529
1521
  .onSet(async (value) => {
1530
1522
  try {
1531
- if (this.accessory.operationMode === 'auto') {
1523
+ if (this.accessory.targetOperationMode === 0) {
1532
1524
  await this.saveData(this.defaultHeatingSetTemperatureFile, value);
1533
1525
  value = (value + this.accessory.defaultCoolingSetTemperature) / 2;
1534
1526
  }
1535
1527
 
1536
1528
  const temp = `${MiElHVAC.SetTemp}${value}`
1537
1529
  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}`);
1530
+ const info = this.disableLogInfo ? false : this.emit('message', `Set ${this.accessory.targetOperationMode === 1 ? 'temperature' : 'heating threshold temperature'}: ${value}${this.accessory.temperatureUnit}`);
1539
1531
  } catch (error) {
1540
1532
  this.emit('warn', `Set heating threshold temperature error: ${error}`);
1541
1533
  };