homebridge-tuya-plus 4.1.0-dev.71 → 4.1.0-pr.100.74
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/config.schema.json +10 -1
- package/lib/SimpleFanAccessory.js +47 -6
- package/package.json +1 -1
package/config.schema.json
CHANGED
|
@@ -505,9 +505,10 @@
|
|
|
505
505
|
},
|
|
506
506
|
"dpCurrentTemperature": {
|
|
507
507
|
"type": "integer",
|
|
508
|
+
"title": "Current Temperature DP",
|
|
508
509
|
"placeholder": "3",
|
|
509
510
|
"condition": {
|
|
510
|
-
"functionBody": "return model.devices && model.devices[arrayIndices] && ['Convector', 'SimpleHeater'].includes(model.devices[arrayIndices].type);"
|
|
511
|
+
"functionBody": "return model.devices && model.devices[arrayIndices] && ['Convector', 'SimpleHeater', 'Fan', 'FanLight'].includes(model.devices[arrayIndices].type);"
|
|
511
512
|
}
|
|
512
513
|
},
|
|
513
514
|
"dpLightOn": {
|
|
@@ -555,6 +556,14 @@
|
|
|
555
556
|
"functionBody": "return model.devices && model.devices[arrayIndices] && ['Fan'].includes(model.devices[arrayIndices].type);"
|
|
556
557
|
}
|
|
557
558
|
},
|
|
559
|
+
"directionUseBool": {
|
|
560
|
+
"title": "Use Boolean for Direction",
|
|
561
|
+
"type": "boolean",
|
|
562
|
+
"description": "Sends true/false instead of forward/reverse strings for oscillation/direction.",
|
|
563
|
+
"condition": {
|
|
564
|
+
"functionBody": "return model.devices && model.devices[arrayIndices] && ['Fan', 'FanLight'].includes(model.devices[arrayIndices].type);"
|
|
565
|
+
}
|
|
566
|
+
},
|
|
558
567
|
"maxSpeed": {
|
|
559
568
|
"type": "integer",
|
|
560
569
|
"placeholder": "3",
|
|
@@ -12,23 +12,37 @@ class SimpleFanAccessory extends BaseAccessory {
|
|
|
12
12
|
_registerPlatformAccessory() {
|
|
13
13
|
const {Service} = this.hap;
|
|
14
14
|
this.accessory.addService(Service.Fan, this.device.context.name);
|
|
15
|
+
|
|
16
|
+
if (this.device.context.dpCurrentTemperature) {
|
|
17
|
+
this.accessory.addService(Service.TemperatureSensor, this.device.context.name + ' Temperature');
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
super._registerPlatformAccessory();
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
_registerCharacteristics(dps) {
|
|
19
24
|
const {Service, Characteristic} = this.hap;
|
|
25
|
+
|
|
20
26
|
const serviceFan = this.accessory.getService(Service.Fan);
|
|
21
27
|
this._checkServiceName(serviceFan, this.device.context.name);
|
|
28
|
+
|
|
29
|
+
let serviceTemp;
|
|
30
|
+
if (this.device.context.dpCurrentTemperature) {
|
|
31
|
+
serviceTemp = this.accessory.getService(Service.TemperatureSensor);
|
|
32
|
+
if (serviceTemp) {
|
|
33
|
+
this._checkServiceName(serviceTemp, this.device.context.name + ' Temperature');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
this.dpFanOn = this._getCustomDP(this.device.context.dpFanOn) || '1';
|
|
23
38
|
this.dpRotationSpeed = this._getCustomDP(this.device.context.dpRotationSpeed) || '3';
|
|
24
39
|
this.dpFanDirection = this._getCustomDP(this.device.context.dpFanDirection) || '2';
|
|
25
|
-
// Oscillation is opt-in: SwingMode is only exposed when the fan's boolean
|
|
26
|
-
// swing DP is configured, so existing setups are unchanged (issue #96).
|
|
27
40
|
this.dpSwing = this._getCustomDP(this.device.context.dpSwing);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
|
|
42
|
+
this.dpCurrentTemperature = this._getCustomDP(this.device.context.dpCurrentTemperature);
|
|
43
|
+
|
|
31
44
|
this.noDirection = this._coerceBoolean(this.device.context.noDirection, false);
|
|
45
|
+
this.directionUseBool = this._coerceBoolean(this.device.context.directionUseBool, false);
|
|
32
46
|
|
|
33
47
|
this.maxSpeed = parseInt(this.device.context.maxSpeed) || 3;
|
|
34
48
|
this.fanDefaultSpeed = parseInt(this.device.context.fanDefaultSpeed) || 1;
|
|
@@ -67,6 +81,13 @@ class SimpleFanAccessory extends BaseAccessory {
|
|
|
67
81
|
.onSet(value => this.setSwingMode(value));
|
|
68
82
|
} else this._removeCharacteristic(serviceFan, Characteristic.SwingMode);
|
|
69
83
|
|
|
84
|
+
let characteristicTemperature;
|
|
85
|
+
if (this.dpCurrentTemperature && serviceTemp) {
|
|
86
|
+
characteristicTemperature = serviceTemp.getCharacteristic(Characteristic.CurrentTemperature)
|
|
87
|
+
.updateValue(this._getCurrentTemperature(dps[this.dpCurrentTemperature]))
|
|
88
|
+
.onGet(() => this.getCurrentTemperature());
|
|
89
|
+
}
|
|
90
|
+
|
|
70
91
|
this.device.on('change', (changes, state) => {
|
|
71
92
|
if (changes.hasOwnProperty(this.dpFanOn) && characteristicFanOn.value !== changes[this.dpFanOn])
|
|
72
93
|
characteristicFanOn.updateValue(changes[this.dpFanOn]);
|
|
@@ -84,6 +105,11 @@ class SimpleFanAccessory extends BaseAccessory {
|
|
|
84
105
|
if (characteristicSwingMode.value !== swing) characteristicSwingMode.updateValue(swing);
|
|
85
106
|
}
|
|
86
107
|
|
|
108
|
+
if (characteristicTemperature && changes.hasOwnProperty(this.dpCurrentTemperature)) {
|
|
109
|
+
const temp = this._getCurrentTemperature(changes[this.dpCurrentTemperature]);
|
|
110
|
+
if (characteristicTemperature.value !== temp) characteristicTemperature.updateValue(temp);
|
|
111
|
+
}
|
|
112
|
+
|
|
87
113
|
this.log.debug('SimpleFan changed: ' + JSON.stringify(state));
|
|
88
114
|
});
|
|
89
115
|
}
|
|
@@ -148,11 +174,17 @@ class SimpleFanAccessory extends BaseAccessory {
|
|
|
148
174
|
|
|
149
175
|
_getFanDirection(dp) {
|
|
150
176
|
const {Characteristic} = this.hap;
|
|
177
|
+
if (this.directionUseBool) {
|
|
178
|
+
return dp ? Characteristic.RotationDirection.CLOCKWISE : Characteristic.RotationDirection.COUNTER_CLOCKWISE;
|
|
179
|
+
}
|
|
151
180
|
return (dp === 'reverse') ? Characteristic.RotationDirection.COUNTER_CLOCKWISE : Characteristic.RotationDirection.CLOCKWISE;
|
|
152
181
|
}
|
|
153
182
|
|
|
154
183
|
setFanDirection(value) {
|
|
155
184
|
const {Characteristic} = this.hap;
|
|
185
|
+
if (this.directionUseBool) {
|
|
186
|
+
return this.setStateAsync(this.dpFanDirection, value !== Characteristic.RotationDirection.COUNTER_CLOCKWISE);
|
|
187
|
+
}
|
|
156
188
|
const tuyaVal = (value === Characteristic.RotationDirection.COUNTER_CLOCKWISE) ? 'reverse' : 'forward';
|
|
157
189
|
return this.setStateAsync(this.dpFanDirection, tuyaVal);
|
|
158
190
|
}
|
|
@@ -171,6 +203,15 @@ class SimpleFanAccessory extends BaseAccessory {
|
|
|
171
203
|
return this.setStateAsync(this.dpSwing, value === Characteristic.SwingMode.SWING_ENABLED);
|
|
172
204
|
}
|
|
173
205
|
|
|
206
|
+
getCurrentTemperature() {
|
|
207
|
+
return this._getCurrentTemperature(this.getStateAsync(this.dpCurrentTemperature));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
_getCurrentTemperature(dp) {
|
|
211
|
+
const v = parseFloat(dp);
|
|
212
|
+
return isNaN(v) ? 0 : v;
|
|
213
|
+
}
|
|
214
|
+
|
|
174
215
|
convertRotationSpeedFromTuyaToHomeKit(value) {
|
|
175
216
|
const v = parseInt(value) || 0;
|
|
176
217
|
if (v <= 0) return 0;
|
|
@@ -185,4 +226,4 @@ class SimpleFanAccessory extends BaseAccessory {
|
|
|
185
226
|
}
|
|
186
227
|
}
|
|
187
228
|
|
|
188
|
-
module.exports = SimpleFanAccessory;
|
|
229
|
+
module.exports = SimpleFanAccessory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-tuya-plus",
|
|
3
|
-
"version": "4.1.0-
|
|
3
|
+
"version": "4.1.0-pr.100.74",
|
|
4
4
|
"description": "A community-maintained Homebridge plugin for controlling Tuya devices locally over LAN, with an optional Tuya Cloud fallback for whatever the LAN can't reach. Includes new features, fixes, and updated device support. PRs welcome: if it runs, it ships (almost).",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|