homebridge-tuya-plus 3.11.3-beta.8 → 3.13.0
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/lib/AirConditionerAccessory.js +41 -13
- package/package.json +1 -1
|
@@ -60,6 +60,17 @@ class AirConditionerAccessory extends BaseAccessory {
|
|
|
60
60
|
this.dpTempUnits = this._getCustomDP(this.device.context.dpTempUnits) || '19';
|
|
61
61
|
this.dpSwingMode = this._getCustomDP(this.device.context.dpSwingMode) || '104';
|
|
62
62
|
|
|
63
|
+
// temperatureDivisor is a default for both current and threshold reads.
|
|
64
|
+
// Some Tuya AC firmwares report temperatures scaled by 10 (e.g.
|
|
65
|
+
// temp_set = 170 means 17.0 °C). Use temperatureDivisor: 10 for those.
|
|
66
|
+
// currentTemperatureDivisor / thresholdTemperatureDivisor override
|
|
67
|
+
// the default per side, since the two DPs are not always scaled the
|
|
68
|
+
// same way (it's common for current temp to be unscaled while the
|
|
69
|
+
// setpoint is in tenths of a degree).
|
|
70
|
+
const baseDivisor = parseInt(this.device.context.temperatureDivisor) || 1;
|
|
71
|
+
this.currentTemperatureDivisor = parseInt(this.device.context.currentTemperatureDivisor) || baseDivisor;
|
|
72
|
+
this.thresholdTemperatureDivisor = parseInt(this.device.context.thresholdTemperatureDivisor) || baseDivisor;
|
|
73
|
+
|
|
63
74
|
const characteristicActive = service.getCharacteristic(Characteristic.Active)
|
|
64
75
|
.updateValue(this._getActive(dps[this.dpActive]))
|
|
65
76
|
.onGet(() => this.getActive())
|
|
@@ -81,8 +92,8 @@ class AirConditionerAccessory extends BaseAccessory {
|
|
|
81
92
|
.onSet(value => this.setTargetHeaterCoolerState(value));
|
|
82
93
|
|
|
83
94
|
const characteristicCurrentTemperature = service.getCharacteristic(Characteristic.CurrentTemperature)
|
|
84
|
-
.updateValue(dps[this.dpCurrentTemperature])
|
|
85
|
-
.onGet(() => this.getStateAsync(this.dpCurrentTemperature));
|
|
95
|
+
.updateValue(this._scaleCurrent(dps[this.dpCurrentTemperature]))
|
|
96
|
+
.onGet(() => this._scaleCurrent(this.getStateAsync(this.dpCurrentTemperature)));
|
|
86
97
|
|
|
87
98
|
let characteristicSwingMode;
|
|
88
99
|
if (!this.device.context.noSwing) {
|
|
@@ -108,8 +119,8 @@ class AirConditionerAccessory extends BaseAccessory {
|
|
|
108
119
|
maxValue: this.device.context.maxTemperature || 35,
|
|
109
120
|
minStep: this.device.context.minTemperatureSteps || 1
|
|
110
121
|
})
|
|
111
|
-
.updateValue(dps[this.dpThreshold])
|
|
112
|
-
.onGet(() => this.getStateAsync(this.dpThreshold))
|
|
122
|
+
.updateValue(this._scaleThreshold(dps[this.dpThreshold]))
|
|
123
|
+
.onGet(() => this._scaleThreshold(this.getStateAsync(this.dpThreshold)))
|
|
113
124
|
.onSet(value => this.setTargetThresholdTemperature('cool', value));
|
|
114
125
|
} else this._removeCharacteristic(service, Characteristic.CoolingThresholdTemperature);
|
|
115
126
|
|
|
@@ -121,8 +132,8 @@ class AirConditionerAccessory extends BaseAccessory {
|
|
|
121
132
|
maxValue: this.device.context.maxTemperature || 35,
|
|
122
133
|
minStep: this.device.context.minTemperatureSteps || 1
|
|
123
134
|
})
|
|
124
|
-
.updateValue(dps[this.dpThreshold])
|
|
125
|
-
.onGet(() => this.getStateAsync(this.dpThreshold))
|
|
135
|
+
.updateValue(this._scaleThreshold(dps[this.dpThreshold]))
|
|
136
|
+
.onGet(() => this._scaleThreshold(this.getStateAsync(this.dpThreshold)))
|
|
126
137
|
.onSet(value => this.setTargetThresholdTemperature('heat', value));
|
|
127
138
|
} else this._removeCharacteristic(service, Characteristic.HeatingThresholdTemperature);
|
|
128
139
|
|
|
@@ -158,14 +169,18 @@ class AirConditionerAccessory extends BaseAccessory {
|
|
|
158
169
|
}
|
|
159
170
|
|
|
160
171
|
if (changes.hasOwnProperty(this.dpThreshold)) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
172
|
+
const scaled = this._scaleThreshold(changes[this.dpThreshold]);
|
|
173
|
+
if (!this.device.context.noCool && characteristicCoolingThresholdTemperature && characteristicCoolingThresholdTemperature.value !== scaled)
|
|
174
|
+
characteristicCoolingThresholdTemperature.updateValue(scaled);
|
|
175
|
+
if (!this.device.context.noHeat && characteristicHeatingThresholdTemperature && characteristicHeatingThresholdTemperature.value !== scaled)
|
|
176
|
+
characteristicHeatingThresholdTemperature.updateValue(scaled);
|
|
165
177
|
}
|
|
166
178
|
|
|
167
|
-
if (changes.hasOwnProperty(this.dpCurrentTemperature)
|
|
168
|
-
|
|
179
|
+
if (changes.hasOwnProperty(this.dpCurrentTemperature)) {
|
|
180
|
+
const scaled = this._scaleCurrent(changes[this.dpCurrentTemperature]);
|
|
181
|
+
if (characteristicCurrentTemperature.value !== scaled)
|
|
182
|
+
characteristicCurrentTemperature.updateValue(scaled);
|
|
183
|
+
}
|
|
169
184
|
|
|
170
185
|
if (changes.hasOwnProperty(this.dpMode)) {
|
|
171
186
|
const newTargetHeaterCoolerState = this._getTargetHeaterCoolerState(changes[this.dpMode]);
|
|
@@ -304,7 +319,8 @@ class AirConditionerAccessory extends BaseAccessory {
|
|
|
304
319
|
}
|
|
305
320
|
|
|
306
321
|
async setTargetThresholdTemperature(mode, value) {
|
|
307
|
-
|
|
322
|
+
const raw = Math.round(value * this.thresholdTemperatureDivisor);
|
|
323
|
+
await this.setMultiStateLegacyAsync({[this.dpActive]: true, [this.dpThreshold]: raw});
|
|
308
324
|
if (mode === 'cool' && !this.device.context.noHeat && this.characteristicHeatingThresholdTemperature) {
|
|
309
325
|
this.characteristicHeatingThresholdTemperature.updateValue(value);
|
|
310
326
|
} else if (mode === 'heat' && !this.device.context.noCool && this.characteristicCoolingThresholdTemperature) {
|
|
@@ -312,6 +328,18 @@ class AirConditionerAccessory extends BaseAccessory {
|
|
|
312
328
|
}
|
|
313
329
|
}
|
|
314
330
|
|
|
331
|
+
_scaleCurrent(raw) {
|
|
332
|
+
const v = parseFloat(raw);
|
|
333
|
+
if (!isFinite(v)) return 0;
|
|
334
|
+
return v / this.currentTemperatureDivisor;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
_scaleThreshold(raw) {
|
|
338
|
+
const v = parseFloat(raw);
|
|
339
|
+
if (!isFinite(v)) return 0;
|
|
340
|
+
return v / this.thresholdTemperatureDivisor;
|
|
341
|
+
}
|
|
342
|
+
|
|
315
343
|
getTemperatureDisplayUnits() {
|
|
316
344
|
return this._getTemperatureDisplayUnits(this.getStateAsync(this.dpTempUnits));
|
|
317
345
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-tuya-plus",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "A community-maintained Homebridge plugin for controlling Tuya devices locally over LAN. Includes new features, fixes, and updated device support.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|