@camstack/server 1.2.821 → 1.2.823
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 +12 -0
- package/dist/api/trpc/generated-cap-routers.js +20 -0
- package/package.json +9 -10
- package/system/dist/addon-runner.js +18 -13
- package/system/dist/addon-runner.mjs +19 -14
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/{agent-https-N6Or6UAu.mjs → agent-https-CDl7mB_F.mjs} +1 -1
- package/system/dist/{agent-https-Bp5yzi8b.js → agent-https-Df53Fvk1.js} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composed-device-set.d.ts +5 -1
- package/system/dist/builtins/composer/composed-device.d.ts +4 -0
- package/system/dist/builtins/composer/composed-name.d.ts +30 -0
- package/system/dist/builtins/composer/composer.addon.js +94 -6
- package/system/dist/builtins/composer/composer.addon.mjs +94 -6
- package/system/dist/builtins/composer/composer.d.ts +13 -0
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/actions-service.d.ts +16 -0
- package/system/dist/builtins/core-blocks/composition-api.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +214 -8
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +214 -8
- package/system/dist/builtins/core-blocks/device-template-door.d.ts +25 -0
- package/system/dist/builtins/core-blocks/fan-presets-service.d.ts +5 -0
- package/system/dist/builtins/core-blocks/rename-composition-block.d.ts +16 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-engine.d.ts +5 -0
- package/system/dist/builtins/core-blocks/step-condition-door.d.ts +19 -0
- package/system/dist/builtins/core-blocks/sync-composed-device-name.d.ts +19 -0
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.d.ts +7 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +691 -4
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +689 -3
- package/system/dist/builtins/device-manager/device-template/template-host.d.ts +60 -0
- package/system/dist/builtins/device-manager/device-template-actions.d.ts +33 -0
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +10 -10
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +9 -9
- package/system/dist/builtins/system-config/system-config.addon.mjs +287 -287
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-4lB0sLCf.js → capture-engine-C0Z5rwCO.js} +1 -1
- package/system/dist/{capture-engine-Cz7z5d36.mjs → capture-engine-D_GQBgrZ.mjs} +1 -1
- package/system/dist/{composition-sources-C9gEj25e.js → composition-sources-DIZx3mW3.js} +1 -1
- package/system/dist/{composition-sources-C0e2g_VP.mjs → composition-sources-mx-2yCDv.mjs} +1 -1
- package/system/dist/{constants-CZMy7dor.mjs → constants-BQlx9HDp.mjs} +1 -1
- package/system/dist/{constants-Cq3B9yzj.js → constants-CAOcKiWT.js} +1 -1
- package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
- package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
- package/system/dist/{device-ca-BenyQXJV.js → device-ca-93LsCF_Q.js} +1 -1
- package/system/dist/{device-ca-BmQ6N-A-.mjs → device-ca-CK6GTnNh.mjs} +1 -1
- package/system/dist/device-template-worker.js +5 -7032
- package/system/dist/device-template-worker.mjs +1 -7026
- package/system/dist/{dist-DuKMbGBM.mjs → dist-BQiyo22b.mjs} +667 -50
- package/system/dist/{dist-M5VX8Hqf.js → dist-izXDzt4g.js} +714 -49
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-k3pOKWyZ.js → hub-mdns-ciao-Dt_tgvol.js} +2 -2
- package/system/dist/{hub-mdns-ciao-CXBfBwAy.mjs → hub-mdns-ciao-srpOrqIP.mjs} +2 -2
- package/system/dist/index.js +26 -21
- package/system/dist/index.mjs +238 -233
- package/system/dist/{legacy-integration-rows-door-mIpR3e6X.js → legacy-integration-rows-door-BH43eDu6.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-C13OeuW9.mjs → legacy-integration-rows-door-wu2GWY6U.mjs} +1 -1
- package/system/dist/rename-composition-block-6oLQVzft.js +112 -0
- package/system/dist/rename-composition-block-CH6ZoSJA.mjs +101 -0
- package/system/dist/{restore-archive-DDeQFJN5.mjs → restore-archive-C4rR2SYV.mjs} +154 -154
- package/system/dist/{restore-archive-CCgt7SZ8.js → restore-archive-DpZ2PbLN.js} +7 -7
- package/system/dist/template-protocol-BmMM5VBf.mjs +7033 -0
- package/system/dist/template-protocol-CTP4eAo_.js +7059 -0
- package/system/dist/{wal-maintenance-Cj7xe4wN.mjs → wal-maintenance-CNfp0HHX.mjs} +0 -0
- package/system/dist/{wal-maintenance-D5M6hl53.js → wal-maintenance-DAA2qJja.js} +0 -0
- package/system/package.json +1 -1
|
@@ -803,7 +803,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
803
803
|
return EventCategory;
|
|
804
804
|
}({});
|
|
805
805
|
//#endregion
|
|
806
|
-
//#region ../types/dist/
|
|
806
|
+
//#region ../types/dist/composed-stable-id-DLcPInGv.mjs
|
|
807
807
|
/**
|
|
808
808
|
import { errMsg } from '@camstack/types'
|
|
809
809
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -1214,8 +1214,14 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1214
1214
|
DeviceRole["IrTransmitter"] = "ir-transmitter";
|
|
1215
1215
|
return DeviceRole;
|
|
1216
1216
|
}({});
|
|
1217
|
+
/**
|
|
1218
|
+
* A composed device's stableId is this prefix plus the block id. Its own module,
|
|
1219
|
+
* free of zod, so the addon runner can read it through `@camstack/types/addon`
|
|
1220
|
+
* without loading the schema barrel (D28).
|
|
1221
|
+
*/
|
|
1222
|
+
var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
|
|
1217
1223
|
//#endregion
|
|
1218
|
-
//#region ../types/dist/sleep-
|
|
1224
|
+
//#region ../types/dist/sleep-B36hHDDz.mjs
|
|
1219
1225
|
/**
|
|
1220
1226
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
1221
1227
|
* window to float samples (D455).
|
|
@@ -3342,7 +3348,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
3342
3348
|
this.name = "SecretOverwriteRefusedError";
|
|
3343
3349
|
}
|
|
3344
3350
|
};
|
|
3345
|
-
function isRecord$3(value) {
|
|
3351
|
+
function isRecord$3$1(value) {
|
|
3346
3352
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3347
3353
|
}
|
|
3348
3354
|
function resolvedValue(pass, marker) {
|
|
@@ -3371,7 +3377,7 @@ function inArray(pass, incoming, stored) {
|
|
|
3371
3377
|
return incoming.map((item, index) => {
|
|
3372
3378
|
const twin = stored[index];
|
|
3373
3379
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
3374
|
-
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
3380
|
+
if (isRecord$3$1(item) && isRecord$3$1(twin)) return inArrayRow(pass, item, twin);
|
|
3375
3381
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
3376
3382
|
return item;
|
|
3377
3383
|
});
|
|
@@ -3382,7 +3388,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
3382
3388
|
const twin = stored[key];
|
|
3383
3389
|
if (isSecretMarker(twin)) {
|
|
3384
3390
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
3385
|
-
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
3391
|
+
} else if (isRecord$3$1(value) && isRecord$3$1(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
3386
3392
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
3387
3393
|
}
|
|
3388
3394
|
return out;
|
|
@@ -3390,7 +3396,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
3390
3396
|
async function walk(pass, incoming, stored) {
|
|
3391
3397
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
3392
3398
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
3393
|
-
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
3399
|
+
if (!isRecord$3$1(incoming) || !isRecord$3$1(stored)) return incoming;
|
|
3394
3400
|
const out = { ...incoming };
|
|
3395
3401
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
3396
3402
|
return out;
|
|
@@ -3421,7 +3427,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
3421
3427
|
function isJsonEqual(a, b) {
|
|
3422
3428
|
if (Object.is(a, b)) return true;
|
|
3423
3429
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
3424
|
-
if (isRecord$3(a) && isRecord$3(b)) {
|
|
3430
|
+
if (isRecord$3$1(a) && isRecord$3$1(b)) {
|
|
3425
3431
|
const keys = Object.keys(a);
|
|
3426
3432
|
if (keys.length !== Object.keys(b).length) return false;
|
|
3427
3433
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -3445,7 +3451,7 @@ function markerKeysOf(blob, owner) {
|
|
|
3445
3451
|
}
|
|
3446
3452
|
function nodeFromStored(value, owner) {
|
|
3447
3453
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
3448
|
-
if (!isRecord$3(value)) return null;
|
|
3454
|
+
if (!isRecord$3$1(value)) return null;
|
|
3449
3455
|
const children = /* @__PURE__ */ new Map();
|
|
3450
3456
|
for (const [key, child] of Object.entries(value)) {
|
|
3451
3457
|
const node = nodeFromStored(child, owner);
|
|
@@ -13805,7 +13811,7 @@ function sleep(ms) {
|
|
|
13805
13811
|
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
13806
13812
|
}
|
|
13807
13813
|
//#endregion
|
|
13808
|
-
//#region ../types/dist/composition-
|
|
13814
|
+
//#region ../types/dist/composition-BFJq1Y88.mjs
|
|
13809
13815
|
var AUDIO_ENCODER_BY_CODEC = {
|
|
13810
13816
|
opus: "libopus",
|
|
13811
13817
|
aac: "aac",
|
|
@@ -16200,8 +16206,6 @@ function helperMembers(spec) {
|
|
|
16200
16206
|
*/
|
|
16201
16207
|
/** The owner of every composed device: the `composer` builtin. */
|
|
16202
16208
|
var COMPOSER_ADDON_ID = "composer";
|
|
16203
|
-
/** A composed device's stableId is this prefix plus the block id. */
|
|
16204
|
-
var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
|
|
16205
16209
|
/** Longest snippet a `code` source may carry (slice 4). */
|
|
16206
16210
|
var MAX_COMPOSITION_CODE_LENGTH = 2e4;
|
|
16207
16211
|
/** One field of one capability of one source device. */
|
|
@@ -43881,11 +43885,35 @@ function normalizeStepTargets(steps) {
|
|
|
43881
43885
|
/**
|
|
43882
43886
|
* The steps an internal Action may contain: cap and wait, and nothing that can
|
|
43883
43887
|
* call back into an Action — so an Action can never reach itself (no cycles).
|
|
43888
|
+
* This is the LEAF shape: no condition of its own.
|
|
43889
|
+
*/
|
|
43890
|
+
var LeafActionStepSchema = zod.z.discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCapStepSchema]);
|
|
43891
|
+
/**
|
|
43892
|
+
* The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
|
|
43893
|
+
* on the state mirror when the step is reached; `else` runs when it is false.
|
|
43894
|
+
* An `else` holds leaf steps only — the nesting is bounded at ONE level, so a
|
|
43895
|
+
* branch can never grow a tree the trace has to draw.
|
|
43884
43896
|
*/
|
|
43885
|
-
var
|
|
43897
|
+
var stepGuardShape = {
|
|
43898
|
+
if: AutomationWhenSchema.optional(),
|
|
43899
|
+
else: zod.z.array(LeafActionStepSchema).max(10).optional()
|
|
43900
|
+
};
|
|
43901
|
+
var elseNeedsIf = {
|
|
43902
|
+
message: "an else list needs the condition it is the other side of (if)",
|
|
43903
|
+
path: ["else"]
|
|
43904
|
+
};
|
|
43905
|
+
var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
43906
|
+
var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
|
|
43907
|
+
message: "a cap step needs a target",
|
|
43908
|
+
path: ["target"]
|
|
43909
|
+
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
43910
|
+
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
43911
|
+
path: ["actionId"]
|
|
43912
|
+
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
43913
|
+
var ActionStepSchema = zod.z.discriminatedUnion("kind", [GuardedWaitStepSchema, GuardedCapStepSchema]);
|
|
43886
43914
|
var AutomationActionSchema = zod.z.discriminatedUnion("kind", [
|
|
43887
|
-
|
|
43888
|
-
|
|
43915
|
+
GuardedWaitStepSchema,
|
|
43916
|
+
GuardedCapStepSchema,
|
|
43889
43917
|
zod.z.object({
|
|
43890
43918
|
kind: zod.z.literal("action"),
|
|
43891
43919
|
/** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
|
|
@@ -44804,7 +44832,7 @@ var StepDeviceTraceSchema = zod.z.object({
|
|
|
44804
44832
|
outcome: zod.z.enum(["ok", "error"]),
|
|
44805
44833
|
message: zod.z.string().optional()
|
|
44806
44834
|
});
|
|
44807
|
-
var
|
|
44835
|
+
var StepTraceBaseSchema = zod.z.object({
|
|
44808
44836
|
/** `actions.<i>` */
|
|
44809
44837
|
path: zod.z.string().min(1),
|
|
44810
44838
|
kind: zod.z.string().min(1),
|
|
@@ -44823,15 +44851,35 @@ var AutomationStepTraceSchema = zod.z.object({
|
|
|
44823
44851
|
* is shown as {@link REDACTED_ARG}. Absent on traces written before it existed.
|
|
44824
44852
|
*/
|
|
44825
44853
|
args: zod.z.record(zod.z.string(), TraceValueSchema).optional(),
|
|
44826
|
-
/**
|
|
44854
|
+
/**
|
|
44855
|
+
* The device values a templated arg printed as `—`, one `ref: reason` each
|
|
44856
|
+
* (D1021): why a sentence says "—" where a number was expected. Bounded.
|
|
44857
|
+
*/
|
|
44858
|
+
templates: zod.z.array(zod.z.string()).max(20).optional(),
|
|
44859
|
+
/**
|
|
44860
|
+
* What the step's own `if` read when the step was reached (#472): `true` the
|
|
44861
|
+
* step ran, `false` its `else` ran (or nothing did), `unknown` a state leaf
|
|
44862
|
+
* could not be read, so NEITHER side ran. Absent on an unguarded step.
|
|
44863
|
+
*/
|
|
44864
|
+
condition: zod.z.enum([
|
|
44865
|
+
"true",
|
|
44866
|
+
"false",
|
|
44867
|
+
"unknown"
|
|
44868
|
+
]).optional(),
|
|
44869
|
+
/** Why the condition read what it read, in the evaluator's own words. */
|
|
44870
|
+
conditionReason: zod.z.string().optional(),
|
|
44871
|
+
/** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. */
|
|
44827
44872
|
outcome: zod.z.enum([
|
|
44828
44873
|
"ok",
|
|
44829
44874
|
"error",
|
|
44830
44875
|
"not-run",
|
|
44831
|
-
"empty"
|
|
44876
|
+
"empty",
|
|
44877
|
+
"skipped"
|
|
44832
44878
|
]),
|
|
44833
44879
|
message: zod.z.string().optional()
|
|
44834
44880
|
});
|
|
44881
|
+
/** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
|
|
44882
|
+
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({ else: zod.z.array(StepTraceBaseSchema).optional() });
|
|
44835
44883
|
var AutomationRunTraceSchema = zod.z.object({
|
|
44836
44884
|
runId: zod.z.string().min(1),
|
|
44837
44885
|
startedAt: zod.z.number(),
|
|
@@ -45139,6 +45187,7 @@ zod.z.enum([
|
|
|
45139
45187
|
"invalid-variables",
|
|
45140
45188
|
"invalid-steps",
|
|
45141
45189
|
"not-linked",
|
|
45190
|
+
"template-scope",
|
|
45142
45191
|
"busy"
|
|
45143
45192
|
]);
|
|
45144
45193
|
/**
|
|
@@ -45163,9 +45212,50 @@ var ActionRunChangedSchema = zod.z.object({
|
|
|
45163
45212
|
lastRunAt: zod.z.number().nullable(),
|
|
45164
45213
|
lastError: zod.z.string().nullable()
|
|
45165
45214
|
});
|
|
45215
|
+
/**
|
|
45216
|
+
* The guard of a conditional step (#472): the step's `if` is the ONE `when`
|
|
45217
|
+
* tree (D980), read on a {@link ConditionMirror} filled for exactly the leaves
|
|
45218
|
+
* the tree names, at the moment the step is reached. A state that cannot be
|
|
45219
|
+
* read is UNKNOWN, and unknown runs neither side (D49: a failed read changes
|
|
45220
|
+
* nothing, and never decides a branch).
|
|
45221
|
+
*/
|
|
45222
|
+
/** Fill a mirror for the tree's leaves from `fetchers` and judge it NOW. */
|
|
45223
|
+
async function evaluateStepCondition(when, fetchers, now = Date.now) {
|
|
45224
|
+
const mirror = new ConditionMirror(collectWhenMirrorSources(when));
|
|
45225
|
+
await mirror.refresh(fetchers);
|
|
45226
|
+
const evaluation = evaluateWhenTree(when, mirror, now());
|
|
45227
|
+
const first = evaluation.nodes.filter((n) => n.outcome !== "pass").map((n) => n.reason)[0];
|
|
45228
|
+
if (evaluation.unknown) return {
|
|
45229
|
+
result: "unknown",
|
|
45230
|
+
reason: `a state the condition reads is not known${first === void 0 ? "" : ` (${first})`}`
|
|
45231
|
+
};
|
|
45232
|
+
return evaluation.pass ? {
|
|
45233
|
+
result: "true",
|
|
45234
|
+
reason: "the condition holds"
|
|
45235
|
+
} : {
|
|
45236
|
+
result: "false",
|
|
45237
|
+
reason: first ?? "the condition does not hold"
|
|
45238
|
+
};
|
|
45239
|
+
}
|
|
45166
45240
|
function errorMessage(err) {
|
|
45167
45241
|
return err instanceof Error ? err.message : String(err);
|
|
45168
45242
|
}
|
|
45243
|
+
/** A guard that throws is an unknown, never a crash of the run. */
|
|
45244
|
+
async function readGuard(guard) {
|
|
45245
|
+
try {
|
|
45246
|
+
return await guard();
|
|
45247
|
+
} catch (err) {
|
|
45248
|
+
return {
|
|
45249
|
+
result: "unknown",
|
|
45250
|
+
reason: `the condition could not be read: ${errorMessage(err)}`
|
|
45251
|
+
};
|
|
45252
|
+
}
|
|
45253
|
+
}
|
|
45254
|
+
/** The else level of a trace is one level deep: a nested trace carries no `else` of its own. */
|
|
45255
|
+
function withoutElse(trace) {
|
|
45256
|
+
const { else: _else, ...rest } = trace;
|
|
45257
|
+
return rest;
|
|
45258
|
+
}
|
|
45169
45259
|
async function runSteps(steps, options) {
|
|
45170
45260
|
const traces = [];
|
|
45171
45261
|
let failed = false;
|
|
@@ -45183,10 +45273,57 @@ async function runSteps(steps, options) {
|
|
|
45183
45273
|
continue;
|
|
45184
45274
|
}
|
|
45185
45275
|
const startedAt = options.now();
|
|
45276
|
+
let guardTrace = {};
|
|
45277
|
+
if (step.guard !== void 0) {
|
|
45278
|
+
const verdict = await readGuard(step.guard);
|
|
45279
|
+
guardTrace = {
|
|
45280
|
+
condition: verdict.result,
|
|
45281
|
+
conditionReason: verdict.reason
|
|
45282
|
+
};
|
|
45283
|
+
if (verdict.result === "unknown") options.onGuardUnknown?.({
|
|
45284
|
+
index,
|
|
45285
|
+
path,
|
|
45286
|
+
reason: verdict.reason,
|
|
45287
|
+
deviceId: step.meta.deviceId
|
|
45288
|
+
});
|
|
45289
|
+
if (verdict.result !== "true") {
|
|
45290
|
+
const branch = verdict.result === "false" ? step.otherwise ?? [] : [];
|
|
45291
|
+
if (branch.length === 0) {
|
|
45292
|
+
traces.push({
|
|
45293
|
+
...step.meta,
|
|
45294
|
+
...guardTrace,
|
|
45295
|
+
path,
|
|
45296
|
+
startedAt,
|
|
45297
|
+
endedAt: options.now(),
|
|
45298
|
+
outcome: "skipped",
|
|
45299
|
+
message: verdict.result === "unknown" ? `not run: ${verdict.reason}` : `not run: the condition is false (${verdict.reason})`
|
|
45300
|
+
});
|
|
45301
|
+
continue;
|
|
45302
|
+
}
|
|
45303
|
+
const sub = await runSteps(branch, {
|
|
45304
|
+
...options,
|
|
45305
|
+
pathPrefix: `${path}.else`
|
|
45306
|
+
});
|
|
45307
|
+
if (sub.failed) failed = true;
|
|
45308
|
+
else if (sub.aborted) aborted = true;
|
|
45309
|
+
traces.push({
|
|
45310
|
+
...step.meta,
|
|
45311
|
+
...guardTrace,
|
|
45312
|
+
path,
|
|
45313
|
+
startedAt,
|
|
45314
|
+
endedAt: options.now(),
|
|
45315
|
+
outcome: sub.failed ? "error" : "ok",
|
|
45316
|
+
...sub.failed ? { message: "an else step failed" } : {},
|
|
45317
|
+
else: sub.steps.map(withoutElse)
|
|
45318
|
+
});
|
|
45319
|
+
continue;
|
|
45320
|
+
}
|
|
45321
|
+
}
|
|
45186
45322
|
let deviceId = step.meta.deviceId;
|
|
45187
45323
|
let sent;
|
|
45188
45324
|
const perDevice = [];
|
|
45189
45325
|
let emptyReason;
|
|
45326
|
+
let templateNotes = [];
|
|
45190
45327
|
const scope = {
|
|
45191
45328
|
setDeviceId: (id) => {
|
|
45192
45329
|
deviceId = id;
|
|
@@ -45199,8 +45336,12 @@ async function runSteps(steps, options) {
|
|
|
45199
45336
|
},
|
|
45200
45337
|
setArgs: (args) => {
|
|
45201
45338
|
sent = args;
|
|
45339
|
+
},
|
|
45340
|
+
setTemplateNotes: (notes) => {
|
|
45341
|
+
templateNotes = notes.slice(0, 20);
|
|
45202
45342
|
}
|
|
45203
45343
|
};
|
|
45344
|
+
const templatesTrace = () => templateNotes.length === 0 ? {} : { templates: [...templateNotes] };
|
|
45204
45345
|
const argsTrace = () => sent === void 0 ? {} : { args: buildStepArgsTrace(sent) };
|
|
45205
45346
|
const devicesTrace = () => perDevice.length === 0 ? {} : { devices: perDevice.slice(0, 200) };
|
|
45206
45347
|
try {
|
|
@@ -45209,7 +45350,9 @@ async function runSteps(steps, options) {
|
|
|
45209
45350
|
...step.meta,
|
|
45210
45351
|
...deviceId === void 0 || perDevice.length > 1 ? {} : { deviceId },
|
|
45211
45352
|
...argsTrace(),
|
|
45353
|
+
...templatesTrace(),
|
|
45212
45354
|
...devicesTrace(),
|
|
45355
|
+
...guardTrace,
|
|
45213
45356
|
path,
|
|
45214
45357
|
startedAt,
|
|
45215
45358
|
endedAt: options.now(),
|
|
@@ -45229,7 +45372,9 @@ async function runSteps(steps, options) {
|
|
|
45229
45372
|
...step.meta,
|
|
45230
45373
|
...deviceId === void 0 || perDevice.length > 1 ? {} : { deviceId },
|
|
45231
45374
|
...argsTrace(),
|
|
45375
|
+
...templatesTrace(),
|
|
45232
45376
|
...devicesTrace(),
|
|
45377
|
+
...guardTrace,
|
|
45233
45378
|
path,
|
|
45234
45379
|
startedAt,
|
|
45235
45380
|
endedAt: options.now(),
|
|
@@ -45278,6 +45423,125 @@ function resolveStepArgs(value, vars, onMissing) {
|
|
|
45278
45423
|
if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, resolveStepArgs(v, vars, onMissing)]));
|
|
45279
45424
|
return value;
|
|
45280
45425
|
}
|
|
45426
|
+
/** A device template that did not render: the step fails with this, never throws past `runSteps`. */
|
|
45427
|
+
var StepTemplateError = class extends Error {
|
|
45428
|
+
reason;
|
|
45429
|
+
constructor(reason, message) {
|
|
45430
|
+
super(`device template [${reason}]: ${message}`);
|
|
45431
|
+
this.reason = reason;
|
|
45432
|
+
this.name = "StepTemplateError";
|
|
45433
|
+
}
|
|
45434
|
+
};
|
|
45435
|
+
/**
|
|
45436
|
+
* A `{{vars.x}}` slot, set aside while a template renders. The slot carries a
|
|
45437
|
+
* nonce drawn per call, so a device value that happens to contain the sentinel
|
|
45438
|
+
* characters can never name a held variable.
|
|
45439
|
+
*/
|
|
45440
|
+
var VAR_SLOT_OPEN = "";
|
|
45441
|
+
var VAR_SLOT_CLOSE = "";
|
|
45442
|
+
var TEMPLATE_MARKUP_RE = /\{\{|\{%/;
|
|
45443
|
+
function newSlotNonce() {
|
|
45444
|
+
return Math.random().toString(36).slice(2, 12);
|
|
45445
|
+
}
|
|
45446
|
+
function slotPattern(nonce) {
|
|
45447
|
+
return new RegExp(`${VAR_SLOT_OPEN}${nonce}:([A-Za-z_][A-Za-z0-9_]*)${VAR_SLOT_CLOSE}`, "g");
|
|
45448
|
+
}
|
|
45449
|
+
/** True when a string, once its `{{vars.x}}` slots are set aside, still carries template markup. */
|
|
45450
|
+
function carriesDeviceTemplate(text) {
|
|
45451
|
+
return TEMPLATE_MARKUP_RE.test(text.replace(TEMPLATE_RE, ""));
|
|
45452
|
+
}
|
|
45453
|
+
/** Every string in `value` that is a device template (D1021), de-duplicated, in walk order. */
|
|
45454
|
+
function collectDeviceTemplates(value) {
|
|
45455
|
+
const found = /* @__PURE__ */ new Set();
|
|
45456
|
+
const walk = (node) => {
|
|
45457
|
+
if (typeof node === "string") {
|
|
45458
|
+
if (carriesDeviceTemplate(node)) found.add(node);
|
|
45459
|
+
} else if (Array.isArray(node)) for (const item of node) walk(item);
|
|
45460
|
+
else if (node !== null && typeof node === "object") for (const item of Object.values(node)) walk(item);
|
|
45461
|
+
};
|
|
45462
|
+
walk(value);
|
|
45463
|
+
return [...found];
|
|
45464
|
+
}
|
|
45465
|
+
function protectVarSlots(text, nonce) {
|
|
45466
|
+
return text.replace(TEMPLATE_RE, (_m, key) => `${VAR_SLOT_OPEN}${nonce}:${key}${VAR_SLOT_CLOSE}`);
|
|
45467
|
+
}
|
|
45468
|
+
function restoreVarSlots(text, nonce, vars, onMissing) {
|
|
45469
|
+
return text.replace(slotPattern(nonce), (_m, key) => {
|
|
45470
|
+
const v = vars[key];
|
|
45471
|
+
if (v === void 0) {
|
|
45472
|
+
onMissing(key);
|
|
45473
|
+
return "";
|
|
45474
|
+
}
|
|
45475
|
+
return String(v);
|
|
45476
|
+
});
|
|
45477
|
+
}
|
|
45478
|
+
/**
|
|
45479
|
+
* {@link resolveStepArgs} plus the device templates of a step (D1021). A string
|
|
45480
|
+
* that carries `{{ … }}` / `{% … %}` beyond a `{{vars.x}}` slot is rendered by
|
|
45481
|
+
* `render` BEFORE the variables are put in, so a variable's value is data and
|
|
45482
|
+
* never template source (an action variable can come from a non-admin caller).
|
|
45483
|
+
* A refused render, or no renderer, throws {@link StepTemplateError}: the step
|
|
45484
|
+
* fails with the typed reason and nothing is dispatched.
|
|
45485
|
+
*/
|
|
45486
|
+
async function resolveStepArgsWithTemplates(value, vars, onMissing, render) {
|
|
45487
|
+
const nonce = newSlotNonce();
|
|
45488
|
+
const sources = [];
|
|
45489
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
45490
|
+
const hold = (text) => {
|
|
45491
|
+
const known = indexOf.get(text);
|
|
45492
|
+
if (known !== void 0) return known;
|
|
45493
|
+
sources.push(text);
|
|
45494
|
+
indexOf.set(text, sources.length - 1);
|
|
45495
|
+
return sources.length - 1;
|
|
45496
|
+
};
|
|
45497
|
+
class Pending {
|
|
45498
|
+
index;
|
|
45499
|
+
constructor(index) {
|
|
45500
|
+
this.index = index;
|
|
45501
|
+
}
|
|
45502
|
+
}
|
|
45503
|
+
const collect = (node) => {
|
|
45504
|
+
if (isVarRef(node)) return resolveStepArgs(node, vars, onMissing);
|
|
45505
|
+
if (typeof node === "string") return carriesDeviceTemplate(node) ? new Pending(hold(protectVarSlots(node, nonce))) : resolveStepArgs(node, vars, onMissing);
|
|
45506
|
+
if (Array.isArray(node)) return node.map(collect);
|
|
45507
|
+
if (node !== null && typeof node === "object") return Object.fromEntries(Object.entries(node).map(([k, v]) => [k, collect(v)]));
|
|
45508
|
+
return node;
|
|
45509
|
+
};
|
|
45510
|
+
const skeleton = collect(value);
|
|
45511
|
+
if (sources.length === 0) return {
|
|
45512
|
+
value: skeleton,
|
|
45513
|
+
notes: []
|
|
45514
|
+
};
|
|
45515
|
+
if (render === void 0) throw new StepTemplateError("unavailable", "this node has no device template renderer");
|
|
45516
|
+
let answers;
|
|
45517
|
+
try {
|
|
45518
|
+
answers = await render(sources);
|
|
45519
|
+
} catch (err) {
|
|
45520
|
+
throw new StepTemplateError("unavailable", errorMessage(err));
|
|
45521
|
+
}
|
|
45522
|
+
const texts = [];
|
|
45523
|
+
const notes = [];
|
|
45524
|
+
for (const index of sources.keys()) {
|
|
45525
|
+
const answer = answers[index];
|
|
45526
|
+
if (answer === void 0) throw new StepTemplateError("unavailable", `no answer for template ${index + 1}`);
|
|
45527
|
+
if (!answer.ok) throw new StepTemplateError(answer.refusal.reason, answer.refusal.message);
|
|
45528
|
+
texts.push(restoreVarSlots(answer.text, nonce, vars, onMissing));
|
|
45529
|
+
for (const entry of answer.trace) {
|
|
45530
|
+
const note = `${entry.ref}: ${entry.reason}`;
|
|
45531
|
+
if (!notes.includes(note)) notes.push(note);
|
|
45532
|
+
}
|
|
45533
|
+
}
|
|
45534
|
+
const fill = (node) => {
|
|
45535
|
+
if (node instanceof Pending) return texts[node.index] ?? "";
|
|
45536
|
+
if (Array.isArray(node)) return node.map(fill);
|
|
45537
|
+
if (node !== null && typeof node === "object") return Object.fromEntries(Object.entries(node).map(([k, v]) => [k, fill(v)]));
|
|
45538
|
+
return node;
|
|
45539
|
+
};
|
|
45540
|
+
return {
|
|
45541
|
+
value: fill(skeleton),
|
|
45542
|
+
notes
|
|
45543
|
+
};
|
|
45544
|
+
}
|
|
45281
45545
|
function stepMetaOfAction(step) {
|
|
45282
45546
|
if (step.kind === "wait") return { kind: "wait" };
|
|
45283
45547
|
const { target, actionId } = normalizeCapStep(step);
|
|
@@ -45331,19 +45595,36 @@ async function runForDevices(deviceIds, scope, work, concurrency = 4) {
|
|
|
45331
45595
|
* variables. Variables are substituted per step, at the moment it runs, so a
|
|
45332
45596
|
* missing one fails THAT step (traced) and leaves the later ones not-run.
|
|
45333
45597
|
*/
|
|
45598
|
+
/** The guard and the else list of a step, bound to the run (#472); `{}` for an unguarded step. */
|
|
45599
|
+
function guardOf(step, vars, deps) {
|
|
45600
|
+
const when = step.if;
|
|
45601
|
+
if (when === void 0) return {};
|
|
45602
|
+
const evaluate = deps.evaluateCondition;
|
|
45603
|
+
return {
|
|
45604
|
+
guard: async () => evaluate === void 0 ? {
|
|
45605
|
+
result: "unknown",
|
|
45606
|
+
reason: "this consumer has no condition evaluator"
|
|
45607
|
+
} : evaluate(when),
|
|
45608
|
+
...step.else === void 0 ? {} : { otherwise: buildActionSteps(step.else, vars, deps) }
|
|
45609
|
+
};
|
|
45610
|
+
}
|
|
45334
45611
|
function buildActionSteps(steps, vars, deps) {
|
|
45335
45612
|
return steps.map((step) => {
|
|
45613
|
+
const guarded = guardOf(step, vars, deps);
|
|
45336
45614
|
const meta = stepMetaOfAction(step);
|
|
45337
45615
|
if (step.kind === "wait") return {
|
|
45338
45616
|
meta,
|
|
45617
|
+
...guarded,
|
|
45339
45618
|
run: () => deps.sleep(step.seconds * 1e3)
|
|
45340
45619
|
};
|
|
45341
45620
|
const normalized = normalizeCapStep(step);
|
|
45342
45621
|
return {
|
|
45343
45622
|
meta,
|
|
45623
|
+
...guarded,
|
|
45344
45624
|
run: async (scope) => {
|
|
45345
|
-
const
|
|
45346
|
-
|
|
45625
|
+
const templated = await resolveStepArgsWithTemplates(step.args ?? {}, vars, deps.onMissingVar, deps.renderTemplates);
|
|
45626
|
+
if (templated.notes.length > 0) scope.setTemplateNotes(templated.notes);
|
|
45627
|
+
const args = isPlainRecord(templated.value) ? templated.value : {};
|
|
45347
45628
|
const target = await deps.resolveTarget(normalized.target, normalized.actionId, vars, {
|
|
45348
45629
|
actionId: normalized.actionId,
|
|
45349
45630
|
owner: deps.owner
|
|
@@ -53106,6 +53387,25 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
53106
53387
|
}]
|
|
53107
53388
|
}
|
|
53108
53389
|
};
|
|
53390
|
+
/**
|
|
53391
|
+
* Unit meta on runtime-state fields. The composed-device row reads this;
|
|
53392
|
+
* it is not an override list (D944).
|
|
53393
|
+
*/
|
|
53394
|
+
var CAP_RUNTIME_FIELD_UNITS = {
|
|
53395
|
+
"ambient-light-sensor": { illuminance: "lx" },
|
|
53396
|
+
"battery": {
|
|
53397
|
+
level: "%",
|
|
53398
|
+
voltage: "V"
|
|
53399
|
+
},
|
|
53400
|
+
"humidity-sensor": { humidity: "%" },
|
|
53401
|
+
"power-meter": {
|
|
53402
|
+
power: "W",
|
|
53403
|
+
energy: "kWh",
|
|
53404
|
+
voltage: "V",
|
|
53405
|
+
current: "A"
|
|
53406
|
+
},
|
|
53407
|
+
"temperature-sensor": { temperature: "°C" }
|
|
53408
|
+
};
|
|
53109
53409
|
function problem(code, path, message) {
|
|
53110
53410
|
return {
|
|
53111
53411
|
code,
|
|
@@ -57947,6 +58247,161 @@ function checkDeviceAlias(alias, isTaken) {
|
|
|
57947
58247
|
};
|
|
57948
58248
|
}
|
|
57949
58249
|
/**
|
|
58250
|
+
* Device value templates, the parts that need no template engine (D1021).
|
|
58251
|
+
*
|
|
58252
|
+
* A template is plain text with Jinja-style `{{ … }}` / `{% … %}` blocks:
|
|
58253
|
+
* `{{ stufa_veranda.temperature | unit('°F') | round(1) }}`. Devices are named
|
|
58254
|
+
* by their alias (`device-alias.ts`); a field is `alias.field` when the field
|
|
58255
|
+
* name is unique across the device's capabilities, else `alias.<cap>.field`,
|
|
58256
|
+
* and an ambiguous `alias.field` is refused by name.
|
|
58257
|
+
*
|
|
58258
|
+
* The engine itself (nunjucks) lives ONLY in the hub's renderer
|
|
58259
|
+
* (`packages/system/src/builtins/device-manager/device-template/`, guard
|
|
58260
|
+
* `check-device-template-grammar`): it does not sandbox, so it renders only in
|
|
58261
|
+
* a worker thread under a wall-time budget, over frozen plain data. This file
|
|
58262
|
+
* is the shared vocabulary — limits, refusal reasons, the trace, and how a
|
|
58263
|
+
* `(alias, path)` reference resolves against a device's slices.
|
|
58264
|
+
*/
|
|
58265
|
+
var DEVICE_TEMPLATE_MAX_LENGTH = 4096;
|
|
58266
|
+
var DEVICE_TEMPLATE_MAX_OUTPUT = 4096;
|
|
58267
|
+
var DeviceTemplateSchema = zod.z.string().min(1).max(DEVICE_TEMPLATE_MAX_LENGTH);
|
|
58268
|
+
/** The filters a template may use. Anything else is refused at parse time. */
|
|
58269
|
+
var DEVICE_TEMPLATE_FILTERS = [
|
|
58270
|
+
"unit",
|
|
58271
|
+
"round",
|
|
58272
|
+
"default",
|
|
58273
|
+
"since",
|
|
58274
|
+
"ago",
|
|
58275
|
+
"format",
|
|
58276
|
+
"upper",
|
|
58277
|
+
"lower",
|
|
58278
|
+
"title",
|
|
58279
|
+
"capitalize",
|
|
58280
|
+
"trim",
|
|
58281
|
+
"abs",
|
|
58282
|
+
"int",
|
|
58283
|
+
"float",
|
|
58284
|
+
"length",
|
|
58285
|
+
"d",
|
|
58286
|
+
"join",
|
|
58287
|
+
"replace",
|
|
58288
|
+
"first",
|
|
58289
|
+
"last",
|
|
58290
|
+
"sort",
|
|
58291
|
+
"reverse",
|
|
58292
|
+
"sum",
|
|
58293
|
+
"string",
|
|
58294
|
+
"list",
|
|
58295
|
+
"truncate"
|
|
58296
|
+
];
|
|
58297
|
+
var DeviceTemplateRefusalSchema = zod.z.object({
|
|
58298
|
+
reason: zod.z.enum([
|
|
58299
|
+
"too-long",
|
|
58300
|
+
"syntax",
|
|
58301
|
+
"forbidden-syntax",
|
|
58302
|
+
"forbidden-member",
|
|
58303
|
+
"unknown-filter",
|
|
58304
|
+
"ambiguous-field",
|
|
58305
|
+
"busy",
|
|
58306
|
+
"budget-exceeded",
|
|
58307
|
+
"timeout",
|
|
58308
|
+
"output-too-large",
|
|
58309
|
+
"render-failed",
|
|
58310
|
+
"out-of-scope",
|
|
58311
|
+
"unavailable"
|
|
58312
|
+
]),
|
|
58313
|
+
message: zod.z.string()
|
|
58314
|
+
});
|
|
58315
|
+
var DeviceTemplateTraceEntrySchema = zod.z.object({
|
|
58316
|
+
ref: zod.z.string(),
|
|
58317
|
+
reason: zod.z.enum([
|
|
58318
|
+
"unknown-alias",
|
|
58319
|
+
"unknown-field",
|
|
58320
|
+
"no-field",
|
|
58321
|
+
"unavailable"
|
|
58322
|
+
])
|
|
58323
|
+
});
|
|
58324
|
+
var DeviceTemplateRenderSchema = zod.z.discriminatedUnion("ok", [zod.z.object({
|
|
58325
|
+
ok: zod.z.literal(true),
|
|
58326
|
+
text: zod.z.string(),
|
|
58327
|
+
trace: zod.z.array(DeviceTemplateTraceEntrySchema)
|
|
58328
|
+
}), zod.z.object({
|
|
58329
|
+
ok: zod.z.literal(false),
|
|
58330
|
+
refusal: DeviceTemplateRefusalSchema,
|
|
58331
|
+
trace: zod.z.array(DeviceTemplateTraceEntrySchema)
|
|
58332
|
+
})]);
|
|
58333
|
+
/** A capability name as a template spells it: `temperature-sensor` → `temperature_sensor`. */
|
|
58334
|
+
function templateCapKey(cap) {
|
|
58335
|
+
return cap.replace(/-/g, "_");
|
|
58336
|
+
}
|
|
58337
|
+
function isRecord$3(value) {
|
|
58338
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
58339
|
+
}
|
|
58340
|
+
function pickPath(root, path) {
|
|
58341
|
+
let cursor = root;
|
|
58342
|
+
for (const part of path) if (Array.isArray(cursor) && typeof part === "number") cursor = cursor[part];
|
|
58343
|
+
else if (isRecord$3(cursor) && Object.hasOwn(cursor, String(part))) cursor = cursor[String(part)];
|
|
58344
|
+
else return;
|
|
58345
|
+
return cursor;
|
|
58346
|
+
}
|
|
58347
|
+
/**
|
|
58348
|
+
* Resolve the path after an alias. `<cap>.field…` when the first segment names
|
|
58349
|
+
* one of the device's caps; otherwise `field…` when exactly one cap carries a
|
|
58350
|
+
* field of that name; several caps carrying it is `ambiguous`, naming them.
|
|
58351
|
+
*/
|
|
58352
|
+
function resolveTemplateRef(view, path) {
|
|
58353
|
+
const head = path[0];
|
|
58354
|
+
if (head === void 0) return {
|
|
58355
|
+
kind: "missing",
|
|
58356
|
+
reason: "no-field"
|
|
58357
|
+
};
|
|
58358
|
+
const caps = Object.keys(view.slices);
|
|
58359
|
+
const named = caps.find((cap) => cap === head || templateCapKey(cap) === head);
|
|
58360
|
+
if (named !== void 0) {
|
|
58361
|
+
const rest = path.slice(1);
|
|
58362
|
+
if (rest.length === 0) return {
|
|
58363
|
+
kind: "missing",
|
|
58364
|
+
reason: "no-field"
|
|
58365
|
+
};
|
|
58366
|
+
const value = pickPath(view.slices[named], rest);
|
|
58367
|
+
if (value === void 0) return {
|
|
58368
|
+
kind: "missing",
|
|
58369
|
+
reason: "unknown-field"
|
|
58370
|
+
};
|
|
58371
|
+
return {
|
|
58372
|
+
kind: "value",
|
|
58373
|
+
cap: named,
|
|
58374
|
+
fieldPath: rest,
|
|
58375
|
+
value
|
|
58376
|
+
};
|
|
58377
|
+
}
|
|
58378
|
+
const owners = caps.filter((cap) => {
|
|
58379
|
+
const slice = view.slices[cap];
|
|
58380
|
+
return isRecord$3(slice) && Object.hasOwn(slice, String(head));
|
|
58381
|
+
});
|
|
58382
|
+
if (owners.length === 0) return {
|
|
58383
|
+
kind: "missing",
|
|
58384
|
+
reason: "unknown-field"
|
|
58385
|
+
};
|
|
58386
|
+
const [only] = owners;
|
|
58387
|
+
if (owners.length > 1 || only === void 0) return {
|
|
58388
|
+
kind: "ambiguous",
|
|
58389
|
+
field: String(head),
|
|
58390
|
+
caps: owners
|
|
58391
|
+
};
|
|
58392
|
+
const value = pickPath(view.slices[only], path);
|
|
58393
|
+
if (value === void 0) return {
|
|
58394
|
+
kind: "missing",
|
|
58395
|
+
reason: "unknown-field"
|
|
58396
|
+
};
|
|
58397
|
+
return {
|
|
58398
|
+
kind: "value",
|
|
58399
|
+
cap: only,
|
|
58400
|
+
fieldPath: path,
|
|
58401
|
+
value
|
|
58402
|
+
};
|
|
58403
|
+
}
|
|
58404
|
+
/**
|
|
57950
58405
|
* A SITE ZONE — a named part of the property that several locations belong to.
|
|
57951
58406
|
*
|
|
57952
58407
|
* "Night zone" holds every bedroom; "Zona giorno" the living room and the
|
|
@@ -58839,7 +59294,13 @@ var deviceManagerCapability = {
|
|
|
58839
59294
|
* row + emits `EventCategory.DeviceMetaChanged`. */
|
|
58840
59295
|
setName: method(zod.z.object({
|
|
58841
59296
|
deviceId: zod.z.number(),
|
|
58842
|
-
name: zod.z.string()
|
|
59297
|
+
name: zod.z.string(),
|
|
59298
|
+
/**
|
|
59299
|
+
* Absent or true: an operator rename, which stamps `userNamed`.
|
|
59300
|
+
* False: the system copying a block name onto the device. That write
|
|
59301
|
+
* must not look like the operator's, or the next reconcile freezes it.
|
|
59302
|
+
*/
|
|
59303
|
+
stampUserNamed: zod.z.boolean().optional()
|
|
58843
59304
|
}), zod.z.void(), {
|
|
58844
59305
|
kind: "mutation",
|
|
58845
59306
|
auth: "admin"
|
|
@@ -58868,6 +59329,38 @@ var deviceManagerCapability = {
|
|
|
58868
59329
|
kind: "mutation",
|
|
58869
59330
|
auth: "admin"
|
|
58870
59331
|
}),
|
|
59332
|
+
/**
|
|
59333
|
+
* Render device value templates (D1021). The ONE door every consumer uses:
|
|
59334
|
+
* an action step, a scheduler point, a notification rule, a generated
|
|
59335
|
+
* automation block. Admin-only (an in-process block carries the mesh
|
|
59336
|
+
* principal): it reads device state by alias, so a non-admin never calls it
|
|
59337
|
+
* directly. `allowedDeviceIds` is the set the END caller was proven to see;
|
|
59338
|
+
* a template naming another device answers `out-of-scope`. Answers are
|
|
59339
|
+
* index-aligned with `templates`.
|
|
59340
|
+
*/
|
|
59341
|
+
renderDeviceTemplates: method(zod.z.object({
|
|
59342
|
+
templates: zod.z.array(DeviceTemplateSchema).max(64),
|
|
59343
|
+
allowedDeviceIds: zod.z.array(zod.z.number().int()).optional()
|
|
59344
|
+
}), zod.z.object({ results: zod.z.array(DeviceTemplateRenderSchema) }), { auth: "admin" }),
|
|
59345
|
+
/**
|
|
59346
|
+
* Vet templates without rendering them: the syntax refusal, or the devices
|
|
59347
|
+
* each names and whether `allowedDeviceIds` covers them. The save door and
|
|
59348
|
+
* the run-time scope check both ask this.
|
|
59349
|
+
*/
|
|
59350
|
+
checkDeviceTemplates: method(zod.z.object({
|
|
59351
|
+
templates: zod.z.array(zod.z.string()).max(64),
|
|
59352
|
+
allowedDeviceIds: zod.z.array(zod.z.number().int()).optional()
|
|
59353
|
+
}), zod.z.object({ results: zod.z.array(zod.z.discriminatedUnion("ok", [zod.z.object({
|
|
59354
|
+
ok: zod.z.literal(true),
|
|
59355
|
+
aliases: zod.z.array(zod.z.object({
|
|
59356
|
+
alias: zod.z.string(),
|
|
59357
|
+
deviceId: zod.z.number().int().nullable(),
|
|
59358
|
+
allowed: zod.z.boolean()
|
|
59359
|
+
}))
|
|
59360
|
+
}), zod.z.object({
|
|
59361
|
+
ok: zod.z.literal(false),
|
|
59362
|
+
refusal: DeviceTemplateRefusalSchema
|
|
59363
|
+
})])) }), { auth: "admin" }),
|
|
58871
59364
|
/** Update the operator-organisational location label. `null`
|
|
58872
59365
|
* clears it. */
|
|
58873
59366
|
setLocation: method(zod.z.object({
|
|
@@ -63479,6 +63972,17 @@ var TIMED_RUN_DEVICE_TYPES = [DeviceType.Heater, DeviceType.PetFountain];
|
|
|
63479
63972
|
function timedRunLimitOf(deviceType) {
|
|
63480
63973
|
return TIMED_RUN_LIMITS[deviceType] ?? null;
|
|
63481
63974
|
}
|
|
63975
|
+
var MS_PER_SECOND = 1e3;
|
|
63976
|
+
var MS_PER_MINUTE = 6e4;
|
|
63977
|
+
/**
|
|
63978
|
+
* Whole units left on an armed run. Minutes and seconds both ceil, and a run
|
|
63979
|
+
* that has not expired yet never reads as zero.
|
|
63980
|
+
*/
|
|
63981
|
+
function timedRunRemaining(activeUntil, now, unit) {
|
|
63982
|
+
const left = activeUntil - now;
|
|
63983
|
+
if (left <= 0) return 0;
|
|
63984
|
+
return Math.max(1, Math.ceil(left / (unit === "min" ? MS_PER_MINUTE : MS_PER_SECOND)));
|
|
63985
|
+
}
|
|
63482
63986
|
/** Seconds in a duration of `duration` `unit`. */
|
|
63483
63987
|
function timedRunSeconds(duration, unit) {
|
|
63484
63988
|
return unit === "min" ? duration * 60 : duration;
|
|
@@ -64018,7 +64522,13 @@ var HeroTimedRunSlotSchema = zod.z.object({
|
|
|
64018
64522
|
activeUntil: zod.z.number().nullable(),
|
|
64019
64523
|
quickRun: TimedRunQuickRunSchema,
|
|
64020
64524
|
run: HeroActionSchema,
|
|
64021
|
-
cancel: HeroActionSchema
|
|
64525
|
+
cancel: HeroActionSchema,
|
|
64526
|
+
/**
|
|
64527
|
+
* Whole units left (the limit's unit, ceil). `null` while nothing is armed.
|
|
64528
|
+
* A number, not words: the row formats it, and a text here would not fit the
|
|
64529
|
+
* hero-layout declaration.
|
|
64530
|
+
*/
|
|
64531
|
+
remaining: zod.z.number().nullable()
|
|
64022
64532
|
});
|
|
64023
64533
|
var HeroPowerSupplySlotSchema = zod.z.object({
|
|
64024
64534
|
/** The plug's state; `null` = unknown, never off. */
|
|
@@ -64137,18 +64647,31 @@ var HeroModelSchema = zod.z.object({
|
|
|
64137
64647
|
* 4. a trailing fact (power, else battery, else consumables).
|
|
64138
64648
|
*
|
|
64139
64649
|
* Selection rules, all taken from the model:
|
|
64140
|
-
* -
|
|
64650
|
+
* - the primary control is the device's own power; else the FIRST control of
|
|
64141
64651
|
* the FIRST row that has any (a later row's control is never promoted). When
|
|
64142
64652
|
* the model lists that part in `gated`, the row has no inline control: the
|
|
64143
64653
|
* projection never falls through to another control the caller could use.
|
|
64654
|
+
* - a timed run, when the model carries the slot, sits beside that primary:
|
|
64655
|
+
* Run while idle, Stop while armed. Gating the slot hides the control.
|
|
64144
64656
|
* - the status line is the head (what plays, else the state) plus at most
|
|
64145
|
-
* {@link ROW_STATUS_FACTS_MAX} facts, the trailing fact excluded
|
|
64657
|
+
* {@link ROW_STATUS_FACTS_MAX} facts, the trailing fact excluded, then the
|
|
64658
|
+
* time left on an armed timed run;
|
|
64146
64659
|
* - the trailing fact is the first of power, battery, consumables.
|
|
64147
64660
|
*
|
|
64148
64661
|
* `projectDeviceRow` is pure and computes nothing: it selects from a
|
|
64149
64662
|
* {@link HeroModel}. A row that needed a value the hero lacks would mean the
|
|
64150
64663
|
* model is missing it, so the fix goes in the model.
|
|
64151
64664
|
*/
|
|
64665
|
+
/**
|
|
64666
|
+
* The row's timed-run control. `id` is `timed-run.run` while idle and
|
|
64667
|
+
* `timed-run.cancel` while armed; `duration` and `unit` are the one-tap run
|
|
64668
|
+
* a Run press starts.
|
|
64669
|
+
*/
|
|
64670
|
+
var HeroRowTimedRunSchema = zod.z.object({
|
|
64671
|
+
id: zod.z.enum(["timed-run.run", "timed-run.cancel"]),
|
|
64672
|
+
duration: zod.z.number(),
|
|
64673
|
+
unit: zod.z.enum(["min", "s"])
|
|
64674
|
+
});
|
|
64152
64675
|
var HeroRowModelSchema = zod.z.object({
|
|
64153
64676
|
deviceId: zod.z.number().int(),
|
|
64154
64677
|
name: zod.z.string(),
|
|
@@ -64161,6 +64684,11 @@ var HeroRowModelSchema = zod.z.object({
|
|
|
64161
64684
|
statusLine: zod.z.array(HeroTextSchema),
|
|
64162
64685
|
/** `null` = the type has no inline control, or the caller may not act on it. */
|
|
64163
64686
|
primary: HeroControlSchema.nullable(),
|
|
64687
|
+
/**
|
|
64688
|
+
* Beside `primary` when the device offers a timed run: Run while idle, Stop
|
|
64689
|
+
* while armed. `null` when there is no slot, or the caller may not act.
|
|
64690
|
+
*/
|
|
64691
|
+
timedRun: HeroRowTimedRunSchema.nullable(),
|
|
64164
64692
|
trailing: HeroFactSchema.nullable()
|
|
64165
64693
|
});
|
|
64166
64694
|
/** The trailing fact, in order of preference. */
|
|
@@ -64197,7 +64725,30 @@ function primaryOf(model) {
|
|
|
64197
64725
|
return null;
|
|
64198
64726
|
}
|
|
64199
64727
|
function statusLineOf(model, trailing) {
|
|
64200
|
-
|
|
64728
|
+
const head = model.rows.find((r) => r.id === "now-playing")?.status ?? null ?? model.title;
|
|
64729
|
+
const rest = model.facts.filter((f) => f !== trailing).map((f) => f.text).slice(0, 3);
|
|
64730
|
+
const slot = model.timedRun;
|
|
64731
|
+
if (slot === null || slot.remaining === null) return [head, ...rest];
|
|
64732
|
+
const word = slot.quickRun.unit === "min" ? "min" : "s";
|
|
64733
|
+
const left = {
|
|
64734
|
+
en: `${slot.remaining} ${word}`,
|
|
64735
|
+
it: `${slot.remaining} ${word}`
|
|
64736
|
+
};
|
|
64737
|
+
return [
|
|
64738
|
+
head,
|
|
64739
|
+
...rest,
|
|
64740
|
+
left
|
|
64741
|
+
];
|
|
64742
|
+
}
|
|
64743
|
+
/** Run while the slot is idle, Stop while it is armed. Hidden when the caller may not act. */
|
|
64744
|
+
function timedRunOf(model) {
|
|
64745
|
+
const slot = model.timedRun;
|
|
64746
|
+
if (slot === null || model.gated.includes("timed-run")) return null;
|
|
64747
|
+
return {
|
|
64748
|
+
id: slot.activeUntil === null ? "timed-run.run" : "timed-run.cancel",
|
|
64749
|
+
duration: slot.quickRun.duration,
|
|
64750
|
+
unit: slot.quickRun.unit
|
|
64751
|
+
};
|
|
64201
64752
|
}
|
|
64202
64753
|
function projectDeviceRow(model) {
|
|
64203
64754
|
const trailing = trailingOf(model.facts);
|
|
@@ -64211,6 +64762,7 @@ function projectDeviceRow(model) {
|
|
|
64211
64762
|
scene: model.scene,
|
|
64212
64763
|
statusLine: statusLineOf(model, trailing),
|
|
64213
64764
|
primary: primaryOf(model),
|
|
64765
|
+
timedRun: timedRunOf(model),
|
|
64214
64766
|
trailing
|
|
64215
64767
|
};
|
|
64216
64768
|
}
|
|
@@ -97638,12 +98190,42 @@ function deriveBatteryPresence(input) {
|
|
|
97638
98190
|
* priority-in-sync.ts` fails the build when either drifts — the comment that
|
|
97639
98191
|
* used to ask for this could not.
|
|
97640
98192
|
*
|
|
97641
|
-
* The rule has
|
|
97642
|
-
* wins outright
|
|
97643
|
-
*
|
|
97644
|
-
*
|
|
98193
|
+
* The rule has three halves and the ORDER matters: an operator's explicit pick
|
|
98194
|
+
* wins outright; else a declaration on the device type
|
|
98195
|
+
* ({@link CONTAINER_PRIMARY_CHILD_RULES}); else role, namesake, then type
|
|
98196
|
+
* priority. The pick is keyed on the child's re-sync-stable `entityId`, not
|
|
98197
|
+
* its numeric id, so it survives a re-sync that reallocates ids.
|
|
97645
98198
|
*/
|
|
97646
98199
|
/**
|
|
98200
|
+
* Device types that name their primary child. A heat pump stands for itself:
|
|
98201
|
+
* its hero is the system row, not the climate circuit that type-rank would
|
|
98202
|
+
* otherwise pick.
|
|
98203
|
+
*/
|
|
98204
|
+
var CONTAINER_PRIMARY_CHILD_RULES = [{
|
|
98205
|
+
deviceType: DeviceType.HeatPump,
|
|
98206
|
+
primary: "self"
|
|
98207
|
+
}];
|
|
98208
|
+
/**
|
|
98209
|
+
* The type declaration, before the heuristic. `fall-through` means the
|
|
98210
|
+
* heuristic still decides: the type declared nothing, or it named a child
|
|
98211
|
+
* type that is not among the children.
|
|
98212
|
+
*/
|
|
98213
|
+
function declaredChildType(primary) {
|
|
98214
|
+
if (primary === "self") return void 0;
|
|
98215
|
+
return primary.childType;
|
|
98216
|
+
}
|
|
98217
|
+
function applyPrimaryChildRule(rule, children) {
|
|
98218
|
+
if (rule === void 0) return { kind: "fall-through" };
|
|
98219
|
+
const childType = declaredChildType(rule.primary);
|
|
98220
|
+
if (childType === void 0) return { kind: "none" };
|
|
98221
|
+
const match = children.find((child) => child.type === childType);
|
|
98222
|
+
if (match === void 0) return { kind: "fall-through" };
|
|
98223
|
+
return {
|
|
98224
|
+
kind: "child",
|
|
98225
|
+
child: match
|
|
98226
|
+
};
|
|
98227
|
+
}
|
|
98228
|
+
/**
|
|
97647
98229
|
* Type priority, most→least "primary". An actuator (climate / lock / cover / …)
|
|
97648
98230
|
* outranks a bare `switch` so a container's defining child wins over its
|
|
97649
98231
|
* auxiliary switches. Unknown or absent types sort after every entry.
|
|
@@ -97730,9 +98312,10 @@ function rank(type) {
|
|
|
97730
98312
|
}
|
|
97731
98313
|
/**
|
|
97732
98314
|
* The child a container stands for: the operator's pick when it still exists,
|
|
97733
|
-
* else the highest-priority type. `null`
|
|
97734
|
-
*
|
|
97735
|
-
* child
|
|
98315
|
+
* else the device type's declaration, else the highest-priority type. `null`
|
|
98316
|
+
* for a childless container, and for a type that stands for itself — a caller
|
|
98317
|
+
* must decide what "no child" means for it, rather than being handed a child
|
|
98318
|
+
* that is not the device.
|
|
97736
98319
|
*/
|
|
97737
98320
|
/**
|
|
97738
98321
|
* Two names for the same thing, compared the way an integration writes them.
|
|
@@ -97761,11 +98344,14 @@ function sameName(childName, containerName) {
|
|
|
97761
98344
|
const flatten = (v) => v.toLowerCase().replace(/[-_\s]+/g, " ").trim();
|
|
97762
98345
|
return flatten(childName) === flatten(containerName);
|
|
97763
98346
|
}
|
|
97764
|
-
function resolveContainerPrimaryChild(children, overrideEntityId, containerName) {
|
|
98347
|
+
function resolveContainerPrimaryChild(children, overrideEntityId, containerName, containerType) {
|
|
97765
98348
|
if (overrideEntityId !== void 0 && overrideEntityId !== null) {
|
|
97766
98349
|
const picked = children.find((c) => c.stableId === overrideEntityId) ?? children.find((c) => c.entityId !== void 0 && c.entityId === overrideEntityId);
|
|
97767
98350
|
if (picked !== void 0) return picked;
|
|
97768
98351
|
}
|
|
98352
|
+
const declared = applyPrimaryChildRule(CONTAINER_PRIMARY_CHILD_RULES.find((entry) => entry.deviceType === containerType), children);
|
|
98353
|
+
if (declared.kind === "none") return null;
|
|
98354
|
+
if (declared.kind === "child") return declared.child;
|
|
97769
98355
|
const namesake = (c) => containerName !== void 0 && containerName.length > 0 && c.name !== void 0 && sameName(c.name, containerName) ? 0 : 1;
|
|
97770
98356
|
return [...children].toSorted((a, b) => roleRank(a.role) - roleRank(b.role) || namesake(a) - namesake(b) || rank(a.type) - rank(b.type))[0] ?? null;
|
|
97771
98357
|
}
|
|
@@ -97813,7 +98399,7 @@ function expandContainer(id, byId, byParent, visited, out) {
|
|
|
97813
98399
|
type: c.type,
|
|
97814
98400
|
...c.role !== void 0 && c.role !== null ? { role: c.role } : {},
|
|
97815
98401
|
...c.name !== void 0 ? { name: c.name } : {}
|
|
97816
|
-
})), byId.get(id)?.primaryChildEntityId, byId.get(id)?.name);
|
|
98402
|
+
})), byId.get(id)?.primaryChildEntityId, byId.get(id)?.name, candidate.type);
|
|
97817
98403
|
if (primary !== null) expandContainer(primary.id, byId, byParent, nextVisited, out);
|
|
97818
98404
|
}
|
|
97819
98405
|
/**
|
|
@@ -99903,7 +100489,7 @@ var CLIMATE_FAMILY_CONTRIBUTIONS = {
|
|
|
99903
100489
|
/**
|
|
99904
100490
|
* The heat pump's contribution to a hero (D1026): the compressor scene, every
|
|
99905
100491
|
* circuit as a row with its own label and icon, the powers as pills (the
|
|
99906
|
-
* instantaneous COP
|
|
100492
|
+
* instantaneous COP is "—" when it cannot be computed) and a "System" group with
|
|
99907
100493
|
* one selector per mode. Values and their limits come from the slice, which the
|
|
99908
100494
|
* gateway filled: a selector with no allowed value is not drawn, a missing
|
|
99909
100495
|
* reading is never a 0 (D393).
|
|
@@ -99975,9 +100561,22 @@ function circuitRow(circuit) {
|
|
|
99975
100561
|
};
|
|
99976
100562
|
}
|
|
99977
100563
|
var kilowatts = (watts) => `${Number((watts / 1e3).toFixed(2))} kW`;
|
|
100564
|
+
/** A COP that cannot be computed is still the pill: "—", never an absent reading (D393). */
|
|
100565
|
+
function copPill(cop) {
|
|
100566
|
+
if (cop === null) return {
|
|
100567
|
+
icon: "gauge",
|
|
100568
|
+
text: t("Instantaneous COP —", "COP istantaneo —"),
|
|
100569
|
+
tone: "muted"
|
|
100570
|
+
};
|
|
100571
|
+
const text = String(Number(cop.toFixed(1)));
|
|
100572
|
+
return {
|
|
100573
|
+
icon: "gauge",
|
|
100574
|
+
text: t(`Instantaneous COP ${text}`, `COP istantaneo ${text}`),
|
|
100575
|
+
tone: "success"
|
|
100576
|
+
};
|
|
100577
|
+
}
|
|
99978
100578
|
function powerPills(status) {
|
|
99979
100579
|
const { thermalW, electricalW } = status.power;
|
|
99980
|
-
const cop = heatPumpInstantCop(status.power);
|
|
99981
100580
|
const pills = [];
|
|
99982
100581
|
if (thermalW !== null) pills.push({
|
|
99983
100582
|
icon: "flame",
|
|
@@ -99989,14 +100588,7 @@ function powerPills(status) {
|
|
|
99989
100588
|
text: t(`Electrical ${kilowatts(electricalW)}`, `Elettrica ${kilowatts(electricalW)}`),
|
|
99990
100589
|
tone: "muted"
|
|
99991
100590
|
});
|
|
99992
|
-
|
|
99993
|
-
const text = String(Number(cop.toFixed(1)));
|
|
99994
|
-
pills.push({
|
|
99995
|
-
icon: "gauge",
|
|
99996
|
-
text: t(`Instantaneous COP ${text}`, `COP istantaneo ${text}`),
|
|
99997
|
-
tone: "success"
|
|
99998
|
-
});
|
|
99999
|
-
}
|
|
100591
|
+
pills.push(copPill(heatPumpInstantCop(status.power)));
|
|
100000
100592
|
return pills;
|
|
100001
100593
|
}
|
|
100002
100594
|
/** The independent system modes, in the order the card draws them. */
|
|
@@ -100524,10 +101116,14 @@ function timerTile(quickRun) {
|
|
|
100524
101116
|
value: t(text, text)
|
|
100525
101117
|
};
|
|
100526
101118
|
}
|
|
101119
|
+
function remainingWords(amount, unit) {
|
|
101120
|
+
const word = unit === "min" ? "min" : "s";
|
|
101121
|
+
return t(`${amount} ${word}`, `${amount} ${word}`);
|
|
101122
|
+
}
|
|
100527
101123
|
var timedRunContribution = contribution("timed-run", TimedRunStatusSchema, (slice, ctx) => {
|
|
100528
101124
|
const type = deviceTypeOf(ctx.type);
|
|
100529
|
-
const limit = type === void 0 ?
|
|
100530
|
-
if (limit ===
|
|
101125
|
+
const limit = type === void 0 ? null : timedRunLimitOf(type);
|
|
101126
|
+
if (limit === null) return {};
|
|
100531
101127
|
const quickRun = slice?.quickRun ?? timedRunQuickRun(limit, null);
|
|
100532
101128
|
const activeUntil = slice?.activeUntil != null && slice.activeUntil > ctx.now ? slice.activeUntil : null;
|
|
100533
101129
|
const runArgs = {
|
|
@@ -100537,11 +101133,12 @@ var timedRunContribution = contribution("timed-run", TimedRunStatusSchema, (slic
|
|
|
100537
101133
|
const run = action("timed-run.run", t(`Run ${quickRun.duration} ${quickRun.unit}`, `Avvia ${quickRun.duration} ${quickRun.unit}`), "timer", "timed-run", "runFor", runArgs, "primary");
|
|
100538
101134
|
const cancel = action("timed-run.cancel", t("Stop", "Ferma"), "timer-off", "timed-run", "cancel");
|
|
100539
101135
|
const restart = action("timed-run.restart", t("Restart", "Riavvia"), "rotate-cw", "timed-run", "runFor", runArgs);
|
|
100540
|
-
const
|
|
101136
|
+
const remaining = activeUntil === null ? null : timedRunRemaining(activeUntil, ctx.now, quickRun.unit);
|
|
101137
|
+
const words = remaining === null ? null : remainingWords(remaining, quickRun.unit);
|
|
100541
101138
|
const row = {
|
|
100542
101139
|
id: "run-for",
|
|
100543
101140
|
icon: "timer",
|
|
100544
|
-
status:
|
|
101141
|
+
status: words === null ? t(`Run for ${quickRun.duration} ${quickRun.unit}`, `Avvia per ${quickRun.duration} ${quickRun.unit}`) : t(`Stops in ${words.en}`, `Si ferma tra ${words.it}`),
|
|
100545
101142
|
controls: activeUntil === null ? [asAction(run)] : [asAction(cancel), asAction(restart)]
|
|
100546
101143
|
};
|
|
100547
101144
|
const armed = activeUntil === null ? {} : { right: [timerTile(quickRun)] };
|
|
@@ -100550,7 +101147,8 @@ var timedRunContribution = contribution("timed-run", TimedRunStatusSchema, (slic
|
|
|
100550
101147
|
activeUntil,
|
|
100551
101148
|
quickRun,
|
|
100552
101149
|
run,
|
|
100553
|
-
cancel
|
|
101150
|
+
cancel,
|
|
101151
|
+
remaining
|
|
100554
101152
|
},
|
|
100555
101153
|
rows: [row],
|
|
100556
101154
|
tilesFallback: true,
|
|
@@ -104214,6 +104812,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
104214
104812
|
access: "create",
|
|
104215
104813
|
role: "admin"
|
|
104216
104814
|
},
|
|
104815
|
+
"deviceManager.checkDeviceTemplates": {
|
|
104816
|
+
capName: "device-manager",
|
|
104817
|
+
capScope: "system",
|
|
104818
|
+
addonId: null,
|
|
104819
|
+
access: "view",
|
|
104820
|
+
role: "admin"
|
|
104821
|
+
},
|
|
104217
104822
|
"deviceManager.cleanupDeletedDevicesData": {
|
|
104218
104823
|
capName: "device-manager",
|
|
104219
104824
|
capScope: "system",
|
|
@@ -104613,6 +105218,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
104613
105218
|
access: "create",
|
|
104614
105219
|
role: "admin"
|
|
104615
105220
|
},
|
|
105221
|
+
"deviceManager.renderDeviceTemplates": {
|
|
105222
|
+
capName: "device-manager",
|
|
105223
|
+
capScope: "system",
|
|
105224
|
+
addonId: null,
|
|
105225
|
+
access: "view",
|
|
105226
|
+
role: "admin"
|
|
105227
|
+
},
|
|
104616
105228
|
"deviceManager.reportDiscoveryObservations": {
|
|
104617
105229
|
capName: "device-manager",
|
|
104618
105230
|
capScope: "system",
|
|
@@ -112529,7 +113141,6 @@ function offered(received) {
|
|
|
112529
113141
|
};
|
|
112530
113142
|
}
|
|
112531
113143
|
offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
|
|
112532
|
-
zod.z.string().min(1).max(4096);
|
|
112533
113144
|
/**
|
|
112534
113145
|
* Runtime list of cap names with status. Used by the settings
|
|
112535
113146
|
* aggregator to enumerate caps whose `status` should be polled +
|
|
@@ -116099,6 +116710,12 @@ var SESSION_ONLY_POLICY = {
|
|
|
116099
116710
|
durability: "session",
|
|
116100
116711
|
volatileFields: []
|
|
116101
116712
|
};
|
|
116713
|
+
/**
|
|
116714
|
+
* The unit a composed-device field row offers convert-unit from (D941, D944).
|
|
116715
|
+
*/
|
|
116716
|
+
function runtimeFieldUnit(cap, path) {
|
|
116717
|
+
return CAP_RUNTIME_FIELD_UNITS[cap]?.[path];
|
|
116718
|
+
}
|
|
116102
116719
|
var G711_SCALE_CORRECTION_DB = {
|
|
116103
116720
|
PCMU: 20 * Math.log10(4),
|
|
116104
116721
|
PCMA: 20 * Math.log10(8)
|
|
@@ -118040,6 +118657,12 @@ Object.defineProperty(exports, "CATALOG_LANGS", {
|
|
|
118040
118657
|
return CATALOG_LANGS;
|
|
118041
118658
|
}
|
|
118042
118659
|
});
|
|
118660
|
+
Object.defineProperty(exports, "COMPOSED_DEVICE_STABLE_ID_PREFIX", {
|
|
118661
|
+
enumerable: true,
|
|
118662
|
+
get: function() {
|
|
118663
|
+
return COMPOSED_DEVICE_STABLE_ID_PREFIX;
|
|
118664
|
+
}
|
|
118665
|
+
});
|
|
118043
118666
|
Object.defineProperty(exports, "COMPOSED_ITEM_FIXED_FIELDS", {
|
|
118044
118667
|
enumerable: true,
|
|
118045
118668
|
get: function() {
|
|
@@ -118232,6 +118855,24 @@ Object.defineProperty(exports, "DEVICE_STATUS_METHOD", {
|
|
|
118232
118855
|
return DEVICE_STATUS_METHOD;
|
|
118233
118856
|
}
|
|
118234
118857
|
});
|
|
118858
|
+
Object.defineProperty(exports, "DEVICE_TEMPLATE_FILTERS", {
|
|
118859
|
+
enumerable: true,
|
|
118860
|
+
get: function() {
|
|
118861
|
+
return DEVICE_TEMPLATE_FILTERS;
|
|
118862
|
+
}
|
|
118863
|
+
});
|
|
118864
|
+
Object.defineProperty(exports, "DEVICE_TEMPLATE_MAX_LENGTH", {
|
|
118865
|
+
enumerable: true,
|
|
118866
|
+
get: function() {
|
|
118867
|
+
return DEVICE_TEMPLATE_MAX_LENGTH;
|
|
118868
|
+
}
|
|
118869
|
+
});
|
|
118870
|
+
Object.defineProperty(exports, "DEVICE_TEMPLATE_MAX_OUTPUT", {
|
|
118871
|
+
enumerable: true,
|
|
118872
|
+
get: function() {
|
|
118873
|
+
return DEVICE_TEMPLATE_MAX_OUTPUT;
|
|
118874
|
+
}
|
|
118875
|
+
});
|
|
118235
118876
|
Object.defineProperty(exports, "DEVICE_TOMBSTONE_RETENTION_MS", {
|
|
118236
118877
|
enumerable: true,
|
|
118237
118878
|
get: function() {
|
|
@@ -119144,6 +119785,12 @@ Object.defineProperty(exports, "cloneStatefulExpressionMemory", {
|
|
|
119144
119785
|
return cloneStatefulExpressionMemory;
|
|
119145
119786
|
}
|
|
119146
119787
|
});
|
|
119788
|
+
Object.defineProperty(exports, "collectDeviceTemplates", {
|
|
119789
|
+
enumerable: true,
|
|
119790
|
+
get: function() {
|
|
119791
|
+
return collectDeviceTemplates;
|
|
119792
|
+
}
|
|
119793
|
+
});
|
|
119147
119794
|
Object.defineProperty(exports, "collectSecretConfigKeys", {
|
|
119148
119795
|
enumerable: true,
|
|
119149
119796
|
get: function() {
|
|
@@ -119528,6 +120175,12 @@ Object.defineProperty(exports, "evaluateStatistic", {
|
|
|
119528
120175
|
return evaluateStatistic;
|
|
119529
120176
|
}
|
|
119530
120177
|
});
|
|
120178
|
+
Object.defineProperty(exports, "evaluateStepCondition", {
|
|
120179
|
+
enumerable: true,
|
|
120180
|
+
get: function() {
|
|
120181
|
+
return evaluateStepCondition;
|
|
120182
|
+
}
|
|
120183
|
+
});
|
|
119531
120184
|
Object.defineProperty(exports, "evaluateWhenTree", {
|
|
119532
120185
|
enumerable: true,
|
|
119533
120186
|
get: function() {
|
|
@@ -120428,6 +121081,12 @@ Object.defineProperty(exports, "resolveStepArgs", {
|
|
|
120428
121081
|
return resolveStepArgs;
|
|
120429
121082
|
}
|
|
120430
121083
|
});
|
|
121084
|
+
Object.defineProperty(exports, "resolveTemplateRef", {
|
|
121085
|
+
enumerable: true,
|
|
121086
|
+
get: function() {
|
|
121087
|
+
return resolveTemplateRef;
|
|
121088
|
+
}
|
|
121089
|
+
});
|
|
120431
121090
|
Object.defineProperty(exports, "runFanOut", {
|
|
120432
121091
|
enumerable: true,
|
|
120433
121092
|
get: function() {
|
|
@@ -120440,6 +121099,12 @@ Object.defineProperty(exports, "runSteps", {
|
|
|
120440
121099
|
return runSteps;
|
|
120441
121100
|
}
|
|
120442
121101
|
});
|
|
121102
|
+
Object.defineProperty(exports, "runtimeFieldUnit", {
|
|
121103
|
+
enumerable: true,
|
|
121104
|
+
get: function() {
|
|
121105
|
+
return runtimeFieldUnit;
|
|
121106
|
+
}
|
|
121107
|
+
});
|
|
120443
121108
|
Object.defineProperty(exports, "runtimeStatePolicyFor", {
|
|
120444
121109
|
enumerable: true,
|
|
120445
121110
|
get: function() {
|