homebridge-tuya-plus 3.4.0 → 3.5.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/Readme.MD +1 -1
- package/config.schema.json +11 -0
- package/index.js +14 -10
- package/lib/AirConditionerAccessory.js +362 -445
- package/lib/AirPurifierAccessory.js +150 -335
- package/lib/BaseAccessory.js +34 -0
- package/lib/ConvectorAccessory.js +250 -313
- package/lib/CustomMultiOutletAccessory.js +97 -111
- package/lib/DehumidifierAccessory.js +40 -115
- package/lib/EnergyCharacteristics.js +5 -5
- package/lib/GarageDoorAccessory.js +225 -307
- package/lib/MultiOutletAccessory.js +92 -106
- package/lib/OilDiffuserAccessory.js +379 -480
- package/lib/OutletAccessory.js +83 -83
- package/lib/RGBTWLightAccessory.js +219 -249
- package/lib/RGBTWOutletAccessory.js +270 -296
- package/lib/SimpleBlindsAccessory.js +56 -85
- package/lib/SimpleDimmer2Accessory.js +54 -54
- package/lib/SimpleDimmerAccessory.js +54 -54
- package/lib/SimpleFanAccessory.js +31 -67
- package/lib/SimpleFanLightAccessory.js +58 -117
- package/lib/SimpleHeaterAccessory.js +140 -166
- package/lib/SimpleLightAccessory.js +2 -2
- package/lib/SwitchAccessory.js +16 -30
- package/lib/TWLightAccessory.js +92 -94
- package/lib/ValveAccessory.js +60 -72
- package/lib/VerticalBlindsWithTilt.js +66 -186
- package/package.json +6 -5
- package/test/BaseAccessory.test.js +269 -0
- package/test/EnergyCharacteristics.test.js +74 -0
- package/test/GarageDoorAccessory.test.js +131 -0
- package/test/MultiOutletAccessory.test.js +86 -0
- package/test/RGBTWLightAccessory.test.js +143 -0
- package/test/support/mocks.js +163 -0
- package/wiki/Supported-Device-Types.md +19 -0
- package/wiki/User-documented-device-config.md +27 -0
package/Readme.MD
CHANGED
|
@@ -43,7 +43,7 @@ A community-maintained Homebridge plugin for controlling Tuya devices locally ov
|
|
|
43
43
|
* Color<sup>[12](https://github.com/adrianjagielak/homebridge-tuya-plus/blob/main/wiki/Supported-Device-Types.md#white-and-color-light-bulbs)</sup> (Hue, Saturation, Adaptive Lighting)
|
|
44
44
|
* Oil Diffusers<sup>[13](https://github.com/adrianjagielak/homebridge-tuya-plus/blob/main/wiki/Supported-Device-Types.md)</sup>
|
|
45
45
|
* Outlets<sup>[14](https://github.com/adrianjagielak/homebridge-tuya-plus/blob/main/wiki/Supported-Device-Types.md#outlets)</sup>
|
|
46
|
-
* Switches<sup>[15](https://github.com/adrianjagielak/homebridge-tuya-plus/blob/main/wiki/Supported-Device-Types.md)</sup>
|
|
46
|
+
* Switches<sup>[15](https://github.com/adrianjagielak/homebridge-tuya-plus/blob/main/wiki/Supported-Device-Types.md#switch)</sup>
|
|
47
47
|
* Vertical Blinds<sup>[16](https://github.com/adrianjagielak/homebridge-tuya-plus/blob/main/wiki/Supported-Device-Types.md#vertical-blinds-with-tilt)</sup>
|
|
48
48
|
|
|
49
49
|
Note: Motion, and other sensor types don't behave well with responce requests, so they will not be added.
|
package/config.schema.json
CHANGED
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"title": "Please select device type...",
|
|
31
31
|
"enum": ["null"]
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
"title": "Switch Gang / Basic Switch",
|
|
35
|
+
"enum": ["Switch"]
|
|
36
|
+
},
|
|
33
37
|
{
|
|
34
38
|
"title": "Smart Plug / Barely Smart Power Strip",
|
|
35
39
|
"enum": ["Outlet"]
|
|
@@ -147,6 +151,13 @@
|
|
|
147
151
|
"functionBody": "return model.devices && model.devices[arrayIndices].type !== 'null';"
|
|
148
152
|
}
|
|
149
153
|
},
|
|
154
|
+
"switchCount": {
|
|
155
|
+
"type": "integer",
|
|
156
|
+
"placeholder": "3",
|
|
157
|
+
"condition": {
|
|
158
|
+
"functionBody": "return model.devices && model.devices[arrayIndices] && ['Switch'].includes(model.devices[arrayIndices].type);"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
150
161
|
"voltsId": {
|
|
151
162
|
"type": "integer",
|
|
152
163
|
"placeholder": "9",
|
package/index.js
CHANGED
|
@@ -25,8 +25,12 @@ const OilDiffuserAccessory = require('./lib/OilDiffuserAccessory');
|
|
|
25
25
|
const DoorbellAccessory = require('./lib/DoorbellAccessory');
|
|
26
26
|
const VerticalBlindsWithTilt = require('./lib/VerticalBlindsWithTilt');
|
|
27
27
|
|
|
28
|
-
const PLUGIN_NAME = 'homebridge-tuya';
|
|
28
|
+
const PLUGIN_NAME = 'homebridge-tuya-plus';
|
|
29
29
|
const PLATFORM_NAME = 'TuyaLan';
|
|
30
|
+
// Seed used to derive accessory UUIDs. Must remain 'homebridge-tuya' so that
|
|
31
|
+
// devices already paired with HomeKit keep their existing identity (names,
|
|
32
|
+
// rooms, automations).
|
|
33
|
+
const UUID_SEED = 'homebridge-tuya';
|
|
30
34
|
const DEFAULT_DISCOVER_TIMEOUT = 60000;
|
|
31
35
|
|
|
32
36
|
const CLASS_DEF = {
|
|
@@ -55,12 +59,12 @@ const CLASS_DEF = {
|
|
|
55
59
|
verticalblindswithtilt: VerticalBlindsWithTilt
|
|
56
60
|
};
|
|
57
61
|
|
|
58
|
-
let Characteristic,
|
|
62
|
+
let Characteristic, Formats, Perms, Categories, PlatformAccessory, Service, AdaptiveLightingController, UUID;
|
|
59
63
|
|
|
60
64
|
module.exports = function(homebridge) {
|
|
61
65
|
({
|
|
62
66
|
platformAccessory: PlatformAccessory,
|
|
63
|
-
hap: {Characteristic,
|
|
67
|
+
hap: {Characteristic, Formats, Perms, Categories, Service, AdaptiveLightingController, uuid: UUID}
|
|
64
68
|
} = homebridge);
|
|
65
69
|
|
|
66
70
|
homebridge.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, TuyaLan, true);
|
|
@@ -71,14 +75,14 @@ class TuyaLan {
|
|
|
71
75
|
[this.log, this.config, this.api] = [...props];
|
|
72
76
|
|
|
73
77
|
this.cachedAccessories = new Map();
|
|
74
|
-
this.api.hap.EnergyCharacteristics = require('./lib/EnergyCharacteristics')(this.api.hap
|
|
78
|
+
this.api.hap.EnergyCharacteristics = require('./lib/EnergyCharacteristics')(this.api.hap);
|
|
75
79
|
|
|
76
80
|
if(!this.config || !this.config.devices) {
|
|
77
81
|
this.log("No devices found. Check that you have specified them in your config.json file.");
|
|
78
82
|
return false;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
this._expectedUUIDs = this.config.devices.map(device => UUID.generate(
|
|
85
|
+
this._expectedUUIDs = this.config.devices.map(device => UUID.generate(UUID_SEED +(device.fake ? ':fake:' : ':') + device.id));
|
|
82
86
|
|
|
83
87
|
this.api.on('didFinishLaunching', () => {
|
|
84
88
|
this.discoverDevices();
|
|
@@ -122,7 +126,7 @@ class TuyaLan {
|
|
|
122
126
|
const device = new TuyaAccessory({
|
|
123
127
|
...devices[config.id], ...config,
|
|
124
128
|
log: this.log,
|
|
125
|
-
UUID: UUID.generate(
|
|
129
|
+
UUID: UUID.generate(UUID_SEED + ':' + config.id),
|
|
126
130
|
connect: false
|
|
127
131
|
});
|
|
128
132
|
this.addAccessory(device);
|
|
@@ -133,7 +137,7 @@ class TuyaLan {
|
|
|
133
137
|
this.addAccessory(new TuyaAccessory({
|
|
134
138
|
...config,
|
|
135
139
|
log: this.log,
|
|
136
|
-
UUID: UUID.generate(
|
|
140
|
+
UUID: UUID.generate(UUID_SEED + ':fake:' + config.id),
|
|
137
141
|
connect: false
|
|
138
142
|
}));
|
|
139
143
|
});
|
|
@@ -149,7 +153,7 @@ class TuyaLan {
|
|
|
149
153
|
const device = new TuyaAccessory({
|
|
150
154
|
...devices[deviceId],
|
|
151
155
|
log: this.log,
|
|
152
|
-
UUID: UUID.generate(
|
|
156
|
+
UUID: UUID.generate(UUID_SEED + ':' + deviceId),
|
|
153
157
|
connect: false
|
|
154
158
|
});
|
|
155
159
|
this.addAccessory(device);
|
|
@@ -174,7 +178,7 @@ class TuyaLan {
|
|
|
174
178
|
if (!characteristic.props ||
|
|
175
179
|
!Array.isArray(characteristic.props.perms) ||
|
|
176
180
|
characteristic.props.perms.length !== 3 ||
|
|
177
|
-
!(characteristic.props.perms.includes(
|
|
181
|
+
!(characteristic.props.perms.includes(Perms.WRITE) && characteristic.props.perms.includes(Perms.NOTIFY))
|
|
178
182
|
) return;
|
|
179
183
|
|
|
180
184
|
this.log.info('Marked %s unreachable by faulting Service.%s.%s', accessory.displayName, service.displayName, characteristic.displayName);
|
|
@@ -236,7 +240,7 @@ class TuyaLan {
|
|
|
236
240
|
this.log.warn('Unregistering', homebridgeAccessory.displayName);
|
|
237
241
|
|
|
238
242
|
delete this.cachedAccessories[homebridgeAccessory.UUID];
|
|
239
|
-
this.api.unregisterPlatformAccessories(
|
|
243
|
+
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [homebridgeAccessory]);
|
|
240
244
|
}
|
|
241
245
|
|
|
242
246
|
removeAccessoryByUUID(uuid) {
|