homebridge-tuya-plus 3.3.0 → 3.5.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.
Files changed (38) hide show
  1. package/Readme.MD +2 -1
  2. package/config.schema.json +23 -0
  3. package/index.js +9 -7
  4. package/lib/AirConditionerAccessory.js +362 -445
  5. package/lib/AirPurifierAccessory.js +150 -335
  6. package/lib/BaseAccessory.js +34 -0
  7. package/lib/ConvectorAccessory.js +250 -313
  8. package/lib/CustomMultiOutletAccessory.js +97 -111
  9. package/lib/DehumidifierAccessory.js +40 -115
  10. package/lib/EnergyCharacteristics.js +5 -5
  11. package/lib/GarageDoorAccessory.js +225 -307
  12. package/lib/MultiOutletAccessory.js +92 -106
  13. package/lib/OilDiffuserAccessory.js +379 -480
  14. package/lib/OutletAccessory.js +83 -83
  15. package/lib/RGBTWLightAccessory.js +219 -249
  16. package/lib/RGBTWOutletAccessory.js +270 -296
  17. package/lib/SimpleBlindsAccessory.js +56 -85
  18. package/lib/SimpleDimmer2Accessory.js +54 -54
  19. package/lib/SimpleDimmerAccessory.js +54 -54
  20. package/lib/SimpleFanAccessory.js +31 -67
  21. package/lib/SimpleFanLightAccessory.js +58 -117
  22. package/lib/SimpleHeaterAccessory.js +140 -166
  23. package/lib/SimpleLightAccessory.js +2 -2
  24. package/lib/SwitchAccessory.js +16 -30
  25. package/lib/TWLightAccessory.js +92 -94
  26. package/lib/TuyaAccessory.js +251 -38
  27. package/lib/TuyaDiscovery.js +268 -165
  28. package/lib/ValveAccessory.js +60 -72
  29. package/lib/VerticalBlindsWithTilt.js +311 -0
  30. package/package.json +6 -5
  31. package/test/BaseAccessory.test.js +269 -0
  32. package/test/EnergyCharacteristics.test.js +74 -0
  33. package/test/GarageDoorAccessory.test.js +131 -0
  34. package/test/MultiOutletAccessory.test.js +86 -0
  35. package/test/RGBTWLightAccessory.test.js +143 -0
  36. package/test/support/mocks.js +163 -0
  37. package/wiki/Supported-Device-Types.md +49 -0
  38. package/wiki/User-documented-device-config.md +27 -0
package/Readme.MD CHANGED
@@ -43,7 +43,8 @@ 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
+ * Vertical Blinds<sup>[16](https://github.com/adrianjagielak/homebridge-tuya-plus/blob/main/wiki/Supported-Device-Types.md#vertical-blinds-with-tilt)</sup>
47
48
 
48
49
  Note: Motion, and other sensor types don't behave well with responce requests, so they will not be added.
49
50
 
@@ -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"]
@@ -78,6 +82,10 @@
78
82
  "title": "Simple Blinds",
79
83
  "enum": ["SimpleBlinds"]
80
84
  },
85
+ {
86
+ "title": "Vertical Blinds with Tilt",
87
+ "enum": ["VerticalBlindsWithTilt"]
88
+ },
81
89
  {
82
90
  "title": "Smart Plug w/ White and Color Lights",
83
91
  "enum": ["RGBTWOutlet"]
@@ -143,6 +151,13 @@
143
151
  "functionBody": "return model.devices && model.devices[arrayIndices].type !== 'null';"
144
152
  }
145
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
+ },
146
161
  "voltsId": {
147
162
  "type": "integer",
148
163
  "placeholder": "9",
@@ -498,6 +513,14 @@
498
513
  "functionBody": "return model.devices && model.devices[arrayIndices] && ['SimpleBlinds'].includes(model.devices[arrayIndices].type);"
499
514
  }
500
515
  },
