homebridge-bond 3.2.11 → 3.2.12
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/dist/BondApi.js +13 -0
- package/dist/accessories/ShadesAccessory.js +33 -12
- package/dist/enum/Action.js +1 -0
- package/dist/interface/Device.js +5 -0
- package/package.json +4 -4
package/dist/BondApi.js
CHANGED
|
@@ -180,6 +180,19 @@ class BondApi {
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
+
setPosition(device, position, callback) {
|
|
184
|
+
return this.request(HTTPMethod.PUT, this.uri.action(device.id, Action_1.Action.SetPosition), { argument: position })
|
|
185
|
+
.then(() => {
|
|
186
|
+
if (callback) {
|
|
187
|
+
callback(null);
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
.catch((error) => {
|
|
191
|
+
if (callback) {
|
|
192
|
+
callback(Error(error));
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
183
196
|
setFanSpeed(device, speed, callback) {
|
|
184
197
|
return this.action(device, Action_1.Action.SetSpeed, callback, { argument: speed });
|
|
185
198
|
}
|
|
@@ -23,9 +23,17 @@ class ShadesAccessory {
|
|
|
23
23
|
}
|
|
24
24
|
updateState(state) {
|
|
25
25
|
if (this.windowCoveringService) {
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
// If position is available, use it, otherwise fall back to open state
|
|
27
|
+
if (state.position !== undefined) {
|
|
28
|
+
// Convert Bond's extended percentage (0=open, 100=closed) to HomeKit's open percentage (0=closed, 100=open)
|
|
29
|
+
const homekitPosition = 100 - state.position;
|
|
30
|
+
this.windowCoveringService.currentPosition.updateValue(homekitPosition);
|
|
31
|
+
this.windowCoveringService.targetPosition.updateValue(homekitPosition);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.windowCoveringService.currentPosition.updateValue(state.open === 1 ? 100 : 0);
|
|
35
|
+
this.windowCoveringService.targetPosition.updateValue(state.open === 1 ? 100 : 0);
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
observe(bond) {
|
|
@@ -46,18 +54,31 @@ class ShadesAccessory {
|
|
|
46
54
|
const props = {
|
|
47
55
|
minValue: 0,
|
|
48
56
|
maxValue: 100,
|
|
49
|
-
minStep: 100,
|
|
57
|
+
minStep: Device_1.Device.MShasPosition(device) ? 1 : 100,
|
|
50
58
|
};
|
|
51
59
|
this.windowCoveringService.targetPosition.setProps(props);
|
|
52
60
|
Observer_1.Observer.set(this.windowCoveringService.targetPosition, (value, callback) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
if (Device_1.Device.MShasPosition(device)) {
|
|
62
|
+
// Convert HomeKit's open percentage (0=closed, 100=open) to Bond's extended percentage (0=open, 100=closed)
|
|
63
|
+
const bondPosition = 100 - value;
|
|
64
|
+
bond.api.setPosition(device, bondPosition, callback)
|
|
65
|
+
.then(() => {
|
|
66
|
+
this.platform.debug(this.accessory, `Set position: ${bondPosition} (HomeKit: ${value})`);
|
|
67
|
+
})
|
|
68
|
+
.catch((error) => {
|
|
69
|
+
this.platform.error(this.accessory, `Error setting position: ${error}`);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// Otherwise, toggle open/closed based on target position
|
|
74
|
+
bond.api.toggleOpen(device, callback)
|
|
75
|
+
.then(() => {
|
|
76
|
+
this.platform.debug(this.accessory, `Toggled open: ${value}`);
|
|
77
|
+
})
|
|
78
|
+
.catch((error) => {
|
|
79
|
+
this.platform.error(this.accessory, `Error toggling open: ${error}`);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
61
82
|
});
|
|
62
83
|
}
|
|
63
84
|
observePreset(bond, device) {
|
package/dist/enum/Action.js
CHANGED
package/dist/interface/Device.js
CHANGED
|
@@ -122,4 +122,9 @@ var Device;
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
Device.fanSpeeds = fanSpeeds;
|
|
125
|
+
function MShasPosition(device) {
|
|
126
|
+
const required = [Action_1.Action.SetPosition];
|
|
127
|
+
return required.every(r => device.actions.includes(r));
|
|
128
|
+
}
|
|
129
|
+
Device.MShasPosition = MShasPosition;
|
|
125
130
|
})(Device = exports.Device || (exports.Device = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-bond",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.12",
|
|
4
4
|
"description": "A homebridge plugin to control your Bond devices over the v2 API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
"eslint": "^7.22.0",
|
|
43
43
|
"homebridge": "^1.3.1",
|
|
44
44
|
"mocha": "^9.1.2",
|
|
45
|
-
"nodemon": "^
|
|
45
|
+
"nodemon": "^3.1.7",
|
|
46
46
|
"nyc": "^15.1.0",
|
|
47
47
|
"rimraf": "^3.0.2",
|
|
48
48
|
"ts-node": "^10.8.1",
|
|
49
49
|
"typescript": "^4.2.2"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"axios": "^0.
|
|
52
|
+
"axios": "^0.28.0",
|
|
53
53
|
"axios-retry": "^3.1.8",
|
|
54
54
|
"biguint-format": "^1.0.2",
|
|
55
55
|
"flake-idgen": "^1.4.0"
|
|
56
56
|
},
|
|
57
57
|
"homepage": "https://github.com/aarons22/homebridge-bond#readme",
|
|
58
58
|
"author": "Aaron Sapp"
|
|
59
|
-
}
|
|
59
|
+
}
|