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 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 a Switch.
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
- - Turning a zone on (to a configurable open %, default 100) or off
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
- Not implemented yet (the protocol has no obvious blocker, just not wired
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", "onPercent": 100 },
41
- { "id": 1, "name": "Bedroom", "onPercent": 80 }
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
- - `zones[].onPercent`: how far open the zone damper goes when switched on
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
 
@@ -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
  }
@@ -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.Switch) || accessory.addService(Service.Switch);
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.On)
15
- .onGet(() => this._getOn())
16
- .onSet((value) => this._setOn(value));
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
- this.service.updateCharacteristic(Characteristic.On, update.isOn);
33
+ const position = update.isOn ? update.percent : 0;
34
+ this.service.updateCharacteristic(Characteristic.CurrentPosition, position);
22
35
  }
23
36
  });
24
37
  }
25
38
 
26
- _getOn() {
27
- return this.platform.client.getZoneState(this.zoneConfig.id).isOn;
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
- _setOn(value) {
31
- this.platform.client.setZoneOn(this.zoneConfig.id, value, this.zoneConfig.onPercent || 100);
48
+ _setPosition(value) {
49
+ this.targetPosition = value;
50
+ this.platform.client.setZoneOn(this.zoneConfig.id, value > 0, value);
32
51
  }
33
52
  }
34
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-zonetouch3",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Homebridge plugin for Polyaire ZoneTouch 3 AC zone control",
5
5
  "repository": {
6
6
  "type": "git",