homebridge-zonetouch3 0.1.0 → 0.2.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/README.md +7 -9
- package/config.schema.json +1 -6
- package/lib/zoneAccessory.js +29 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# homebridge-zonetouch3
|
|
2
2
|
|
|
3
3
|
A Homebridge plugin for the Polyaire **ZoneTouch 3**. Each configured zone
|
|
4
|
-
shows up in HomeKit as
|
|
4
|
+
shows up in HomeKit as an adjustable Window Covering, with its position mapped
|
|
5
|
+
to the zone damper percentage.
|
|
5
6
|
|
|
6
7
|
## Status: real, working protocol
|
|
7
8
|
|
|
@@ -12,12 +13,10 @@ the Home Assistant community (see the "ZoneTouch 3 by Polyaire" thread on
|
|
|
12
13
|
community.home-assistant.io); this plugin ports that protocol directly.
|
|
13
14
|
|
|
14
15
|
Supported:
|
|
15
|
-
-
|
|
16
|
+
- Setting each zone damper from 0% (closed) to 100% (fully open)
|
|
16
17
|
- Polling zone state and temperature every `pollIntervalSeconds` (default 30s)
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
up): exposing zone open-percentage as a HomeKit dimmer instead of a plain
|
|
20
|
-
switch, and exposing the temperature sensor as a HomeKit accessory.
|
|
19
|
+
The temperature sensor is not exposed as a HomeKit accessory.
|
|
21
20
|
|
|
22
21
|
## Install
|
|
23
22
|
|
|
@@ -37,8 +36,8 @@ built-in `net` module).
|
|
|
37
36
|
"port": 7030,
|
|
38
37
|
"pollIntervalSeconds": 30,
|
|
39
38
|
"zones": [
|
|
40
|
-
{ "id": 0, "name": "Living Room"
|
|
41
|
-
{ "id": 1, "name": "Bedroom"
|
|
39
|
+
{ "id": 0, "name": "Living Room" },
|
|
40
|
+
{ "id": 1, "name": "Bedroom" }
|
|
42
41
|
]
|
|
43
42
|
}
|
|
44
43
|
]
|
|
@@ -51,8 +50,7 @@ built-in `net` module).
|
|
|
51
50
|
doesn't respond, this is the first thing worth double-checking.
|
|
52
51
|
- `zones[].id`: zone index starting at 0, in the same order they appear in
|
|
53
52
|
the ZoneTouch app.
|
|
54
|
-
-
|
|
55
|
-
in HomeKit (the app calls this separately from "on/off").
|
|
53
|
+
- Each zone's HomeKit position control sets the damper opening percentage.
|
|
56
54
|
|
|
57
55
|
## A couple of protocol quirks worth knowing
|
|
58
56
|
|
package/config.schema.json
CHANGED
|
@@ -34,12 +34,7 @@
|
|
|
34
34
|
"type": "object",
|
|
35
35
|
"properties": {
|
|
36
36
|
"id": { "title": "Zone index (0-based)", "type": "integer" },
|
|
37
|
-
"name": { "title": "Zone name", "type": "string" }
|
|
38
|
-
"onPercent": {
|
|
39
|
-
"title": "Open percentage when switched on",
|
|
40
|
-
"type": "integer",
|
|
41
|
-
"default": 100
|
|
42
|
-
}
|
|
37
|
+
"name": { "title": "Zone name", "type": "string" }
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
40
|
}
|
package/lib/zoneAccessory.js
CHANGED
|
@@ -3,32 +3,51 @@ class ZoneAccessory {
|
|
|
3
3
|
this.platform = platform;
|
|
4
4
|
this.accessory = accessory;
|
|
5
5
|
this.zoneConfig = zoneConfig;
|
|
6
|
+
this.targetPosition = null;
|
|
6
7
|
const { Service, Characteristic } = platform.api.hap;
|
|
7
8
|
|
|
9
|
+
const oldSwitchService = accessory.getService(Service.Switch);
|
|
10
|
+
if (oldSwitchService) accessory.removeService(oldSwitchService);
|
|
11
|
+
|
|
12
|
+
accessory.displayName = zoneConfig.name;
|
|
8
13
|
this.service =
|
|
9
|
-
accessory.getService(Service.
|
|
14
|
+
accessory.getService(Service.WindowCovering) || accessory.addService(Service.WindowCovering);
|
|
10
15
|
|
|
11
16
|
this.service.setCharacteristic(Characteristic.Name, zoneConfig.name);
|
|
12
17
|
|
|
13
18
|
this.service
|
|
14
|
-
.getCharacteristic(Characteristic.
|
|
15
|
-
.onGet(() => this.
|
|
16
|
-
|
|
19
|
+
.getCharacteristic(Characteristic.CurrentPosition)
|
|
20
|
+
.onGet(() => this._getPosition());
|
|
21
|
+
|
|
22
|
+
this.service
|
|
23
|
+
.getCharacteristic(Characteristic.TargetPosition)
|
|
24
|
+
.onGet(() => this._getTargetPosition())
|
|
25
|
+
.onSet((value) => this._setPosition(value));
|
|
26
|
+
|
|
27
|
+
this.service
|
|
28
|
+
.getCharacteristic(Characteristic.PositionState)
|
|
29
|
+
.onGet(() => Characteristic.PositionState.STOPPED);
|
|
17
30
|
|
|
18
|
-
// Once client.js emits real zone updates, push them into HomeKit:
|
|
19
31
|
platform.client.on('zoneUpdate', (update) => {
|
|
20
32
|
if (update.zoneId === zoneConfig.id) {
|
|
21
|
-
|
|
33
|
+
const position = update.isOn ? update.percent : 0;
|
|
34
|
+
this.service.updateCharacteristic(Characteristic.CurrentPosition, position);
|
|
22
35
|
}
|
|
23
36
|
});
|
|
24
37
|
}
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
_getPosition() {
|
|
40
|
+
const state = this.platform.client.getZoneState(this.zoneConfig.id);
|
|
41
|
+
return state.isOn ? state.percent : 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_getTargetPosition() {
|
|
45
|
+
return this.targetPosition ?? this._getPosition();
|
|
28
46
|
}
|
|
29
47
|
|
|
30
|
-
|
|
31
|
-
this.
|
|
48
|
+
_setPosition(value) {
|
|
49
|
+
this.targetPosition = value;
|
|
50
|
+
this.platform.client.setZoneOn(this.zoneConfig.id, value > 0, value);
|
|
32
51
|
}
|
|
33
52
|
}
|
|
34
53
|
|