homebridge-tuya-plus 3.5.3 → 3.6.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/index.js +3 -1
- package/lib/PercentBlindsAccessory.js +80 -0
- package/package.json +1 -1
- package/wiki/Supported-Device-Types.md +38 -0
package/index.js
CHANGED
|
@@ -24,6 +24,7 @@ const ValveAccessory = require('./lib/ValveAccessory');
|
|
|
24
24
|
const OilDiffuserAccessory = require('./lib/OilDiffuserAccessory');
|
|
25
25
|
const DoorbellAccessory = require('./lib/DoorbellAccessory');
|
|
26
26
|
const VerticalBlindsWithTilt = require('./lib/VerticalBlindsWithTilt');
|
|
27
|
+
const PercentBlindsAccessory = require('./lib/PercentBlindsAccessory');
|
|
27
28
|
|
|
28
29
|
const PLUGIN_NAME = 'homebridge-tuya-plus';
|
|
29
30
|
const PLATFORM_NAME = 'TuyaLan';
|
|
@@ -56,7 +57,8 @@ const CLASS_DEF = {
|
|
|
56
57
|
watervalve: ValveAccessory,
|
|
57
58
|
oildiffuser: OilDiffuserAccessory,
|
|
58
59
|
doorbell: DoorbellAccessory,
|
|
59
|
-
verticalblindswithtilt: VerticalBlindsWithTilt
|
|
60
|
+
verticalblindswithtilt: VerticalBlindsWithTilt,
|
|
61
|
+
percentblinds: PercentBlindsAccessory
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
let Characteristic, Formats, Perms, Categories, PlatformAccessory, Service, AdaptiveLightingController, UUID;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const BaseAccessory = require('./BaseAccessory');
|
|
2
|
+
|
|
3
|
+
class PercentBlindsAccessory extends BaseAccessory {
|
|
4
|
+
static getCategory(Categories) {
|
|
5
|
+
return Categories.WINDOW_COVERING;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
constructor(...props) {
|
|
9
|
+
super(...props);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_registerPlatformAccessory() {
|
|
13
|
+
const {Service} = this.hap;
|
|
14
|
+
this.accessory.addService(Service.WindowCovering, this.device.context.name);
|
|
15
|
+
super._registerPlatformAccessory();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_registerCharacteristics(dps) {
|
|
19
|
+
const {Service, Characteristic} = this.hap;
|
|
20
|
+
const service = this.accessory.getService(Service.WindowCovering);
|
|
21
|
+
this._checkServiceName(service, this.device.context.name);
|
|
22
|
+
|
|
23
|
+
this.dpPercentControl = this._getCustomDP(this.device.context.dpPercentControl) || '2';
|
|
24
|
+
this.dpPercentState = this._getCustomDP(this.device.context.dpPercentState) || '2';
|
|
25
|
+
this.flipState = !!this.device.context.flipState;
|
|
26
|
+
|
|
27
|
+
const characteristicCurrentPosition = service.getCharacteristic(Characteristic.CurrentPosition)
|
|
28
|
+
.updateValue(this._mapPosition(dps[this.dpPercentState] !== undefined ? dps[this.dpPercentState] : 0))
|
|
29
|
+
.on('get', this.getCurrentPosition.bind(this));
|
|
30
|
+
|
|
31
|
+
const characteristicTargetPosition = service.getCharacteristic(Characteristic.TargetPosition)
|
|
32
|
+
.updateValue(this._mapPosition(dps[this.dpPercentControl] !== undefined ? dps[this.dpPercentControl] : 0))
|
|
33
|
+
.on('get', this.getTargetPosition.bind(this))
|
|
34
|
+
.on('set', this.setTargetPosition.bind(this));
|
|
35
|
+
|
|
36
|
+
service.getCharacteristic(Characteristic.PositionState)
|
|
37
|
+
.updateValue(Characteristic.PositionState.STOPPED)
|
|
38
|
+
.on('get', callback => callback(null, Characteristic.PositionState.STOPPED));
|
|
39
|
+
|
|
40
|
+
this.device.on('change', changes => {
|
|
41
|
+
if (changes.hasOwnProperty(this.dpPercentState)) {
|
|
42
|
+
const position = this._mapPosition(changes[this.dpPercentState]);
|
|
43
|
+
this.log.debug(`[TuyaAccessory] Blind current position updated to ${position}`);
|
|
44
|
+
characteristicCurrentPosition.updateValue(position);
|
|
45
|
+
}
|
|
46
|
+
if (changes.hasOwnProperty(this.dpPercentControl)) {
|
|
47
|
+
const position = this._mapPosition(changes[this.dpPercentControl]);
|
|
48
|
+
this.log.debug(`[TuyaAccessory] Blind target position updated to ${position}`);
|
|
49
|
+
characteristicTargetPosition.updateValue(position);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_mapPosition(value) {
|
|
55
|
+
const position = parseInt(value) || 0;
|
|
56
|
+
return this.flipState ? 100 - position : position;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getCurrentPosition(callback) {
|
|
60
|
+
this.getState(this.dpPercentState, (err, dp) => {
|
|
61
|
+
if (err) return callback(err);
|
|
62
|
+
callback(null, this._mapPosition(dp));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getTargetPosition(callback) {
|
|
67
|
+
this.getState(this.dpPercentControl, (err, dp) => {
|
|
68
|
+
if (err) return callback(err);
|
|
69
|
+
callback(null, this._mapPosition(dp));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setTargetPosition(value, callback) {
|
|
74
|
+
const position = this._mapPosition(value);
|
|
75
|
+
this.log.debug(`[TuyaAccessory] Setting blind position to ${position}`);
|
|
76
|
+
this.setState(this.dpPercentControl, position, callback);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = PercentBlindsAccessory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-tuya-plus",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.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": {
|
|
@@ -21,6 +21,7 @@ If you are looking for verified configurations for your specific device, please
|
|
|
21
21
|
|Simple Blinds|`SimpleBlinds`<sup>[11](#simple-blinds)</sup>|Smart blinds and smart switches that control blinds <small>([instructions](#simple-blinds))</small>|
|
|
22
22
|
|Simple Blinds2|`SimpleBlinds2`<sup>[11](#simple-blinds)</sup>|Smart blinds and smart switches that control blinds(Use if simple Blinds (1) doesn't work for you. <small>([instructions](#simple-blinds))</small>|
|
|
23
23
|
|Vertical Blinds with Tilt|`VerticalBlindsWithTilt`<sup>[11](#vertical-blinds-with-tilt)</sup>|Smart vertical blinds with open/close and panel rotation <small>([instructions](#vertical-blinds-with-tilt))</small>|
|
|
24
|
+
|Percent Control Blinds|`PercentBlinds`<sup>[11](#percent-control-blinds)</sup>|Blinds that natively report and accept a percentage position via a `percent_control` datapoint <small>([instructions](#percent-control-blinds))</small>|
|
|
24
25
|
|Smart Plug w/ White and Color Lights|`RGBTWOutlet`<sup>[12](#outlets-with-white-and-color-lights)</sup>|Smart plugs that have controllable RGBTW LEDs <small>([instructions](#outlets-with-white-and-color-lights))</small>|
|
|
25
26
|
|Smart Fan Regulator|`SimpleFanAccessory`<sup>[more](#smart-fan-regulators-and-accessories)</sup>|Smart Fan Regulators that have controllable Speeds <small>([instructions](#smart-fan-regulators-and-accessories))</small>|
|
|
26
27
|
|Smart Fan with Light|`SimpleFanLightAccessory`<sup>[more](#smart-fan-with-light)</sup>|Smart Fan devices that have controllable Speeds, Directions and a built-in Light<small>([instructions](#smart-fan-with-light))</small>|
|
|
@@ -456,6 +457,43 @@ Support for Tuya/Graywind Smart Vertical Blinds with open/close (retract/extend)
|
|
|
456
457
|
}
|
|
457
458
|
```
|
|
458
459
|
|
|
460
|
+
### Percent Control Blinds
|
|
461
|
+
These are blinds or roller shades that natively report their current position and accept a target position as a percentage via a `percent_control` datapoint. Unlike `SimpleBlinds`, no timing calibration is needed — the device reports its actual position directly.
|
|
462
|
+
|
|
463
|
+
#### Minimal Configuration
|
|
464
|
+
```json
|
|
465
|
+
{
|
|
466
|
+
"name": "My Blinds",
|
|
467
|
+
"type": "PercentBlinds",
|
|
468
|
+
"id": "032000123456789abcde",
|
|
469
|
+
"key": "0123456789abcdef"
|
|
470
|
+
}
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
#### Full Configuration
|
|
474
|
+
```json5
|
|
475
|
+
{
|
|
476
|
+
"name": "My Blinds",
|
|
477
|
+
"type": "PercentBlinds",
|
|
478
|
+
"manufacturer": "Tuya",
|
|
479
|
+
"model": "Smart Roller Blind",
|
|
480
|
+
"id": "032000123456789abcde",
|
|
481
|
+
"key": "0123456789abcdef",
|
|
482
|
+
|
|
483
|
+
/* Additional parameters to override defaults only if needed */
|
|
484
|
+
|
|
485
|
+
/* Override the default datapoint identifier for setting target position (0–100) */
|
|
486
|
+
"dpPercentControl": "2",
|
|
487
|
+
|
|
488
|
+
/* Override the default datapoint identifier for reading current position (0–100).
|
|
489
|
+
Use "3" if your device reports position on a separate datapoint from control. */
|
|
490
|
+
"dpPercentState": "2",
|
|
491
|
+
|
|
492
|
+
/* If the device reports 0 as fully open instead of fully closed, flip the range */
|
|
493
|
+
"flipState": true
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
459
497
|
### Outlets with White and Color Lights
|
|
460
498
|
These are plugs with a single outlet that that have controllable white and colored LEDs on them.
|
|
461
499
|
|