@camstack/addon-matter-broker 0.2.149 → 0.2.151
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/CHANGELOG.md +8 -1
- package/README.md +27 -8
- package/dist/addon.js +1464 -155
- package/dist/addon.mjs +1464 -155
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -5587,7 +5587,7 @@ var ZodIssueCode = {
|
|
|
5587
5587
|
var ZodFirstPartyTypeKind;
|
|
5588
5588
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5589
5589
|
//#endregion
|
|
5590
|
-
//#region ../types/dist/sleep
|
|
5590
|
+
//#region ../types/dist/sleep--jXS9hWo.mjs
|
|
5591
5591
|
/**
|
|
5592
5592
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5593
5593
|
* window to float samples (D455).
|
|
@@ -6602,7 +6602,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
6602
6602
|
this.name = "SecretOverwriteRefusedError";
|
|
6603
6603
|
}
|
|
6604
6604
|
};
|
|
6605
|
-
function isRecord$4(value) {
|
|
6605
|
+
function isRecord$4$1(value) {
|
|
6606
6606
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6607
6607
|
}
|
|
6608
6608
|
function resolvedValue(pass, marker) {
|
|
@@ -6631,7 +6631,7 @@ function inArray(pass, incoming, stored) {
|
|
|
6631
6631
|
return incoming.map((item, index) => {
|
|
6632
6632
|
const twin = stored[index];
|
|
6633
6633
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
6634
|
-
if (isRecord$4(item) && isRecord$4(twin)) return inArrayRow(pass, item, twin);
|
|
6634
|
+
if (isRecord$4$1(item) && isRecord$4$1(twin)) return inArrayRow(pass, item, twin);
|
|
6635
6635
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
6636
6636
|
return item;
|
|
6637
6637
|
});
|
|
@@ -6642,7 +6642,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
6642
6642
|
const twin = stored[key];
|
|
6643
6643
|
if (isSecretMarker(twin)) {
|
|
6644
6644
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
6645
|
-
} else if (isRecord$4(value) && isRecord$4(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
6645
|
+
} else if (isRecord$4$1(value) && isRecord$4$1(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
6646
6646
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
6647
6647
|
}
|
|
6648
6648
|
return out;
|
|
@@ -6650,7 +6650,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
6650
6650
|
async function walk(pass, incoming, stored) {
|
|
6651
6651
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
6652
6652
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
6653
|
-
if (!isRecord$4(incoming) || !isRecord$4(stored)) return incoming;
|
|
6653
|
+
if (!isRecord$4$1(incoming) || !isRecord$4$1(stored)) return incoming;
|
|
6654
6654
|
const out = { ...incoming };
|
|
6655
6655
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
6656
6656
|
return out;
|
|
@@ -6681,7 +6681,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
6681
6681
|
function isJsonEqual(a, b) {
|
|
6682
6682
|
if (Object.is(a, b)) return true;
|
|
6683
6683
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
6684
|
-
if (isRecord$4(a) && isRecord$4(b)) {
|
|
6684
|
+
if (isRecord$4$1(a) && isRecord$4$1(b)) {
|
|
6685
6685
|
const keys = Object.keys(a);
|
|
6686
6686
|
if (keys.length !== Object.keys(b).length) return false;
|
|
6687
6687
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -6705,7 +6705,7 @@ function markerKeysOf(blob, owner) {
|
|
|
6705
6705
|
}
|
|
6706
6706
|
function nodeFromStored(value, owner) {
|
|
6707
6707
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
6708
|
-
if (!isRecord$4(value)) return null;
|
|
6708
|
+
if (!isRecord$4$1(value)) return null;
|
|
6709
6709
|
const children = /* @__PURE__ */ new Map();
|
|
6710
6710
|
for (const [key, child] of Object.entries(value)) {
|
|
6711
6711
|
const node = nodeFromStored(child, owner);
|
|
@@ -8968,6 +8968,7 @@ var CAP_NAMES = Object.freeze([
|
|
|
8968
8968
|
"filesystem-browse",
|
|
8969
8969
|
"flood",
|
|
8970
8970
|
"gas",
|
|
8971
|
+
"group-active",
|
|
8971
8972
|
"group-commands",
|
|
8972
8973
|
"group-status",
|
|
8973
8974
|
"heating-valve",
|
|
@@ -8990,6 +8991,7 @@ var CAP_NAMES = Object.freeze([
|
|
|
8990
8991
|
"login-method",
|
|
8991
8992
|
"media-player",
|
|
8992
8993
|
"mesh-network",
|
|
8994
|
+
"meter",
|
|
8993
8995
|
"metrics-provider",
|
|
8994
8996
|
"model-convert",
|
|
8995
8997
|
"model-distributor",
|
|
@@ -9788,6 +9790,10 @@ Object.freeze({
|
|
|
9788
9790
|
"path": "detected",
|
|
9789
9791
|
"valueType": "boolean"
|
|
9790
9792
|
}],
|
|
9793
|
+
"group-active": [{
|
|
9794
|
+
"path": "active",
|
|
9795
|
+
"valueType": "boolean"
|
|
9796
|
+
}],
|
|
9791
9797
|
"group-status": [
|
|
9792
9798
|
{
|
|
9793
9799
|
"path": "included",
|
|
@@ -10047,6 +10053,10 @@ Object.freeze({
|
|
|
10047
10053
|
]
|
|
10048
10054
|
}
|
|
10049
10055
|
],
|
|
10056
|
+
"meter": [{
|
|
10057
|
+
"path": "value",
|
|
10058
|
+
"valueType": "number"
|
|
10059
|
+
}],
|
|
10050
10060
|
"motion": [
|
|
10051
10061
|
{
|
|
10052
10062
|
"path": "detected",
|
|
@@ -10790,7 +10800,7 @@ object({
|
|
|
10790
10800
|
params: record(string$2(), union([string$2(), number()])).optional()
|
|
10791
10801
|
});
|
|
10792
10802
|
//#endregion
|
|
10793
|
-
//#region ../types/dist/err-msg-
|
|
10803
|
+
//#region ../types/dist/err-msg-DIorGYeC.mjs
|
|
10794
10804
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
10795
10805
|
DeviceType["Camera"] = "camera";
|
|
10796
10806
|
DeviceType["Hub"] = "hub";
|
|
@@ -10884,8 +10894,14 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
10884
10894
|
DeviceType["PetFeeder"] = "pet-feeder";
|
|
10885
10895
|
/** Built-in dishwasher — program lifecycle, door / remote-start gates,
|
|
10886
10896
|
* salt and rinse-aid levels. Installed with the `dishwasher` cap.
|
|
10887
|
-
* Sources: native Bosch Home Connect, reusable by similar integrations.
|
|
10897
|
+
* Sources: native Bosch Home Connect, reusable by similar integrations.
|
|
10898
|
+
* A plug-built dishwasher carries running-state and power instead. */
|
|
10888
10899
|
DeviceType["Dishwasher"] = "dishwasher";
|
|
10900
|
+
/** Washing machine. A plug-built one is running while its power stays
|
|
10901
|
+
* above a threshold. No program cap — that surface is the dishwasher's. */
|
|
10902
|
+
DeviceType["Washer"] = "washer";
|
|
10903
|
+
/** Tumble dryer. Same plug-built running surface as {@link Washer}. */
|
|
10904
|
+
DeviceType["Dryer"] = "dryer";
|
|
10889
10905
|
return DeviceType;
|
|
10890
10906
|
}({});
|
|
10891
10907
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -11143,7 +11159,7 @@ function errMsg(err) {
|
|
|
11143
11159
|
return String(err);
|
|
11144
11160
|
}
|
|
11145
11161
|
//#endregion
|
|
11146
|
-
//#region ../types/dist/composition-
|
|
11162
|
+
//#region ../types/dist/composition-Bb8iwHEJ.mjs
|
|
11147
11163
|
/**
|
|
11148
11164
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11149
11165
|
*
|
|
@@ -11256,7 +11272,7 @@ var ExpressionEvalError = class extends Error {
|
|
|
11256
11272
|
this.name = "ExpressionEvalError";
|
|
11257
11273
|
}
|
|
11258
11274
|
};
|
|
11259
|
-
function asFiniteNumber(value, name, index) {
|
|
11275
|
+
function asFiniteNumber$1(value, name, index) {
|
|
11260
11276
|
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
11261
11277
|
return value;
|
|
11262
11278
|
}
|
|
@@ -11269,7 +11285,7 @@ function finiteResult(value, name) {
|
|
|
11269
11285
|
return value;
|
|
11270
11286
|
}
|
|
11271
11287
|
function allFiniteNumbers(args, name) {
|
|
11272
|
-
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
11288
|
+
return args.map((a, idx) => asFiniteNumber$1(a, name, idx));
|
|
11273
11289
|
}
|
|
11274
11290
|
function asBoolean$2(value, name, index) {
|
|
11275
11291
|
if (typeof value !== "boolean") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a boolean`);
|
|
@@ -11306,29 +11322,29 @@ var table = {
|
|
|
11306
11322
|
abs: {
|
|
11307
11323
|
minArgs: 1,
|
|
11308
11324
|
maxArgs: 1,
|
|
11309
|
-
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
11325
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber$1(args[0], "abs", 0)), "abs")
|
|
11310
11326
|
},
|
|
11311
11327
|
floor: {
|
|
11312
11328
|
minArgs: 1,
|
|
11313
11329
|
maxArgs: 1,
|
|
11314
|
-
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
11330
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber$1(args[0], "floor", 0)), "floor")
|
|
11315
11331
|
},
|
|
11316
11332
|
ceil: {
|
|
11317
11333
|
minArgs: 1,
|
|
11318
11334
|
maxArgs: 1,
|
|
11319
|
-
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
11335
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber$1(args[0], "ceil", 0)), "ceil")
|
|
11320
11336
|
},
|
|
11321
11337
|
sqrt: {
|
|
11322
11338
|
minArgs: 1,
|
|
11323
11339
|
maxArgs: 1,
|
|
11324
|
-
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
11340
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber$1(args[0], "sqrt", 0)), "sqrt")
|
|
11325
11341
|
},
|
|
11326
11342
|
round: {
|
|
11327
11343
|
minArgs: 1,
|
|
11328
11344
|
maxArgs: 2,
|
|
11329
11345
|
apply: (args) => {
|
|
11330
|
-
const x = asFiniteNumber(args[0], "round", 0);
|
|
11331
|
-
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
11346
|
+
const x = asFiniteNumber$1(args[0], "round", 0);
|
|
11347
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber$1(args[1], "round", 1)) : 0;
|
|
11332
11348
|
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
11333
11349
|
const factor = 10 ** digits;
|
|
11334
11350
|
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
@@ -11337,15 +11353,15 @@ var table = {
|
|
|
11337
11353
|
pow: {
|
|
11338
11354
|
minArgs: 2,
|
|
11339
11355
|
maxArgs: 2,
|
|
11340
|
-
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
11356
|
+
apply: (args) => finiteResult(asFiniteNumber$1(args[0], "pow", 0) ** asFiniteNumber$1(args[1], "pow", 1), "pow")
|
|
11341
11357
|
},
|
|
11342
11358
|
clamp: {
|
|
11343
11359
|
minArgs: 3,
|
|
11344
11360
|
maxArgs: 3,
|
|
11345
11361
|
apply: (args) => {
|
|
11346
|
-
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
11347
|
-
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
11348
|
-
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
11362
|
+
const x = asFiniteNumber$1(args[0], "clamp", 0);
|
|
11363
|
+
const lo = asFiniteNumber$1(args[1], "clamp", 1);
|
|
11364
|
+
const hi = asFiniteNumber$1(args[2], "clamp", 2);
|
|
11349
11365
|
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
11350
11366
|
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
11351
11367
|
}
|
|
@@ -11374,13 +11390,13 @@ var table = {
|
|
|
11374
11390
|
age: {
|
|
11375
11391
|
minArgs: 2,
|
|
11376
11392
|
maxArgs: 2,
|
|
11377
|
-
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
11393
|
+
apply: (args) => finiteResult(asFiniteNumber$1(args[0], "age", 0) - asFiniteNumber$1(args[1], "age", 1), "age")
|
|
11378
11394
|
},
|
|
11379
11395
|
convert: {
|
|
11380
11396
|
minArgs: 3,
|
|
11381
11397
|
maxArgs: 3,
|
|
11382
11398
|
apply: (args, hooks) => {
|
|
11383
|
-
const x = asFiniteNumber(args[0], "convert", 0);
|
|
11399
|
+
const x = asFiniteNumber$1(args[0], "convert", 0);
|
|
11384
11400
|
const from = asString(args[1], "convert", 1).trim();
|
|
11385
11401
|
const to = asString(args[2], "convert", 2).trim();
|
|
11386
11402
|
if (hooks.convert) {
|
|
@@ -11406,11 +11422,11 @@ var table = {
|
|
|
11406
11422
|
minArgs: 2,
|
|
11407
11423
|
maxArgs: 2,
|
|
11408
11424
|
apply: (args, hooks) => {
|
|
11409
|
-
const windowMs = asFiniteNumber(args[1], "within", 1);
|
|
11425
|
+
const windowMs = asFiniteNumber$1(args[1], "within", 1);
|
|
11410
11426
|
if (windowMs < 0) throw new ExpressionEvalError("within: the window must not be negative");
|
|
11411
11427
|
const at = args[0];
|
|
11412
11428
|
if (at === null) return false;
|
|
11413
|
-
const ts = asFiniteNumber(at, "within", 0);
|
|
11429
|
+
const ts = asFiniteNumber$1(at, "within", 0);
|
|
11414
11430
|
const now = hooks.now;
|
|
11415
11431
|
if (now === void 0 || !Number.isFinite(now)) throw new ExpressionEvalError("within: no clock was supplied to this evaluation");
|
|
11416
11432
|
const inside = now - ts <= windowMs;
|
|
@@ -11427,7 +11443,7 @@ var table = {
|
|
|
11427
11443
|
minArgs: 1,
|
|
11428
11444
|
maxArgs: INF,
|
|
11429
11445
|
apply: (args) => {
|
|
11430
|
-
const present = args.flatMap((a, i) => a === null ? [] : [asFiniteNumber(a, "latest", i)]);
|
|
11446
|
+
const present = args.flatMap((a, i) => a === null ? [] : [asFiniteNumber$1(a, "latest", i)]);
|
|
11431
11447
|
return present.length === 0 ? null : finiteResult(Math.max(...present), "latest");
|
|
11432
11448
|
}
|
|
11433
11449
|
},
|
|
@@ -11458,6 +11474,13 @@ var table = {
|
|
|
11458
11474
|
apply: () => {
|
|
11459
11475
|
throw new ExpressionEvalError("latchedAt: stateful evaluation context is required");
|
|
11460
11476
|
}
|
|
11477
|
+
},
|
|
11478
|
+
schmitt: {
|
|
11479
|
+
minArgs: 3,
|
|
11480
|
+
maxArgs: 5,
|
|
11481
|
+
apply: () => {
|
|
11482
|
+
throw new ExpressionEvalError("schmitt: stateful evaluation context is required");
|
|
11483
|
+
}
|
|
11461
11484
|
}
|
|
11462
11485
|
};
|
|
11463
11486
|
Object.freeze(Object.assign(Object.create(null), table));
|
|
@@ -11899,6 +11922,99 @@ function validateExpressionSource(src) {
|
|
|
11899
11922
|
return null;
|
|
11900
11923
|
}
|
|
11901
11924
|
/**
|
|
11925
|
+
* One power reading becomes a washer, dryer or dishwasher (D944 helper).
|
|
11926
|
+
*
|
|
11927
|
+
* Standby of the control board is under 5 W; a motor or a heater is far
|
|
11928
|
+
* above that, so 5 W is the line. A door lock or a short pump spike is not
|
|
11929
|
+
* a cycle, so running starts only after 30 s above the line.
|
|
11930
|
+
*
|
|
11931
|
+
* A wash, dry or dishwasher pause (soak, heat-wait, heater off between
|
|
11932
|
+
* bursts) lasts several minutes. Ending the cycle on the first dip would
|
|
11933
|
+
* report "finished" in the middle of the program, so the stop dwell is
|
|
11934
|
+
* 10 minutes on every type. The number is stored per type so one machine
|
|
11935
|
+
* can move later without moving the others.
|
|
11936
|
+
*/
|
|
11937
|
+
var APPLIANCE_TEMPLATE_ID = "appliance";
|
|
11938
|
+
var APPLIANCE_KINDS = [
|
|
11939
|
+
"washer",
|
|
11940
|
+
"dryer",
|
|
11941
|
+
"dishwasher"
|
|
11942
|
+
];
|
|
11943
|
+
DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher;
|
|
11944
|
+
/**
|
|
11945
|
+
* Statistics and integrals over a history read (D944).
|
|
11946
|
+
*
|
|
11947
|
+
* Pure: the same points always give the same answer, so a restart recomputes
|
|
11948
|
+
* rather than trusting a buffer. A gauge mean is time-weighted (value × ms),
|
|
11949
|
+
* never the mean of the samples. A hole with no held value is not integrated
|
|
11950
|
+
* as zero. A truncated read is not published.
|
|
11951
|
+
*/
|
|
11952
|
+
var STATISTIC_STATS = [
|
|
11953
|
+
"min",
|
|
11954
|
+
"max",
|
|
11955
|
+
"mean",
|
|
11956
|
+
"sum",
|
|
11957
|
+
"count",
|
|
11958
|
+
"change"
|
|
11959
|
+
];
|
|
11960
|
+
/**
|
|
11961
|
+
* The range a statistics or integral helper asks history for (D944).
|
|
11962
|
+
*
|
|
11963
|
+
* Calendar edges are the hub's timezone, never UTC midnight: a day is 23, 24
|
|
11964
|
+
* or 25 hours across a DST change. A tier is eligible only when its retention
|
|
11965
|
+
* is strictly longer than the longest that range can be. Forever qualifies.
|
|
11966
|
+
* Equal to a tier's retention is a refusal, not a short answer.
|
|
11967
|
+
*/
|
|
11968
|
+
var MINUTE_MS = 6e4;
|
|
11969
|
+
var HOUR_MS = 60 * MINUTE_MS;
|
|
11970
|
+
var DAY_MS = 24 * HOUR_MS;
|
|
11971
|
+
var ROLLING_SPANS = [
|
|
11972
|
+
"1h",
|
|
11973
|
+
"24h",
|
|
11974
|
+
"2d",
|
|
11975
|
+
"7d",
|
|
11976
|
+
"30d",
|
|
11977
|
+
"custom"
|
|
11978
|
+
];
|
|
11979
|
+
var CALENDAR_PERIODS = [
|
|
11980
|
+
"today",
|
|
11981
|
+
"yesterday",
|
|
11982
|
+
"this-week",
|
|
11983
|
+
"this-month"
|
|
11984
|
+
];
|
|
11985
|
+
var RESET_PERIODS = [
|
|
11986
|
+
"never",
|
|
11987
|
+
"daily",
|
|
11988
|
+
"weekly",
|
|
11989
|
+
"monthly"
|
|
11990
|
+
];
|
|
11991
|
+
5 * MINUTE_MS;
|
|
11992
|
+
24 * HOUR_MS, 2 * DAY_MS, 7 * DAY_MS, 30 * DAY_MS;
|
|
11993
|
+
7 * DAY_MS, 30 * DAY_MS, 365 * DAY_MS;
|
|
11994
|
+
var rollingWindowObject = object({
|
|
11995
|
+
kind: literal("rolling"),
|
|
11996
|
+
span: _enum(ROLLING_SPANS),
|
|
11997
|
+
customMinutes: number().int().min(5).optional()
|
|
11998
|
+
}).check((payload) => {
|
|
11999
|
+
if (payload.value.span === "custom" && payload.value.customMinutes === void 0) payload.issues.push({
|
|
12000
|
+
code: "custom",
|
|
12001
|
+
message: "a custom range needs a duration in minutes",
|
|
12002
|
+
path: ["customMinutes"],
|
|
12003
|
+
input: payload.value
|
|
12004
|
+
});
|
|
12005
|
+
if (payload.value.span !== "custom" && payload.value.customMinutes !== void 0) payload.issues.push({
|
|
12006
|
+
code: "custom",
|
|
12007
|
+
message: "only a custom range carries a duration",
|
|
12008
|
+
path: ["customMinutes"],
|
|
12009
|
+
input: payload.value
|
|
12010
|
+
});
|
|
12011
|
+
});
|
|
12012
|
+
var RollingWindowSchema = rollingWindowObject;
|
|
12013
|
+
var StatisticWindowSchema = discriminatedUnion("kind", [rollingWindowObject, object({
|
|
12014
|
+
kind: literal("calendar"),
|
|
12015
|
+
period: _enum(CALENDAR_PERIODS)
|
|
12016
|
+
})]);
|
|
12017
|
+
/**
|
|
11902
12018
|
* A composition source identity: `(addonId, stableId)`, never a numeric device
|
|
11903
12019
|
* id. Split out so helper schemas can name it without a cycle through
|
|
11904
12020
|
* `composition.ts` (D659).
|
|
@@ -11924,7 +12040,13 @@ var GROUP_TEMPLATE_IDS = [
|
|
|
11924
12040
|
"occupancy",
|
|
11925
12041
|
"binary",
|
|
11926
12042
|
"switch",
|
|
11927
|
-
"light"
|
|
12043
|
+
"light",
|
|
12044
|
+
"fan",
|
|
12045
|
+
"cover",
|
|
12046
|
+
"valve",
|
|
12047
|
+
"lock",
|
|
12048
|
+
"media-player",
|
|
12049
|
+
"climate"
|
|
11928
12050
|
];
|
|
11929
12051
|
var NUMERIC_AGGREGATES = [
|
|
11930
12052
|
"mean",
|
|
@@ -11954,14 +12076,73 @@ var HelperMemberSchema = object({
|
|
|
11954
12076
|
cap: string$2().min(1),
|
|
11955
12077
|
fieldPath: string$2().min(1)
|
|
11956
12078
|
});
|
|
11957
|
-
var HelperSpecSchema = discriminatedUnion("kind", [
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
|
|
12079
|
+
var HelperSpecSchema = discriminatedUnion("kind", [
|
|
12080
|
+
object({
|
|
12081
|
+
kind: literal("group"),
|
|
12082
|
+
templateId: GroupTemplateIdSchema,
|
|
12083
|
+
aggregate: AggregateReducerSchema,
|
|
12084
|
+
members: array(HelperMemberSchema).min(1).max(64),
|
|
12085
|
+
/** Actuator groups only. Readings leave this unset. */
|
|
12086
|
+
active: ActiveCriterionSchema.optional()
|
|
12087
|
+
}),
|
|
12088
|
+
object({
|
|
12089
|
+
kind: literal("appliance"),
|
|
12090
|
+
templateId: literal(APPLIANCE_TEMPLATE_ID),
|
|
12091
|
+
appliance: _enum(APPLIANCE_KINDS),
|
|
12092
|
+
thresholdWatts: number().positive(),
|
|
12093
|
+
startDwellMs: number().int().nonnegative(),
|
|
12094
|
+
stopDwellMs: number().int().nonnegative(),
|
|
12095
|
+
member: HelperMemberSchema
|
|
12096
|
+
}),
|
|
12097
|
+
object({
|
|
12098
|
+
kind: literal("statistic"),
|
|
12099
|
+
stat: _enum(STATISTIC_STATS),
|
|
12100
|
+
window: StatisticWindowSchema,
|
|
12101
|
+
source: HelperMemberSchema
|
|
12102
|
+
}),
|
|
12103
|
+
object({
|
|
12104
|
+
kind: literal("integral"),
|
|
12105
|
+
reset: _enum(RESET_PERIODS),
|
|
12106
|
+
output: _enum(["energy", "meter"]),
|
|
12107
|
+
source: HelperMemberSchema
|
|
12108
|
+
}),
|
|
12109
|
+
object({
|
|
12110
|
+
kind: literal("threshold"),
|
|
12111
|
+
source: HelperMemberSchema,
|
|
12112
|
+
high: number(),
|
|
12113
|
+
low: number(),
|
|
12114
|
+
onForMs: number().int().nonnegative(),
|
|
12115
|
+
offForMs: number().int().nonnegative()
|
|
12116
|
+
}),
|
|
12117
|
+
object({
|
|
12118
|
+
kind: literal("arithmetic"),
|
|
12119
|
+
op: _enum([
|
|
12120
|
+
"sum",
|
|
12121
|
+
"difference",
|
|
12122
|
+
"ratio"
|
|
12123
|
+
]),
|
|
12124
|
+
inputs: array(HelperMemberSchema).min(2).max(64)
|
|
12125
|
+
}),
|
|
12126
|
+
object({
|
|
12127
|
+
kind: literal("expression"),
|
|
12128
|
+
expr: string$2().min(1),
|
|
12129
|
+
inputs: array(object({
|
|
12130
|
+
name: string$2().min(1),
|
|
12131
|
+
member: HelperMemberSchema
|
|
12132
|
+
})).min(1).max(64),
|
|
12133
|
+
output: _enum(["number", "boolean"])
|
|
12134
|
+
}),
|
|
12135
|
+
object({
|
|
12136
|
+
kind: literal("derivative"),
|
|
12137
|
+
window: RollingWindowSchema,
|
|
12138
|
+
per: _enum([
|
|
12139
|
+
"second",
|
|
12140
|
+
"minute",
|
|
12141
|
+
"hour"
|
|
12142
|
+
]),
|
|
12143
|
+
source: HelperMemberSchema
|
|
12144
|
+
})
|
|
12145
|
+
]);
|
|
11965
12146
|
/** A composed device's stableId is this prefix plus the block id. */
|
|
11966
12147
|
var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
|
|
11967
12148
|
/** Longest snippet a `code` source may carry (slice 4). */
|
|
@@ -12022,6 +12203,12 @@ var CompositionFieldSourceSchema = discriminatedUnion("kind", [
|
|
|
12022
12203
|
"all"
|
|
12023
12204
|
]),
|
|
12024
12205
|
reads: array(CompositionFieldReadSchema).min(1).max(64),
|
|
12206
|
+
/**
|
|
12207
|
+
* Set when the reads are an enum state, not a yes/no: the listed states
|
|
12208
|
+
* count as active (a cover is `open`). A state outside the list is inactive;
|
|
12209
|
+
* a read that is not a state at all is left out. Only `any` / `all` use it.
|
|
12210
|
+
*/
|
|
12211
|
+
activeWhen: array(string$2().min(1)).min(1).optional(),
|
|
12025
12212
|
/** `value` is the reading; the others are the member counts. */
|
|
12026
12213
|
publish: _enum([
|
|
12027
12214
|
"value",
|
|
@@ -12035,6 +12222,26 @@ var CompositionFieldSourceSchema = discriminatedUnion("kind", [
|
|
|
12035
12222
|
"omit",
|
|
12036
12223
|
"offline"
|
|
12037
12224
|
])
|
|
12225
|
+
}),
|
|
12226
|
+
object({
|
|
12227
|
+
kind: literal("series"),
|
|
12228
|
+
read: CompositionFieldReadSchema,
|
|
12229
|
+
/** `value` is the statistic or the integral. The others are the gap counts. */
|
|
12230
|
+
publish: _enum([
|
|
12231
|
+
"value",
|
|
12232
|
+
"included",
|
|
12233
|
+
"excluded",
|
|
12234
|
+
"total"
|
|
12235
|
+
]),
|
|
12236
|
+
/**
|
|
12237
|
+
* What an unanswered `value` does. Counts ignore this. `offline` leaves the
|
|
12238
|
+
* device unseeded until history answers, so a restart cannot publish 0.
|
|
12239
|
+
*/
|
|
12240
|
+
empty: _enum([
|
|
12241
|
+
"null",
|
|
12242
|
+
"omit",
|
|
12243
|
+
"offline"
|
|
12244
|
+
])
|
|
12038
12245
|
})
|
|
12039
12246
|
]);
|
|
12040
12247
|
var CompositionCommandTargetSchema = discriminatedUnion("kind", [object({
|
|
@@ -17194,7 +17401,22 @@ var BrokerProviderInfoSchema = object({
|
|
|
17194
17401
|
*/
|
|
17195
17402
|
interactiveConnectPath: string$2().min(1).optional(),
|
|
17196
17403
|
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
17197
|
-
interactiveDisconnectPath: string$2().min(1).optional()
|
|
17404
|
+
interactiveDisconnectPath: string$2().min(1).optional(),
|
|
17405
|
+
/**
|
|
17406
|
+
* The kind signs in through a server-held interactive session instead of
|
|
17407
|
+
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
17408
|
+
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
17409
|
+
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
17410
|
+
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
17411
|
+
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
17412
|
+
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
17413
|
+
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
17414
|
+
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
17415
|
+
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
17416
|
+
* offers it as the default path; the fields the session fills are
|
|
17417
|
+
* marked `filledBySignIn` in the kind's settings schema.
|
|
17418
|
+
*/
|
|
17419
|
+
signIn: object({ basePath: string$2().min(1) }).optional()
|
|
17198
17420
|
}))
|
|
17199
17421
|
});
|
|
17200
17422
|
var ListInputSchema = object({
|
|
@@ -18348,7 +18570,8 @@ var CompositionProblemSchema = object({
|
|
|
18348
18570
|
"native-capability-replace",
|
|
18349
18571
|
"mixed-quantity",
|
|
18350
18572
|
"helper-mismatch",
|
|
18351
|
-
"member-constraint"
|
|
18573
|
+
"member-constraint",
|
|
18574
|
+
"retention"
|
|
18352
18575
|
]),
|
|
18353
18576
|
path: string$2(),
|
|
18354
18577
|
message: string$2()
|
|
@@ -18582,13 +18805,17 @@ Object.freeze({
|
|
|
18582
18805
|
latchedAt: {
|
|
18583
18806
|
kind: "fixed",
|
|
18584
18807
|
result: ["number", "null"]
|
|
18808
|
+
},
|
|
18809
|
+
schmitt: {
|
|
18810
|
+
kind: "fixed",
|
|
18811
|
+
result: ["boolean", "null"]
|
|
18585
18812
|
}
|
|
18586
18813
|
});
|
|
18587
18814
|
/**
|
|
18588
18815
|
* One catalog row per base reading a group helper can build (D944 §3).
|
|
18589
18816
|
* Data, not a form default written into the block.
|
|
18590
18817
|
*/
|
|
18591
|
-
var NOW = {
|
|
18818
|
+
var NOW$2 = {
|
|
18592
18819
|
fieldPath: "lastFetchedAt",
|
|
18593
18820
|
expr: "now"
|
|
18594
18821
|
};
|
|
@@ -18602,6 +18829,8 @@ function numeric(input) {
|
|
|
18602
18829
|
family: "numeric",
|
|
18603
18830
|
deviceType: DeviceType.Sensor,
|
|
18604
18831
|
memberDeviceType: DeviceType.Sensor,
|
|
18832
|
+
memberDeviceTypes: [DeviceType.Sensor],
|
|
18833
|
+
activeWhen: void 0,
|
|
18605
18834
|
commandCaps: [],
|
|
18606
18835
|
baseUnit: baseUnitOf(input.quantity),
|
|
18607
18836
|
aggregates: NUMERIC_AGGREGATES,
|
|
@@ -18617,6 +18846,8 @@ function binary(input) {
|
|
|
18617
18846
|
family: "binary",
|
|
18618
18847
|
deviceType: DeviceType.Sensor,
|
|
18619
18848
|
memberDeviceType: DeviceType.Sensor,
|
|
18849
|
+
memberDeviceTypes: [DeviceType.Sensor],
|
|
18850
|
+
activeWhen: void 0,
|
|
18620
18851
|
commandCaps: [],
|
|
18621
18852
|
quantity: "none",
|
|
18622
18853
|
baseUnit: void 0,
|
|
@@ -18634,7 +18865,7 @@ var GROUP_TEMPLATES = [
|
|
|
18634
18865
|
quantity: "temperature",
|
|
18635
18866
|
defaultAggregate: "mean",
|
|
18636
18867
|
empty: "null",
|
|
18637
|
-
companions: [NOW]
|
|
18868
|
+
companions: [NOW$2]
|
|
18638
18869
|
}),
|
|
18639
18870
|
numeric({
|
|
18640
18871
|
id: "humidity",
|
|
@@ -18645,7 +18876,7 @@ var GROUP_TEMPLATES = [
|
|
|
18645
18876
|
quantity: "humidity",
|
|
18646
18877
|
defaultAggregate: "mean",
|
|
18647
18878
|
empty: "null",
|
|
18648
|
-
companions: [NOW]
|
|
18879
|
+
companions: [NOW$2]
|
|
18649
18880
|
}),
|
|
18650
18881
|
numeric({
|
|
18651
18882
|
id: "pressure",
|
|
@@ -18656,7 +18887,7 @@ var GROUP_TEMPLATES = [
|
|
|
18656
18887
|
quantity: "pressure",
|
|
18657
18888
|
defaultAggregate: "mean",
|
|
18658
18889
|
empty: "null",
|
|
18659
|
-
companions: [NOW]
|
|
18890
|
+
companions: [NOW$2]
|
|
18660
18891
|
}),
|
|
18661
18892
|
numeric({
|
|
18662
18893
|
id: "illuminance",
|
|
@@ -18667,7 +18898,7 @@ var GROUP_TEMPLATES = [
|
|
|
18667
18898
|
quantity: "illuminance",
|
|
18668
18899
|
defaultAggregate: "mean",
|
|
18669
18900
|
empty: "null",
|
|
18670
|
-
companions: [NOW]
|
|
18901
|
+
companions: [NOW$2]
|
|
18671
18902
|
}),
|
|
18672
18903
|
numeric({
|
|
18673
18904
|
id: "power",
|
|
@@ -18678,7 +18909,7 @@ var GROUP_TEMPLATES = [
|
|
|
18678
18909
|
quantity: "power",
|
|
18679
18910
|
defaultAggregate: "sum",
|
|
18680
18911
|
empty: "omit",
|
|
18681
|
-
companions: [NOW]
|
|
18912
|
+
companions: [NOW$2]
|
|
18682
18913
|
}),
|
|
18683
18914
|
numeric({
|
|
18684
18915
|
id: "energy",
|
|
@@ -18689,7 +18920,7 @@ var GROUP_TEMPLATES = [
|
|
|
18689
18920
|
quantity: "energy",
|
|
18690
18921
|
defaultAggregate: "sum",
|
|
18691
18922
|
empty: "omit",
|
|
18692
|
-
companions: [NOW]
|
|
18923
|
+
companions: [NOW$2]
|
|
18693
18924
|
}),
|
|
18694
18925
|
numeric({
|
|
18695
18926
|
id: "battery",
|
|
@@ -18724,7 +18955,7 @@ var GROUP_TEMPLATES = [
|
|
|
18724
18955
|
quantity: "device",
|
|
18725
18956
|
defaultAggregate: "mean",
|
|
18726
18957
|
empty: "null",
|
|
18727
|
-
companions: [NOW]
|
|
18958
|
+
companions: [NOW$2]
|
|
18728
18959
|
}),
|
|
18729
18960
|
binary({
|
|
18730
18961
|
id: "motion",
|
|
@@ -18818,6 +19049,11 @@ var GROUP_TEMPLATES = [
|
|
|
18818
19049
|
summary: "On when at least one switch is on, or when all of them are. Offline and unknown members are left out of that decision, never read as off, and still receive the command.",
|
|
18819
19050
|
deviceType: DeviceType.Switch,
|
|
18820
19051
|
outputCap: "switch",
|
|
19052
|
+
outputField: "on",
|
|
19053
|
+
member: {
|
|
19054
|
+
cap: "switch",
|
|
19055
|
+
fieldPath: "on"
|
|
19056
|
+
},
|
|
18821
19057
|
commandCaps: ["switch"]
|
|
18822
19058
|
}),
|
|
18823
19059
|
actuator({
|
|
@@ -18825,34 +19061,136 @@ var GROUP_TEMPLATES = [
|
|
|
18825
19061
|
summary: "On when at least one light is on, or when all of them are. Brightness and colour are offered only when every member has them. A command is not sent to a member that lacks it.",
|
|
18826
19062
|
deviceType: DeviceType.Light,
|
|
18827
19063
|
outputCap: "switch",
|
|
19064
|
+
outputField: "on",
|
|
19065
|
+
member: {
|
|
19066
|
+
cap: "switch",
|
|
19067
|
+
fieldPath: "on"
|
|
19068
|
+
},
|
|
18828
19069
|
commandCaps: [
|
|
18829
19070
|
"switch",
|
|
18830
19071
|
"brightness",
|
|
18831
19072
|
"color"
|
|
18832
19073
|
]
|
|
19074
|
+
}),
|
|
19075
|
+
actuator({
|
|
19076
|
+
id: "fan",
|
|
19077
|
+
summary: "On when at least one fan is on, or when all of them are. Speed, preset, direction and oscillation are offered only when every fan has them. A command is not sent to a fan that lacks it.",
|
|
19078
|
+
deviceType: DeviceType.Fan,
|
|
19079
|
+
outputCap: "switch",
|
|
19080
|
+
outputField: "on",
|
|
19081
|
+
member: {
|
|
19082
|
+
cap: "switch",
|
|
19083
|
+
fieldPath: "on"
|
|
19084
|
+
},
|
|
19085
|
+
commandCaps: ["switch", "fan-control"]
|
|
19086
|
+
}),
|
|
19087
|
+
actuator({
|
|
19088
|
+
id: "cover",
|
|
19089
|
+
summary: "Open when at least one cover is open or part-open, or only when all of them are. Position and tilt are offered only when every cover has them. A cover that reports nothing is left out, never read as closed.",
|
|
19090
|
+
deviceType: DeviceType.Cover,
|
|
19091
|
+
outputCap: "group-active",
|
|
19092
|
+
outputField: "active",
|
|
19093
|
+
member: {
|
|
19094
|
+
cap: "cover",
|
|
19095
|
+
fieldPath: "state"
|
|
19096
|
+
},
|
|
19097
|
+
activeWhen: [
|
|
19098
|
+
"open",
|
|
19099
|
+
"opening",
|
|
19100
|
+
"stopped"
|
|
19101
|
+
],
|
|
19102
|
+
commandCaps: ["cover"]
|
|
19103
|
+
}),
|
|
19104
|
+
actuator({
|
|
19105
|
+
id: "valve",
|
|
19106
|
+
summary: "Open when at least one valve is open or part-open, or only when all of them are. Position is offered only when every valve has it. A valve that reports nothing is left out, never read as closed.",
|
|
19107
|
+
deviceType: DeviceType.Valve,
|
|
19108
|
+
outputCap: "group-active",
|
|
19109
|
+
outputField: "active",
|
|
19110
|
+
member: {
|
|
19111
|
+
cap: "valve",
|
|
19112
|
+
fieldPath: "state"
|
|
19113
|
+
},
|
|
19114
|
+
activeWhen: [
|
|
19115
|
+
"open",
|
|
19116
|
+
"opening",
|
|
19117
|
+
"stopped"
|
|
19118
|
+
],
|
|
19119
|
+
commandCaps: ["valve"]
|
|
19120
|
+
}),
|
|
19121
|
+
actuator({
|
|
19122
|
+
id: "lock",
|
|
19123
|
+
summary: "Locked when at least one lock is locked, or only when all of them are. A jammed or moving lock is not locked. Locking is one tap; unlocking the group needs a confirmation every time, and nothing is sent without it.",
|
|
19124
|
+
deviceType: DeviceType.Lock,
|
|
19125
|
+
outputCap: "group-active",
|
|
19126
|
+
outputField: "active",
|
|
19127
|
+
member: {
|
|
19128
|
+
cap: "lock-control",
|
|
19129
|
+
fieldPath: "state"
|
|
19130
|
+
},
|
|
19131
|
+
activeWhen: ["locked"],
|
|
19132
|
+
commandCaps: ["lock-control"]
|
|
19133
|
+
}),
|
|
19134
|
+
actuator({
|
|
19135
|
+
id: "media-player",
|
|
19136
|
+
summary: "Playing when at least one player is playing, or only when all of them are. Volume is offered only when every player has it. A player that reports nothing is left out, never read as stopped.",
|
|
19137
|
+
deviceType: DeviceType.MediaPlayer,
|
|
19138
|
+
outputCap: "group-active",
|
|
19139
|
+
outputField: "active",
|
|
19140
|
+
member: {
|
|
19141
|
+
cap: "media-player",
|
|
19142
|
+
fieldPath: "state"
|
|
19143
|
+
},
|
|
19144
|
+
activeWhen: ["playing", "buffering"],
|
|
19145
|
+
commandCaps: ["media-player"]
|
|
19146
|
+
}),
|
|
19147
|
+
actuator({
|
|
19148
|
+
id: "climate",
|
|
19149
|
+
summary: "Running when at least one thermostat or air conditioner is not off, or only when all of them are. Target temperature and fan are offered only when every device has them. A device that reports nothing is left out, never read as off.",
|
|
19150
|
+
deviceType: DeviceType.Thermostat,
|
|
19151
|
+
memberDeviceTypes: [DeviceType.Thermostat, DeviceType.Climate],
|
|
19152
|
+
outputCap: "group-active",
|
|
19153
|
+
outputField: "active",
|
|
19154
|
+
member: {
|
|
19155
|
+
cap: "climate-control",
|
|
19156
|
+
fieldPath: "mode"
|
|
19157
|
+
},
|
|
19158
|
+
activeWhen: [
|
|
19159
|
+
"heat",
|
|
19160
|
+
"cool",
|
|
19161
|
+
"auto",
|
|
19162
|
+
"heat_cool",
|
|
19163
|
+
"fan_only",
|
|
19164
|
+
"dry"
|
|
19165
|
+
],
|
|
19166
|
+
commandCaps: ["climate-control"]
|
|
18833
19167
|
})
|
|
18834
19168
|
];
|
|
18835
19169
|
function actuator(input) {
|
|
18836
19170
|
return {
|
|
18837
|
-
|
|
19171
|
+
id: input.id,
|
|
19172
|
+
summary: input.summary,
|
|
19173
|
+
deviceType: input.deviceType,
|
|
19174
|
+
outputCap: input.outputCap,
|
|
19175
|
+
outputField: input.outputField,
|
|
19176
|
+
commandCaps: input.commandCaps,
|
|
18838
19177
|
family: "actuator",
|
|
18839
19178
|
role: void 0,
|
|
18840
19179
|
memberDeviceType: input.deviceType,
|
|
18841
|
-
|
|
19180
|
+
memberDeviceTypes: input.memberDeviceTypes ?? [input.deviceType],
|
|
19181
|
+
activeWhen: input.activeWhen,
|
|
18842
19182
|
quantity: "none",
|
|
18843
19183
|
baseUnit: void 0,
|
|
18844
19184
|
aggregates: BINARY_AGGREGATES,
|
|
18845
19185
|
defaultAggregate: "any",
|
|
18846
19186
|
empty: "offline",
|
|
18847
|
-
accept: [
|
|
18848
|
-
cap: "switch",
|
|
18849
|
-
fieldPath: "on"
|
|
18850
|
-
}],
|
|
19187
|
+
accept: [input.member],
|
|
18851
19188
|
companions: [CHANGED]
|
|
18852
19189
|
};
|
|
18853
19190
|
}
|
|
18854
19191
|
new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
|
|
18855
19192
|
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
19193
|
+
DeviceType.Camera;
|
|
18856
19194
|
`${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
|
|
18857
19195
|
/**
|
|
18858
19196
|
* What a composition may BUILD on a device type (G2, D676): the caps a new
|
|
@@ -44076,7 +44414,7 @@ var NetworkAccessStatusSchema = object({
|
|
|
44076
44414
|
});
|
|
44077
44415
|
/**
|
|
44078
44416
|
* Optional, richer endpoint shape returned by providers that expose
|
|
44079
|
-
* MORE than one ingress concurrently (Tailscale
|
|
44417
|
+
* MORE than one ingress concurrently (Tailscale Funnel with mixed
|
|
44080
44418
|
* serve+funnel rules, future ngrok multi-tunnel, …). Each entry carries
|
|
44081
44419
|
* the originating provider config (mode + sourcePort) so the
|
|
44082
44420
|
* orchestrator UI can label rows distinctly. Providers that expose only
|
|
@@ -46763,7 +47101,20 @@ var NcRuleInputSchema = object({
|
|
|
46763
47101
|
* save by the hub's grouping guard). `.optional()`, never `.default()`: the addon cap
|
|
46764
47102
|
* path does not run Zod defaults.
|
|
46765
47103
|
*/
|
|
46766
|
-
groupingSec: number().int().min(5).max(60).optional()
|
|
47104
|
+
groupingSec: number().int().min(5).max(60).optional(),
|
|
47105
|
+
/**
|
|
47106
|
+
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
47107
|
+
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
47108
|
+
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
47109
|
+
* same mark the Library writes, and records whose notification it was and
|
|
47110
|
+
* when. A channel with no buttons gets the same two choices as links.
|
|
47111
|
+
*
|
|
47112
|
+
* `.optional()`, never `.default()` (a Zod default does not run on the addon
|
|
47113
|
+
* cap path): absent and `false` both mean off, which is what every rule
|
|
47114
|
+
* authored before this field meant. An editor turns it off by writing
|
|
47115
|
+
* `false`, so it needs no `clear` key.
|
|
47116
|
+
*/
|
|
47117
|
+
askVerdict: boolean().optional()
|
|
46767
47118
|
});
|
|
46768
47119
|
/**
|
|
46769
47120
|
* Partial patch for `updateRule` — any subset of the input fields, plus the
|
|
@@ -57483,7 +57834,8 @@ var BATTERY_DEVICE_TYPES = [
|
|
|
57483
57834
|
DeviceType.Switch,
|
|
57484
57835
|
DeviceType.PetFeeder,
|
|
57485
57836
|
DeviceType.Container,
|
|
57486
|
-
DeviceType.Thermostat
|
|
57837
|
+
DeviceType.Thermostat,
|
|
57838
|
+
DeviceType.EventEmitter
|
|
57487
57839
|
];
|
|
57488
57840
|
/** Generic Customize target for the percentage reading (D936). */
|
|
57489
57841
|
var batteryCustomize = {
|
|
@@ -60360,7 +60712,17 @@ var groupCommandsCapability = {
|
|
|
60360
60712
|
scope: "device",
|
|
60361
60713
|
deviceNative: true,
|
|
60362
60714
|
mode: "singleton",
|
|
60363
|
-
deviceTypes: [
|
|
60715
|
+
deviceTypes: [
|
|
60716
|
+
DeviceType.Switch,
|
|
60717
|
+
DeviceType.Light,
|
|
60718
|
+
DeviceType.Fan,
|
|
60719
|
+
DeviceType.Cover,
|
|
60720
|
+
DeviceType.Valve,
|
|
60721
|
+
DeviceType.Lock,
|
|
60722
|
+
DeviceType.MediaPlayer,
|
|
60723
|
+
DeviceType.Thermostat,
|
|
60724
|
+
DeviceType.Climate
|
|
60725
|
+
],
|
|
60364
60726
|
methods: {},
|
|
60365
60727
|
status: {
|
|
60366
60728
|
schema: GroupCommandsSchema,
|
|
@@ -60378,6 +60740,49 @@ var groupCommandsCapability = {
|
|
|
60378
60740
|
history: "none"
|
|
60379
60741
|
};
|
|
60380
60742
|
/**
|
|
60743
|
+
* Whether a helper actuator group counts as active (D944): at least one
|
|
60744
|
+
* included member is, or every included member is. What "active" means is the
|
|
60745
|
+
* type's: a cover is open, a lock is locked, a media player is playing, a
|
|
60746
|
+
* climate device is not off. A group of lights, switches and fans reports
|
|
60747
|
+
* `switch.on` instead; this cap is for the types whose own state is not a
|
|
60748
|
+
* yes/no. Unknown members are left out (`group-status` counts them) and an
|
|
60749
|
+
* empty included set takes the device offline, never `active: false`.
|
|
60750
|
+
*/
|
|
60751
|
+
var GroupActiveSchema = object({
|
|
60752
|
+
active: boolean().meta({ label: "Active" }),
|
|
60753
|
+
/** Ms epoch when the slice was last updated. */
|
|
60754
|
+
lastChangedAt: number()
|
|
60755
|
+
});
|
|
60756
|
+
var groupActiveCapability = {
|
|
60757
|
+
name: "group-active",
|
|
60758
|
+
scope: "device",
|
|
60759
|
+
deviceNative: true,
|
|
60760
|
+
mode: "singleton",
|
|
60761
|
+
deviceTypes: [
|
|
60762
|
+
DeviceType.Cover,
|
|
60763
|
+
DeviceType.Valve,
|
|
60764
|
+
DeviceType.Lock,
|
|
60765
|
+
DeviceType.MediaPlayer,
|
|
60766
|
+
DeviceType.Climate,
|
|
60767
|
+
DeviceType.Thermostat
|
|
60768
|
+
],
|
|
60769
|
+
methods: {},
|
|
60770
|
+
status: {
|
|
60771
|
+
schema: GroupActiveSchema,
|
|
60772
|
+
kind: "push"
|
|
60773
|
+
},
|
|
60774
|
+
runtimeState: GroupActiveSchema,
|
|
60775
|
+
/**
|
|
60776
|
+
* Runtime-state durability: **session** — recomputed from the members on the
|
|
60777
|
+
* next source event; a restored value would outlive the members it named.
|
|
60778
|
+
*
|
|
60779
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
60780
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
60781
|
+
*/
|
|
60782
|
+
durability: "session",
|
|
60783
|
+
history: "none"
|
|
60784
|
+
};
|
|
60785
|
+
/**
|
|
60381
60786
|
* How many members of a helper group answered (D944). Counts are integers,
|
|
60382
60787
|
* not measurements: zero included is a real count, never a stand-in reading.
|
|
60383
60788
|
* The reading itself stays on the output capability. History is none — the
|
|
@@ -60408,7 +60813,14 @@ var groupStatusCapability = {
|
|
|
60408
60813
|
deviceTypes: [
|
|
60409
60814
|
DeviceType.Sensor,
|
|
60410
60815
|
DeviceType.Switch,
|
|
60411
|
-
DeviceType.Light
|
|
60816
|
+
DeviceType.Light,
|
|
60817
|
+
DeviceType.Fan,
|
|
60818
|
+
DeviceType.Cover,
|
|
60819
|
+
DeviceType.Valve,
|
|
60820
|
+
DeviceType.Lock,
|
|
60821
|
+
DeviceType.MediaPlayer,
|
|
60822
|
+
DeviceType.Thermostat,
|
|
60823
|
+
DeviceType.Climate
|
|
60412
60824
|
],
|
|
60413
60825
|
methods: {},
|
|
60414
60826
|
status: {
|
|
@@ -61681,7 +62093,14 @@ var lockControlCapability = {
|
|
|
61681
62093
|
}),
|
|
61682
62094
|
unlock: method(object({
|
|
61683
62095
|
deviceId: number().int().nonnegative(),
|
|
61684
|
-
code: string$2().min(1).optional()
|
|
62096
|
+
code: string$2().min(1).optional(),
|
|
62097
|
+
/**
|
|
62098
|
+
* Honoured by a helper lock GROUP only (D944): unlocking several doors
|
|
62099
|
+
* with one call is refused unless the caller says it was confirmed. A
|
|
62100
|
+
* single lock ignores it. The refusal lives in the callee, so no
|
|
62101
|
+
* automation or API caller reaches the doors by skipping a dialog.
|
|
62102
|
+
*/
|
|
62103
|
+
confirm: boolean().optional()
|
|
61685
62104
|
}), _void(), {
|
|
61686
62105
|
kind: "mutation",
|
|
61687
62106
|
auth: "protected"
|
|
@@ -61718,6 +62137,44 @@ var lockControlCapability = {
|
|
|
61718
62137
|
volatileStateFields: ["lastChangedAt"]
|
|
61719
62138
|
};
|
|
61720
62139
|
/**
|
|
62140
|
+
* A monotonic total between resets (D944). Energy uses `power-meter.kwhTotal`
|
|
62141
|
+
* so dashboards keep one series; every other instantaneous reading lands here.
|
|
62142
|
+
* `value` is the time integral in the source quantity's accumulated base
|
|
62143
|
+
* (base-unit seconds, or kWh on the power meter). `null` is a gap, never zero.
|
|
62144
|
+
*/
|
|
62145
|
+
var MeterStatusSchema = object({
|
|
62146
|
+
value: number().nullable().meta(readingMeta("device", { label: "Total" })),
|
|
62147
|
+
lastFetchedAt: number()
|
|
62148
|
+
});
|
|
62149
|
+
var meterCapability = {
|
|
62150
|
+
name: "meter",
|
|
62151
|
+
scope: "device",
|
|
62152
|
+
deviceNative: true,
|
|
62153
|
+
mode: "singleton",
|
|
62154
|
+
deviceTypes: [DeviceType.Sensor],
|
|
62155
|
+
methods: {},
|
|
62156
|
+
status: {
|
|
62157
|
+
schema: MeterStatusSchema,
|
|
62158
|
+
kind: "push"
|
|
62159
|
+
},
|
|
62160
|
+
runtimeState: MeterStatusSchema,
|
|
62161
|
+
/**
|
|
62162
|
+
* Runtime-state durability: **restored** — the total is a cache of the
|
|
62163
|
+
* history integral. A restart shows it only until the history pass
|
|
62164
|
+
* recomputes the open period; it is not an in-memory buffer.
|
|
62165
|
+
*
|
|
62166
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
62167
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
62168
|
+
*/
|
|
62169
|
+
durability: "restored",
|
|
62170
|
+
history: { fields: { value: {
|
|
62171
|
+
kind: "counter",
|
|
62172
|
+
deadband: .001,
|
|
62173
|
+
minIntervalMs: 6e4
|
|
62174
|
+
} } },
|
|
62175
|
+
volatileStateFields: ["lastFetchedAt"]
|
|
62176
|
+
};
|
|
62177
|
+
/**
|
|
61721
62178
|
* Media-player cap. Models HA `media_player.*` (Sonos, Chromecast,
|
|
61722
62179
|
* Apple TV, Spotify, Roku, generic OTT receivers, …) on
|
|
61723
62180
|
* `DeviceType.MediaPlayer`. Disjoint from the camera streaming
|
|
@@ -64229,9 +64686,9 @@ var PowerMeterStatusSchema = object({
|
|
|
64229
64686
|
/** Cumulative energy in kilowatt-hours since the meter was reset. */
|
|
64230
64687
|
kwhTotal: number().optional().meta(readingMeta("energy", { label: "Energy" })),
|
|
64231
64688
|
/** Voltage in volts. */
|
|
64232
|
-
volts: number().optional().meta(readingMeta("voltage")),
|
|
64689
|
+
volts: number().optional().meta(readingMeta("voltage", { label: "Voltage" })),
|
|
64233
64690
|
/** Current in amperes. */
|
|
64234
|
-
amps: number().optional().meta(readingMeta("current")),
|
|
64691
|
+
amps: number().optional().meta(readingMeta("current", { label: "Current" })),
|
|
64235
64692
|
/** Apparent power in volt-amperes. */
|
|
64236
64693
|
va: number().optional().meta(readingMeta("apparent-power")),
|
|
64237
64694
|
/** Power factor (0..1) if reported. */
|
|
@@ -64239,12 +64696,74 @@ var PowerMeterStatusSchema = object({
|
|
|
64239
64696
|
/** Ms epoch when the slice was last updated. */
|
|
64240
64697
|
lastFetchedAt: number()
|
|
64241
64698
|
});
|
|
64699
|
+
/**
|
|
64700
|
+
* Loads that draw metered mains power (D951). The reading is a feature of the
|
|
64701
|
+
* device itself — a plug, a lamp, a fan, an air conditioner, a boiler, a
|
|
64702
|
+
* vacuum dock — not a separate sensor beside it. A `Sensor` stays: a clamp
|
|
64703
|
+
* meter or a standalone energy monitor IS the device. Cover, lock, valve,
|
|
64704
|
+
* camera and the like are left out: their draw is not what anyone meters.
|
|
64705
|
+
*/
|
|
64706
|
+
var POWER_METER_DEVICE_TYPES = [
|
|
64707
|
+
DeviceType.Sensor,
|
|
64708
|
+
DeviceType.Switch,
|
|
64709
|
+
DeviceType.Light,
|
|
64710
|
+
DeviceType.Fan,
|
|
64711
|
+
DeviceType.Climate,
|
|
64712
|
+
DeviceType.Thermostat,
|
|
64713
|
+
DeviceType.Humidifier,
|
|
64714
|
+
DeviceType.WaterHeater,
|
|
64715
|
+
DeviceType.MediaPlayer,
|
|
64716
|
+
DeviceType.Washer,
|
|
64717
|
+
DeviceType.Dryer,
|
|
64718
|
+
DeviceType.Dishwasher,
|
|
64719
|
+
DeviceType.Vacuum,
|
|
64720
|
+
DeviceType.LawnMower,
|
|
64721
|
+
DeviceType.PetFeeder
|
|
64722
|
+
];
|
|
64723
|
+
/** Everything but a bare `Sensor`: a sensor that takes its reading from another sensor adds nothing. */
|
|
64724
|
+
var POWER_METER_CUSTOMIZE_DEVICE_TYPES = POWER_METER_DEVICE_TYPES.filter((type) => type !== DeviceType.Sensor);
|
|
64725
|
+
/** One scalar target per reading; each is sourced from a device of its own (D951). */
|
|
64726
|
+
function powerTarget(id, unit) {
|
|
64727
|
+
return {
|
|
64728
|
+
id,
|
|
64729
|
+
cardinality: "scalar",
|
|
64730
|
+
vocabulary: {
|
|
64731
|
+
cap: "power-meter",
|
|
64732
|
+
stateField: id
|
|
64733
|
+
},
|
|
64734
|
+
deviceTypes: POWER_METER_CUSTOMIZE_DEVICE_TYPES,
|
|
64735
|
+
apply: "add",
|
|
64736
|
+
path: id,
|
|
64737
|
+
sources: [{
|
|
64738
|
+
kind: "numeric",
|
|
64739
|
+
requiredUnit: unit,
|
|
64740
|
+
transforms: [{ kind: "identity" }]
|
|
64741
|
+
}],
|
|
64742
|
+
companions: [{
|
|
64743
|
+
kind: "clock",
|
|
64744
|
+
path: "lastFetchedAt",
|
|
64745
|
+
when: "always"
|
|
64746
|
+
}],
|
|
64747
|
+
sourceReport: { status: "assignment-status" },
|
|
64748
|
+
advancedExpression: true
|
|
64749
|
+
};
|
|
64750
|
+
}
|
|
64751
|
+
/** "Power and energy" extension: watts, energy, voltage and current from other devices (D951). */
|
|
64752
|
+
var powerMeterCustomize = {
|
|
64753
|
+
version: 1,
|
|
64754
|
+
targets: [
|
|
64755
|
+
powerTarget("watts", "W"),
|
|
64756
|
+
powerTarget("kwhTotal", "kWh"),
|
|
64757
|
+
powerTarget("volts", "V"),
|
|
64758
|
+
powerTarget("amps", "A")
|
|
64759
|
+
]
|
|
64760
|
+
};
|
|
64242
64761
|
var powerMeterCapability = {
|
|
64243
64762
|
name: "power-meter",
|
|
64244
64763
|
scope: "device",
|
|
64245
64764
|
deviceNative: true,
|
|
64246
64765
|
mode: "singleton",
|
|
64247
|
-
deviceTypes:
|
|
64766
|
+
deviceTypes: POWER_METER_DEVICE_TYPES,
|
|
64248
64767
|
methods: {},
|
|
64249
64768
|
status: {
|
|
64250
64769
|
schema: PowerMeterStatusSchema,
|
|
@@ -64301,7 +64820,8 @@ var powerMeterCapability = {
|
|
|
64301
64820
|
} },
|
|
64302
64821
|
/** Clock fields: written, but excluded from the compare that decides
|
|
64303
64822
|
* whether persisting is worth a SQLite commit. */
|
|
64304
|
-
volatileStateFields: ["lastFetchedAt"]
|
|
64823
|
+
volatileStateFields: ["lastFetchedAt"],
|
|
64824
|
+
customize: powerMeterCustomize
|
|
64305
64825
|
};
|
|
64306
64826
|
/**
|
|
64307
64827
|
* Presence cap. Models HA `person.*` and `device_tracker.*` entities
|
|
@@ -64982,6 +65502,8 @@ var runningCustomize = {
|
|
|
64982
65502
|
stateField: "running"
|
|
64983
65503
|
},
|
|
64984
65504
|
deviceTypes: [
|
|
65505
|
+
DeviceType.Washer,
|
|
65506
|
+
DeviceType.Dryer,
|
|
64985
65507
|
DeviceType.Dishwasher,
|
|
64986
65508
|
DeviceType.Vacuum,
|
|
64987
65509
|
DeviceType.LawnMower,
|
|
@@ -67471,7 +67993,8 @@ var switchCapability = {
|
|
|
67471
67993
|
deviceTypes: [
|
|
67472
67994
|
DeviceType.Switch,
|
|
67473
67995
|
DeviceType.Siren,
|
|
67474
|
-
DeviceType.Light
|
|
67996
|
+
DeviceType.Light,
|
|
67997
|
+
DeviceType.Fan
|
|
67475
67998
|
],
|
|
67476
67999
|
methods: { setState: method(object({
|
|
67477
68000
|
deviceId: number(),
|
|
@@ -69684,8 +70207,9 @@ method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" })
|
|
|
69684
70207
|
kind: "mutation",
|
|
69685
70208
|
auth: "admin"
|
|
69686
70209
|
});
|
|
70210
|
+
DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
|
|
69687
70211
|
SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
|
|
69688
|
-
DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher, DeviceType.Camera, DeviceType.Camera, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder;
|
|
70212
|
+
DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Camera, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder;
|
|
69689
70213
|
String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
|
|
69690
70214
|
DeviceRole.BinarySensor, DeviceRole.MotionSensor;
|
|
69691
70215
|
new Set(CAP_NAMES);
|
|
@@ -70014,6 +70538,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
70014
70538
|
featureProbe: featureProbeCapability,
|
|
70015
70539
|
flood: floodCapability,
|
|
70016
70540
|
gas: gasCapability,
|
|
70541
|
+
groupActive: groupActiveCapability,
|
|
70017
70542
|
groupCommands: groupCommandsCapability,
|
|
70018
70543
|
groupStatus: groupStatusCapability,
|
|
70019
70544
|
heatingValve: heatingValveCapability,
|
|
@@ -70025,6 +70550,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
70025
70550
|
lawnMowerControl: lawnMowerControlCapability,
|
|
70026
70551
|
lockControl: lockControlCapability,
|
|
70027
70552
|
mediaPlayer: mediaPlayerCapability,
|
|
70553
|
+
meter: meterCapability,
|
|
70028
70554
|
motion: motionCapability,
|
|
70029
70555
|
motionTrigger: motionTriggerCapability,
|
|
70030
70556
|
motionZones: motionZonesCapability,
|
|
@@ -71284,7 +71810,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
71284
71810
|
return toDeviceSummary(device, this.addonId);
|
|
71285
71811
|
}
|
|
71286
71812
|
};
|
|
71287
|
-
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher;
|
|
71813
|
+
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer;
|
|
71288
71814
|
new Set(Object.values(DeviceType));
|
|
71289
71815
|
Object.freeze({
|
|
71290
71816
|
"accessories.getStatus": {
|
|
@@ -74507,6 +75033,13 @@ Object.freeze({
|
|
|
74507
75033
|
access: "view",
|
|
74508
75034
|
role: "viewer"
|
|
74509
75035
|
},
|
|
75036
|
+
"groupActive.getStatus": {
|
|
75037
|
+
capName: "group-active",
|
|
75038
|
+
capScope: "device",
|
|
75039
|
+
addonId: null,
|
|
75040
|
+
access: "view",
|
|
75041
|
+
role: "viewer"
|
|
75042
|
+
},
|
|
74510
75043
|
"groupCommands.getStatus": {
|
|
74511
75044
|
capName: "group-commands",
|
|
74512
75045
|
capScope: "device",
|
|
@@ -75473,6 +76006,13 @@ Object.freeze({
|
|
|
75473
76006
|
access: "create",
|
|
75474
76007
|
role: "admin"
|
|
75475
76008
|
},
|
|
76009
|
+
"meter.getStatus": {
|
|
76010
|
+
capName: "meter",
|
|
76011
|
+
capScope: "device",
|
|
76012
|
+
addonId: null,
|
|
76013
|
+
access: "view",
|
|
76014
|
+
role: "viewer"
|
|
76015
|
+
},
|
|
75476
76016
|
"metricsProvider.collectSnapshot": {
|
|
75477
76017
|
capName: "metrics-provider",
|
|
75478
76018
|
capScope: "system",
|
|
@@ -83571,7 +84111,39 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
83571
84111
|
phrase: t("When {device} finishes", "Quando {device} finisce"),
|
|
83572
84112
|
icon: "square"
|
|
83573
84113
|
}
|
|
83574
|
-
}
|
|
84114
|
+
},
|
|
84115
|
+
overrides: { byType: {
|
|
84116
|
+
[DeviceType.Washer]: {
|
|
84117
|
+
state: { running: {
|
|
84118
|
+
whenTrue: t("When the washing machine starts", "Quando la lavatrice inizia"),
|
|
84119
|
+
whenFalse: t("When the washing machine has finished", "Quando la lavatrice ha finito")
|
|
84120
|
+
} },
|
|
84121
|
+
events: {
|
|
84122
|
+
onStarted: { phrase: t("When the washing machine starts", "Quando la lavatrice inizia") },
|
|
84123
|
+
onFinished: { phrase: t("When the washing machine has finished", "Quando la lavatrice ha finito") }
|
|
84124
|
+
}
|
|
84125
|
+
},
|
|
84126
|
+
[DeviceType.Dryer]: {
|
|
84127
|
+
state: { running: {
|
|
84128
|
+
whenTrue: t("When the dryer starts", "Quando l'asciugatrice inizia"),
|
|
84129
|
+
whenFalse: t("When the dryer has finished", "Quando l'asciugatrice ha finito")
|
|
84130
|
+
} },
|
|
84131
|
+
events: {
|
|
84132
|
+
onStarted: { phrase: t("When the dryer starts", "Quando l'asciugatrice inizia") },
|
|
84133
|
+
onFinished: { phrase: t("When the dryer has finished", "Quando l'asciugatrice ha finito") }
|
|
84134
|
+
}
|
|
84135
|
+
},
|
|
84136
|
+
[DeviceType.Dishwasher]: {
|
|
84137
|
+
state: { running: {
|
|
84138
|
+
whenTrue: t("When the dishwasher starts", "Quando la lavastoviglie inizia"),
|
|
84139
|
+
whenFalse: t("When the dishwasher has finished", "Quando la lavastoviglie ha finito")
|
|
84140
|
+
} },
|
|
84141
|
+
events: {
|
|
84142
|
+
onStarted: { phrase: t("When the dishwasher starts", "Quando la lavastoviglie inizia") },
|
|
84143
|
+
onFinished: { phrase: t("When the dishwasher has finished", "Quando la lavastoviglie ha finito") }
|
|
84144
|
+
}
|
|
84145
|
+
}
|
|
84146
|
+
} }
|
|
83575
84147
|
},
|
|
83576
84148
|
update: {
|
|
83577
84149
|
scope: "device",
|
|
@@ -84343,6 +84915,10 @@ var SENSOR_CAP_VOCABULARY = {
|
|
|
84343
84915
|
icon: "flame"
|
|
84344
84916
|
}]
|
|
84345
84917
|
},
|
|
84918
|
+
"group-active": {
|
|
84919
|
+
scope: "device",
|
|
84920
|
+
noun: t("Group state", "Stato del gruppo")
|
|
84921
|
+
},
|
|
84346
84922
|
"group-commands": {
|
|
84347
84923
|
scope: "device",
|
|
84348
84924
|
noun: t("Group command", "Comando di gruppo")
|
|
@@ -84399,6 +84975,17 @@ var SENSOR_CAP_VOCABULARY = {
|
|
|
84399
84975
|
}],
|
|
84400
84976
|
events: { onMotionChanged: { notOperatorFacing: "the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)" } }
|
|
84401
84977
|
},
|
|
84978
|
+
meter: {
|
|
84979
|
+
scope: "device",
|
|
84980
|
+
noun: t("Meter", "Contatore"),
|
|
84981
|
+
state: [{
|
|
84982
|
+
kind: "numeric",
|
|
84983
|
+
field: "value",
|
|
84984
|
+
quantity: t("the total", "il totale"),
|
|
84985
|
+
label: t("Total", "Totale"),
|
|
84986
|
+
icon: "gauge"
|
|
84987
|
+
}]
|
|
84988
|
+
},
|
|
84402
84989
|
"numeric-sensor": {
|
|
84403
84990
|
scope: "device",
|
|
84404
84991
|
noun: t("Sensor", "Sensore"),
|
|
@@ -84871,8 +85458,47 @@ function projectAction(cap, action) {
|
|
|
84871
85458
|
};
|
|
84872
85459
|
}
|
|
84873
85460
|
Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
|
|
84874
|
-
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher;
|
|
85461
|
+
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer;
|
|
84875
85462
|
DeviceFeature.BatteryOperated;
|
|
85463
|
+
DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher;
|
|
85464
|
+
var HA_AS = "a power sensor (device_class power). Home Assistant has no laundry domain. running-state stays unexported until a null reading can be published as unavailable.";
|
|
85465
|
+
var HOMEKIT_REASON = "HomeKit has no laundry-appliance service. The export tab would pair an accessory with nothing on it: running-state is withheld until a null reading can be unavailable, and power is not a HomeKit service this export honours.";
|
|
85466
|
+
var ALEXA_REASON = "Alexa has no laundry category in this export, and neither power nor running has an Alexa interface.";
|
|
85467
|
+
var GOOGLE_REASON = "Google WASHER, DRYER and DISHWASHER require RunCycle. A power threshold is not that trait, and this export does not publish RunCycle.";
|
|
85468
|
+
var MATTER_REASON = "No Matter export is built. The closest device types are Laundry Washer (0x0073) and Laundry Dryer (0x0074); a power threshold is not the Laundry Washer Mode cluster.";
|
|
85469
|
+
function withheld(reason) {
|
|
85470
|
+
return {
|
|
85471
|
+
[DeviceType.Washer]: {
|
|
85472
|
+
exported: false,
|
|
85473
|
+
reason
|
|
85474
|
+
},
|
|
85475
|
+
[DeviceType.Dryer]: {
|
|
85476
|
+
exported: false,
|
|
85477
|
+
reason
|
|
85478
|
+
},
|
|
85479
|
+
[DeviceType.Dishwasher]: {
|
|
85480
|
+
exported: false,
|
|
85481
|
+
reason
|
|
85482
|
+
}
|
|
85483
|
+
};
|
|
85484
|
+
}
|
|
85485
|
+
function offered(received) {
|
|
85486
|
+
return {
|
|
85487
|
+
[DeviceType.Washer]: {
|
|
85488
|
+
exported: true,
|
|
85489
|
+
as: received
|
|
85490
|
+
},
|
|
85491
|
+
[DeviceType.Dryer]: {
|
|
85492
|
+
exported: true,
|
|
85493
|
+
as: received
|
|
85494
|
+
},
|
|
85495
|
+
[DeviceType.Dishwasher]: {
|
|
85496
|
+
exported: true,
|
|
85497
|
+
as: received
|
|
85498
|
+
}
|
|
85499
|
+
};
|
|
85500
|
+
}
|
|
85501
|
+
offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
|
|
84876
85502
|
Object.freeze({
|
|
84877
85503
|
"accessories.getStatus": [{
|
|
84878
85504
|
name: "deviceId",
|
|
@@ -85839,6 +86465,11 @@ Object.freeze({
|
|
|
85839
86465
|
form: "single",
|
|
85840
86466
|
optional: false
|
|
85841
86467
|
}],
|
|
86468
|
+
"groupActive.getStatus": [{
|
|
86469
|
+
name: "deviceId",
|
|
86470
|
+
form: "single",
|
|
86471
|
+
optional: false
|
|
86472
|
+
}],
|
|
85842
86473
|
"groupCommands.getStatus": [{
|
|
85843
86474
|
name: "deviceId",
|
|
85844
86475
|
form: "single",
|
|
@@ -86049,6 +86680,11 @@ Object.freeze({
|
|
|
86049
86680
|
form: "single",
|
|
86050
86681
|
optional: false
|
|
86051
86682
|
}],
|
|
86683
|
+
"meter.getStatus": [{
|
|
86684
|
+
name: "deviceId",
|
|
86685
|
+
form: "single",
|
|
86686
|
+
optional: false
|
|
86687
|
+
}],
|
|
86052
86688
|
"motion.getStatus": [{
|
|
86053
86689
|
name: "deviceId",
|
|
86054
86690
|
form: "single",
|
|
@@ -87656,7 +88292,6 @@ Object.freeze({
|
|
|
87656
88292
|
"network-access": "ingress",
|
|
87657
88293
|
"smtp-provider": "email"
|
|
87658
88294
|
});
|
|
87659
|
-
DeviceType.Camera;
|
|
87660
88295
|
/**
|
|
87661
88296
|
* A saved Customize assignment (D936). The schema is the type: callers use
|
|
87662
88297
|
* `z.infer`, they do not restate the shape.
|
|
@@ -197514,6 +198149,7 @@ var StubMatterController = class {
|
|
|
197514
198149
|
async removeNode(_nodeId) {
|
|
197515
198150
|
throw new MatterControllerNotWiredError("removeNode");
|
|
197516
198151
|
}
|
|
198152
|
+
async syncSubscriptions() {}
|
|
197517
198153
|
};
|
|
197518
198154
|
/**
|
|
197519
198155
|
* Factory seam (stub default): build a {@link StubMatterController}.
|
|
@@ -197686,7 +198322,13 @@ var MatterAttributeId = {
|
|
|
197686
198322
|
/** ElectricalPowerMeasurement.ActivePower (int64, mW). */
|
|
197687
198323
|
ActivePower: 8,
|
|
197688
198324
|
/** ElectricalEnergyMeasurement.CumulativeEnergyImported (energy struct, mWh). */
|
|
197689
|
-
CumulativeEnergyImported: 1
|
|
198325
|
+
CumulativeEnergyImported: 1,
|
|
198326
|
+
/** DoorLock.LockState (enum: 0 NotFullyLocked, 1 Locked, 2 Unlocked, 3 Unlatched). */
|
|
198327
|
+
LockState: 0,
|
|
198328
|
+
/** DoorLock.DoorState (enum; 2 = DoorJammed). Present only with the door sensor. */
|
|
198329
|
+
DoorState: 3,
|
|
198330
|
+
/** DoorLock.RequirePinForRemoteOperation (bool). */
|
|
198331
|
+
RequirePinForRemoteOperation: 51
|
|
197690
198332
|
};
|
|
197691
198333
|
/** Thermostat.SystemMode enum → CamStack HvacMode (climate-control). */
|
|
197692
198334
|
var SYSTEM_MODE_TO_HVAC = new Map([
|
|
@@ -197718,8 +198360,11 @@ function asBoolean(value) {
|
|
|
197718
198360
|
* matter.js may surface a `MeasuredValue` either as a plain scaled int or wrapped
|
|
197719
198361
|
* in an energy-measurement struct (`{ energy }`). Pull the numeric payload out.
|
|
197720
198362
|
*/
|
|
198363
|
+
function isRecord$4(value) {
|
|
198364
|
+
return typeof value === "object" && value !== null;
|
|
198365
|
+
}
|
|
197721
198366
|
function asEnergyMilliWattHours(value) {
|
|
197722
|
-
if (
|
|
198367
|
+
if (isRecord$4(value) && "energy" in value) return asNumber(value["energy"]);
|
|
197723
198368
|
return asNumber(value);
|
|
197724
198369
|
}
|
|
197725
198370
|
/**
|
|
@@ -197741,9 +198386,77 @@ function decodeMatterAttribute(input) {
|
|
|
197741
198386
|
case MatterClusterId.Thermostat: return decodeThermostat(attributeId, value);
|
|
197742
198387
|
case MatterClusterId.ElectricalPowerMeasurement: return decodeElectricalPower(attributeId, value);
|
|
197743
198388
|
case MatterClusterId.ElectricalEnergyMeasurement: return decodeElectricalEnergy(attributeId, value);
|
|
198389
|
+
case MatterClusterId.DoorLock: return decodeDoorLock(attributeId, value);
|
|
197744
198390
|
default: return null;
|
|
197745
198391
|
}
|
|
197746
198392
|
}
|
|
198393
|
+
/** LockState enum → cap state. NotFullyLocked has no cap value of its own. */
|
|
198394
|
+
var LOCK_STATE_TO_CAP = new Map([
|
|
198395
|
+
[0, {
|
|
198396
|
+
state: "jammed",
|
|
198397
|
+
detail: "not-fully-locked"
|
|
198398
|
+
}],
|
|
198399
|
+
[1, { state: "locked" }],
|
|
198400
|
+
[2, { state: "unlocked" }],
|
|
198401
|
+
[3, {
|
|
198402
|
+
state: "unlocked",
|
|
198403
|
+
detail: "unlatched"
|
|
198404
|
+
}]
|
|
198405
|
+
]);
|
|
198406
|
+
/** DoorState enum → a detail. Only DoorJammed also moves the lock cap. */
|
|
198407
|
+
var DOOR_STATE_DETAIL = new Map([
|
|
198408
|
+
[0, "door-open"],
|
|
198409
|
+
[1, "door-closed"],
|
|
198410
|
+
[2, "door-jammed"],
|
|
198411
|
+
[3, "door-forced-open"],
|
|
198412
|
+
[4, "door-unspecified"],
|
|
198413
|
+
[5, "door-ajar"]
|
|
198414
|
+
]);
|
|
198415
|
+
function decodeDoorLock(attributeId, value) {
|
|
198416
|
+
if (attributeId === MatterAttributeId.LockState) {
|
|
198417
|
+
const raw = asNumber(value);
|
|
198418
|
+
if (raw === null) return null;
|
|
198419
|
+
const mapped = LOCK_STATE_TO_CAP.get(raw);
|
|
198420
|
+
if (mapped === void 0) return null;
|
|
198421
|
+
return {
|
|
198422
|
+
cap: "lock-control",
|
|
198423
|
+
patch: {
|
|
198424
|
+
state: mapped.state,
|
|
198425
|
+
lastChangedAt: Date.now()
|
|
198426
|
+
},
|
|
198427
|
+
...mapped.detail !== void 0 ? { detail: mapped.detail } : {}
|
|
198428
|
+
};
|
|
198429
|
+
}
|
|
198430
|
+
if (attributeId === MatterAttributeId.DoorState) {
|
|
198431
|
+
const raw = asNumber(value);
|
|
198432
|
+
if (raw === null) return null;
|
|
198433
|
+
const detail = DOOR_STATE_DETAIL.get(raw);
|
|
198434
|
+
if (detail === void 0) return null;
|
|
198435
|
+
if (detail === "door-jammed") return {
|
|
198436
|
+
cap: "lock-control",
|
|
198437
|
+
patch: {
|
|
198438
|
+
state: "jammed",
|
|
198439
|
+
lastChangedAt: Date.now()
|
|
198440
|
+
},
|
|
198441
|
+
detail
|
|
198442
|
+
};
|
|
198443
|
+
return {
|
|
198444
|
+
cap: "lock-control",
|
|
198445
|
+
patch: {},
|
|
198446
|
+
detail
|
|
198447
|
+
};
|
|
198448
|
+
}
|
|
198449
|
+
if (attributeId === MatterAttributeId.RequirePinForRemoteOperation) {
|
|
198450
|
+
const required = asBoolean(value);
|
|
198451
|
+
if (required === null) return null;
|
|
198452
|
+
return {
|
|
198453
|
+
cap: "lock-control",
|
|
198454
|
+
patch: {},
|
|
198455
|
+
detail: required ? "pin-required" : "pin-not-required"
|
|
198456
|
+
};
|
|
198457
|
+
}
|
|
198458
|
+
return null;
|
|
198459
|
+
}
|
|
197747
198460
|
function decodeOnOff(attributeId, value) {
|
|
197748
198461
|
if (attributeId !== MatterAttributeId.OnOff) return null;
|
|
197749
198462
|
const on = asBoolean(value);
|
|
@@ -197967,7 +198680,10 @@ var ATTR_NAME_TO_ID = new Map([
|
|
|
197967
198680
|
["voltage", MatterAttributeId.Voltage],
|
|
197968
198681
|
["activeCurrent", MatterAttributeId.ActiveCurrent],
|
|
197969
198682
|
["activePower", MatterAttributeId.ActivePower],
|
|
197970
|
-
["cumulativeEnergyImported", MatterAttributeId.CumulativeEnergyImported]
|
|
198683
|
+
["cumulativeEnergyImported", MatterAttributeId.CumulativeEnergyImported],
|
|
198684
|
+
["lockState", MatterAttributeId.LockState],
|
|
198685
|
+
["doorState", MatterAttributeId.DoorState],
|
|
198686
|
+
["requirePinForRemoteOperation", MatterAttributeId.RequirePinForRemoteOperation]
|
|
197971
198687
|
]);
|
|
197972
198688
|
/** clusterId → matter.js behavior id (camelCase) for outbound command clusters. */
|
|
197973
198689
|
var CLUSTER_ID_TO_BEHAVIOR_ID = new Map([
|
|
@@ -197979,14 +198695,14 @@ var CLUSTER_ID_TO_BEHAVIOR_ID = new Map([
|
|
|
197979
198695
|
[258, "windowCovering"]
|
|
197980
198696
|
]);
|
|
197981
198697
|
/** True when `value` is a non-null object (cast-free record narrowing). */
|
|
197982
|
-
function isRecord$
|
|
198698
|
+
function isRecord$3(value) {
|
|
197983
198699
|
return typeof value === "object" && value !== null;
|
|
197984
198700
|
}
|
|
197985
198701
|
/** Read a finite numeric cluster id from a `Behavior.Type`'s `.cluster.id`. */
|
|
197986
198702
|
function clusterIdOf(behaviorType) {
|
|
197987
|
-
if (!isRecord$
|
|
198703
|
+
if (!isRecord$3(behaviorType)) return null;
|
|
197988
198704
|
const cluster = behaviorType["cluster"];
|
|
197989
|
-
if (!isRecord$
|
|
198705
|
+
if (!isRecord$3(cluster)) return null;
|
|
197990
198706
|
const id = cluster["id"];
|
|
197991
198707
|
if (typeof id === "number" && Number.isFinite(id)) return id;
|
|
197992
198708
|
if (typeof id === "bigint") return Number(id);
|
|
@@ -197997,13 +198713,13 @@ function clusterIdOf(behaviorType) {
|
|
|
197997
198713
|
* the matter.js `Endpoint` interop at one typed boundary.
|
|
197998
198714
|
*/
|
|
197999
198715
|
function asDynamicEndpoint(value) {
|
|
198000
|
-
if (!isRecord$
|
|
198716
|
+
if (!isRecord$3(value)) return null;
|
|
198001
198717
|
const number = value["number"];
|
|
198002
198718
|
const behaviors = value["behaviors"];
|
|
198003
198719
|
const parts = value["parts"];
|
|
198004
198720
|
const stateOf = value["stateOf"];
|
|
198005
198721
|
const commandsOf = value["commandsOf"];
|
|
198006
|
-
if (typeof number === "number" && isRecord$
|
|
198722
|
+
if (typeof number === "number" && isRecord$3(behaviors) && "supported" in behaviors && typeof stateOf === "function" && typeof commandsOf === "function" && isIterable$2(parts)) return {
|
|
198007
198723
|
number,
|
|
198008
198724
|
behaviors: { supported: behaviors["supported"] },
|
|
198009
198725
|
parts: mapIterable(parts, asDynamicEndpointOrThrow),
|
|
@@ -198027,7 +198743,7 @@ async function invokeNodeCommand(input) {
|
|
|
198027
198743
|
const behaviorId = CLUSTER_ID_TO_BEHAVIOR_ID.get(clusterId);
|
|
198028
198744
|
if (behaviorId === void 0) throw new Error(`matter-broker: cluster 0x${clusterId.toString(16)} has no command binding`);
|
|
198029
198745
|
const commands = target.commandsOf(behaviorId);
|
|
198030
|
-
if (!isRecord$
|
|
198746
|
+
if (!isRecord$3(commands)) throw new Error(`matter-broker: endpoint ${endpointId} has no '${behaviorId}' commands`);
|
|
198031
198747
|
const command = commands[commandName];
|
|
198032
198748
|
const fn = asCommandFn(command);
|
|
198033
198749
|
if (fn === null) throw new Error(`matter-broker: command '${commandName}' unavailable on '${behaviorId}'`);
|
|
@@ -198052,8 +198768,8 @@ function asDynamicEndpointOrThrow(value) {
|
|
|
198052
198768
|
if (ep === null) throw new TypeError("matter-broker: unexpected non-endpoint child part");
|
|
198053
198769
|
return ep;
|
|
198054
198770
|
}
|
|
198055
|
-
function isIterable$
|
|
198056
|
-
return isRecord$
|
|
198771
|
+
function isIterable$2(value) {
|
|
198772
|
+
return isRecord$3(value) && typeof Reflect.get(value, Symbol.iterator) === "function";
|
|
198057
198773
|
}
|
|
198058
198774
|
function* mapIterable(it, fn) {
|
|
198059
198775
|
for (const v of it) yield fn(v);
|
|
@@ -198074,7 +198790,7 @@ function collectEndpoint(endpoint, out) {
|
|
|
198074
198790
|
const supported = endpoint.behaviors.supported;
|
|
198075
198791
|
const clusterIds = [];
|
|
198076
198792
|
const attributes = [];
|
|
198077
|
-
if (isRecord$
|
|
198793
|
+
if (isRecord$3(supported)) for (const [behaviorId, behaviorType] of Object.entries(supported)) {
|
|
198078
198794
|
const clusterId = clusterIdOf(behaviorType);
|
|
198079
198795
|
if (clusterId === null) continue;
|
|
198080
198796
|
clusterIds.push(clusterId);
|
|
@@ -198094,7 +198810,7 @@ function readBehaviorAttributes(endpoint, behaviorId, clusterId, attributes) {
|
|
|
198094
198810
|
} catch {
|
|
198095
198811
|
return;
|
|
198096
198812
|
}
|
|
198097
|
-
if (!isRecord$
|
|
198813
|
+
if (!isRecord$3(struct)) return;
|
|
198098
198814
|
for (const [attrName, value] of Object.entries(struct)) {
|
|
198099
198815
|
const attributeId = ATTR_NAME_TO_ID.get(attrName);
|
|
198100
198816
|
if (attributeId === void 0) continue;
|
|
@@ -198106,35 +198822,413 @@ function readBehaviorAttributes(endpoint, behaviorId, clusterId, attributes) {
|
|
|
198106
198822
|
}
|
|
198107
198823
|
}
|
|
198108
198824
|
//#endregion
|
|
198825
|
+
//#region src/matter-commission-progress.ts
|
|
198826
|
+
/**
|
|
198827
|
+
* Commissioning progress the admin UI polls, plus the named failures a share
|
|
198828
|
+
* code can produce. Pure — no matter.js import.
|
|
198829
|
+
*
|
|
198830
|
+
* Phases follow the on-network share path: discover the device, establish
|
|
198831
|
+
* PASE, then commission onto this fabric. A missing or malformed code never
|
|
198832
|
+
* becomes a later phase.
|
|
198833
|
+
*/
|
|
198834
|
+
var CommissionPhase = {
|
|
198835
|
+
Idle: "idle",
|
|
198836
|
+
Discovering: "discovering",
|
|
198837
|
+
Pase: "pase",
|
|
198838
|
+
Commissioning: "commissioning",
|
|
198839
|
+
Done: "done",
|
|
198840
|
+
Failed: "failed"
|
|
198841
|
+
};
|
|
198842
|
+
var CommissionFailureCode = {
|
|
198843
|
+
CodeExpired: "code-expired",
|
|
198844
|
+
DeviceNotFound: "device-not-found",
|
|
198845
|
+
WrongCode: "wrong-code",
|
|
198846
|
+
InvalidCode: "invalid-code",
|
|
198847
|
+
Unknown: "unknown"
|
|
198848
|
+
};
|
|
198849
|
+
var IDLE_COMMISSION_PROGRESS = {
|
|
198850
|
+
phase: CommissionPhase.Idle,
|
|
198851
|
+
failure: null,
|
|
198852
|
+
message: null
|
|
198853
|
+
};
|
|
198854
|
+
/** Stable prefix the UI matches. The human text follows the colon. */
|
|
198855
|
+
function commissionFailureMessage(code, detail) {
|
|
198856
|
+
return `matter-commission:${code}: ${detail}`;
|
|
198857
|
+
}
|
|
198858
|
+
/**
|
|
198859
|
+
* Map a controller or matter.js error onto a named failure. Order matters:
|
|
198860
|
+
* an expired commissioning window is not "device not found", and a rejected
|
|
198861
|
+
* passcode is not a network miss.
|
|
198862
|
+
*/
|
|
198863
|
+
function classifyCommissionError(message) {
|
|
198864
|
+
const text = message.toLowerCase();
|
|
198865
|
+
if (text.includes("invalid pairing code") || text.includes("11 or 21")) return CommissionFailureCode.InvalidCode;
|
|
198866
|
+
if (text.includes("expired") || text.includes("commissioning window") || text.includes("window closed")) return CommissionFailureCode.CodeExpired;
|
|
198867
|
+
if (text.includes("passcode") || text.includes("wrong code") || text.includes("pase") || text.includes("authentication failed") || text.includes("status 0x7e") || text.includes("invalid code")) return CommissionFailureCode.WrongCode;
|
|
198868
|
+
if (text.includes("not found") || text.includes("no device") || text.includes("no commissionable") || text.includes("discovery") || text.includes("timed out") || text.includes("timeout") || text.includes("unreachable")) return CommissionFailureCode.DeviceNotFound;
|
|
198869
|
+
return CommissionFailureCode.Unknown;
|
|
198870
|
+
}
|
|
198871
|
+
//#endregion
|
|
198872
|
+
//#region src/matter-subscription.ts
|
|
198873
|
+
/**
|
|
198874
|
+
* Per-node Matter attribute subscriptions. The matter.js call itself lives in
|
|
198875
|
+
* {@link import('./matter-peer-subscribe.js')}; this module owns the lifecycle:
|
|
198876
|
+
* open, resubscribe after the session drops or the node returns, and a bounded
|
|
198877
|
+
* backoff. A report whose value is missing is not a value (D393) and is dropped.
|
|
198878
|
+
*/
|
|
198879
|
+
/** First wait after a dropped subscription. */
|
|
198880
|
+
var SUBSCRIPTION_BACKOFF_INITIAL_MS = 1e3;
|
|
198881
|
+
/** Cap so a sleepy Thread node cannot be hammered. */
|
|
198882
|
+
var SUBSCRIPTION_BACKOFF_MAX_MS = 6e4;
|
|
198883
|
+
/**
|
|
198884
|
+
* One supervisor per fabric. `sync` is safe to call on start, after commission,
|
|
198885
|
+
* and on the reconcile timer (the backstop when a lifecycle event was missed).
|
|
198886
|
+
*/
|
|
198887
|
+
var MatterSubscriptionSupervisor = class {
|
|
198888
|
+
#brokerId;
|
|
198889
|
+
#logger;
|
|
198890
|
+
#resolveDeviceId;
|
|
198891
|
+
#onReport;
|
|
198892
|
+
#slots = /* @__PURE__ */ new Map();
|
|
198893
|
+
#stopped = false;
|
|
198894
|
+
constructor(options) {
|
|
198895
|
+
this.#brokerId = options.brokerId;
|
|
198896
|
+
this.#logger = options.logger;
|
|
198897
|
+
this.#resolveDeviceId = options.resolveDeviceId;
|
|
198898
|
+
this.#onReport = options.onReport;
|
|
198899
|
+
}
|
|
198900
|
+
/** How many times `subscribe` has been entered for a node (tests). */
|
|
198901
|
+
subscribeAttempts(nodeId) {
|
|
198902
|
+
return this.#slots.get(nodeId)?.generation ?? 0;
|
|
198903
|
+
}
|
|
198904
|
+
phase(nodeId) {
|
|
198905
|
+
return this.#slots.get(nodeId)?.phase ?? null;
|
|
198906
|
+
}
|
|
198907
|
+
async sync(peers) {
|
|
198908
|
+
if (this.#stopped) return;
|
|
198909
|
+
const live = /* @__PURE__ */ new Set();
|
|
198910
|
+
for (const peer of peers) {
|
|
198911
|
+
live.add(peer.nodeId);
|
|
198912
|
+
const slot = this.#slots.get(peer.nodeId);
|
|
198913
|
+
if (slot === void 0) {
|
|
198914
|
+
await this.#open(peer);
|
|
198915
|
+
continue;
|
|
198916
|
+
}
|
|
198917
|
+
slot.peer = peer;
|
|
198918
|
+
if (slot.phase !== "subscribed" && peer.online() && slot.phase !== "resubscribing") {
|
|
198919
|
+
slot.attempt = 0;
|
|
198920
|
+
await this.#open(peer);
|
|
198921
|
+
}
|
|
198922
|
+
}
|
|
198923
|
+
for (const [nodeId, slot] of this.#slots) {
|
|
198924
|
+
if (live.has(nodeId)) continue;
|
|
198925
|
+
await this.#drop(slot);
|
|
198926
|
+
this.#slots.delete(nodeId);
|
|
198927
|
+
}
|
|
198928
|
+
}
|
|
198929
|
+
async stop() {
|
|
198930
|
+
this.#stopped = true;
|
|
198931
|
+
for (const slot of this.#slots.values()) await this.#drop(slot);
|
|
198932
|
+
this.#slots.clear();
|
|
198933
|
+
}
|
|
198934
|
+
async #open(peer) {
|
|
198935
|
+
if (this.#stopped) return;
|
|
198936
|
+
const existing = this.#slots.get(peer.nodeId);
|
|
198937
|
+
if (existing?.phase === "subscribed" && existing.subscription !== null) return;
|
|
198938
|
+
if (existing?.timer !== null && existing?.timer !== void 0) {
|
|
198939
|
+
clearTimeout(existing.timer);
|
|
198940
|
+
existing.timer = null;
|
|
198941
|
+
}
|
|
198942
|
+
const generation = (existing?.generation ?? 0) + 1;
|
|
198943
|
+
const slot = existing ?? this.#fresh(peer);
|
|
198944
|
+
slot.peer = peer;
|
|
198945
|
+
slot.generation = generation;
|
|
198946
|
+
slot.phase = "resubscribing";
|
|
198947
|
+
this.#slots.set(peer.nodeId, slot);
|
|
198948
|
+
this.#listen(slot);
|
|
198949
|
+
this.#log(peer.nodeId, "resubscribing");
|
|
198950
|
+
let subscription;
|
|
198951
|
+
try {
|
|
198952
|
+
subscription = await peer.subscribe({
|
|
198953
|
+
onReport: (report) => {
|
|
198954
|
+
if (report.value === void 0 || report.value === null) return;
|
|
198955
|
+
this.#onReport(report);
|
|
198956
|
+
},
|
|
198957
|
+
onClosed: () => {
|
|
198958
|
+
const current = this.#slots.get(peer.nodeId);
|
|
198959
|
+
if (current === void 0 || current.generation !== generation) return;
|
|
198960
|
+
this.#onClosed(peer.nodeId);
|
|
198961
|
+
}
|
|
198962
|
+
});
|
|
198963
|
+
} catch (err) {
|
|
198964
|
+
this.#log(peer.nodeId, "subscribe-failed", { error: errMsg(err) });
|
|
198965
|
+
const current = this.#slots.get(peer.nodeId);
|
|
198966
|
+
if (current === void 0 || current.generation !== generation) return;
|
|
198967
|
+
current.phase = "subscribe-failed";
|
|
198968
|
+
this.#schedule(peer.nodeId);
|
|
198969
|
+
return;
|
|
198970
|
+
}
|
|
198971
|
+
if (this.#stopped || this.#slots.get(peer.nodeId)?.generation !== generation) {
|
|
198972
|
+
await subscription.close().catch(() => void 0);
|
|
198973
|
+
return;
|
|
198974
|
+
}
|
|
198975
|
+
slot.subscription = subscription;
|
|
198976
|
+
slot.phase = "subscribed";
|
|
198977
|
+
slot.attempt = 0;
|
|
198978
|
+
this.#log(peer.nodeId, "subscribed");
|
|
198979
|
+
}
|
|
198980
|
+
#onClosed(nodeId) {
|
|
198981
|
+
const slot = this.#slots.get(nodeId);
|
|
198982
|
+
if (slot === void 0 || slot.dropping) return;
|
|
198983
|
+
if (slot.phase !== "subscribed" && slot.phase !== "resubscribing") return;
|
|
198984
|
+
slot.subscription = null;
|
|
198985
|
+
slot.phase = "closed";
|
|
198986
|
+
this.#log(nodeId, "closed");
|
|
198987
|
+
if (!slot.peer.online()) {
|
|
198988
|
+
slot.phase = "offline";
|
|
198989
|
+
this.#log(nodeId, "offline");
|
|
198990
|
+
return;
|
|
198991
|
+
}
|
|
198992
|
+
this.#schedule(nodeId);
|
|
198993
|
+
}
|
|
198994
|
+
#schedule(nodeId) {
|
|
198995
|
+
const slot = this.#slots.get(nodeId);
|
|
198996
|
+
if (slot === void 0 || this.#stopped) return;
|
|
198997
|
+
if (slot.timer !== null) clearTimeout(slot.timer);
|
|
198998
|
+
const delay = Math.min(SUBSCRIPTION_BACKOFF_MAX_MS, SUBSCRIPTION_BACKOFF_INITIAL_MS * 2 ** slot.attempt);
|
|
198999
|
+
slot.attempt += 1;
|
|
199000
|
+
slot.phase = "backing-off";
|
|
199001
|
+
this.#log(nodeId, "backing-off", {
|
|
199002
|
+
delayMs: delay,
|
|
199003
|
+
attempt: slot.attempt
|
|
199004
|
+
});
|
|
199005
|
+
slot.timer = setTimeout(() => {
|
|
199006
|
+
slot.timer = null;
|
|
199007
|
+
this.#open(slot.peer);
|
|
199008
|
+
}, delay);
|
|
199009
|
+
if (typeof slot.timer.unref === "function") slot.timer.unref();
|
|
199010
|
+
}
|
|
199011
|
+
#listen(slot) {
|
|
199012
|
+
if (slot.listening) return;
|
|
199013
|
+
slot.listening = true;
|
|
199014
|
+
slot.unlisten.push(slot.peer.onOffline(() => {
|
|
199015
|
+
const current = this.#slots.get(slot.peer.nodeId);
|
|
199016
|
+
if (current === void 0) return;
|
|
199017
|
+
if (current.phase === "offline") return;
|
|
199018
|
+
current.phase = "offline";
|
|
199019
|
+
this.#log(slot.peer.nodeId, "offline");
|
|
199020
|
+
}));
|
|
199021
|
+
slot.unlisten.push(slot.peer.onOnline(() => {
|
|
199022
|
+
const current = this.#slots.get(slot.peer.nodeId);
|
|
199023
|
+
if (current === void 0 || this.#stopped) return;
|
|
199024
|
+
current.attempt = 0;
|
|
199025
|
+
if (current.timer !== null) {
|
|
199026
|
+
clearTimeout(current.timer);
|
|
199027
|
+
current.timer = null;
|
|
199028
|
+
}
|
|
199029
|
+
this.#log(slot.peer.nodeId, "online");
|
|
199030
|
+
this.#open(current.peer);
|
|
199031
|
+
}));
|
|
199032
|
+
}
|
|
199033
|
+
async #drop(slot) {
|
|
199034
|
+
slot.dropping = true;
|
|
199035
|
+
if (slot.timer !== null) clearTimeout(slot.timer);
|
|
199036
|
+
slot.timer = null;
|
|
199037
|
+
for (const unlisten of slot.unlisten) unlisten();
|
|
199038
|
+
slot.unlisten = [];
|
|
199039
|
+
const subscription = slot.subscription;
|
|
199040
|
+
slot.subscription = null;
|
|
199041
|
+
if (subscription !== null) try {
|
|
199042
|
+
await subscription.close();
|
|
199043
|
+
} catch (err) {
|
|
199044
|
+
this.#logger.warn("Matter subscription close failed", {
|
|
199045
|
+
tags: this.#tags(slot.peer.nodeId),
|
|
199046
|
+
meta: {
|
|
199047
|
+
nodeId: slot.peer.nodeId,
|
|
199048
|
+
error: errMsg(err)
|
|
199049
|
+
}
|
|
199050
|
+
});
|
|
199051
|
+
}
|
|
199052
|
+
}
|
|
199053
|
+
#fresh(peer) {
|
|
199054
|
+
return {
|
|
199055
|
+
peer,
|
|
199056
|
+
phase: "resubscribing",
|
|
199057
|
+
attempt: 0,
|
|
199058
|
+
timer: null,
|
|
199059
|
+
subscription: null,
|
|
199060
|
+
unlisten: [],
|
|
199061
|
+
generation: 0,
|
|
199062
|
+
listening: false,
|
|
199063
|
+
dropping: false
|
|
199064
|
+
};
|
|
199065
|
+
}
|
|
199066
|
+
#tags(nodeId) {
|
|
199067
|
+
const deviceId = this.#resolveDeviceId(nodeId);
|
|
199068
|
+
if (deviceId !== null) return { deviceId };
|
|
199069
|
+
return { brokerId: this.#brokerId };
|
|
199070
|
+
}
|
|
199071
|
+
#log(nodeId, phase, extra) {
|
|
199072
|
+
const deviceId = this.#resolveDeviceId(nodeId);
|
|
199073
|
+
this.#logger.info("Matter subscription state", {
|
|
199074
|
+
tags: deviceId !== null ? { deviceId } : { brokerId: this.#brokerId },
|
|
199075
|
+
meta: {
|
|
199076
|
+
nodeId,
|
|
199077
|
+
phase,
|
|
199078
|
+
...extra
|
|
199079
|
+
}
|
|
199080
|
+
});
|
|
199081
|
+
}
|
|
199082
|
+
};
|
|
199083
|
+
function isRecord$2(value) {
|
|
199084
|
+
return typeof value === "object" && value !== null;
|
|
199085
|
+
}
|
|
199086
|
+
function asFiniteNumber(value) {
|
|
199087
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
199088
|
+
if (typeof value === "bigint") {
|
|
199089
|
+
const n = Number(value);
|
|
199090
|
+
return Number.isFinite(n) ? n : null;
|
|
199091
|
+
}
|
|
199092
|
+
return null;
|
|
199093
|
+
}
|
|
199094
|
+
function isIterable$1(value) {
|
|
199095
|
+
return isRecord$2(value) && typeof Reflect.get(value, Symbol.iterator) === "function";
|
|
199096
|
+
}
|
|
199097
|
+
function isAsyncIterable(value) {
|
|
199098
|
+
return isRecord$2(value) && typeof Reflect.get(value, Symbol.asyncIterator) === "function";
|
|
199099
|
+
}
|
|
199100
|
+
/**
|
|
199101
|
+
* Pull attribute values out of a matter.js `ReadResult` (or a recorded fixture
|
|
199102
|
+
* of the same shape). Status reports and missing values are skipped — they are
|
|
199103
|
+
* not a measurement.
|
|
199104
|
+
*/
|
|
199105
|
+
async function collectAttributeReports(nodeId, update) {
|
|
199106
|
+
const out = [];
|
|
199107
|
+
const chunks = isAsyncIterable(update) ? update : isIterable$1(update) ? update : [];
|
|
199108
|
+
for await (const chunk of chunks) {
|
|
199109
|
+
const reports = isIterable$1(chunk) ? chunk : [];
|
|
199110
|
+
for (const report of reports) {
|
|
199111
|
+
const decoded = reportFromRecord(nodeId, report);
|
|
199112
|
+
if (decoded !== null) out.push(decoded);
|
|
199113
|
+
}
|
|
199114
|
+
}
|
|
199115
|
+
return out;
|
|
199116
|
+
}
|
|
199117
|
+
function reportFromRecord(nodeId, report) {
|
|
199118
|
+
if (!isRecord$2(report)) return null;
|
|
199119
|
+
if (report["kind"] !== "attr-value") return null;
|
|
199120
|
+
if (report["value"] === void 0 || report["value"] === null) return null;
|
|
199121
|
+
const path = report["path"];
|
|
199122
|
+
if (!isRecord$2(path)) return null;
|
|
199123
|
+
const endpointId = asFiniteNumber(path["endpointId"]);
|
|
199124
|
+
const clusterId = asFiniteNumber(path["clusterId"]);
|
|
199125
|
+
const attributeId = asFiniteNumber(path["attributeId"]);
|
|
199126
|
+
if (endpointId === null || clusterId === null || attributeId === null) return null;
|
|
199127
|
+
return {
|
|
199128
|
+
nodeId,
|
|
199129
|
+
endpointId,
|
|
199130
|
+
clusterId,
|
|
199131
|
+
attributeId,
|
|
199132
|
+
value: report["value"]
|
|
199133
|
+
};
|
|
199134
|
+
}
|
|
199135
|
+
function isRecord$1(value) {
|
|
199136
|
+
return typeof value === "object" && value !== null;
|
|
199137
|
+
}
|
|
199138
|
+
function peerOnline$1(peer) {
|
|
199139
|
+
const lifecycle = peer["lifecycle"];
|
|
199140
|
+
if (!isRecord$1(lifecycle)) return false;
|
|
199141
|
+
return lifecycle["isOnline"] === true;
|
|
199142
|
+
}
|
|
199143
|
+
function listenLifecycle(peer, event, handler) {
|
|
199144
|
+
const lifecycle = peer["lifecycle"];
|
|
199145
|
+
if (!isRecord$1(lifecycle)) return () => void 0;
|
|
199146
|
+
const observable = lifecycle[event];
|
|
199147
|
+
if (!isRecord$1(observable)) return () => void 0;
|
|
199148
|
+
const on = observable["on"];
|
|
199149
|
+
const off = observable["off"];
|
|
199150
|
+
if (typeof on !== "function" || typeof off !== "function") return () => void 0;
|
|
199151
|
+
Reflect.apply(on, observable, [handler]);
|
|
199152
|
+
return () => {
|
|
199153
|
+
Reflect.apply(off, observable, [handler]);
|
|
199154
|
+
};
|
|
199155
|
+
}
|
|
199156
|
+
/** Stop matter.js's own wildcard subscription so this addon owns the session. */
|
|
199157
|
+
function disableAutoSubscribe(peer) {
|
|
199158
|
+
const stateOf = peer["stateOf"];
|
|
199159
|
+
if (typeof stateOf !== "function") return;
|
|
199160
|
+
let network;
|
|
199161
|
+
try {
|
|
199162
|
+
network = Reflect.apply(stateOf, peer, ["network"]);
|
|
199163
|
+
} catch {
|
|
199164
|
+
return;
|
|
199165
|
+
}
|
|
199166
|
+
if (!isRecord$1(network)) return;
|
|
199167
|
+
if ("autoSubscribe" in network) network["autoSubscribe"] = false;
|
|
199168
|
+
}
|
|
199169
|
+
function subscriptionFrom(result) {
|
|
199170
|
+
return { close: async () => {
|
|
199171
|
+
if (!isRecord$1(result)) return;
|
|
199172
|
+
const fn = result["close"];
|
|
199173
|
+
if (typeof fn !== "function") return;
|
|
199174
|
+
await Promise.resolve(Reflect.apply(fn, result, []));
|
|
199175
|
+
} };
|
|
199176
|
+
}
|
|
199177
|
+
/**
|
|
199178
|
+
* Build a subscribable view of a commissioned peer, or null when the peer has
|
|
199179
|
+
* no `interaction.subscribe` (nothing to attach — the caller logs that).
|
|
199180
|
+
*/
|
|
199181
|
+
function subscribableFromPeer(peer, nodeId) {
|
|
199182
|
+
if (!isRecord$1(peer)) return null;
|
|
199183
|
+
const interaction = peer["interaction"];
|
|
199184
|
+
if (!isRecord$1(interaction) || typeof interaction["subscribe"] !== "function") return null;
|
|
199185
|
+
const subscribe = interaction["subscribe"];
|
|
199186
|
+
return {
|
|
199187
|
+
nodeId,
|
|
199188
|
+
online: () => peerOnline$1(peer),
|
|
199189
|
+
onOnline: (handler) => listenLifecycle(peer, "online", handler),
|
|
199190
|
+
onOffline: (handler) => listenLifecycle(peer, "offline", handler),
|
|
199191
|
+
subscribe: async (handlers) => {
|
|
199192
|
+
disableAutoSubscribe(peer);
|
|
199193
|
+
const request = {
|
|
199194
|
+
sustain: true,
|
|
199195
|
+
keepSubscriptions: false,
|
|
199196
|
+
fabricFilter: true,
|
|
199197
|
+
attributes: [{}],
|
|
199198
|
+
minIntervalFloor: Seconds(0),
|
|
199199
|
+
maxIntervalCeiling: Seconds(60),
|
|
199200
|
+
bootstrapWithRead: true,
|
|
199201
|
+
updated: async (update) => {
|
|
199202
|
+
const reports = await collectAttributeReports(nodeId, update);
|
|
199203
|
+
for (const report of reports) handlers.onReport(report);
|
|
199204
|
+
},
|
|
199205
|
+
closed: () => {
|
|
199206
|
+
handlers.onClosed();
|
|
199207
|
+
}
|
|
199208
|
+
};
|
|
199209
|
+
return subscriptionFrom(await Promise.resolve(Reflect.apply(subscribe, interaction, [request])));
|
|
199210
|
+
}
|
|
199211
|
+
};
|
|
199212
|
+
}
|
|
199213
|
+
//#endregion
|
|
198109
199214
|
//#region src/matter-controller-impl.ts
|
|
198110
199215
|
/**
|
|
198111
|
-
* Real {@link MatterController} backed by matter.js
|
|
198112
|
-
* `@matter/nodejs`).
|
|
198113
|
-
*
|
|
198114
|
-
*
|
|
198115
|
-
*
|
|
198116
|
-
*
|
|
198117
|
-
*
|
|
198118
|
-
*
|
|
198119
|
-
*
|
|
198120
|
-
*
|
|
198121
|
-
* - `
|
|
198122
|
-
* - `
|
|
198123
|
-
*
|
|
198124
|
-
* - `
|
|
198125
|
-
*
|
|
198126
|
-
*
|
|
198127
|
-
* - `clientNode.decommission()` — remove a node from the fabric.
|
|
198128
|
-
* - endpoint `commandsOf(behaviorId)[name](args)` — outbound cluster commands.
|
|
198129
|
-
*
|
|
198130
|
-
* The dynamic endpoint/cluster/attribute introspection lives in
|
|
198131
|
-
* `matter-endpoint-introspect.ts` (the single matter.js dynamic-shape boundary).
|
|
198132
|
-
* This class polls each node's endpoint state on reconcile + emits decoded
|
|
198133
|
-
* attribute reports, and re-emits on node online/offline transitions.
|
|
198134
|
-
*
|
|
198135
|
-
* BLE commissioning (`@matter/nodejs-ble`) is NOT wired — that package is not
|
|
198136
|
-
* installed. IP / on-network commissioning is the supported path; see the class
|
|
198137
|
-
* `commissionNode` note.
|
|
199216
|
+
* Real {@link MatterController} backed by matter.js (`@matter/main` +
|
|
199217
|
+
* `@matter/nodejs`). ServerNode / ClientNode is the API this controller uses.
|
|
199218
|
+
*
|
|
199219
|
+
* One `ServerNode` per broker (= one fabric). Storage is matter.js's own
|
|
199220
|
+
* files under the addon `dataDir` (`Environment` `storage.path`) — the
|
|
199221
|
+
* library-owned exception for fabric root / NOC / node registry, same class
|
|
199222
|
+
* as HAP pairing files. Not the keychain.
|
|
199223
|
+
*
|
|
199224
|
+
* Bound API:
|
|
199225
|
+
* - `ServerNode.create({ environment, id })` — fabric owner.
|
|
199226
|
+
* - `serverNode.peers.commission({ pairingCode, continueCommissioningAfterPase })`.
|
|
199227
|
+
* - `clientNode.interaction.subscribe({ sustain: true })` — attribute reports.
|
|
199228
|
+
* - `clientNode.lifecycle` online / offline — resubscribe.
|
|
199229
|
+
* - endpoint `commandsOf(behaviorId)[name](args)` — outbound commands.
|
|
199230
|
+
*
|
|
199231
|
+
* BLE commissioning is not wired. IP / on-network share codes only.
|
|
198138
199232
|
*/
|
|
198139
199233
|
/** A commissioning failure (bad code / device unreachable), distinct from runtime. */
|
|
198140
199234
|
var MatterCommissioningError = class extends Error {
|
|
@@ -198154,12 +199248,19 @@ var MatterJsController = class {
|
|
|
198154
199248
|
#options;
|
|
198155
199249
|
#logger;
|
|
198156
199250
|
#handlers = /* @__PURE__ */ new Set();
|
|
199251
|
+
#subscriptions;
|
|
198157
199252
|
#server = null;
|
|
198158
199253
|
/** Last emitted value per `node:endpoint:cluster:attribute` (change detection). */
|
|
198159
199254
|
#lastValues = /* @__PURE__ */ new Map();
|
|
198160
199255
|
constructor(options, logger) {
|
|
198161
199256
|
this.#options = options;
|
|
198162
199257
|
this.#logger = logger;
|
|
199258
|
+
this.#subscriptions = new MatterSubscriptionSupervisor({
|
|
199259
|
+
brokerId: options.brokerId,
|
|
199260
|
+
logger,
|
|
199261
|
+
resolveDeviceId: options.resolveDeviceId ?? (() => null),
|
|
199262
|
+
onReport: (report) => this.#emitIfChanged(report)
|
|
199263
|
+
});
|
|
198163
199264
|
}
|
|
198164
199265
|
get options() {
|
|
198165
199266
|
return this.#options;
|
|
@@ -198167,19 +199268,17 @@ var MatterJsController = class {
|
|
|
198167
199268
|
/** Boot the ServerNode fabric, loading/persisting state from `dataDir`. */
|
|
198168
199269
|
async start() {
|
|
198169
199270
|
if (this.#server !== null) return;
|
|
198170
|
-
const
|
|
198171
|
-
const server = await ServerNode.create({
|
|
198172
|
-
environment,
|
|
198173
|
-
id: this.#options.brokerId
|
|
198174
|
-
});
|
|
199271
|
+
const server = this.#options.openServer !== void 0 ? await this.#options.openServer() : await this.#openProductionServer();
|
|
198175
199272
|
this.#server = server;
|
|
198176
199273
|
await server.start();
|
|
198177
199274
|
this.#logger.info("MatterJsController: ServerNode online", { tags: { brokerId: this.#options.brokerId } });
|
|
199275
|
+
await this.syncSubscriptions();
|
|
198178
199276
|
this.#emitAllReports();
|
|
198179
199277
|
}
|
|
198180
|
-
/** Close
|
|
199278
|
+
/** Close subscriptions FIRST, then the ServerNode. */
|
|
198181
199279
|
async stop() {
|
|
198182
199280
|
this.#handlers.clear();
|
|
199281
|
+
await this.#subscriptions.stop();
|
|
198183
199282
|
const server = this.#server;
|
|
198184
199283
|
this.#server = null;
|
|
198185
199284
|
this.#lastValues.clear();
|
|
@@ -198200,19 +199299,49 @@ var MatterJsController = class {
|
|
|
198200
199299
|
*/
|
|
198201
199300
|
async commissionNode(pairingCode) {
|
|
198202
199301
|
const server = this.#requireServer("commissionNode");
|
|
199302
|
+
this.#progress({
|
|
199303
|
+
phase: CommissionPhase.Discovering,
|
|
199304
|
+
failure: null,
|
|
199305
|
+
message: null
|
|
199306
|
+
});
|
|
198203
199307
|
try {
|
|
198204
|
-
const node = await server.
|
|
199308
|
+
const node = await server.commission({
|
|
199309
|
+
pairingCode,
|
|
199310
|
+
onPase: () => {
|
|
199311
|
+
this.#progress({
|
|
199312
|
+
phase: CommissionPhase.Pase,
|
|
199313
|
+
failure: null,
|
|
199314
|
+
message: null
|
|
199315
|
+
});
|
|
199316
|
+
this.#progress({
|
|
199317
|
+
phase: CommissionPhase.Commissioning,
|
|
199318
|
+
failure: null,
|
|
199319
|
+
message: null
|
|
199320
|
+
});
|
|
199321
|
+
}
|
|
199322
|
+
});
|
|
198205
199323
|
const view = this.#viewPeer(node);
|
|
198206
199324
|
this.#logger.info("MatterJsController: node commissioned", {
|
|
198207
199325
|
tags: { brokerId: this.#options.brokerId },
|
|
198208
199326
|
meta: { nodeId: view?.id ?? "(unknown)" }
|
|
198209
199327
|
});
|
|
199328
|
+
await this.syncSubscriptions();
|
|
198210
199329
|
this.#emitAllReports();
|
|
198211
199330
|
if (view === null) throw new MatterCommissioningError("commissioned node exposed no operational id");
|
|
199331
|
+
this.#progress({
|
|
199332
|
+
phase: CommissionPhase.Done,
|
|
199333
|
+
failure: null,
|
|
199334
|
+
message: null
|
|
199335
|
+
});
|
|
198212
199336
|
return { nodeId: view.id };
|
|
198213
199337
|
} catch (err) {
|
|
198214
|
-
if (err instanceof MatterCommissioningError
|
|
198215
|
-
|
|
199338
|
+
if (err instanceof MatterCommissioningError && err.message.includes("no operational id")) {
|
|
199339
|
+
this.#failCommission(err.message);
|
|
199340
|
+
throw err;
|
|
199341
|
+
}
|
|
199342
|
+
const message = errMsg(err);
|
|
199343
|
+
this.#failCommission(message);
|
|
199344
|
+
throw new MatterCommissioningError(commissionFailureMessage(classifyCommissionError(message), message), { cause: err });
|
|
198216
199345
|
}
|
|
198217
199346
|
}
|
|
198218
199347
|
/** Pull the live commissioned-node inventory off `serverNode.peers`. */
|
|
@@ -198220,12 +199349,31 @@ var MatterJsController = class {
|
|
|
198220
199349
|
const server = this.#server;
|
|
198221
199350
|
if (server === null) return [];
|
|
198222
199351
|
const out = [];
|
|
198223
|
-
for (const peer of
|
|
199352
|
+
for (const peer of server.listPeers()) {
|
|
198224
199353
|
const snapshot = this.#snapshot(peer);
|
|
198225
199354
|
if (snapshot !== null) out.push(snapshot);
|
|
198226
199355
|
}
|
|
198227
199356
|
return out;
|
|
198228
199357
|
}
|
|
199358
|
+
async syncSubscriptions() {
|
|
199359
|
+
const server = this.#server;
|
|
199360
|
+
if (server === null) return;
|
|
199361
|
+
const peers = [];
|
|
199362
|
+
for (const peer of server.listPeers()) {
|
|
199363
|
+
const view = this.#viewPeer(peer);
|
|
199364
|
+
if (view === null) continue;
|
|
199365
|
+
const subscribable = subscribableFromPeer(peer, view.id);
|
|
199366
|
+
if (subscribable === null) {
|
|
199367
|
+
this.#logger.warn("MatterJsController: peer has no attribute subscription", {
|
|
199368
|
+
tags: { brokerId: this.#options.brokerId },
|
|
199369
|
+
meta: { nodeId: view.id }
|
|
199370
|
+
});
|
|
199371
|
+
continue;
|
|
199372
|
+
}
|
|
199373
|
+
peers.push(subscribable);
|
|
199374
|
+
}
|
|
199375
|
+
await this.#subscriptions.sync(peers);
|
|
199376
|
+
}
|
|
198229
199377
|
async getNode(nodeId) {
|
|
198230
199378
|
return (await this.listNodes()).find((n) => n.nodeId === nodeId) ?? null;
|
|
198231
199379
|
}
|
|
@@ -198266,6 +199414,25 @@ var MatterJsController = class {
|
|
|
198266
199414
|
throw err;
|
|
198267
199415
|
}
|
|
198268
199416
|
}
|
|
199417
|
+
async #openProductionServer() {
|
|
199418
|
+
const environment = this.#buildEnvironment();
|
|
199419
|
+
const server = await ServerNode.create({
|
|
199420
|
+
environment,
|
|
199421
|
+
id: this.#options.brokerId
|
|
199422
|
+
});
|
|
199423
|
+
return {
|
|
199424
|
+
start: () => server.start(),
|
|
199425
|
+
close: () => server.close(),
|
|
199426
|
+
listPeers: () => this.#serverPeers(server),
|
|
199427
|
+
commission: ({ pairingCode, onPase }) => server.peers.commission({
|
|
199428
|
+
pairingCode,
|
|
199429
|
+
continueCommissioningAfterPase: () => {
|
|
199430
|
+
onPase();
|
|
199431
|
+
return true;
|
|
199432
|
+
}
|
|
199433
|
+
})
|
|
199434
|
+
};
|
|
199435
|
+
}
|
|
198269
199436
|
#buildEnvironment() {
|
|
198270
199437
|
const env = Environment.default;
|
|
198271
199438
|
env.vars.set("storage.path", this.#options.dataDir);
|
|
@@ -198278,13 +199445,13 @@ var MatterJsController = class {
|
|
|
198278
199445
|
return this.#server;
|
|
198279
199446
|
}
|
|
198280
199447
|
/** Iterate the commissioned peers of a ServerNode (cast-free). */
|
|
198281
|
-
#
|
|
199448
|
+
#serverPeers(server) {
|
|
198282
199449
|
const peers = server.peers;
|
|
198283
199450
|
if (isIterable(peers)) return peers;
|
|
198284
199451
|
return [];
|
|
198285
199452
|
}
|
|
198286
199453
|
#findPeer(server, nodeId) {
|
|
198287
|
-
for (const peer of
|
|
199454
|
+
for (const peer of server.listPeers()) {
|
|
198288
199455
|
const view = this.#viewPeer(peer);
|
|
198289
199456
|
if (view !== null && view.id === nodeId) return view;
|
|
198290
199457
|
}
|
|
@@ -198292,12 +199459,23 @@ var MatterJsController = class {
|
|
|
198292
199459
|
}
|
|
198293
199460
|
/** Raw (un-viewed) peer object for operations that call its methods. */
|
|
198294
199461
|
#rawPeer(server, nodeId) {
|
|
198295
|
-
for (const peer of
|
|
199462
|
+
for (const peer of server.listPeers()) {
|
|
198296
199463
|
const view = this.#viewPeer(peer);
|
|
198297
199464
|
if (view !== null && view.id === nodeId) return peer;
|
|
198298
199465
|
}
|
|
198299
199466
|
return null;
|
|
198300
199467
|
}
|
|
199468
|
+
#progress(progress) {
|
|
199469
|
+
this.#options.onCommissionProgress?.(progress);
|
|
199470
|
+
}
|
|
199471
|
+
#failCommission(message) {
|
|
199472
|
+
const failure = classifyCommissionError(message);
|
|
199473
|
+
this.#progress({
|
|
199474
|
+
phase: CommissionPhase.Failed,
|
|
199475
|
+
failure,
|
|
199476
|
+
message: commissionFailureMessage(failure, message)
|
|
199477
|
+
});
|
|
199478
|
+
}
|
|
198301
199479
|
/** Reduce a peer to the read-only view the addon models. */
|
|
198302
199480
|
#viewPeer(peer) {
|
|
198303
199481
|
if (!isRecord(peer)) return null;
|
|
@@ -198341,7 +199519,7 @@ var MatterJsController = class {
|
|
|
198341
199519
|
#emitAllReports() {
|
|
198342
199520
|
const server = this.#server;
|
|
198343
199521
|
if (server === null) return;
|
|
198344
|
-
for (const peer of
|
|
199522
|
+
for (const peer of server.listPeers()) {
|
|
198345
199523
|
const view = this.#viewPeer(peer);
|
|
198346
199524
|
if (view === null) continue;
|
|
198347
199525
|
for (const ep of readNodeEndpoints(view.rootEndpoint)) for (const attr of ep.attributes) {
|
|
@@ -198357,6 +199535,7 @@ var MatterJsController = class {
|
|
|
198357
199535
|
}
|
|
198358
199536
|
}
|
|
198359
199537
|
#emitIfChanged(report) {
|
|
199538
|
+
if (report.value === void 0 || report.value === null) return;
|
|
198360
199539
|
const key = `${report.nodeId}:${report.endpointId}:${report.clusterId}:${report.attributeId}`;
|
|
198361
199540
|
const prev = this.#lastValues.get(key);
|
|
198362
199541
|
if (prev !== void 0 && shallowEqual(prev, report.value)) return;
|
|
@@ -198442,12 +199621,24 @@ var MatterNodeResolver = class {
|
|
|
198442
199621
|
#attrs = /* @__PURE__ */ new Map();
|
|
198443
199622
|
/** Live attribute-report subscribers (endpoint device classes). */
|
|
198444
199623
|
#listeners = /* @__PURE__ */ new Set();
|
|
199624
|
+
/** Adopted container id per Matter node, for subscription logs. */
|
|
199625
|
+
#deviceIds = /* @__PURE__ */ new Map();
|
|
198445
199626
|
/**
|
|
198446
199627
|
* Subscribe to live attribute reports across all brokers. Endpoint device
|
|
198447
199628
|
* classes subscribe on activate (filtering to their own node/endpoint) so a
|
|
198448
199629
|
* push report decodes straight into their runtime-state slice. Returns a
|
|
198449
199630
|
* disposer.
|
|
198450
199631
|
*/
|
|
199632
|
+
/** Remember the CamStack container id for a commissioned node. */
|
|
199633
|
+
bindDevice(nodeId, deviceId) {
|
|
199634
|
+
this.#deviceIds.set(nodeId, deviceId);
|
|
199635
|
+
}
|
|
199636
|
+
unbindDevice(nodeId) {
|
|
199637
|
+
this.#deviceIds.delete(nodeId);
|
|
199638
|
+
}
|
|
199639
|
+
deviceIdFor(nodeId) {
|
|
199640
|
+
return this.#deviceIds.get(nodeId) ?? null;
|
|
199641
|
+
}
|
|
198451
199642
|
onAttributeReport(listener) {
|
|
198452
199643
|
this.#listeners.add(listener);
|
|
198453
199644
|
return () => {
|
|
@@ -198509,6 +199700,7 @@ var MatterNodeResolver = class {
|
|
|
198509
199700
|
this.#nodes.clear();
|
|
198510
199701
|
this.#attrs.clear();
|
|
198511
199702
|
this.#listeners.clear();
|
|
199703
|
+
this.#deviceIds.clear();
|
|
198512
199704
|
}
|
|
198513
199705
|
};
|
|
198514
199706
|
/** The single in-process per-broker node resolver shared across the addon. */
|
|
@@ -198568,6 +199760,7 @@ var MatterIntegrationManager = class {
|
|
|
198568
199760
|
#nodeCount = 0;
|
|
198569
199761
|
#lastCheckedAt = null;
|
|
198570
199762
|
#error = null;
|
|
199763
|
+
#commission = IDLE_COMMISSION_PROGRESS;
|
|
198571
199764
|
constructor(options) {
|
|
198572
199765
|
this.#id = options.id;
|
|
198573
199766
|
this.#name = options.name;
|
|
@@ -198578,7 +199771,17 @@ var MatterIntegrationManager = class {
|
|
|
198578
199771
|
this.#onDisconnected = options.onDisconnected;
|
|
198579
199772
|
this.#onNodesChanged = options.onNodesChanged;
|
|
198580
199773
|
this.#onAttributeReport = options.onAttributeReport;
|
|
198581
|
-
this.#makeController = options.makeController ?? ((opts) => new MatterJsController(
|
|
199774
|
+
this.#makeController = options.makeController ?? ((opts) => new MatterJsController({
|
|
199775
|
+
...opts,
|
|
199776
|
+
onCommissionProgress: (progress) => {
|
|
199777
|
+
this.#commission = progress;
|
|
199778
|
+
},
|
|
199779
|
+
resolveDeviceId: (nodeId) => matterNodes.deviceIdFor(nodeId)
|
|
199780
|
+
}, this.#logger));
|
|
199781
|
+
}
|
|
199782
|
+
/** Latest commissioning phase for `broker.getState({ key: 'commission' })`. */
|
|
199783
|
+
getCommissionProgress() {
|
|
199784
|
+
return this.#commission;
|
|
198582
199785
|
}
|
|
198583
199786
|
/** The connection settings the manager is currently configured with. */
|
|
198584
199787
|
getConnection() {
|
|
@@ -198653,6 +199856,7 @@ var MatterIntegrationManager = class {
|
|
|
198653
199856
|
if (controller === null) return;
|
|
198654
199857
|
try {
|
|
198655
199858
|
const nodes = await controller.listNodes();
|
|
199859
|
+
await controller.syncSubscriptions();
|
|
198656
199860
|
this.#nodeCount = nodes.length;
|
|
198657
199861
|
this.#lastCheckedAt = Date.now();
|
|
198658
199862
|
matterNodes.setNodes(this.#id, nodes);
|
|
@@ -198833,6 +200037,10 @@ var MatterBrokerRegistry = class {
|
|
|
198833
200037
|
if (!mgr) throw new Error(`MatterBrokerRegistry: unknown broker id "${brokerId}"`);
|
|
198834
200038
|
return mgr.commissionNode(pairingCode);
|
|
198835
200039
|
}
|
|
200040
|
+
getCommissionProgress(brokerId) {
|
|
200041
|
+
const mgr = this.#managers.get(brokerId);
|
|
200042
|
+
return mgr ? mgr.getCommissionProgress() : null;
|
|
200043
|
+
}
|
|
198836
200044
|
async removeNode(brokerId, nodeId) {
|
|
198837
200045
|
const mgr = this.#managers.get(brokerId);
|
|
198838
200046
|
if (!mgr) throw new Error(`MatterBrokerRegistry: unknown broker id "${brokerId}"`);
|
|
@@ -198935,6 +200143,26 @@ function toRecord(value) {
|
|
|
198935
200143
|
function settingsToMatterConnection(settings) {
|
|
198936
200144
|
return matterConnectionSchema.parse(toRecord(settings));
|
|
198937
200145
|
}
|
|
200146
|
+
/**
|
|
200147
|
+
* Settings readers see an empty string for both secrets. The stored value
|
|
200148
|
+
* stays in the keychain (records `secret` meta). An empty round-trip must
|
|
200149
|
+
* not wipe it — see {@link mergeMatterSecrets}.
|
|
200150
|
+
*/
|
|
200151
|
+
function publicMatterConnection(connection) {
|
|
200152
|
+
return {
|
|
200153
|
+
...connection,
|
|
200154
|
+
wifiPassword: "",
|
|
200155
|
+
threadDataset: ""
|
|
200156
|
+
};
|
|
200157
|
+
}
|
|
200158
|
+
/** Keep a stored secret when the form sent back the redacted empty string. */
|
|
200159
|
+
function mergeMatterSecrets(existing, incoming) {
|
|
200160
|
+
return {
|
|
200161
|
+
...incoming,
|
|
200162
|
+
wifiPassword: incoming.wifiPassword.length > 0 ? incoming.wifiPassword : existing.wifiPassword,
|
|
200163
|
+
threadDataset: incoming.threadDataset.length > 0 ? incoming.threadDataset : existing.threadDataset
|
|
200164
|
+
};
|
|
200165
|
+
}
|
|
198938
200166
|
/** Hand-written connection form for the broker/integration creation UI. */
|
|
198939
200167
|
function buildConnectionFormSchema() {
|
|
198940
200168
|
return { sections: [{
|
|
@@ -198946,9 +200174,10 @@ function buildConnectionFormSchema() {
|
|
|
198946
200174
|
columns: 1,
|
|
198947
200175
|
fields: [
|
|
198948
200176
|
{
|
|
198949
|
-
type: "
|
|
200177
|
+
type: "password",
|
|
198950
200178
|
key: "threadDataset",
|
|
198951
200179
|
secret: true,
|
|
200180
|
+
showToggle: true,
|
|
198952
200181
|
label: "Thread operational dataset (hex, optional)",
|
|
198953
200182
|
labelKey: "matter-broker:connection.s_matter-fabric.threadDataset.label",
|
|
198954
200183
|
placeholder: "0e08000000000001…"
|
|
@@ -199025,17 +200254,14 @@ var MATTER_KIND = "matter";
|
|
|
199025
200254
|
* Construct the `broker` cap provider for the Matter addon. Pure builder.
|
|
199026
200255
|
* Mirrors `buildEcowittBrokerProvider`. The defining Matter operation —
|
|
199027
200256
|
* commissioning — is surfaced through `publish` with
|
|
199028
|
-
* `target: { action: 'commissionNode' }` and `payload: { pairingCode }`.
|
|
199029
|
-
*
|
|
199030
|
-
* preserved on an empty round-trip.
|
|
200257
|
+
* `target: { action: 'commissionNode' }` and `payload: { pairingCode }`.
|
|
200258
|
+
* `threadDataset` and `wifiPassword` are redacted on settings reads and
|
|
200259
|
+
* preserved on an empty round-trip. Fabric keys stay in matter.js storage.
|
|
199031
200260
|
*/
|
|
199032
200261
|
function buildMatterBrokerProvider(deps) {
|
|
199033
200262
|
const { ownerAddonId, registry, getBrokers, persistBrokers, cascadeRemoveDevices, logger } = deps;
|
|
199034
200263
|
const owns = (id) => getBrokers().some((b) => b.id === id);
|
|
199035
|
-
const redact = (entry) => (
|
|
199036
|
-
...entry.connection,
|
|
199037
|
-
wifiPassword: ""
|
|
199038
|
-
});
|
|
200264
|
+
const redact = (entry) => publicMatterConnection(entry.connection);
|
|
199039
200265
|
return {
|
|
199040
200266
|
list: async ({ kind }) => {
|
|
199041
200267
|
if (kind && kind !== MATTER_KIND) return [];
|
|
@@ -199103,10 +200329,7 @@ function buildMatterBrokerProvider(deps) {
|
|
|
199103
200329
|
const existing = getBrokers().find((b) => b.id === id);
|
|
199104
200330
|
if (!existing) return;
|
|
199105
200331
|
const parsed = settingsToMatterConnection(settings);
|
|
199106
|
-
const merged =
|
|
199107
|
-
...parsed,
|
|
199108
|
-
wifiPassword: parsed.wifiPassword.length > 0 ? parsed.wifiPassword : existing.connection.wifiPassword
|
|
199109
|
-
};
|
|
200332
|
+
const merged = mergeMatterSecrets(existing.connection, parsed);
|
|
199110
200333
|
const updated = await registry.updateEntry(id, merged);
|
|
199111
200334
|
await persistBrokers(getBrokers().map((b) => b.id === id ? updated : b));
|
|
199112
200335
|
},
|
|
@@ -199142,7 +200365,7 @@ function buildMatterBrokerProvider(deps) {
|
|
|
199142
200365
|
if (!owns(brokerId)) throw new Error(`matter: unknown broker ${brokerId}`);
|
|
199143
200366
|
const action = typeof target["action"] === "string" ? target["action"] : void 0;
|
|
199144
200367
|
if (action === "commissionNode") {
|
|
199145
|
-
const code =
|
|
200368
|
+
const code = pairingCodeFromPayload(payload);
|
|
199146
200369
|
parsePairingCode(code);
|
|
199147
200370
|
return registry.commissionNode(brokerId, code);
|
|
199148
200371
|
}
|
|
@@ -199150,13 +200373,23 @@ function buildMatterBrokerProvider(deps) {
|
|
|
199150
200373
|
},
|
|
199151
200374
|
subscribe: async () => ({ subscriptionId: "" }),
|
|
199152
200375
|
unsubscribe: async () => void 0,
|
|
199153
|
-
getState: async () =>
|
|
200376
|
+
getState: async ({ brokerId, key }) => {
|
|
200377
|
+
if (key !== "commission") return null;
|
|
200378
|
+
return registry.getCommissionProgress(brokerId);
|
|
200379
|
+
},
|
|
199154
200380
|
getStatus: async () => ({
|
|
199155
200381
|
brokerCount: registry.size(),
|
|
199156
200382
|
connectedCount: registry.connectedCount()
|
|
199157
200383
|
})
|
|
199158
200384
|
};
|
|
199159
200385
|
}
|
|
200386
|
+
function pairingCodeFromPayload(payload) {
|
|
200387
|
+
if (typeof payload !== "object" || payload === null || !("pairingCode" in payload)) return "";
|
|
200388
|
+
const code = payload.pairingCode;
|
|
200389
|
+
if (typeof code === "string") return code;
|
|
200390
|
+
if (typeof code === "number" && Number.isFinite(code)) return String(code);
|
|
200391
|
+
return "";
|
|
200392
|
+
}
|
|
199160
200393
|
//#endregion
|
|
199161
200394
|
//#region src/matter-discovery.ts
|
|
199162
200395
|
/**
|
|
@@ -199387,6 +200620,27 @@ function setBrokerDevicesOnline(devices, brokerId, online) {
|
|
|
199387
200620
|
return count;
|
|
199388
200621
|
}
|
|
199389
200622
|
//#endregion
|
|
200623
|
+
//#region src/matter-lock-command.ts
|
|
200624
|
+
/**
|
|
200625
|
+
* Decide the command arguments. `pinRequired` comes from the live
|
|
200626
|
+
* RequirePinForRemoteOperation attribute, not from a stored secret.
|
|
200627
|
+
*/
|
|
200628
|
+
function planDoorLockCommand(input) {
|
|
200629
|
+
const code = input.code?.trim() ?? "";
|
|
200630
|
+
if (input.pinRequired && code.length === 0) return {
|
|
200631
|
+
ok: false,
|
|
200632
|
+
reason: "pin-required"
|
|
200633
|
+
};
|
|
200634
|
+
if (code.length > 0) return {
|
|
200635
|
+
ok: true,
|
|
200636
|
+
args: { pinCode: code }
|
|
200637
|
+
};
|
|
200638
|
+
return {
|
|
200639
|
+
ok: true,
|
|
200640
|
+
args: {}
|
|
200641
|
+
};
|
|
200642
|
+
}
|
|
200643
|
+
//#endregion
|
|
199390
200644
|
//#region src/devices/matter-endpoint-device.ts
|
|
199391
200645
|
/**
|
|
199392
200646
|
* Persisted config every Matter endpoint child carries. `nodeId`/`endpointId`
|
|
@@ -199478,7 +200732,8 @@ var COLD_POWER = { lastFetchedAt: 0 };
|
|
|
199478
200732
|
* arrives, each cap reads its cold-start default.
|
|
199479
200733
|
*/
|
|
199480
200734
|
var MatterEndpointDevice = class extends BaseDevice {
|
|
199481
|
-
|
|
200735
|
+
/** Live RequirePinForRemoteOperation. Commands read this, not a stored PIN. */
|
|
200736
|
+
pinRequired = false;
|
|
199482
200737
|
brokerId;
|
|
199483
200738
|
nodeId;
|
|
199484
200739
|
endpointId;
|
|
@@ -199492,12 +200747,17 @@ var MatterEndpointDevice = class extends BaseDevice {
|
|
|
199492
200747
|
this.nodeId = persisted.nodeId;
|
|
199493
200748
|
this.endpointId = persisted.endpointId;
|
|
199494
200749
|
this.caps = persisted.capabilities.filter(isKnownCap);
|
|
200750
|
+
this.pinRequired = matterNodes.getAttribute(this.brokerId, this.nodeId, this.endpointId, MatterClusterId.DoorLock, MatterAttributeId.RequirePinForRemoteOperation) === true;
|
|
199495
200751
|
this.online = matterNodes.getNode(this.brokerId, this.nodeId)?.online ?? true;
|
|
199496
200752
|
this.updateSourceInfo({
|
|
199497
200753
|
id: `${this.nodeId}:${this.endpointId}`,
|
|
199498
200754
|
system: "matter"
|
|
199499
200755
|
});
|
|
199500
200756
|
}
|
|
200757
|
+
/** PIN-required locks advertise the feature the lock UI already understands. */
|
|
200758
|
+
get features() {
|
|
200759
|
+
return this.pinRequired ? [DeviceFeature.LockPinRequired] : [];
|
|
200760
|
+
}
|
|
199501
200761
|
async onActivate() {
|
|
199502
200762
|
await super.onActivate();
|
|
199503
200763
|
for (const cap of this.caps) {
|
|
@@ -199525,7 +200785,29 @@ var MatterEndpointDevice = class extends BaseDevice {
|
|
|
199525
200785
|
value: report.value
|
|
199526
200786
|
});
|
|
199527
200787
|
if (decoded === null) return;
|
|
200788
|
+
if (decoded.detail === "pin-required" || decoded.detail === "pin-not-required") {
|
|
200789
|
+
const next = decoded.detail === "pin-required";
|
|
200790
|
+
if (next !== this.pinRequired) {
|
|
200791
|
+
this.pinRequired = next;
|
|
200792
|
+
this.ctx.logger.info("Matter lock PIN requirement changed", {
|
|
200793
|
+
tags: { deviceId: this.id },
|
|
200794
|
+
meta: {
|
|
200795
|
+
nodeId: this.nodeId,
|
|
200796
|
+
endpointId: this.endpointId,
|
|
200797
|
+
pinRequired: next
|
|
200798
|
+
}
|
|
200799
|
+
});
|
|
200800
|
+
}
|
|
200801
|
+
} else if (decoded.detail !== void 0) this.ctx.logger.info("Matter lock detail", {
|
|
200802
|
+
tags: { deviceId: this.id },
|
|
200803
|
+
meta: {
|
|
200804
|
+
nodeId: this.nodeId,
|
|
200805
|
+
endpointId: this.endpointId,
|
|
200806
|
+
detail: decoded.detail
|
|
200807
|
+
}
|
|
200808
|
+
});
|
|
199528
200809
|
if (!this.registeredCaps.has(decoded.cap)) return;
|
|
200810
|
+
if (Object.keys(decoded.patch).length === 0) return;
|
|
199529
200811
|
this.runtimeState.patchCapState(CAP_SLICE_NAME[decoded.cap], decoded.patch);
|
|
199530
200812
|
}
|
|
199531
200813
|
/** Invoke a cluster command on this endpoint via the live controller. */
|
|
@@ -199621,30 +200903,52 @@ var MatterEndpointDevice = class extends BaseDevice {
|
|
|
199621
200903
|
};
|
|
199622
200904
|
this.ctx.registerNativeCap(lockControlCapability, {
|
|
199623
200905
|
getStatus: async () => this.runtimeState.getCapState("lock-control") ?? COLD,
|
|
199624
|
-
lock: async () => {
|
|
199625
|
-
await this.
|
|
199626
|
-
this.runtimeState.setCapState("lock-control", {
|
|
199627
|
-
state: "locked",
|
|
199628
|
-
lastChangedAt: Date.now()
|
|
199629
|
-
});
|
|
200906
|
+
lock: async ({ code }) => {
|
|
200907
|
+
await this.invokeLock("lockDoor", "locking", code);
|
|
199630
200908
|
},
|
|
199631
|
-
unlock: async () => {
|
|
199632
|
-
await this.
|
|
199633
|
-
this.runtimeState.setCapState("lock-control", {
|
|
199634
|
-
state: "unlocked",
|
|
199635
|
-
lastChangedAt: Date.now()
|
|
199636
|
-
});
|
|
200909
|
+
unlock: async ({ code }) => {
|
|
200910
|
+
await this.invokeLock("unlockDoor", "unlocking", code);
|
|
199637
200911
|
},
|
|
199638
200912
|
open: async () => {
|
|
199639
|
-
await this.
|
|
199640
|
-
this.runtimeState.setCapState("lock-control", {
|
|
199641
|
-
state: "unlocked",
|
|
199642
|
-
lastChangedAt: Date.now()
|
|
199643
|
-
});
|
|
200913
|
+
await this.invokeLock("unlockDoor", "unlocking", void 0);
|
|
199644
200914
|
}
|
|
199645
200915
|
});
|
|
199646
200916
|
this.runtimeState.setCapState("lock-control", COLD);
|
|
199647
200917
|
}
|
|
200918
|
+
/**
|
|
200919
|
+
* Send lockDoor / unlockDoor. The final locked/unlocked state arrives on the
|
|
200920
|
+
* attribute subscription — this method only records the in-flight transition.
|
|
200921
|
+
* A PIN is forwarded on the command and nowhere else.
|
|
200922
|
+
*/
|
|
200923
|
+
async invokeLock(commandName, pending, code) {
|
|
200924
|
+
const plan = planDoorLockCommand({
|
|
200925
|
+
pinRequired: this.pinRequired,
|
|
200926
|
+
code
|
|
200927
|
+
});
|
|
200928
|
+
if (!plan.ok) {
|
|
200929
|
+
this.ctx.logger.warn("Matter lock command refused: PIN required and none was provided", {
|
|
200930
|
+
tags: { deviceId: this.id },
|
|
200931
|
+
meta: {
|
|
200932
|
+
nodeId: this.nodeId,
|
|
200933
|
+
endpointId: this.endpointId,
|
|
200934
|
+
commandName
|
|
200935
|
+
}
|
|
200936
|
+
});
|
|
200937
|
+
throw new Error("matter-broker: this lock requires a PIN for remote operation");
|
|
200938
|
+
}
|
|
200939
|
+
const previous = this.runtimeState.getCapState("lock-control");
|
|
200940
|
+
this.runtimeState.setCapState("lock-control", {
|
|
200941
|
+
state: pending,
|
|
200942
|
+
lastChangedAt: Date.now()
|
|
200943
|
+
});
|
|
200944
|
+
try {
|
|
200945
|
+
const args = "pinCode" in plan.args ? plan.args : void 0;
|
|
200946
|
+
await this.invoke(MatterClusterId.DoorLock, commandName, args);
|
|
200947
|
+
} catch (err) {
|
|
200948
|
+
if (previous !== void 0) this.runtimeState.setCapState("lock-control", previous);
|
|
200949
|
+
throw err;
|
|
200950
|
+
}
|
|
200951
|
+
}
|
|
199648
200952
|
registerCover() {
|
|
199649
200953
|
const COLD = {
|
|
199650
200954
|
state: "closed",
|
|
@@ -199865,11 +201169,16 @@ var MatterNodeDevice = class extends BaseDevice {
|
|
|
199865
201169
|
this.nodeId = cfg.nodeId;
|
|
199866
201170
|
this.integrationId = cfg.integrationId;
|
|
199867
201171
|
this.online = matterNodes.getNode(this.brokerId, this.nodeId)?.online ?? false;
|
|
201172
|
+
matterNodes.bindDevice(this.nodeId, this.id);
|
|
199868
201173
|
this.updateSourceInfo({
|
|
199869
201174
|
id: this.nodeId,
|
|
199870
201175
|
system: "matter"
|
|
199871
201176
|
});
|
|
199872
201177
|
}
|
|
201178
|
+
async removeDevice() {
|
|
201179
|
+
matterNodes.unbindDevice(this.nodeId);
|
|
201180
|
+
await super.removeDevice();
|
|
201181
|
+
}
|
|
199873
201182
|
getAccessoryChildren() {
|
|
199874
201183
|
const specs = [];
|
|
199875
201184
|
for (const endpoint of this.config.values.endpoints) {
|