homebridge 2.3.1-beta.8 → 2.3.1-beta.9
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.
|
@@ -33,17 +33,8 @@ export declare class AccessoryQuery {
|
|
|
33
33
|
*/
|
|
34
34
|
private getDeviceTypeName;
|
|
35
35
|
/**
|
|
36
|
-
* Get current cluster state for an accessory or part
|
|
37
|
-
*
|
|
38
|
-
* The clusters object is what the PLUGIN declared, so on its own it cannot
|
|
39
|
-
* tell a consumer which features the cluster ended up with - a thermostat
|
|
40
|
-
* with and without AutoMode declares the same setpoints, and the deadband is
|
|
41
|
-
* optional either way. The UI needs the features to know which controls to
|
|
42
|
-
* offer, so each cluster is enriched with the live endpoint's featureMap
|
|
43
|
-
* (named booleans, e.g. `{ heating: true, cooling: true, autoMode: false }`).
|
|
44
|
-
* Features never change after registration, and the UI merges later state
|
|
45
|
-
* updates into the cluster object rather than replacing it, so sending the
|
|
46
|
-
* map here is enough.
|
|
36
|
+
* Get current cluster state for an accessory or part, enriched with each
|
|
37
|
+
* cluster's featureMap - see {@link withFeatureMaps}
|
|
47
38
|
*/
|
|
48
39
|
private getCurrentState;
|
|
49
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessoryQuery.d.ts","sourceRoot":"","sources":["../../../src/matter/server/AccessoryQuery.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"AccessoryQuery.d.ts","sourceRoot":"","sources":["../../../src/matter/server/AccessoryQuery.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AA6C3E,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBADjB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,EACjD,iBAAiB,EAAE,MAAM,oBAAoB,GAAG,IAAI;IAGvE;;OAEG;IACH,cAAc,IAAI,eAAe,EAAE;IAQnC;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAWvD;;;OAGG;IACH,uBAAuB,IAAI,yBAAyB,EAAE;IAWtD;;;;OAIG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,yBAAyB,GAAG,SAAS;IAIvE;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAgBvB;;OAEG;IACH,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,EAAE;IA2BzF;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;CAmBhD"}
|
|
@@ -5,6 +5,41 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Logger } from '../../logger.js';
|
|
7
7
|
const log = Logger.withPrefix('Matter/Server');
|
|
8
|
+
/**
|
|
9
|
+
* Add each cluster's featureMap to the declared cluster state.
|
|
10
|
+
*
|
|
11
|
+
* The declared clusters are what the PLUGIN asked for, so on their own they
|
|
12
|
+
* cannot tell a consumer which features the cluster ended up with - a
|
|
13
|
+
* thermostat with and without AutoMode declares the same setpoints, and the
|
|
14
|
+
* deadband is optional either way. The featureMap (named booleans, e.g.
|
|
15
|
+
* `{ heating: true, cooling: true, autoMode: false }`) comes off the live
|
|
16
|
+
* endpoint and settles that.
|
|
17
|
+
*
|
|
18
|
+
* Features never change after registration and the UI merges later state
|
|
19
|
+
* updates into the cluster object rather than replacing it, so sending the map
|
|
20
|
+
* once is enough.
|
|
21
|
+
*/
|
|
22
|
+
function withFeatureMaps(clusters, endpoint) {
|
|
23
|
+
const endpointState = endpoint?.state;
|
|
24
|
+
if (!endpointState) {
|
|
25
|
+
// Not registered yet (or restored without a live endpoint) - serve the
|
|
26
|
+
// declared state as-is and let the consumer fall back
|
|
27
|
+
return clusters;
|
|
28
|
+
}
|
|
29
|
+
const enriched = {};
|
|
30
|
+
for (const [clusterName, state] of Object.entries(clusters)) {
|
|
31
|
+
try {
|
|
32
|
+
const featureMap = endpointState[clusterName]?.featureMap;
|
|
33
|
+
enriched[clusterName] = featureMap !== undefined ? { featureMap, ...state } : state;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Reading a behavior's state can throw while the endpoint is still
|
|
37
|
+
// initialising - the declared state alone is still correct
|
|
38
|
+
enriched[clusterName] = state;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return enriched;
|
|
42
|
+
}
|
|
8
43
|
export class AccessoryQuery {
|
|
9
44
|
accessories;
|
|
10
45
|
getAccessoryCache;
|
|
@@ -63,17 +98,8 @@ export class AccessoryQuery {
|
|
|
63
98
|
return deviceType.name || 'Unknown';
|
|
64
99
|
}
|
|
65
100
|
/**
|
|
66
|
-
* Get current cluster state for an accessory or part
|
|
67
|
-
*
|
|
68
|
-
* The clusters object is what the PLUGIN declared, so on its own it cannot
|
|
69
|
-
* tell a consumer which features the cluster ended up with - a thermostat
|
|
70
|
-
* with and without AutoMode declares the same setpoints, and the deadband is
|
|
71
|
-
* optional either way. The UI needs the features to know which controls to
|
|
72
|
-
* offer, so each cluster is enriched with the live endpoint's featureMap
|
|
73
|
-
* (named booleans, e.g. `{ heating: true, cooling: true, autoMode: false }`).
|
|
74
|
-
* Features never change after registration, and the UI merges later state
|
|
75
|
-
* updates into the cluster object rather than replacing it, so sending the
|
|
76
|
-
* map here is enough.
|
|
101
|
+
* Get current cluster state for an accessory or part, enriched with each
|
|
102
|
+
* cluster's featureMap - see {@link withFeatureMaps}
|
|
77
103
|
*/
|
|
78
104
|
getCurrentState(uuid, partId) {
|
|
79
105
|
const accessory = this.accessories.get(uuid);
|
|
@@ -81,29 +107,12 @@ export class AccessoryQuery {
|
|
|
81
107
|
return {};
|
|
82
108
|
}
|
|
83
109
|
if (partId) {
|
|
110
|
+
// A part carries its own endpoint, so its clusters are enriched the same
|
|
111
|
+
// way - a thermostat exposed as a part needs the features just as much
|
|
84
112
|
const part = accessory._parts?.find(p => p.id === partId);
|
|
85
|
-
return part
|
|
86
|
-
}
|
|
87
|
-
const clusters = accessory.clusters || {};
|
|
88
|
-
const endpointState = accessory.endpoint?.state;
|
|
89
|
-
if (!endpointState) {
|
|
90
|
-
// Not registered yet (or restored without a live endpoint) - serve the
|
|
91
|
-
// declared state as-is and let the consumer fall back
|
|
92
|
-
return clusters;
|
|
93
|
-
}
|
|
94
|
-
const enriched = {};
|
|
95
|
-
for (const [clusterName, state] of Object.entries(clusters)) {
|
|
96
|
-
try {
|
|
97
|
-
const featureMap = endpointState[clusterName]?.featureMap;
|
|
98
|
-
enriched[clusterName] = featureMap !== undefined ? { featureMap, ...state } : state;
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
// Reading a behavior's state can throw while the endpoint is still
|
|
102
|
-
// initialising - the declared state alone is still correct
|
|
103
|
-
enriched[clusterName] = state;
|
|
104
|
-
}
|
|
113
|
+
return part ? withFeatureMaps(part.clusters || {}, part.endpoint) : {};
|
|
105
114
|
}
|
|
106
|
-
return
|
|
115
|
+
return withFeatureMaps(accessory.clusters || {}, accessory.endpoint);
|
|
107
116
|
}
|
|
108
117
|
/**
|
|
109
118
|
* Collect all accessories for UI display
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessoryQuery.js","sourceRoot":"","sources":["../../../src/matter/server/AccessoryQuery.ts"],"names":[],"mappings":"AAAA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