516
+ "timeToClose": {
517
+ "type": "integer",
518
+ "placeholder": "30",
519
+ "description": "Time in seconds for blinds to fully open or close",
520
+ "condition": {
521
+ "functionBody": "return model.devices && model.devices[arrayIndices] && ['VerticalBlindsWithTilt'].includes(model.devices[arrayIndices].type);"
522
+ }
523
+ },
501
524
  "dpLight": {
502
525
  "type": "integer",
503
526
  "placeholder": 1,
package/index.js CHANGED
@@ -23,8 +23,9 @@ const SwitchAccessory = require('./lib/SwitchAccessory');
23
23
  const ValveAccessory = require('./lib/ValveAccessory');
24
24
  const OilDiffuserAccessory = require('./lib/OilDiffuserAccessory');
25
25
  const DoorbellAccessory = require('./lib/DoorbellAccessory');
26
+ const VerticalBlindsWithTilt = require('./lib/VerticalBlindsWithTilt');
26
27
 
27
- const PLUGIN_NAME = 'homebridge-tuya';
28
+ const PLUGIN_NAME = 'homebridge-tuya-plus';
28
29
  const PLATFORM_NAME = 'TuyaLan';
29
30
  const DEFAULT_DISCOVER_TIMEOUT = 60000;
30
31
 
@@ -50,15 +51,16 @@ const CLASS_DEF = {
50
51
  fanlight: SimpleFanLightAccessory,
51
52
  watervalve: ValveAccessory,
52
53
  oildiffuser: OilDiffuserAccessory,
53
- doorbell: DoorbellAccessory
54
+ doorbell: DoorbellAccessory,
55
+ verticalblindswithtilt: VerticalBlindsWithTilt
54
56
  };
55
57
 
56
- let Characteristic, PlatformAccessory, Service, Categories, AdaptiveLightingController, UUID;
58
+ let Characteristic, Formats, Perms, Categories, PlatformAccessory, Service, AdaptiveLightingController, UUID;
57
59
 
58
60
  module.exports = function(homebridge) {
59
61
  ({
60
62
  platformAccessory: PlatformAccessory,
61
- hap: {Characteristic, Service, AdaptiveLightingController, Accessory: {Categories}, uuid: UUID}
63
+ hap: {Characteristic, Formats, Perms, Categories, Service, AdaptiveLightingController, uuid: UUID}
62
64
  } = homebridge);
63
65
 
64
66
  homebridge.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, TuyaLan, true);
@@ -69,7 +71,7 @@ class TuyaLan {
69
71
  [this.log, this.config, this.api] = [...props];
70
72
 
71
73
  this.cachedAccessories = new Map();
72
- this.api.hap.EnergyCharacteristics = require('./lib/EnergyCharacteristics')(this.api.hap.Characteristic);
74
+ this.api.hap.EnergyCharacteristics = require('./lib/EnergyCharacteristics')(this.api.hap);
73
75
 
74
76
  if(!this.config || !this.config.devices) {
75
77
  this.log("No devices found. Check that you have specified them in your config.json file.");
@@ -172,7 +174,7 @@ class TuyaLan {
172
174
  if (!characteristic.props ||
173
175
  !Array.isArray(characteristic.props.perms) ||
174
176
  characteristic.props.perms.length !== 3 ||
175
- !(characteristic.props.perms.includes(Characteristic.Perms.WRITE) && characteristic.props.perms.includes(Characteristic.Perms.NOTIFY))
177
+ !(characteristic.props.perms.includes(Perms.WRITE) && characteristic.props.perms.includes(Perms.NOTIFY))
176
178
  ) return;
177
179
 
178
180
  this.log.info('Marked %s unreachable by faulting Service.%s.%s', accessory.displayName, service.displayName, characteristic.displayName);
@@ -234,7 +236,7 @@ class TuyaLan {
234
236
  this.log.warn('Unregistering', homebridgeAccessory.displayName);
235
237
 
236
238
  delete this.cachedAccessories[homebridgeAccessory.UUID];
237
- this.api.unregisterPlatformAccessories(PLATFORM_NAME, PLATFORM_NAME, [homebridgeAccessory]);
239
+ this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [homebridgeAccessory]);
238
240
  }
239
241
 
240
242
  removeAccessoryByUUID(uuid) {