homebridge-tuya-community 3.3.0 → 3.3.1
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/.github/workflows/npm-publish.yml +54 -0
- package/Readme.MD +3 -3
- package/bin/cli-decode.js +1 -1
- package/bin/cli-find.js +10 -10
- package/index.js +3 -3
- package/lib/AirPurifierAccessory.js +140 -139
- package/lib/CustomMultiOutletAccessory.js +3 -3
- package/lib/DehumidifierAccessory.js +24 -27
- package/lib/GarageDoorAccessory.js +11 -11
- package/lib/MultiOutletAccessory.js +2 -2
- package/lib/OilDiffuserAccessory.js +5 -6
- package/lib/RGBTWLightAccessory.js +11 -11
- package/lib/RGBTWOutletAccessory.js +1 -1
- package/lib/SimpleFanAccessory.js +35 -40
- package/lib/SimpleFanLightAccessory.js +35 -46
- package/lib/SwitchAccessory.js +2 -2
- package/lib/TWLightAccessory.js +3 -3
- package/lib/TuyaAccessory.js +34 -34
- package/package.json +2 -2
|
@@ -26,7 +26,7 @@ class CustomMultiOutletAccessory extends BaseAccessory {
|
|
|
26
26
|
throw new Error('The outlets definition is missing or is malformed: ' + this.device.context.outlets);
|
|
27
27
|
}
|
|
28
28
|
const _validServices = [];
|
|
29
|
-
this.device.context.outlets.forEach((outlet,
|
|
29
|
+
this.device.context.outlets.forEach((outlet, _i) => {
|
|
30
30
|
if (!outlet || !outlet.hasOwnProperty('name') || !outlet.hasOwnProperty('dp') || !isFinite(outlet.dp))
|
|
31
31
|
throw new Error('The outlet definition #${i} is missing or is malformed: ' + outlet);
|
|
32
32
|
|
|
@@ -63,7 +63,7 @@ class CustomMultiOutletAccessory extends BaseAccessory {
|
|
|
63
63
|
.on('set', this.setPower.bind(this, match[1]));
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
this.device.on('change', (changes,
|
|
66
|
+
this.device.on('change', (changes, _state) => {
|
|
67
67
|
Object.keys(changes).forEach(key => {
|
|
68
68
|
if (characteristics[key] && characteristics[key].value !== changes[key]) characteristics[key].updateValue(changes[key]);
|
|
69
69
|
});
|
|
@@ -96,7 +96,7 @@ class CustomMultiOutletAccessory extends BaseAccessory {
|
|
|
96
96
|
async.eachSeries(callbacks, (callback, next) => {
|
|
97
97
|
try {
|
|
98
98
|
callback(err);
|
|
99
|
-
} catch (ex) { }
|
|
99
|
+
} catch (ex) { /* Intentionally empty */ }
|
|
100
100
|
next();
|
|
101
101
|
});
|
|
102
102
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const BaseAccessory = require('./BaseAccessory');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _STATE_OTHER = 9;
|
|
4
4
|
|
|
5
5
|
class DehumidifierAccessory extends BaseAccessory {
|
|
6
6
|
static getCategory(Categories) {
|
|
@@ -16,22 +16,22 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
16
16
|
this.cmdLaundry = '3';
|
|
17
17
|
|
|
18
18
|
this.defaultDps = {
|
|
19
|
-
'Active':
|
|
20
|
-
'Mode':
|
|
21
|
-
'Humidity':
|
|
22
|
-
'Cleaning':
|
|
23
|
-
'FanSpeed':
|
|
24
|
-
'ChildLock':
|
|
19
|
+
'Active': 1,
|
|
20
|
+
'Mode': 2, // 0 - normal, 1 - continual, 2 - automatic, 3 - laundry
|
|
21
|
+
'Humidity': 4,
|
|
22
|
+
'Cleaning': 5,
|
|
23
|
+
'FanSpeed': 6, // 1 - slow, 3 - fast
|
|
24
|
+
'ChildLock': 7,
|
|
25
25
|
'TankState': 11, // 0 - not full, 8 - removed, ... - ?
|
|
26
26
|
// 12, 101, 105 - ?
|
|
27
|
-
'Sleep':
|
|
27
|
+
'Sleep': 102,
|
|
28
28
|
'CurrentTemperature': 103,
|
|
29
|
-
'CurrentHumidity':
|
|
29
|
+
'CurrentHumidity': 104,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
_registerPlatformAccessory() {
|
|
34
|
-
const {Service} = this.hap;
|
|
34
|
+
const { Service } = this.hap;
|
|
35
35
|
|
|
36
36
|
this.accessory.addService(Service.TemperatureSensor, this.device.context.name);
|
|
37
37
|
this.accessory.addService(Service.HumiditySensor, this.device.context.name);
|
|
@@ -49,19 +49,19 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
_registerCharacteristics(dps) {
|
|
52
|
-
const {Service, Characteristic} = this.hap;
|
|
52
|
+
const { Service, Characteristic } = this.hap;
|
|
53
53
|
|
|
54
54
|
const infoService = this.accessory.getService(Service.AccessoryInformation);
|
|
55
55
|
infoService.getCharacteristic(Characteristic.Manufacturer).updateValue(this.device.context.manufacturer);
|
|
56
56
|
infoService.getCharacteristic(Characteristic.Model).updateValue(this.device.context.model);
|
|
57
57
|
|
|
58
|
-
const
|
|
58
|
+
const _characteristicTemperature = this.accessory.getService(Service.TemperatureSensor)
|
|
59
59
|
.getCharacteristic(Characteristic.CurrentTemperature)
|
|
60
60
|
.updateValue(this._getCurrentTemperature(dps[this.getDp('CurrentTemperature')]))
|
|
61
61
|
.on('get', this.getCurrentTemperature.bind(this));
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
const
|
|
64
|
+
const _characteristicCurrentHumidity = this.accessory.getService(Service.HumiditySensor)
|
|
65
65
|
.getCharacteristic(Characteristic.CurrentRelativeHumidity)
|
|
66
66
|
.updateValue(this._getCurrentHumidity(dps[this.getDp('CurrentHumidity')]))
|
|
67
67
|
.on('get', this.getCurrentHumidity.bind(this));
|
|
@@ -89,7 +89,7 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
89
89
|
service.getCharacteristic(Characteristic.TargetHumidifierDehumidifierState)
|
|
90
90
|
.updateValue(Characteristic.TargetHumidifierDehumidifierState.DEHUMIDIFIER);
|
|
91
91
|
|
|
92
|
-
const
|
|
92
|
+
const _characteristicCurrentHumidity2 = service.getCharacteristic(Characteristic.CurrentRelativeHumidity)
|
|
93
93
|
.updateValue(this._getCurrentHumidity(dps[this.getDp('CurrentHumidity')]))
|
|
94
94
|
.on('get', this.getCurrentHumidity.bind(this));
|
|
95
95
|
|
|
@@ -98,7 +98,7 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
98
98
|
.on('get', this.getActive.bind(this))
|
|
99
99
|
.on('set', this.setActive.bind(this));
|
|
100
100
|
|
|
101
|
-
const
|
|
101
|
+
const _characteristicWaterTank = service.getCharacteristic(Characteristic.WaterLevel)
|
|
102
102
|
.updateValue(dps[this.getDp('TankState')])
|
|
103
103
|
.on('get', this.getTankState.bind(this));
|
|
104
104
|
|
|
@@ -117,8 +117,8 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
117
117
|
|
|
118
118
|
this.characteristicHumidity = service.getCharacteristic(Characteristic.RelativeHumidityDehumidifierThreshold);
|
|
119
119
|
this.characteristicHumidity.setProps({
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
minStep: this.device.context.humiditySteps || 5,
|
|
121
|
+
})
|
|
122
122
|
.updateValue(dps[this.getDp('Humidity')])
|
|
123
123
|
.on('get', this.getState.bind(this, this.getDp('Humidity')))
|
|
124
124
|
.on('set', this.setTargetHumidity.bind(this));
|
|
@@ -131,7 +131,7 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
131
131
|
characteristicActive.updateValue(newActive);
|
|
132
132
|
|
|
133
133
|
if (!changes.hasOwnProperty(this.getDp('FanSpeed'))) {
|
|
134
|
-
|
|
134
|
+
characteristicSpeed.updateValue(this._getRotationSpeed(state));
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -159,13 +159,13 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
_getActive(dp) {
|
|
162
|
-
const {Characteristic} = this.hap;
|
|
162
|
+
const { Characteristic } = this.hap;
|
|
163
163
|
|
|
164
164
|
return dp ? Characteristic.Active.ACTIVE : Characteristic.Active.INACTIVE;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
setActive(value, callback) {
|
|
168
|
-
const {Characteristic} = this.hap;
|
|
168
|
+
const { Characteristic } = this.hap;
|
|
169
169
|
|
|
170
170
|
switch (value) {
|
|
171
171
|
case Characteristic.Active.ACTIVE:
|
|
@@ -187,7 +187,6 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
_getTankState(dp) {
|
|
190
|
-
const {Characteristic} = this.hap;
|
|
191
190
|
|
|
192
191
|
return dp ? 100 : 50;
|
|
193
192
|
}
|
|
@@ -201,7 +200,7 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
_getLockTargetState(dp) {
|
|
204
|
-
const {Characteristic} = this.hap;
|
|
203
|
+
const { Characteristic } = this.hap;
|
|
205
204
|
|
|
206
205
|
return dp ? Characteristic.LockTargetState.SECURED : Characteristic.LockTargetState.UNSECURED;
|
|
207
206
|
}
|
|
@@ -209,7 +208,7 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
209
208
|
setLockTargetState(value, callback) {
|
|
210
209
|
if (this.device.context.noLock) return callback();
|
|
211
210
|
|
|
212
|
-
const {Characteristic} = this.hap;
|
|
211
|
+
const { Characteristic } = this.hap;
|
|
213
212
|
|
|
214
213
|
switch (value) {
|
|
215
214
|
case Characteristic.LockTargetState.SECURED:
|
|
@@ -231,9 +230,8 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
231
230
|
}
|
|
232
231
|
|
|
233
232
|
_getRotationSpeed(dp) {
|
|
234
|
-
const {Characteristic} = this.hap;
|
|
235
233
|
|
|
236
|
-
return dp > 1 ? dp-1 : dp;
|
|
234
|
+
return dp > 1 ? dp - 1 : dp;
|
|
237
235
|
}
|
|
238
236
|
|
|
239
237
|
setRotationSpeed(value, callback) {
|
|
@@ -281,7 +279,6 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
281
279
|
}
|
|
282
280
|
|
|
283
281
|
setTargetHumidity(value, callback) {
|
|
284
|
-
const {Characteristic} = this.hap;
|
|
285
282
|
|
|
286
283
|
let origValue = value;
|
|
287
284
|
value = Math.max(value, this.device.context.minHumidity || 40);
|
|
@@ -290,7 +287,7 @@ class DehumidifierAccessory extends BaseAccessory {
|
|
|
290
287
|
this.characteristicHumidity.updateValue(value);
|
|
291
288
|
}
|
|
292
289
|
|
|
293
|
-
this.setMultiState({[this.getDp('Active')]: true, [this.getDp('Humidity')]: value}, callback);
|
|
290
|
+
this.setMultiState({ [this.getDp('Active')]: true, [this.getDp('Humidity')]: value }, callback);
|
|
294
291
|
}
|
|
295
292
|
|
|
296
293
|
getDp(name) {
|
|
@@ -4,8 +4,8 @@ const BaseAccessory = require('./BaseAccessory');
|
|
|
4
4
|
// Action
|
|
5
5
|
const GARAGE_DOOR_OPEN = 'open';
|
|
6
6
|
const GARAGE_DOOR_CLOSE = 'close';
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const _GARAGE_DOOR_FOPEN = 'fopen';
|
|
8
|
+
const _GARAGE_DOOR_FCLOSE = 'fclose';
|
|
9
9
|
|
|
10
10
|
// Status or state
|
|
11
11
|
// yes, 'openning' is not a mistake, that's the text from the Kogan opener
|
|
@@ -14,7 +14,7 @@ const GARAGE_DOOR_CLOSED = 'closed';
|
|
|
14
14
|
const GARAGE_DOOR_OPENNING = 'openning';
|
|
15
15
|
const GARAGE_DOOR_OPENING =
|
|
16
16
|
'opening'; // 'opening' is not currently a valid value; added in case Kogan
|
|
17
|
-
|
|
17
|
+
// one day decides to correct the spelling
|
|
18
18
|
const GARAGE_DOOR_CLOSING = 'closing';
|
|
19
19
|
// Kogan garage door appears to have no stopped status
|
|
20
20
|
|
|
@@ -35,7 +35,7 @@ class GarageDoorAccessory extends BaseAccessory {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
_registerPlatformAccessory() {
|
|
38
|
-
const {Service} = this.hap;
|
|
38
|
+
const { Service } = this.hap;
|
|
39
39
|
|
|
40
40
|
this.accessory.addService(Service.GarageDoorOpener, this.device.context.name);
|
|
41
41
|
|
|
@@ -67,15 +67,15 @@ class GarageDoorAccessory extends BaseAccessory {
|
|
|
67
67
|
|
|
68
68
|
// function to return true if the garage door manufacturer is Wofea
|
|
69
69
|
_isWofea() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
if (this.manufacturer === GARAGE_DOOR_MANUFACTURER_WOFEA.trim()) {
|
|
71
|
+
return true;
|
|
72
|
+
} else {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
76
|
|
|
77
77
|
_registerCharacteristics(dps) {
|
|
78
|
-
const {Service, Characteristic} = this.hap;
|
|
78
|
+
const { Service, Characteristic } = this.hap;
|
|
79
79
|
const service = this.accessory.getService(Service.GarageDoorOpener);
|
|
80
80
|
this._checkServiceName(service, this.device.context.name);
|
|
81
81
|
|
|
@@ -58,7 +58,7 @@ class MultiOutletAccessory extends BaseAccessory {
|
|
|
58
58
|
.on('set', this.setPower.bind(this, match[1]));
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
this.device.on('change', (changes,
|
|
61
|
+
this.device.on('change', (changes, _state) => {
|
|
62
62
|
Object.keys(changes).forEach(key => {
|
|
63
63
|
if (characteristics[key] && characteristics[key].value !== changes[key]) characteristics[key].updateValue(changes[key]);
|
|
64
64
|
});
|
|
@@ -91,7 +91,7 @@ class MultiOutletAccessory extends BaseAccessory {
|
|
|
91
91
|
async.eachSeries(callbacks, (callback, next) => {
|
|
92
92
|
try {
|
|
93
93
|
callback(err);
|
|
94
|
-
} catch (ex) { }
|
|
94
|
+
} catch (ex) { /* Intentionally empty */ }
|
|
95
95
|
next();
|
|
96
96
|
});
|
|
97
97
|
};
|
|
@@ -66,7 +66,7 @@ class OilDiffuserAccessory extends BaseAccessory {
|
|
|
66
66
|
_registerCharacteristics(dps) {
|
|
67
67
|
this._verifyCachedPlatformAccessory();
|
|
68
68
|
|
|
69
|
-
const { Service, AdaptiveLightingController, Characteristic, EnergyCharacteristics } = this.hap;
|
|
69
|
+
const { Service, AdaptiveLightingController, Characteristic, EnergyCharacteristics: _EnergyCharacteristics } = this.hap;
|
|
70
70
|
|
|
71
71
|
const humidifierService = this.accessory.getServiceById(Service.HumidifierDehumidifier, 'humidifier');
|
|
72
72
|
const lightService = this.accessory.getServiceById(Service.Lightbulb, 'lightbulb');
|
|
@@ -201,7 +201,7 @@ class OilDiffuserAccessory extends BaseAccessory {
|
|
|
201
201
|
|
|
202
202
|
|
|
203
203
|
|
|
204
|
-
this.device.on('change', (changes,
|
|
204
|
+
this.device.on('change', (changes, _state) => {
|
|
205
205
|
if (changes.hasOwnProperty(this.dpLight) && characteristicLightOn.value !== changes[this.dpLight]) characteristicLightOn.updateValue(changes[this.dpLight]);
|
|
206
206
|
|
|
207
207
|
if (changes.hasOwnProperty(this.dpActive)) {
|
|
@@ -262,7 +262,7 @@ class OilDiffuserAccessory extends BaseAccessory {
|
|
|
262
262
|
if (value === 0) return callback(null, true);
|
|
263
263
|
|
|
264
264
|
const newColor = this.convertHomeKitColorTemperatureToHomeKitColor(value);
|
|
265
|
-
const
|
|
265
|
+
const _oldColor = this.convertColorFromTuyaToHomeKit(this.device.state[this.dpColor]);
|
|
266
266
|
|
|
267
267
|
this.characteristicHue.updateValue(newColor.h);
|
|
268
268
|
this.characteristicSaturation.updateValue(newColor.s);
|
|
@@ -310,12 +310,12 @@ class OilDiffuserAccessory extends BaseAccessory {
|
|
|
310
310
|
async.eachSeries(callbacks, (callback, next) => {
|
|
311
311
|
try {
|
|
312
312
|
callback(err);
|
|
313
|
-
} catch (ex) { }
|
|
313
|
+
} catch (ex) { /* Intentionally empty */ }
|
|
314
314
|
next();
|
|
315
315
|
});
|
|
316
316
|
};
|
|
317
317
|
|
|
318
|
-
const
|
|
318
|
+
const _isSham = this._pendingHueSaturation.props.h === 0 && this._pendingHueSaturation.props.s === 0;
|
|
319
319
|
const newValue = this.convertColorFromHomeKitToTuya(this._pendingHueSaturation.props);
|
|
320
320
|
this._pendingHueSaturation = null;
|
|
321
321
|
|
|
@@ -409,7 +409,6 @@ class OilDiffuserAccessory extends BaseAccessory {
|
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
setRotationSpeed(value, callback) {
|
|
412
|
-
const { Characteristic } = this.hap;
|
|
413
412
|
|
|
414
413
|
if (value === 0) {
|
|
415
414
|
this.setState(this.dpActive, false, callback);
|
|
@@ -11,7 +11,7 @@ class RGBTWLightAccessory extends BaseAccessory {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
_registerPlatformAccessory() {
|
|
14
|
-
const {Service} = this.hap;
|
|
14
|
+
const { Service } = this.hap;
|
|
15
15
|
|
|
16
16
|
this.accessory.addService(Service.Lightbulb, this.device.context.name);
|
|
17
17
|
|
|
@@ -19,7 +19,7 @@ class RGBTWLightAccessory extends BaseAccessory {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
_registerCharacteristics(dps) {
|
|
22
|
-
const {Service, Characteristic, AdaptiveLightingController} = this.hap;
|
|
22
|
+
const { Service, Characteristic, AdaptiveLightingController } = this.hap;
|
|
23
23
|
const service = this.accessory.getService(Service.Lightbulb);
|
|
24
24
|
this._checkServiceName(service, this.device.context.name);
|
|
25
25
|
|
|
@@ -144,7 +144,7 @@ class RGBTWLightAccessory extends BaseAccessory {
|
|
|
144
144
|
|
|
145
145
|
setBrightness(value, callback) {
|
|
146
146
|
if (this.device.state[this.dpMode] === this.cmdWhite) return this.setState(this.dpBrightness, this.convertBrightnessFromHomeKitToTuya(value), callback);
|
|
147
|
-
this.setState(this.dpColor, this.convertColorFromHomeKitToTuya({b: value}), callback);
|
|
147
|
+
this.setState(this.dpColor, this.convertColorFromHomeKitToTuya({ b: value }), callback);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
getColorTemperature(callback) {
|
|
@@ -160,7 +160,7 @@ class RGBTWLightAccessory extends BaseAccessory {
|
|
|
160
160
|
this.characteristicHue.updateValue(newColor.h);
|
|
161
161
|
this.characteristicSaturation.updateValue(newColor.s);
|
|
162
162
|
|
|
163
|
-
this.setMultiState({[this.dpMode]: this.cmdWhite, [this.dpColorTemperature]: this.convertColorTemperatureFromHomeKitToTuya(value)}, callback);
|
|
163
|
+
this.setMultiState({ [this.dpMode]: this.cmdWhite, [this.dpColorTemperature]: this.convertColorTemperatureFromHomeKitToTuya(value) }, callback);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
getHue(callback) {
|
|
@@ -169,7 +169,7 @@ class RGBTWLightAccessory extends BaseAccessory {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
setHue(value, callback) {
|
|
172
|
-
this._setHueSaturation({h: value}, callback);
|
|
172
|
+
this._setHueSaturation({ h: value }, callback);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
getSaturation(callback) {
|
|
@@ -178,18 +178,18 @@ class RGBTWLightAccessory extends BaseAccessory {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
setSaturation(value, callback) {
|
|
181
|
-
this._setHueSaturation({s: value}, callback);
|
|
181
|
+
this._setHueSaturation({ s: value }, callback);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
_setHueSaturation(prop, callback) {
|
|
185
185
|
if (!this._pendingHueSaturation) {
|
|
186
|
-
this._pendingHueSaturation = {props: {}, callbacks: []};
|
|
186
|
+
this._pendingHueSaturation = { props: {}, callbacks: [] };
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
if (prop) {
|
|
190
190
|
if (this._pendingHueSaturation.timer) clearTimeout(this._pendingHueSaturation.timer);
|
|
191
191
|
|
|
192
|
-
this._pendingHueSaturation.props = {...this._pendingHueSaturation.props, ...prop};
|
|
192
|
+
this._pendingHueSaturation.props = { ...this._pendingHueSaturation.props, ...prop };
|
|
193
193
|
this._pendingHueSaturation.callbacks.push(callback);
|
|
194
194
|
|
|
195
195
|
this._pendingHueSaturation.timer = setTimeout(() => {
|
|
@@ -205,7 +205,7 @@ class RGBTWLightAccessory extends BaseAccessory {
|
|
|
205
205
|
async.eachSeries(callbacks, (callback, next) => {
|
|
206
206
|
try {
|
|
207
207
|
callback(err);
|
|
208
|
-
} catch (ex) {}
|
|
208
|
+
} catch (ex) { /* Intentionally empty */ }
|
|
209
209
|
next();
|
|
210
210
|
}, () => {
|
|
211
211
|
this.characteristicColorTemperature.updateValue(0);
|
|
@@ -219,7 +219,7 @@ class RGBTWLightAccessory extends BaseAccessory {
|
|
|
219
219
|
|
|
220
220
|
if (this.device.state[this.dpMode] === this.cmdWhite && isSham) return callEachBack();
|
|
221
221
|
|
|
222
|
-
this.setMultiState({[this.dpMode]: this.cmdColor, [this.dpColor]: newValue}, callEachBack);
|
|
222
|
+
this.setMultiState({ [this.dpMode]: this.cmdColor, [this.dpColor]: newValue }, callEachBack);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
getControllers() {
|
|
@@ -228,7 +228,7 @@ class RGBTWLightAccessory extends BaseAccessory {
|
|
|
228
228
|
} else {
|
|
229
229
|
return [this.adaptiveLightingController];
|
|
230
230
|
}
|
|
231
|
-
|
|
231
|
+
}
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
module.exports = RGBTWLightAccessory;
|
|
@@ -276,7 +276,7 @@ class RGBTWOutletAccessory extends BaseAccessory {
|
|
|
276
276
|
async.eachSeries(callbacks, (callback, next) => {
|
|
277
277
|
try {
|
|
278
278
|
callback(err);
|
|
279
|
-
} catch (ex) { }
|
|
279
|
+
} catch (ex) { /* Intentionally empty */ }
|
|
280
280
|
next();
|
|
281
281
|
}, () => {
|
|
282
282
|
this.characteristicColorTemperature.updateValue(0);
|
|
@@ -10,13 +10,13 @@ class SimpleFanAccessory extends BaseAccessory {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
_registerPlatformAccessory() {
|
|
13
|
-
const {Service} = this.hap;
|
|
13
|
+
const { Service } = this.hap;
|
|
14
14
|
this.accessory.addService(Service.Fan, this.device.context.name);
|
|
15
15
|
super._registerPlatformAccessory();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
_registerCharacteristics(dps) {
|
|
19
|
-
const {Service, Characteristic} = this.hap;
|
|
19
|
+
const { Service, Characteristic } = this.hap;
|
|
20
20
|
const serviceFan = this.accessory.getService(Service.Fan);
|
|
21
21
|
this._checkServiceName(serviceFan, this.device.context.name);
|
|
22
22
|
this.dpFanOn = this._getCustomDP(this.device.context.dpFanOn) || '1';
|
|
@@ -66,40 +66,37 @@ class SimpleFanAccessory extends BaseAccessory {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
_getFanOn(dp) {
|
|
69
|
-
const {Characteristic} = this.hap;
|
|
70
69
|
return dp;
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
setFanOn(value, callback) {
|
|
74
|
-
const {Characteristic} = this.hap;
|
|
75
73
|
// This uses the multistate set command to send the fan on and speed request in one call.
|
|
76
|
-
if (value == false
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
if (value == false) {
|
|
75
|
+
this.fanCurrentSpeed = 0;
|
|
76
|
+
// This will turn off the fan speed if it is set to be 0.
|
|
77
|
+
return this.setState(this.dpFanOn, false, callback);
|
|
80
78
|
} else {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} else {
|
|
89
|
-
// The current fanCurrentSpeed Variable is there to ensure the fan speed doesn't change if the fan is already on.
|
|
90
|
-
if (this.useStrings) {
|
|
91
|
-
return this.setMultiStateLegacy({[this.dpFanOn]: value, [this.dpRotationSpeed]: this.fanCurrentSpeed.toString()}, callback);
|
|
79
|
+
if (this.fanCurrentSpeed === 0) {
|
|
80
|
+
// The current fanDefaultSpeed Variable is there to have the fan set to a sensible default if turned on.
|
|
81
|
+
if (this.useStrings) {
|
|
82
|
+
return this.setMultiStateLegacy({ [this.dpFanOn]: value, [this.dpRotationSpeed]: this.fanDefaultSpeed.toString() }, callback);
|
|
83
|
+
} else {
|
|
84
|
+
return this.setMultiStateLegacy({ [this.dpFanOn]: value, [this.dpRotationSpeed]: this.fanDefaultSpeed }, callback);
|
|
85
|
+
}
|
|
92
86
|
} else {
|
|
93
|
-
|
|
87
|
+
// The current fanCurrentSpeed Variable is there to ensure the fan speed doesn't change if the fan is already on.
|
|
88
|
+
if (this.useStrings) {
|
|
89
|
+
return this.setMultiStateLegacy({ [this.dpFanOn]: value, [this.dpRotationSpeed]: this.fanCurrentSpeed.toString() }, callback);
|
|
90
|
+
} else {
|
|
91
|
+
return this.setMultiStateLegacy({ [this.dpFanOn]: value, [this.dpRotationSpeed]: this.fanCurrentSpeed }, callback);
|
|
92
|
+
}
|
|
94
93
|
}
|
|
95
|
-
}
|
|
96
94
|
}
|
|
97
|
-
callback();
|
|
98
95
|
}
|
|
99
96
|
|
|
100
97
|
// Get the Current Fan Speed
|
|
101
98
|
getSpeed(callback) {
|
|
102
|
-
this.getState(this.dpRotationSpeed, (err,
|
|
99
|
+
this.getState(this.dpRotationSpeed, (err, _dp) => {
|
|
103
100
|
if (err) return callback(err);
|
|
104
101
|
callback(null, this.convertRotationSpeedFromTuyaToHomeKit(this.device.state[this.dpRotationSpeed]));
|
|
105
102
|
});
|
|
@@ -107,25 +104,23 @@ class SimpleFanAccessory extends BaseAccessory {
|
|
|
107
104
|
|
|
108
105
|
// Set the new fan speed
|
|
109
106
|
setSpeed(value, callback) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
// This is to set the fan speed variable to match the current speed.
|
|
120
|
-
this.fanCurrentSpeed = this.convertRotationSpeedFromHomeKitToTuya(value);
|
|
121
|
-
// This uses the multistatelegacy set command to send the fan on and speed request in one call.
|
|
122
|
-
if (this.useStrings) {
|
|
123
|
-
return this.setMultiStateLegacy({[this.dpFanOn]: true, [this.dpRotationSpeed]: this.convertRotationSpeedFromHomeKitToTuya(value).toString()}, callback);
|
|
107
|
+
if (value === 0) {
|
|
108
|
+
// This is to set the fan speed variable to be 1 when the fan is off.
|
|
109
|
+
if (this.useStrings) {
|
|
110
|
+
return this.setMultiStateLegacy({ [this.dpFanOn]: false, [this.dpRotationSpeed]: this.fanDefaultSpeed.toString() }, callback);
|
|
111
|
+
} else {
|
|
112
|
+
return this.setMultiStateLegacy({ [this.dpFanOn]: false, [this.dpRotationSpeed]: this.fanDefaultSpeed }, callback);
|
|
113
|
+
}
|
|
124
114
|
} else {
|
|
125
|
-
|
|
115
|
+
// This is to set the fan speed variable to match the current speed.
|
|
116
|
+
this.fanCurrentSpeed = this.convertRotationSpeedFromHomeKitToTuya(value);
|
|
117
|
+
// This uses the multistatelegacy set command to send the fan on and speed request in one call.
|
|
118
|
+
if (this.useStrings) {
|
|
119
|
+
return this.setMultiStateLegacy({ [this.dpFanOn]: true, [this.dpRotationSpeed]: this.convertRotationSpeedFromHomeKitToTuya(value).toString() }, callback);
|
|
120
|
+
} else {
|
|
121
|
+
return this.setMultiStateLegacy({ [this.dpFanOn]: true, [this.dpRotationSpeed]: this.convertRotationSpeedFromHomeKitToTuya(value) }, callback);
|
|
122
|
+
}
|
|
126
123
|
}
|
|
127
|
-
}
|
|
128
|
-
callback();
|
|
129
124
|
}
|
|
130
125
|
}
|
|
131
126
|
|