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