@camstack/addon-export-alexa 1.2.195 → 1.2.196
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 +6 -0
- package/dist/export-alexa.addon.js +1272 -539
- package/dist/export-alexa.addon.mjs +1272 -539
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ import "node:fs";
|
|
|
5
5
|
import "node:path";
|
|
6
6
|
import "node:child_process";
|
|
7
7
|
import "node:zlib";
|
|
8
|
-
//#region ../types/dist/event-category-
|
|
8
|
+
//#region ../types/dist/event-category-Dv-Gcv1f.mjs
|
|
9
9
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
10
10
|
EventCategory["SystemBoot"] = "system.boot";
|
|
11
11
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -446,6 +446,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
446
446
|
*/
|
|
447
447
|
EventCategory["DeviceStateChanged"] = "device.state-changed";
|
|
448
448
|
/**
|
|
449
|
+
* A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
|
|
450
|
+
* transition audit (D1022): confirmed, already in place, unconfirmed or
|
|
451
|
+
* failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
|
|
452
|
+
* (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
|
|
453
|
+
* the Notification Center `device-command` kind. Telemetry (D8): losing one
|
|
454
|
+
* costs a notification, never state; the audit row is the record.
|
|
455
|
+
*/
|
|
456
|
+
EventCategory["DeviceCommandSettled"] = "device.command-settled";
|
|
457
|
+
/**
|
|
449
458
|
* The NATIVE shadow of a cap a composition has claimed fields of moved
|
|
450
459
|
* (D663). Payload: `{ deviceId, capName, native }` — what the provider
|
|
451
460
|
* wrote, BEFORE the owned fields are overlaid. Owner-only (D224): it is for
|
|
@@ -6050,7 +6059,7 @@ var ZodIssueCode = {
|
|
|
6050
6059
|
var ZodFirstPartyTypeKind;
|
|
6051
6060
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6052
6061
|
//#endregion
|
|
6053
|
-
//#region ../types/dist/sleep-
|
|
6062
|
+
//#region ../types/dist/sleep-DyIxjZZt.mjs
|
|
6054
6063
|
/**
|
|
6055
6064
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6056
6065
|
* window to float samples (D455).
|
|
@@ -6733,6 +6742,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6733
6742
|
else skipped.push(id);
|
|
6734
6743
|
};
|
|
6735
6744
|
const selected = options.only === void 0 ? null : new Set(options.only);
|
|
6745
|
+
const deferred = /* @__PURE__ */ new Set();
|
|
6746
|
+
const deferredBy = (reason) => {
|
|
6747
|
+
if (selected === null || reason === null) return null;
|
|
6748
|
+
const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
|
|
6749
|
+
if (dep === void 0 || !byId.has(dep)) return null;
|
|
6750
|
+
return !selected.has(dep) || deferred.has(dep) ? dep : null;
|
|
6751
|
+
};
|
|
6736
6752
|
for (const step of declaration.steps) {
|
|
6737
6753
|
if (selected !== null && !selected.has(step.id)) continue;
|
|
6738
6754
|
const bound = byId.get(step.id);
|
|
@@ -6744,6 +6760,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6744
6760
|
try {
|
|
6745
6761
|
const gate = await host.startMigration({ id: step.id });
|
|
6746
6762
|
if (!gate.proceed) {
|
|
6763
|
+
const waitsFor = deferredBy(gate.reason);
|
|
6764
|
+
if (waitsFor !== null) {
|
|
6765
|
+
log.info("migration deferred: its predecessor runs in another phase of this owner", {
|
|
6766
|
+
tags,
|
|
6767
|
+
meta: {
|
|
6768
|
+
waitsFor,
|
|
6769
|
+
reason: gate.reason
|
|
6770
|
+
}
|
|
6771
|
+
});
|
|
6772
|
+
deferred.add(step.id);
|
|
6773
|
+
skipped.push(step.id);
|
|
6774
|
+
continue;
|
|
6775
|
+
}
|
|
6747
6776
|
log.warn("migration not run", {
|
|
6748
6777
|
tags,
|
|
6749
6778
|
meta: {
|
|
@@ -7788,7 +7817,7 @@ async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
|
7788
7817
|
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
7789
7818
|
return out;
|
|
7790
7819
|
}
|
|
7791
|
-
function rowId$
|
|
7820
|
+
function rowId$4(row, idKey) {
|
|
7792
7821
|
const raw = row[idKey];
|
|
7793
7822
|
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
7794
7823
|
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
@@ -7805,7 +7834,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7805
7834
|
}
|
|
7806
7835
|
const storedById = /* @__PURE__ */ new Map();
|
|
7807
7836
|
for (const row of storedRows) {
|
|
7808
|
-
const id = rowId$
|
|
7837
|
+
const id = rowId$4(row, node.idKey);
|
|
7809
7838
|
if (id !== null) storedById.set(id, row);
|
|
7810
7839
|
}
|
|
7811
7840
|
const kept = /* @__PURE__ */ new Set();
|
|
@@ -7815,13 +7844,13 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7815
7844
|
rows.push(row);
|
|
7816
7845
|
continue;
|
|
7817
7846
|
}
|
|
7818
|
-
const id = rowId$
|
|
7847
|
+
const id = rowId$4(row, node.idKey) ?? ctx.mintId();
|
|
7819
7848
|
kept.add(id);
|
|
7820
7849
|
const withId = {
|
|
7821
7850
|
...row,
|
|
7822
7851
|
[node.idKey]: row[node.idKey] ?? id
|
|
7823
7852
|
};
|
|
7824
|
-
if (rowId$
|
|
7853
|
+
if (rowId$4(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
7825
7854
|
const storedRow = storedById.get(id) ?? {};
|
|
7826
7855
|
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
7827
7856
|
}
|
|
@@ -10193,6 +10222,13 @@ var DeviceTransitionSchema = object({
|
|
|
10193
10222
|
actor: TransitionActorSchema,
|
|
10194
10223
|
command: TransitionCommandSchema.optional()
|
|
10195
10224
|
});
|
|
10225
|
+
object({
|
|
10226
|
+
deviceId: number$1().int(),
|
|
10227
|
+
action: string(),
|
|
10228
|
+
outcome: TransitionOutcomeSchema,
|
|
10229
|
+
actor: TransitionActorSchema,
|
|
10230
|
+
at: number$1()
|
|
10231
|
+
});
|
|
10196
10232
|
var READING_QUANTITIES = [
|
|
10197
10233
|
"temperature",
|
|
10198
10234
|
"pressure",
|
|
@@ -12216,7 +12252,10 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
12216
12252
|
"ir-transmitter": {
|
|
12217
12253
|
scope: "device",
|
|
12218
12254
|
noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
|
|
12219
|
-
notOperatorFacing: {
|
|
12255
|
+
notOperatorFacing: {
|
|
12256
|
+
send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
|
|
12257
|
+
learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
|
|
12258
|
+
}
|
|
12220
12259
|
},
|
|
12221
12260
|
control: {
|
|
12222
12261
|
scope: "device",
|
|
@@ -15137,6 +15176,32 @@ var CAP_VOCABULARY_BY_NAME = {
|
|
|
15137
15176
|
...SYSTEM_CAP_VOCABULARY
|
|
15138
15177
|
};
|
|
15139
15178
|
/**
|
|
15179
|
+
* Vocabulary actions by id (D983). An action step names a vocabulary action
|
|
15180
|
+
* (`cover.open`), never a raw cap method; this is the one lookup that turns the
|
|
15181
|
+
* id into its cap, method and effect — and a persisted legacy `cap` + `method`
|
|
15182
|
+
* pair back into the action id when exactly one action matches.
|
|
15183
|
+
*/
|
|
15184
|
+
function buildIndex() {
|
|
15185
|
+
const byId = /* @__PURE__ */ new Map();
|
|
15186
|
+
for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
|
|
15187
|
+
if (entry.scope !== "device") continue;
|
|
15188
|
+
for (const action of entry.actions ?? []) byId.set(action.id, {
|
|
15189
|
+
cap,
|
|
15190
|
+
action
|
|
15191
|
+
});
|
|
15192
|
+
}
|
|
15193
|
+
return byId;
|
|
15194
|
+
}
|
|
15195
|
+
var index;
|
|
15196
|
+
function actionIndex() {
|
|
15197
|
+
index ??= buildIndex();
|
|
15198
|
+
return index;
|
|
15199
|
+
}
|
|
15200
|
+
/** The vocabulary action with this id, or `undefined`. */
|
|
15201
|
+
function findVocabAction(actionId) {
|
|
15202
|
+
return actionIndex().get(actionId);
|
|
15203
|
+
}
|
|
15204
|
+
/**
|
|
15140
15205
|
* `addon-pages-source` — collection cap exposing per-provider raw page
|
|
15141
15206
|
* declarations. Every addon that contributes a UI page registers a
|
|
15142
15207
|
* provider here. The hub-side singleton aggregator (`addon-pages` cap,
|
|
@@ -44808,21 +44873,23 @@ function convertLegacyWhen(half) {
|
|
|
44808
44873
|
* (instants) and state leaves (durations). It replaces the flat trigger list
|
|
44809
44874
|
* plus the separate condition tree; the firing rule is in that file and in
|
|
44810
44875
|
* ADR "one tree".
|
|
44811
|
-
* - **Actions** — the `wait` and `
|
|
44876
|
+
* - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
|
|
44812
44877
|
* fragment of §3.2.2. See {@link AutomationActionSchema}.
|
|
44813
44878
|
*
|
|
44814
44879
|
* A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
|
|
44815
44880
|
* {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
|
|
44816
44881
|
*/
|
|
44817
44882
|
/**
|
|
44818
|
-
* One action step: `wait`, or a `
|
|
44883
|
+
* One action step: `wait`, or a device `command`.
|
|
44819
44884
|
*
|
|
44820
|
-
* A
|
|
44821
|
-
* `{ $var }` resolved from the run's
|
|
44822
|
-
*
|
|
44823
|
-
*
|
|
44824
|
-
*
|
|
44825
|
-
*
|
|
44885
|
+
* A command step names a VOCABULARY action (`cover.open`) and who it acts on
|
|
44886
|
+
* (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
|
|
44887
|
+
* variables). It never names a cap method: the step runner turns the action
|
|
44888
|
+
* id into its cap + method through the vocabulary index when the step runs
|
|
44889
|
+
* (`vocabCall`), the one place that mapping happens. The step runner
|
|
44890
|
+
* (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
|
|
44891
|
+
* variable substitution, once, for every caller — automations, Actions, and
|
|
44892
|
+
* the notification centre, which runs only Actions (planning#473).
|
|
44826
44893
|
*/
|
|
44827
44894
|
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
44828
44895
|
var WAIT_MAX_SECONDS = 3600;
|
|
@@ -44831,39 +44898,22 @@ var AutomationWaitStepSchema = object({
|
|
|
44831
44898
|
kind: literal("wait"),
|
|
44832
44899
|
seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
44833
44900
|
});
|
|
44834
|
-
/** The legacy `deviceId` of a cap step: still READ, never written (D983). */
|
|
44835
|
-
var LegacyStepDeviceSchema = union([
|
|
44836
|
-
number$1().int(),
|
|
44837
|
-
array(number$1().int()).min(1),
|
|
44838
|
-
object({ $var: string().min(1) })
|
|
44839
|
-
]);
|
|
44840
44901
|
/**
|
|
44841
|
-
* The fields of a
|
|
44842
|
-
*
|
|
44843
|
-
* device); a step is {@link AutomationCapStepSchema}.
|
|
44902
|
+
* The fields of a command step, before the vocabulary check. A step is
|
|
44903
|
+
* {@link AutomationCommandStepSchema}.
|
|
44844
44904
|
*/
|
|
44845
|
-
var
|
|
44846
|
-
kind: literal("
|
|
44847
|
-
/**
|
|
44848
|
-
|
|
44849
|
-
|
|
44850
|
-
|
|
44851
|
-
* cap + method match exactly one vocabulary action.
|
|
44852
|
-
*/
|
|
44853
|
-
actionId: string().min(1).optional(),
|
|
44854
|
-
/** WHO the step acts on. The only shape that is written. */
|
|
44855
|
-
target: ActionTargetSchema.optional(),
|
|
44905
|
+
var AutomationCommandStepBaseSchema = object({
|
|
44906
|
+
kind: literal("command"),
|
|
44907
|
+
/** WHO the step acts on. */
|
|
44908
|
+
target: ActionTargetSchema,
|
|
44909
|
+
/** The vocabulary action this step performs (`cover.open`). */
|
|
44910
|
+
actionId: string().min(1),
|
|
44856
44911
|
/**
|
|
44857
|
-
*
|
|
44858
|
-
*
|
|
44859
|
-
*
|
|
44912
|
+
* The values of the action's OPEN args (`position`, `presetId`); the args
|
|
44913
|
+
* the vocabulary bakes into the action are added when the step runs. Values
|
|
44914
|
+
* may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
44915
|
+
* SUBSTITUTE and do not evaluate (§3.2.3).
|
|
44860
44916
|
*/
|
|
44861
|
-
deviceId: LegacyStepDeviceSchema.optional(),
|
|
44862
|
-
cap: string().min(1),
|
|
44863
|
-
method: string().min(1),
|
|
44864
|
-
/** Values may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
44865
|
-
* SUBSTITUTE and do not evaluate (§3.2.3). Anything beyond substitution is
|
|
44866
|
-
* the expression leaf. */
|
|
44867
44917
|
args: record(string(), unknown()).optional(),
|
|
44868
44918
|
/**
|
|
44869
44919
|
* The unit the person picked per arg (display only). `args` always hold the
|
|
@@ -44872,18 +44922,20 @@ var AutomationCapStepBaseSchema = object({
|
|
|
44872
44922
|
*/
|
|
44873
44923
|
argUnits: record(string(), string().min(1)).optional()
|
|
44874
44924
|
});
|
|
44925
|
+
/** The vocabulary check every command step passes: the action exists. */
|
|
44926
|
+
function refineKnownAction(step, ctx) {
|
|
44927
|
+
if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
|
|
44928
|
+
code: "custom",
|
|
44929
|
+
message: `"${step.actionId}" is not a vocabulary action id`,
|
|
44930
|
+
path: ["actionId"]
|
|
44931
|
+
});
|
|
44932
|
+
}
|
|
44875
44933
|
/**
|
|
44876
|
-
* The steps an internal Action may contain:
|
|
44934
|
+
* The steps an internal Action may contain: command and wait, and nothing that can
|
|
44877
44935
|
* call back into an Action — so an Action can never reach itself (no cycles).
|
|
44878
44936
|
* This is the LEAF shape: no condition of its own.
|
|
44879
44937
|
*/
|
|
44880
|
-
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema,
|
|
44881
|
-
message: "a cap step needs a target",
|
|
44882
|
-
path: ["target"]
|
|
44883
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44884
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44885
|
-
path: ["actionId"]
|
|
44886
|
-
})]);
|
|
44938
|
+
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
|
|
44887
44939
|
/**
|
|
44888
44940
|
* The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
|
|
44889
44941
|
* on the state mirror when the step is reached; `else` runs when it is false.
|
|
@@ -44904,13 +44956,7 @@ var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refi
|
|
|
44904
44956
|
* same two step kinds an automation runs, minus a guard that reads the
|
|
44905
44957
|
* automation's trigger, which such a list does not have.
|
|
44906
44958
|
*/
|
|
44907
|
-
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema,
|
|
44908
|
-
message: "a cap step needs a target",
|
|
44909
|
-
path: ["target"]
|
|
44910
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44911
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44912
|
-
path: ["actionId"]
|
|
44913
|
-
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
|
|
44959
|
+
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCommandStepBaseSchema.extend(stepGuardShape).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
|
|
44914
44960
|
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
44915
44961
|
code: "custom",
|
|
44916
44962
|
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
@@ -44925,17 +44971,11 @@ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, Automa
|
|
|
44925
44971
|
var continueOnErrorShape = {
|
|
44926
44972
|
/** A failure of this step is traced `failed-continued` and the next step runs. */
|
|
44927
44973
|
continueOnError: literal(true).optional() };
|
|
44928
|
-
/** An automation's
|
|
44929
|
-
var
|
|
44974
|
+
/** An automation's command step: the shared guarded command step, plus `continueOnError`. */
|
|
44975
|
+
var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
|
|
44930
44976
|
...stepGuardShape,
|
|
44931
44977
|
...continueOnErrorShape
|
|
44932
|
-
}).refine((step) => step.
|
|
44933
|
-
message: "a cap step needs a target",
|
|
44934
|
-
path: ["target"]
|
|
44935
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44936
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44937
|
-
path: ["actionId"]
|
|
44938
|
-
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
44978
|
+
}).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
44939
44979
|
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
44940
44980
|
var AutomationStopStepSchema = object({
|
|
44941
44981
|
kind: literal("stop"),
|
|
@@ -45015,13 +45055,7 @@ function nestTooDeep(issue) {
|
|
|
45015
45055
|
}
|
|
45016
45056
|
var plainStepSchemas = [
|
|
45017
45057
|
AutomationWaitStepSchema.strict(),
|
|
45018
|
-
|
|
45019
|
-
message: "a cap step needs a target",
|
|
45020
|
-
path: ["target"]
|
|
45021
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
45022
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
45023
|
-
path: ["actionId"]
|
|
45024
|
-
}),
|
|
45058
|
+
AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
|
|
45025
45059
|
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
45026
45060
|
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
45027
45061
|
AutomationRunActionStepSchema.strict()
|
|
@@ -45032,7 +45066,7 @@ var plainStepSchemas = [
|
|
|
45032
45066
|
*/
|
|
45033
45067
|
var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
|
|
45034
45068
|
/** A step that can run beside others: it writes no variable and does not end the run. */
|
|
45035
|
-
var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "
|
|
45069
|
+
var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "command" || step.kind === "action" || step.kind === "wait", "a parallel holds device commands, actions and waits only: a set or a stop beside other steps has no order");
|
|
45036
45070
|
/**
|
|
45037
45071
|
* Several steps at once (#500): all are started together and all are awaited.
|
|
45038
45072
|
* A failure fails the run once the others finished, as in a sequence; a member
|
|
@@ -45112,7 +45146,7 @@ var AutomationBodyStepSchema = discriminatedUnion("kind", [
|
|
|
45112
45146
|
var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
|
|
45113
45147
|
var AutomationActionSchema = discriminatedUnion("kind", [
|
|
45114
45148
|
GuardedWaitStepSchema,
|
|
45115
|
-
|
|
45149
|
+
AutomationGuardedCommandStepSchema,
|
|
45116
45150
|
AutomationStopStepSchema,
|
|
45117
45151
|
AutomationSetStepSchema,
|
|
45118
45152
|
chooseSchemaOf(AutomationBodyStepSchema),
|
|
@@ -45183,86 +45217,6 @@ function convertLegacyRecipe(legacy) {
|
|
|
45183
45217
|
};
|
|
45184
45218
|
}
|
|
45185
45219
|
var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
|
|
45186
|
-
var DETECTION_DESCRIPTIONS = {
|
|
45187
|
-
deviceId: "the camera that saw it",
|
|
45188
|
-
className: "what it saw",
|
|
45189
|
-
trackId: "the track",
|
|
45190
|
-
score: "how sure the detector was",
|
|
45191
|
-
label: "the label it matched (a name, a plate), empty when none"
|
|
45192
|
-
};
|
|
45193
|
-
var STATIONARY_DESCRIPTIONS = {
|
|
45194
|
-
deviceId: "the camera that saw it",
|
|
45195
|
-
className: "what it saw",
|
|
45196
|
-
zones: "the zones it is in",
|
|
45197
|
-
phase: "appeared or departed",
|
|
45198
|
-
entryId: "the stopped object"
|
|
45199
|
-
};
|
|
45200
|
-
var BECOMES_DESCRIPTIONS = {
|
|
45201
|
-
deviceId: "the device that changed",
|
|
45202
|
-
from: "the value before the change, empty when it is not known",
|
|
45203
|
-
to: "the value it changed to"
|
|
45204
|
-
};
|
|
45205
|
-
/**
|
|
45206
|
-
* A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
|
|
45207
|
-
* those names depend on the device, so they are not in this list.
|
|
45208
|
-
*/
|
|
45209
|
-
var FIRED_DESCRIPTIONS = {
|
|
45210
|
-
deviceId: "the device that fired",
|
|
45211
|
-
eventType: "the event, as the device names it",
|
|
45212
|
-
sourceId: "the part of the device that fired (a button), empty when it names none",
|
|
45213
|
-
eventKind: "the kind of press (press, long-press …), empty when the device declares none"
|
|
45214
|
-
};
|
|
45215
|
-
function describe$1(descriptions) {
|
|
45216
|
-
return Object.entries(descriptions).map(([name, description]) => ({
|
|
45217
|
-
name,
|
|
45218
|
-
description
|
|
45219
|
-
}));
|
|
45220
|
-
}
|
|
45221
|
-
describe$1(DETECTION_DESCRIPTIONS);
|
|
45222
|
-
describe$1(STATIONARY_DESCRIPTIONS);
|
|
45223
|
-
describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45224
|
-
...v,
|
|
45225
|
-
hintKey: "firedDeviceId"
|
|
45226
|
-
} : v);
|
|
45227
|
-
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45228
|
-
...v,
|
|
45229
|
-
hintKey: "becomesDeviceId"
|
|
45230
|
-
} : v);
|
|
45231
|
-
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
45232
|
-
/**
|
|
45233
|
-
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
45234
|
-
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
45235
|
-
* (NO normalization). Two shapes:
|
|
45236
|
-
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
45237
|
-
* declared set (e.g. press_short, press_long, …).
|
|
45238
|
-
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
45239
|
-
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
45240
|
-
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
45241
|
-
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
45242
|
-
* A fire names the part of the device it came from in `sourceId` when the
|
|
45243
|
-
* vocabulary declares sources (a remote's buttons).
|
|
45244
|
-
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
45245
|
-
*/
|
|
45246
|
-
var EventFireSchema = object({
|
|
45247
|
-
deviceId: number$1(),
|
|
45248
|
-
eventType: string(),
|
|
45249
|
-
sourceId: string().optional(),
|
|
45250
|
-
data: record(string(), unknown()).nullable(),
|
|
45251
|
-
timestamp: number$1().meta(readingMeta("none")),
|
|
45252
|
-
seq: number$1().meta(readingMeta("count"))
|
|
45253
|
-
});
|
|
45254
|
-
var EventEmitterStatusSchema = object({
|
|
45255
|
-
eventTypes: array(string()),
|
|
45256
|
-
/**
|
|
45257
|
-
* Required of a provider by the type. A status written before the field
|
|
45258
|
-
* existed still parses, as an empty vocabulary: read it through
|
|
45259
|
-
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
45260
|
-
*/
|
|
45261
|
-
vocabulary: array(EventVocabularyEntrySchema).default([]),
|
|
45262
|
-
lastEvent: EventFireSchema.nullable(),
|
|
45263
|
-
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
45264
|
-
});
|
|
45265
|
-
DeviceType.EventEmitter;
|
|
45266
45220
|
/**
|
|
45267
45221
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
45268
45222
|
*
|
|
@@ -45661,6 +45615,86 @@ var AutomationStateDocSchema = object({
|
|
|
45661
45615
|
lastRunStartedAt: number$1().nullable(),
|
|
45662
45616
|
traces: array(AutomationRunTraceSchema)
|
|
45663
45617
|
});
|
|
45618
|
+
var DETECTION_DESCRIPTIONS = {
|
|
45619
|
+
deviceId: "the camera that saw it",
|
|
45620
|
+
className: "what it saw",
|
|
45621
|
+
trackId: "the track",
|
|
45622
|
+
score: "how sure the detector was",
|
|
45623
|
+
label: "the label it matched (a name, a plate), empty when none"
|
|
45624
|
+
};
|
|
45625
|
+
var STATIONARY_DESCRIPTIONS = {
|
|
45626
|
+
deviceId: "the camera that saw it",
|
|
45627
|
+
className: "what it saw",
|
|
45628
|
+
zones: "the zones it is in",
|
|
45629
|
+
phase: "appeared or departed",
|
|
45630
|
+
entryId: "the stopped object"
|
|
45631
|
+
};
|
|
45632
|
+
var BECOMES_DESCRIPTIONS = {
|
|
45633
|
+
deviceId: "the device that changed",
|
|
45634
|
+
from: "the value before the change, empty when it is not known",
|
|
45635
|
+
to: "the value it changed to"
|
|
45636
|
+
};
|
|
45637
|
+
/**
|
|
45638
|
+
* A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
|
|
45639
|
+
* those names depend on the device, so they are not in this list.
|
|
45640
|
+
*/
|
|
45641
|
+
var FIRED_DESCRIPTIONS = {
|
|
45642
|
+
deviceId: "the device that fired",
|
|
45643
|
+
eventType: "the event, as the device names it",
|
|
45644
|
+
sourceId: "the part of the device that fired (a button), empty when it names none",
|
|
45645
|
+
eventKind: "the kind of press (press, long-press …), empty when the device declares none"
|
|
45646
|
+
};
|
|
45647
|
+
function describe$1(descriptions) {
|
|
45648
|
+
return Object.entries(descriptions).map(([name, description]) => ({
|
|
45649
|
+
name,
|
|
45650
|
+
description
|
|
45651
|
+
}));
|
|
45652
|
+
}
|
|
45653
|
+
describe$1(DETECTION_DESCRIPTIONS);
|
|
45654
|
+
describe$1(STATIONARY_DESCRIPTIONS);
|
|
45655
|
+
describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45656
|
+
...v,
|
|
45657
|
+
hintKey: "firedDeviceId"
|
|
45658
|
+
} : v);
|
|
45659
|
+
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45660
|
+
...v,
|
|
45661
|
+
hintKey: "becomesDeviceId"
|
|
45662
|
+
} : v);
|
|
45663
|
+
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
45664
|
+
/**
|
|
45665
|
+
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
45666
|
+
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
45667
|
+
* (NO normalization). Two shapes:
|
|
45668
|
+
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
45669
|
+
* declared set (e.g. press_short, press_long, …).
|
|
45670
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
45671
|
+
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
45672
|
+
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
45673
|
+
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
45674
|
+
* A fire names the part of the device it came from in `sourceId` when the
|
|
45675
|
+
* vocabulary declares sources (a remote's buttons).
|
|
45676
|
+
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
45677
|
+
*/
|
|
45678
|
+
var EventFireSchema = object({
|
|
45679
|
+
deviceId: number$1(),
|
|
45680
|
+
eventType: string(),
|
|
45681
|
+
sourceId: string().optional(),
|
|
45682
|
+
data: record(string(), unknown()).nullable(),
|
|
45683
|
+
timestamp: number$1().meta(readingMeta("none")),
|
|
45684
|
+
seq: number$1().meta(readingMeta("count"))
|
|
45685
|
+
});
|
|
45686
|
+
var EventEmitterStatusSchema = object({
|
|
45687
|
+
eventTypes: array(string()),
|
|
45688
|
+
/**
|
|
45689
|
+
* Required of a provider by the type. A status written before the field
|
|
45690
|
+
* existed still parses, as an empty vocabulary: read it through
|
|
45691
|
+
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
45692
|
+
*/
|
|
45693
|
+
vocabulary: array(EventVocabularyEntrySchema).default([]),
|
|
45694
|
+
lastEvent: EventFireSchema.nullable(),
|
|
45695
|
+
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
45696
|
+
});
|
|
45697
|
+
DeviceType.EventEmitter;
|
|
45664
45698
|
/**
|
|
45665
45699
|
* Actions — named, runnable things an operator (or an automation) can start,
|
|
45666
45700
|
* declared as LIST ENTRIES, never as devices.
|
|
@@ -45923,6 +45957,343 @@ function pruneDeletedEntities(selection, live, log, exporter) {
|
|
|
45923
45957
|
dropped
|
|
45924
45958
|
};
|
|
45925
45959
|
}
|
|
45960
|
+
/**
|
|
45961
|
+
* `device-export` — collection cap for addons that export camstack
|
|
45962
|
+
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
45963
|
+
* HomeKit/HAP, Alexa Smart Home, …).
|
|
45964
|
+
*
|
|
45965
|
+
* No `ecosystem` enum — the addon id identifies the export target.
|
|
45966
|
+
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
45967
|
+
* exposes only the COMMON surface: link state, supported device
|
|
45968
|
+
* kinds (so the UI can filter the device picker), and per-device
|
|
45969
|
+
* expose/unexpose.
|
|
45970
|
+
*
|
|
45971
|
+
* INSTANCES. One export addon can serve several independent targets (a
|
|
45972
|
+
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
45973
|
+
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
45974
|
+
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
45975
|
+
* default instance's); present = that instance; an id the provider does not
|
|
45976
|
+
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
45977
|
+
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
45978
|
+
* change always names the target it changes. A single-instance provider
|
|
45979
|
+
* accepts an absent id on a read or its own id, and refuses any other.
|
|
45980
|
+
*/
|
|
45981
|
+
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
45982
|
+
var InstanceIdSchema$1 = string().min(1);
|
|
45983
|
+
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
45984
|
+
/** One independent export target of an addon. */
|
|
45985
|
+
var ExportInstanceSchema = object({
|
|
45986
|
+
instanceId: InstanceIdSchema$1,
|
|
45987
|
+
name: string(),
|
|
45988
|
+
enabled: boolean(),
|
|
45989
|
+
kind: string().optional(),
|
|
45990
|
+
/**
|
|
45991
|
+
* What this instance's platform accepts as a device name, in one operator-facing sentence
|
|
45992
|
+
* (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
|
|
45993
|
+
* about the rule.
|
|
45994
|
+
*/
|
|
45995
|
+
nameRule: string().optional()
|
|
45996
|
+
});
|
|
45997
|
+
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
45998
|
+
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
45999
|
+
var ExportInstanceUnknownError = class extends Error {
|
|
46000
|
+
code = EXPORT_INSTANCE_UNKNOWN;
|
|
46001
|
+
instanceId;
|
|
46002
|
+
constructor(addon, instanceId) {
|
|
46003
|
+
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
46004
|
+
this.name = "ExportInstanceUnknownError";
|
|
46005
|
+
this.instanceId = instanceId;
|
|
46006
|
+
}
|
|
46007
|
+
};
|
|
46008
|
+
/**
|
|
46009
|
+
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
46010
|
+
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
46011
|
+
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
46012
|
+
*/
|
|
46013
|
+
function statusInstanceOf(input) {
|
|
46014
|
+
return "instanceId" in input ? input.instanceId : void 0;
|
|
46015
|
+
}
|
|
46016
|
+
var LinkStateSchema = _enum([
|
|
46017
|
+
"unlinked",
|
|
46018
|
+
"linked",
|
|
46019
|
+
"error"
|
|
46020
|
+
]);
|
|
46021
|
+
/**
|
|
46022
|
+
* A single label/value row surfaced in the export panel's "Setup"
|
|
46023
|
+
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
46024
|
+
* rows are masked by default with a reveal toggle (client ids,
|
|
46025
|
+
* secrets, …).
|
|
46026
|
+
*/
|
|
46027
|
+
var ExportSetupFieldSchema = object({
|
|
46028
|
+
label: string(),
|
|
46029
|
+
value: string(),
|
|
46030
|
+
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
46031
|
+
secret: boolean().optional()
|
|
46032
|
+
});
|
|
46033
|
+
/**
|
|
46034
|
+
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
46035
|
+
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
46036
|
+
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
46037
|
+
* the provider supplies and skips the section entirely when `setup`
|
|
46038
|
+
* is unset.
|
|
46039
|
+
*/
|
|
46040
|
+
var ExportSetupSchema = object({
|
|
46041
|
+
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
46042
|
+
qr: string().optional(),
|
|
46043
|
+
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
46044
|
+
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
46045
|
+
/** Free-form operator instructions rendered above the fields. */
|
|
46046
|
+
note: string().optional()
|
|
46047
|
+
});
|
|
46048
|
+
var DeviceExportStatusSchema = object({
|
|
46049
|
+
linkState: LinkStateSchema,
|
|
46050
|
+
exposedDeviceCount: number$1(),
|
|
46051
|
+
error: string().optional(),
|
|
46052
|
+
/**
|
|
46053
|
+
* Optional pairing/account info the panel renders in a generic
|
|
46054
|
+
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
46055
|
+
* export target, never an `ecosystem` key here.
|
|
46056
|
+
*/
|
|
46057
|
+
setup: ExportSetupSchema.optional()
|
|
46058
|
+
});
|
|
46059
|
+
var DeviceKindSchema = string();
|
|
46060
|
+
/**
|
|
46061
|
+
* EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
|
|
46062
|
+
* device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
|
|
46063
|
+
* store (D865), validated by the exporter against its platform's naming rules, and never reaches
|
|
46064
|
+
* the exported id — a rename updates the SAME device on the platform, never a second one.
|
|
46065
|
+
* Blank or `null` = the device's own name. A name the platform would refuse is refused with
|
|
46066
|
+
* `ExportNameRefusedError` (`export-name-refused`), whose message says why.
|
|
46067
|
+
*/
|
|
46068
|
+
var ExposedDeviceSchema = object({
|
|
46069
|
+
deviceId: string(),
|
|
46070
|
+
exposedAs: string().optional(),
|
|
46071
|
+
/** The operator's name for this device on this instance; absent = the device's own name. */
|
|
46072
|
+
exposedName: string().optional(),
|
|
46073
|
+
capabilities: array(string()).optional()
|
|
46074
|
+
});
|
|
46075
|
+
var ExposeInputSchema = object({
|
|
46076
|
+
instanceId: InstanceIdSchema$1,
|
|
46077
|
+
deviceId: string(),
|
|
46078
|
+
capabilities: array(string()).optional(),
|
|
46079
|
+
/** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
|
|
46080
|
+
exposedName: string().nullable().optional()
|
|
46081
|
+
});
|
|
46082
|
+
var SetExposedNameInputSchema = object({
|
|
46083
|
+
instanceId: InstanceIdSchema$1,
|
|
46084
|
+
deviceId: string(),
|
|
46085
|
+
/** Blank or null = the device's own name. */
|
|
46086
|
+
name: string().nullable(),
|
|
46087
|
+
/**
|
|
46088
|
+
* Validate only: refuse exactly as a real call would, write nothing. A caller saving several
|
|
46089
|
+
* names at once checks every one first, so one refusal writes none (D1049).
|
|
46090
|
+
*/
|
|
46091
|
+
dryRun: boolean().optional()
|
|
46092
|
+
});
|
|
46093
|
+
var EXPORT_NAME_REFUSED = "export-name-refused";
|
|
46094
|
+
/** A name the instance's platform would refuse. The message starts with the code, then the reason. */
|
|
46095
|
+
var ExportNameRefusedError = class extends Error {
|
|
46096
|
+
code = EXPORT_NAME_REFUSED;
|
|
46097
|
+
instanceId;
|
|
46098
|
+
reason;
|
|
46099
|
+
constructor(instanceId, reason) {
|
|
46100
|
+
super(`${EXPORT_NAME_REFUSED}: ${reason}`);
|
|
46101
|
+
this.name = "ExportNameRefusedError";
|
|
46102
|
+
this.instanceId = instanceId;
|
|
46103
|
+
this.reason = reason;
|
|
46104
|
+
}
|
|
46105
|
+
};
|
|
46106
|
+
var UnexposeInputSchema = object({
|
|
46107
|
+
instanceId: InstanceIdSchema$1,
|
|
46108
|
+
deviceId: string()
|
|
46109
|
+
});
|
|
46110
|
+
/**
|
|
46111
|
+
* What an exporter may expose besides devices (D968). An action and a
|
|
46112
|
+
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
46113
|
+
* exporter's own selection, not the device registry.
|
|
46114
|
+
*/
|
|
46115
|
+
var ExportEntityKindSchema = _enum([
|
|
46116
|
+
"device",
|
|
46117
|
+
"action",
|
|
46118
|
+
"notifier"
|
|
46119
|
+
]);
|
|
46120
|
+
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
46121
|
+
object({
|
|
46122
|
+
kind: literal("device"),
|
|
46123
|
+
deviceId: string()
|
|
46124
|
+
}),
|
|
46125
|
+
object({
|
|
46126
|
+
kind: literal("action"),
|
|
46127
|
+
actionId: string().min(1)
|
|
46128
|
+
}),
|
|
46129
|
+
object({
|
|
46130
|
+
kind: literal("notifier"),
|
|
46131
|
+
targetId: string().min(1)
|
|
46132
|
+
})
|
|
46133
|
+
]);
|
|
46134
|
+
var ExposedEntitySchema = object({
|
|
46135
|
+
entity: ExportEntityRefSchema,
|
|
46136
|
+
exposedAs: string().optional()
|
|
46137
|
+
});
|
|
46138
|
+
var ExposeEntityInputSchema = object({
|
|
46139
|
+
instanceId: InstanceIdSchema$1,
|
|
46140
|
+
entity: ExportEntityRefSchema
|
|
46141
|
+
});
|
|
46142
|
+
var UnexposeEntityInputSchema = object({
|
|
46143
|
+
instanceId: InstanceIdSchema$1,
|
|
46144
|
+
entity: ExportEntityRefSchema
|
|
46145
|
+
});
|
|
46146
|
+
var deviceExportCapability = {
|
|
46147
|
+
name: "device-export",
|
|
46148
|
+
scope: "system",
|
|
46149
|
+
mode: "collection",
|
|
46150
|
+
providerKind: "device-export",
|
|
46151
|
+
status: {
|
|
46152
|
+
schema: DeviceExportStatusSchema,
|
|
46153
|
+
kind: "poll"
|
|
46154
|
+
},
|
|
46155
|
+
/**
|
|
46156
|
+
* Each export provider MAY contribute its own per-device "Export" panel
|
|
46157
|
+
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
46158
|
+
* framework methods are mounted on the cap router when present.
|
|
46159
|
+
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
46160
|
+
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
46161
|
+
* never hand-written — D14 — and an exporter is not one of those).
|
|
46162
|
+
*/
|
|
46163
|
+
exposesDeviceSettings: true,
|
|
46164
|
+
methods: {
|
|
46165
|
+
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
46166
|
+
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
46167
|
+
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
46168
|
+
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
46169
|
+
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
46170
|
+
kind: "mutation",
|
|
46171
|
+
auth: "admin"
|
|
46172
|
+
}),
|
|
46173
|
+
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
46174
|
+
kind: "mutation",
|
|
46175
|
+
auth: "admin"
|
|
46176
|
+
}),
|
|
46177
|
+
setExposedName: method(SetExposedNameInputSchema, _void(), {
|
|
46178
|
+
kind: "mutation",
|
|
46179
|
+
auth: "admin"
|
|
46180
|
+
}),
|
|
46181
|
+
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
46182
|
+
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
46183
|
+
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
46184
|
+
kind: "mutation",
|
|
46185
|
+
auth: "admin"
|
|
46186
|
+
}),
|
|
46187
|
+
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
46188
|
+
kind: "mutation",
|
|
46189
|
+
auth: "admin"
|
|
46190
|
+
})
|
|
46191
|
+
}
|
|
46192
|
+
};
|
|
46193
|
+
/**
|
|
46194
|
+
* The exposed name of a device on one export instance (`device-export`, D1049).
|
|
46195
|
+
*
|
|
46196
|
+
* Every exporter keeps its names the same way: in ITS per-device store (D865), under
|
|
46197
|
+
* {@link EXPOSED_NAMES_STORE_KEY}, one entry per instance id. The store is cleared centrally
|
|
46198
|
+
* when the device is deleted, so no removal hook is needed for it. Each exporter supplies the
|
|
46199
|
+
* validator of its own platform; the normalisation, the store shape and the refusal are here so
|
|
46200
|
+
* the four exporters cannot drift apart.
|
|
46201
|
+
*
|
|
46202
|
+
* The name is a label only: no exporter derives the exported id from it, so a rename updates
|
|
46203
|
+
* the same device on the platform.
|
|
46204
|
+
*/
|
|
46205
|
+
/** The per-device store key holding `{ [instanceId]: name }`. */
|
|
46206
|
+
var EXPOSED_NAMES_STORE_KEY = "exposedNames";
|
|
46207
|
+
var ExposedNamesSchema = record(string(), string());
|
|
46208
|
+
/** Trim and collapse whitespace, then the platform rule. Blank or null clears (`name: null`). */
|
|
46209
|
+
function checkExposedName(raw, validate) {
|
|
46210
|
+
if (raw === null || raw === void 0) return {
|
|
46211
|
+
ok: true,
|
|
46212
|
+
name: null
|
|
46213
|
+
};
|
|
46214
|
+
if (typeof raw !== "string") return {
|
|
46215
|
+
ok: false,
|
|
46216
|
+
reason: "The name must be text."
|
|
46217
|
+
};
|
|
46218
|
+
const name = raw.trim().replace(/\s+/g, " ");
|
|
46219
|
+
if (name.length === 0) return {
|
|
46220
|
+
ok: true,
|
|
46221
|
+
name: null
|
|
46222
|
+
};
|
|
46223
|
+
return validate(name);
|
|
46224
|
+
}
|
|
46225
|
+
/** Every saved name of a device, by instance id. A malformed blob reads as none. */
|
|
46226
|
+
function readExposedNames(store) {
|
|
46227
|
+
const parsed = ExposedNamesSchema.safeParse(store[EXPOSED_NAMES_STORE_KEY]);
|
|
46228
|
+
return parsed.success ? parsed.data : {};
|
|
46229
|
+
}
|
|
46230
|
+
/**
|
|
46231
|
+
* The saved name of one instance, or null: never saved, or a stored value the platform would
|
|
46232
|
+
* now refuse (the device's own name is used rather than pushing a name the platform rejects).
|
|
46233
|
+
*/
|
|
46234
|
+
function readExposedName(store, instanceId, validate) {
|
|
46235
|
+
const saved = readExposedNames(store)[instanceId];
|
|
46236
|
+
if (saved === void 0) return null;
|
|
46237
|
+
const check = checkExposedName(saved, validate);
|
|
46238
|
+
return check.ok ? check.name : null;
|
|
46239
|
+
}
|
|
46240
|
+
/** The store patch that sets (or, with null, clears) one instance's name and keeps the others. */
|
|
46241
|
+
function exposedNamePatch(store, instanceId, name) {
|
|
46242
|
+
const others = Object.fromEntries(Object.entries(readExposedNames(store)).filter(([id]) => id !== instanceId));
|
|
46243
|
+
return { [EXPOSED_NAMES_STORE_KEY]: name === null ? others : {
|
|
46244
|
+
...others,
|
|
46245
|
+
[instanceId]: name
|
|
46246
|
+
} };
|
|
46247
|
+
}
|
|
46248
|
+
/**
|
|
46249
|
+
* Validate and save one instance's name. A name the platform would refuse throws
|
|
46250
|
+
* {@link ExportNameRefusedError} BEFORE anything is written, so the old name stays.
|
|
46251
|
+
*/
|
|
46252
|
+
async function saveExposedName(input) {
|
|
46253
|
+
const check = checkExposedName(input.raw, input.validate);
|
|
46254
|
+
if (!check.ok) throw new ExportNameRefusedError(input.instanceId, check.reason);
|
|
46255
|
+
if (input.dryRun === true) return {
|
|
46256
|
+
changed: false,
|
|
46257
|
+
name: check.name
|
|
46258
|
+
};
|
|
46259
|
+
const store = await input.store.read(input.deviceId);
|
|
46260
|
+
if ((readExposedNames(store)[input.instanceId] ?? null) === check.name) return {
|
|
46261
|
+
changed: false,
|
|
46262
|
+
name: check.name
|
|
46263
|
+
};
|
|
46264
|
+
await input.store.write(input.deviceId, exposedNamePatch(store, input.instanceId, check.name));
|
|
46265
|
+
return {
|
|
46266
|
+
changed: true,
|
|
46267
|
+
name: check.name
|
|
46268
|
+
};
|
|
46269
|
+
}
|
|
46270
|
+
/** The exporter's per-device store as an {@link ExposedNameStore}; throws when settings are absent. */
|
|
46271
|
+
function exposedNameStoreOf(settings, owner) {
|
|
46272
|
+
const access = () => {
|
|
46273
|
+
if (settings === void 0) throw new Error(`${owner}: settings are not available`);
|
|
46274
|
+
return settings;
|
|
46275
|
+
};
|
|
46276
|
+
return {
|
|
46277
|
+
read: (deviceId) => access().readDeviceStore(deviceId),
|
|
46278
|
+
write: (deviceId, patch) => access().writeDeviceStore(deviceId, patch)
|
|
46279
|
+
};
|
|
46280
|
+
}
|
|
46281
|
+
/**
|
|
46282
|
+
* Remove every name saved for `instanceId` (the instance was deleted), so a later instance that
|
|
46283
|
+
* reuses the id does not inherit them. Returns the device ids that lost a name. A store that
|
|
46284
|
+
* cannot be read throws; nothing is written for the devices not reached.
|
|
46285
|
+
*/
|
|
46286
|
+
async function pruneExposedNames(settings, instanceId) {
|
|
46287
|
+
const ids = await settings.listDeviceStoreIds();
|
|
46288
|
+
if (ids.length === 0) return [];
|
|
46289
|
+
const pruned = [];
|
|
46290
|
+
for (const [deviceId, store] of await settings.readDeviceStoreBatch(ids)) {
|
|
46291
|
+
if (readExposedNames(store)[instanceId] === void 0) continue;
|
|
46292
|
+
await settings.writeDeviceStore(deviceId, exposedNamePatch(store, instanceId, null));
|
|
46293
|
+
pruned.push(deviceId);
|
|
46294
|
+
}
|
|
46295
|
+
return pruned;
|
|
46296
|
+
}
|
|
45926
46297
|
_enum([
|
|
45927
46298
|
"automation",
|
|
45928
46299
|
"action",
|
|
@@ -50209,11 +50580,13 @@ var IrCodecError = class extends Error {
|
|
|
50209
50580
|
this.code = code;
|
|
50210
50581
|
}
|
|
50211
50582
|
};
|
|
50583
|
+
/** Maximum number of mark/space entries one pulse train may carry. */
|
|
50584
|
+
var IR_TIMINGS_MAX = 1024;
|
|
50212
50585
|
/**
|
|
50213
50586
|
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
50214
50587
|
* alternating, no zeros, 2..1024 entries.
|
|
50215
50588
|
*/
|
|
50216
|
-
var IrTimingsSchema = array(number$1().int()).min(2).max(
|
|
50589
|
+
var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
|
|
50217
50590
|
timings.forEach((value, index) => {
|
|
50218
50591
|
const expectMark = index % 2 === 0;
|
|
50219
50592
|
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
@@ -50260,15 +50633,186 @@ function decodePronto(code) {
|
|
|
50260
50633
|
carrierHz: Math.round(1e6 / unitUs)
|
|
50261
50634
|
};
|
|
50262
50635
|
}
|
|
50263
|
-
/**
|
|
50264
|
-
|
|
50265
|
-
|
|
50266
|
-
|
|
50267
|
-
|
|
50268
|
-
|
|
50269
|
-
|
|
50270
|
-
|
|
50271
|
-
|
|
50636
|
+
/**
|
|
50637
|
+
* FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
|
|
50638
|
+
* literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
|
|
50639
|
+
* is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
|
|
50640
|
+
* between the low 5 bits and the next byte.
|
|
50641
|
+
*/
|
|
50642
|
+
var MAX_DISTANCE = 8192;
|
|
50643
|
+
var MAX_LITERAL_RUN = 32;
|
|
50644
|
+
var MIN_MATCH = 3;
|
|
50645
|
+
var MAX_MATCH = 264;
|
|
50646
|
+
/**
|
|
50647
|
+
* Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
|
|
50648
|
+
* can expand ~130x, so the decoder checks this bound before every write.
|
|
50649
|
+
*/
|
|
50650
|
+
var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
|
|
50651
|
+
function fastlzDecompress(input) {
|
|
50652
|
+
const out = [];
|
|
50653
|
+
let ip = 0;
|
|
50654
|
+
const room = (count) => {
|
|
50655
|
+
if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
|
|
50656
|
+
};
|
|
50657
|
+
const next = () => {
|
|
50658
|
+
const byte = input[ip++];
|
|
50659
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
|
|
50660
|
+
return byte;
|
|
50661
|
+
};
|
|
50662
|
+
while (ip < input.length) {
|
|
50663
|
+
const ctrl = next();
|
|
50664
|
+
if (ctrl < 32) {
|
|
50665
|
+
room(ctrl + 1);
|
|
50666
|
+
for (let i = 0; i <= ctrl; i++) out.push(next());
|
|
50667
|
+
continue;
|
|
50668
|
+
}
|
|
50669
|
+
let len = (ctrl >> 5) - 1;
|
|
50670
|
+
if (len === 6) len += next();
|
|
50671
|
+
const distance = ((ctrl & 31) << 8) + next() + 1;
|
|
50672
|
+
const start = out.length - distance;
|
|
50673
|
+
if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
|
|
50674
|
+
room(len + 3);
|
|
50675
|
+
for (let i = 0; i < len + 3; i++) {
|
|
50676
|
+
const byte = out[start + i];
|
|
50677
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
|
|
50678
|
+
out.push(byte);
|
|
50679
|
+
}
|
|
50680
|
+
}
|
|
50681
|
+
return Uint8Array.from(out);
|
|
50682
|
+
}
|
|
50683
|
+
function fastlzCompress(input) {
|
|
50684
|
+
const out = [];
|
|
50685
|
+
const lastSeen = /* @__PURE__ */ new Map();
|
|
50686
|
+
let literalStart = 0;
|
|
50687
|
+
const flushLiterals = (end) => {
|
|
50688
|
+
for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
|
|
50689
|
+
const to = Math.min(from + MAX_LITERAL_RUN, end);
|
|
50690
|
+
out.push(to - from - 1);
|
|
50691
|
+
for (let i = from; i < to; i++) out.push(input[i] ?? 0);
|
|
50692
|
+
}
|
|
50693
|
+
};
|
|
50694
|
+
let pos = 0;
|
|
50695
|
+
while (pos < input.length) {
|
|
50696
|
+
let matchLen = 0;
|
|
50697
|
+
let matchDistance = 0;
|
|
50698
|
+
if (pos + MIN_MATCH <= input.length) {
|
|
50699
|
+
const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
|
|
50700
|
+
const candidate = lastSeen.get(key);
|
|
50701
|
+
lastSeen.set(key, pos);
|
|
50702
|
+
if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
|
|
50703
|
+
let len = 0;
|
|
50704
|
+
while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
|
|
50705
|
+
if (len >= MIN_MATCH) {
|
|
50706
|
+
matchLen = len;
|
|
50707
|
+
matchDistance = pos - candidate - 1;
|
|
50708
|
+
}
|
|
50709
|
+
}
|
|
50710
|
+
}
|
|
50711
|
+
if (matchLen === 0) {
|
|
50712
|
+
pos++;
|
|
50713
|
+
continue;
|
|
50714
|
+
}
|
|
50715
|
+
flushLiterals(pos);
|
|
50716
|
+
const enc = matchLen - 2;
|
|
50717
|
+
if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
|
|
50718
|
+
else out.push(224 | matchDistance >> 8, enc - 7);
|
|
50719
|
+
out.push(matchDistance & 255);
|
|
50720
|
+
pos += matchLen;
|
|
50721
|
+
literalStart = pos;
|
|
50722
|
+
}
|
|
50723
|
+
flushLiterals(input.length);
|
|
50724
|
+
return Uint8Array.from(out);
|
|
50725
|
+
}
|
|
50726
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
50727
|
+
var MAX_DURATION_US = 65535;
|
|
50728
|
+
function toBase64(bytes) {
|
|
50729
|
+
let out = "";
|
|
50730
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
50731
|
+
const a = bytes[i] ?? 0;
|
|
50732
|
+
const b = bytes[i + 1] ?? 0;
|
|
50733
|
+
const c = bytes[i + 2] ?? 0;
|
|
50734
|
+
const word = a << 16 | b << 8 | c;
|
|
50735
|
+
out += ALPHABET[word >> 18 & 63];
|
|
50736
|
+
out += ALPHABET[word >> 12 & 63];
|
|
50737
|
+
out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
|
|
50738
|
+
out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
|
|
50739
|
+
}
|
|
50740
|
+
return out;
|
|
50741
|
+
}
|
|
50742
|
+
function fromBase64(text) {
|
|
50743
|
+
const clean = text.trim().replace(/=+$/, "");
|
|
50744
|
+
if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
50745
|
+
const out = [];
|
|
50746
|
+
let bits = 0;
|
|
50747
|
+
let acc = 0;
|
|
50748
|
+
for (const ch of clean) {
|
|
50749
|
+
const value = ALPHABET.indexOf(ch);
|
|
50750
|
+
if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
50751
|
+
acc = acc << 6 | value;
|
|
50752
|
+
bits += 6;
|
|
50753
|
+
if (bits >= 8) {
|
|
50754
|
+
bits -= 8;
|
|
50755
|
+
out.push(acc >> bits & 255);
|
|
50756
|
+
}
|
|
50757
|
+
}
|
|
50758
|
+
return Uint8Array.from(out);
|
|
50759
|
+
}
|
|
50760
|
+
/** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
|
|
50761
|
+
function encodeTuya(timings) {
|
|
50762
|
+
const bytes = new Uint8Array(timings.length * 2);
|
|
50763
|
+
timings.forEach((value, index) => {
|
|
50764
|
+
const duration = Math.abs(value);
|
|
50765
|
+
if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
|
|
50766
|
+
bytes[index * 2] = duration & 255;
|
|
50767
|
+
bytes[index * 2 + 1] = duration >> 8;
|
|
50768
|
+
});
|
|
50769
|
+
return toBase64(fastlzCompress(bytes));
|
|
50770
|
+
}
|
|
50771
|
+
/** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
|
|
50772
|
+
function decodeTuya(code) {
|
|
50773
|
+
const bytes = fastlzDecompress(fromBase64(code));
|
|
50774
|
+
if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
|
|
50775
|
+
const timings = [];
|
|
50776
|
+
for (let i = 0; i < bytes.length; i += 2) {
|
|
50777
|
+
const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
|
|
50778
|
+
timings.push(i / 2 % 2 === 0 ? duration : -duration);
|
|
50779
|
+
}
|
|
50780
|
+
const checked = IrTimingsSchema.safeParse(timings);
|
|
50781
|
+
if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
|
|
50782
|
+
return checked.data;
|
|
50783
|
+
}
|
|
50784
|
+
/** Device-native IR code formats a transmitter can replay verbatim. */
|
|
50785
|
+
var IrNativeFormatSchema = _enum(["tuya"]);
|
|
50786
|
+
/**
|
|
50787
|
+
* Longest native code accepted: base64 of the worst-case compressed stream
|
|
50788
|
+
* (every decoded byte as a literal, plus one control byte per 32), with margin.
|
|
50789
|
+
*/
|
|
50790
|
+
var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
|
|
50791
|
+
var IrNativeCodeSchema = object({
|
|
50792
|
+
format: IrNativeFormatSchema,
|
|
50793
|
+
code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
|
|
50794
|
+
});
|
|
50795
|
+
var IR_NATIVE_CODECS = { tuya: {
|
|
50796
|
+
encode: encodeTuya,
|
|
50797
|
+
decode: decodeTuya
|
|
50798
|
+
} };
|
|
50799
|
+
/** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
|
|
50800
|
+
var IrPayloadSchema = discriminatedUnion("kind", [
|
|
50801
|
+
object({
|
|
50802
|
+
kind: literal("raw"),
|
|
50803
|
+
timings: array(number$1().int()),
|
|
50804
|
+
settings: TransmitSettingsSchema.optional()
|
|
50805
|
+
}),
|
|
50806
|
+
object({
|
|
50807
|
+
kind: literal("pronto"),
|
|
50808
|
+
code: string()
|
|
50809
|
+
}),
|
|
50810
|
+
object({
|
|
50811
|
+
kind: literal("native"),
|
|
50812
|
+
format: IrNativeFormatSchema,
|
|
50813
|
+
code: string()
|
|
50814
|
+
})
|
|
50815
|
+
]);
|
|
50272
50816
|
/** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
|
|
50273
50817
|
function toTimings(payload) {
|
|
50274
50818
|
if (payload.kind === "pronto") {
|
|
@@ -50278,6 +50822,10 @@ function toTimings(payload) {
|
|
|
50278
50822
|
settings: { carrierHz: decoded.carrierHz }
|
|
50279
50823
|
};
|
|
50280
50824
|
}
|
|
50825
|
+
if (payload.kind === "native") return {
|
|
50826
|
+
timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
|
|
50827
|
+
settings: {}
|
|
50828
|
+
};
|
|
50281
50829
|
const checked = IrTimingsSchema.safeParse(payload.timings);
|
|
50282
50830
|
if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
|
|
50283
50831
|
return {
|
|
@@ -52362,193 +52910,6 @@ method(object({
|
|
|
52362
52910
|
kind: "mutation",
|
|
52363
52911
|
auth: "admin"
|
|
52364
52912
|
});
|
|
52365
|
-
/**
|
|
52366
|
-
* `device-export` — collection cap for addons that export camstack
|
|
52367
|
-
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
52368
|
-
* HomeKit/HAP, Alexa Smart Home, …).
|
|
52369
|
-
*
|
|
52370
|
-
* No `ecosystem` enum — the addon id identifies the export target.
|
|
52371
|
-
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
52372
|
-
* exposes only the COMMON surface: link state, supported device
|
|
52373
|
-
* kinds (so the UI can filter the device picker), and per-device
|
|
52374
|
-
* expose/unexpose.
|
|
52375
|
-
*
|
|
52376
|
-
* INSTANCES. One export addon can serve several independent targets (a
|
|
52377
|
-
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
52378
|
-
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
52379
|
-
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
52380
|
-
* default instance's); present = that instance; an id the provider does not
|
|
52381
|
-
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
52382
|
-
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
52383
|
-
* change always names the target it changes. A single-instance provider
|
|
52384
|
-
* accepts an absent id on a read or its own id, and refuses any other.
|
|
52385
|
-
*/
|
|
52386
|
-
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
52387
|
-
var InstanceIdSchema$1 = string().min(1);
|
|
52388
|
-
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
52389
|
-
/** One independent export target of an addon. */
|
|
52390
|
-
var ExportInstanceSchema = object({
|
|
52391
|
-
instanceId: InstanceIdSchema$1,
|
|
52392
|
-
name: string(),
|
|
52393
|
-
enabled: boolean(),
|
|
52394
|
-
kind: string().optional()
|
|
52395
|
-
});
|
|
52396
|
-
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
52397
|
-
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
52398
|
-
var ExportInstanceUnknownError = class extends Error {
|
|
52399
|
-
code = EXPORT_INSTANCE_UNKNOWN;
|
|
52400
|
-
instanceId;
|
|
52401
|
-
constructor(addon, instanceId) {
|
|
52402
|
-
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
52403
|
-
this.name = "ExportInstanceUnknownError";
|
|
52404
|
-
this.instanceId = instanceId;
|
|
52405
|
-
}
|
|
52406
|
-
};
|
|
52407
|
-
/**
|
|
52408
|
-
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
52409
|
-
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
52410
|
-
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
52411
|
-
*/
|
|
52412
|
-
function statusInstanceOf(input) {
|
|
52413
|
-
return "instanceId" in input ? input.instanceId : void 0;
|
|
52414
|
-
}
|
|
52415
|
-
var LinkStateSchema = _enum([
|
|
52416
|
-
"unlinked",
|
|
52417
|
-
"linked",
|
|
52418
|
-
"error"
|
|
52419
|
-
]);
|
|
52420
|
-
/**
|
|
52421
|
-
* A single label/value row surfaced in the export panel's "Setup"
|
|
52422
|
-
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
52423
|
-
* rows are masked by default with a reveal toggle (client ids,
|
|
52424
|
-
* secrets, …).
|
|
52425
|
-
*/
|
|
52426
|
-
var ExportSetupFieldSchema = object({
|
|
52427
|
-
label: string(),
|
|
52428
|
-
value: string(),
|
|
52429
|
-
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
52430
|
-
secret: boolean().optional()
|
|
52431
|
-
});
|
|
52432
|
-
/**
|
|
52433
|
-
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
52434
|
-
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
52435
|
-
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
52436
|
-
* the provider supplies and skips the section entirely when `setup`
|
|
52437
|
-
* is unset.
|
|
52438
|
-
*/
|
|
52439
|
-
var ExportSetupSchema = object({
|
|
52440
|
-
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
52441
|
-
qr: string().optional(),
|
|
52442
|
-
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
52443
|
-
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
52444
|
-
/** Free-form operator instructions rendered above the fields. */
|
|
52445
|
-
note: string().optional()
|
|
52446
|
-
});
|
|
52447
|
-
var DeviceExportStatusSchema = object({
|
|
52448
|
-
linkState: LinkStateSchema,
|
|
52449
|
-
exposedDeviceCount: number$1(),
|
|
52450
|
-
error: string().optional(),
|
|
52451
|
-
/**
|
|
52452
|
-
* Optional pairing/account info the panel renders in a generic
|
|
52453
|
-
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
52454
|
-
* export target, never an `ecosystem` key here.
|
|
52455
|
-
*/
|
|
52456
|
-
setup: ExportSetupSchema.optional()
|
|
52457
|
-
});
|
|
52458
|
-
var DeviceKindSchema = string();
|
|
52459
|
-
var ExposedDeviceSchema = object({
|
|
52460
|
-
deviceId: string(),
|
|
52461
|
-
exposedAs: string().optional(),
|
|
52462
|
-
capabilities: array(string()).optional()
|
|
52463
|
-
});
|
|
52464
|
-
var ExposeInputSchema = object({
|
|
52465
|
-
instanceId: InstanceIdSchema$1,
|
|
52466
|
-
deviceId: string(),
|
|
52467
|
-
capabilities: array(string()).optional()
|
|
52468
|
-
});
|
|
52469
|
-
var UnexposeInputSchema = object({
|
|
52470
|
-
instanceId: InstanceIdSchema$1,
|
|
52471
|
-
deviceId: string()
|
|
52472
|
-
});
|
|
52473
|
-
/**
|
|
52474
|
-
* What an exporter may expose besides devices (D968). An action and a
|
|
52475
|
-
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
52476
|
-
* exporter's own selection, not the device registry.
|
|
52477
|
-
*/
|
|
52478
|
-
var ExportEntityKindSchema = _enum([
|
|
52479
|
-
"device",
|
|
52480
|
-
"action",
|
|
52481
|
-
"notifier"
|
|
52482
|
-
]);
|
|
52483
|
-
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
52484
|
-
object({
|
|
52485
|
-
kind: literal("device"),
|
|
52486
|
-
deviceId: string()
|
|
52487
|
-
}),
|
|
52488
|
-
object({
|
|
52489
|
-
kind: literal("action"),
|
|
52490
|
-
actionId: string().min(1)
|
|
52491
|
-
}),
|
|
52492
|
-
object({
|
|
52493
|
-
kind: literal("notifier"),
|
|
52494
|
-
targetId: string().min(1)
|
|
52495
|
-
})
|
|
52496
|
-
]);
|
|
52497
|
-
var ExposedEntitySchema = object({
|
|
52498
|
-
entity: ExportEntityRefSchema,
|
|
52499
|
-
exposedAs: string().optional()
|
|
52500
|
-
});
|
|
52501
|
-
var ExposeEntityInputSchema = object({
|
|
52502
|
-
instanceId: InstanceIdSchema$1,
|
|
52503
|
-
entity: ExportEntityRefSchema
|
|
52504
|
-
});
|
|
52505
|
-
var UnexposeEntityInputSchema = object({
|
|
52506
|
-
instanceId: InstanceIdSchema$1,
|
|
52507
|
-
entity: ExportEntityRefSchema
|
|
52508
|
-
});
|
|
52509
|
-
var deviceExportCapability = {
|
|
52510
|
-
name: "device-export",
|
|
52511
|
-
scope: "system",
|
|
52512
|
-
mode: "collection",
|
|
52513
|
-
providerKind: "device-export",
|
|
52514
|
-
status: {
|
|
52515
|
-
schema: DeviceExportStatusSchema,
|
|
52516
|
-
kind: "poll"
|
|
52517
|
-
},
|
|
52518
|
-
/**
|
|
52519
|
-
* Each export provider MAY contribute its own per-device "Export" panel
|
|
52520
|
-
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
52521
|
-
* framework methods are mounted on the cap router when present.
|
|
52522
|
-
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
52523
|
-
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
52524
|
-
* never hand-written — D14 — and an exporter is not one of those).
|
|
52525
|
-
*/
|
|
52526
|
-
exposesDeviceSettings: true,
|
|
52527
|
-
methods: {
|
|
52528
|
-
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
52529
|
-
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
52530
|
-
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
52531
|
-
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
52532
|
-
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
52533
|
-
kind: "mutation",
|
|
52534
|
-
auth: "admin"
|
|
52535
|
-
}),
|
|
52536
|
-
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
52537
|
-
kind: "mutation",
|
|
52538
|
-
auth: "admin"
|
|
52539
|
-
}),
|
|
52540
|
-
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
52541
|
-
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
52542
|
-
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
52543
|
-
kind: "mutation",
|
|
52544
|
-
auth: "admin"
|
|
52545
|
-
}),
|
|
52546
|
-
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
52547
|
-
kind: "mutation",
|
|
52548
|
-
auth: "admin"
|
|
52549
|
-
})
|
|
52550
|
-
}
|
|
52551
|
-
};
|
|
52552
52913
|
var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
52553
52914
|
var DeviceTemplateSchema = string().min(1).max(4096);
|
|
52554
52915
|
/** One value a caller hands the renderer for `thisDevice`. */
|
|
@@ -56697,6 +57058,128 @@ var StateLookSchema = object({
|
|
|
56697
57058
|
background: _enum(HERO_BACKGROUNDS),
|
|
56698
57059
|
animation: HeroAnimationSchema
|
|
56699
57060
|
});
|
|
57061
|
+
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
57062
|
+
var HeroTextSchema = object({
|
|
57063
|
+
en: string(),
|
|
57064
|
+
it: string()
|
|
57065
|
+
});
|
|
57066
|
+
/**
|
|
57067
|
+
* The ONE measurement a simple sensor shows (card wave, phase 1).
|
|
57068
|
+
*
|
|
57069
|
+
* A sensor that measures a single quantity (a temperature, a humidity, a power,
|
|
57070
|
+
* a contact, a text state) is drawn as that reading, once, big, inside a scene
|
|
57071
|
+
* whose motion says what the number means: heat rising when hot, flakes when
|
|
57072
|
+
* cold, a wire flowing at the speed of the power, a ring while a window is
|
|
57073
|
+
* open. Everything the card draws is decided here; a client only paints it.
|
|
57074
|
+
*/
|
|
57075
|
+
var HERO_MEASUREMENT_QUANTITIES = [
|
|
57076
|
+
"temperature",
|
|
57077
|
+
"humidity",
|
|
57078
|
+
"power",
|
|
57079
|
+
"contact",
|
|
57080
|
+
"text"
|
|
57081
|
+
];
|
|
57082
|
+
/** How a temperature reads to a person; drives the heat or the cold scene. */
|
|
57083
|
+
var HERO_MEASUREMENT_BANDS = [
|
|
57084
|
+
"hot",
|
|
57085
|
+
"mild",
|
|
57086
|
+
"cold"
|
|
57087
|
+
];
|
|
57088
|
+
/** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
|
|
57089
|
+
var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
|
|
57090
|
+
var HeroMeasurementReadingSchema = object({
|
|
57091
|
+
value: number$1(),
|
|
57092
|
+
quantity: ReadingQuantitySchema
|
|
57093
|
+
});
|
|
57094
|
+
var HeroMeasurementSchema = object({
|
|
57095
|
+
quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
|
|
57096
|
+
reading: HeroMeasurementReadingSchema.nullable(),
|
|
57097
|
+
icon: IconKeySchema.nullable(),
|
|
57098
|
+
value: HeroTextSchema,
|
|
57099
|
+
unit: string().nullable(),
|
|
57100
|
+
band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
|
|
57101
|
+
level: number$1().min(0).max(1).nullable(),
|
|
57102
|
+
word: HeroTextSchema,
|
|
57103
|
+
tone: _enum(HERO_TONES),
|
|
57104
|
+
since: number$1().nullable(),
|
|
57105
|
+
sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
|
|
57106
|
+
historyKey: string().nullable()
|
|
57107
|
+
});
|
|
57108
|
+
var same$2 = (text) => t(text, text);
|
|
57109
|
+
var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
|
|
57110
|
+
var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
|
|
57111
|
+
function temperatureBand(celsius) {
|
|
57112
|
+
if (celsius < 12) return "cold";
|
|
57113
|
+
if (celsius > 28) return "hot";
|
|
57114
|
+
return "mild";
|
|
57115
|
+
}
|
|
57116
|
+
var BAND_WORD = {
|
|
57117
|
+
hot: t("Hot", "Caldo"),
|
|
57118
|
+
mild: t("Normal", "Normale"),
|
|
57119
|
+
cold: t("Cold", "Freddo")
|
|
57120
|
+
};
|
|
57121
|
+
var BAND_TONE = {
|
|
57122
|
+
hot: "warning",
|
|
57123
|
+
mild: "muted",
|
|
57124
|
+
cold: "info"
|
|
57125
|
+
};
|
|
57126
|
+
function temperatureMeasurement(celsius, since) {
|
|
57127
|
+
const band = temperatureBand(celsius);
|
|
57128
|
+
return {
|
|
57129
|
+
quantity: "temperature",
|
|
57130
|
+
reading: {
|
|
57131
|
+
value: celsius,
|
|
57132
|
+
quantity: "temperature"
|
|
57133
|
+
},
|
|
57134
|
+
icon: "thermometer",
|
|
57135
|
+
value: same$2(trimmed(celsius, 1)),
|
|
57136
|
+
unit: "°C",
|
|
57137
|
+
band,
|
|
57138
|
+
level: null,
|
|
57139
|
+
word: BAND_WORD[band],
|
|
57140
|
+
tone: BAND_TONE[band],
|
|
57141
|
+
since,
|
|
57142
|
+
sinceKind: "updated",
|
|
57143
|
+
historyKey: "cap:temperature-sensor.temperature"
|
|
57144
|
+
};
|
|
57145
|
+
}
|
|
57146
|
+
function humidityMeasurement(percent, since) {
|
|
57147
|
+
const dry = percent < 30;
|
|
57148
|
+
const humid = percent > 70;
|
|
57149
|
+
return {
|
|
57150
|
+
quantity: "humidity",
|
|
57151
|
+
reading: {
|
|
57152
|
+
value: percent,
|
|
57153
|
+
quantity: "humidity"
|
|
57154
|
+
},
|
|
57155
|
+
icon: "droplets",
|
|
57156
|
+
value: same$2(String(Math.round(percent))),
|
|
57157
|
+
unit: "%",
|
|
57158
|
+
band: null,
|
|
57159
|
+
level: clamp01$1(percent / 100),
|
|
57160
|
+
word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
|
|
57161
|
+
tone: dry || humid ? "warning" : "info",
|
|
57162
|
+
since,
|
|
57163
|
+
sinceKind: "updated",
|
|
57164
|
+
historyKey: "cap:humidity-sensor.humidity"
|
|
57165
|
+
};
|
|
57166
|
+
}
|
|
57167
|
+
function textMeasurement(text, since) {
|
|
57168
|
+
return {
|
|
57169
|
+
quantity: "text",
|
|
57170
|
+
reading: null,
|
|
57171
|
+
icon: null,
|
|
57172
|
+
value: same$2(text),
|
|
57173
|
+
unit: null,
|
|
57174
|
+
band: null,
|
|
57175
|
+
level: null,
|
|
57176
|
+
word: t("Changed", "Cambiato"),
|
|
57177
|
+
tone: "muted",
|
|
57178
|
+
since,
|
|
57179
|
+
sinceKind: "updated",
|
|
57180
|
+
historyKey: null
|
|
57181
|
+
};
|
|
57182
|
+
}
|
|
56700
57183
|
/** The scene as the model carries it. `null` = the device did not say (never a guess). */
|
|
56701
57184
|
var HeroSceneSchema = object({
|
|
56702
57185
|
id: _enum([
|
|
@@ -56748,11 +57231,6 @@ var HeroSceneSchema = object({
|
|
|
56748
57231
|
});
|
|
56749
57232
|
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, 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.HeatPump, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
56750
57233
|
DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
|
|
56751
|
-
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
56752
|
-
var HeroTextSchema = object({
|
|
56753
|
-
en: string(),
|
|
56754
|
-
it: string()
|
|
56755
|
-
});
|
|
56756
57234
|
var HeroRowIdSchema = _enum([
|
|
56757
57235
|
"progress",
|
|
56758
57236
|
"run-for",
|
|
@@ -56858,6 +57336,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
|
|
|
56858
57336
|
optionLabels: record(string(), HeroTextSchema).optional(),
|
|
56859
57337
|
call: HeroCallSchema,
|
|
56860
57338
|
valueArg: string()
|
|
57339
|
+
}),
|
|
57340
|
+
object({
|
|
57341
|
+
kind: literal("number"),
|
|
57342
|
+
id: string(),
|
|
57343
|
+
label: HeroTextSchema,
|
|
57344
|
+
value: number$1().nullable(),
|
|
57345
|
+
/** `null` = any number; the device rounds what it does not accept. */
|
|
57346
|
+
step: number$1().nullable(),
|
|
57347
|
+
unit: string(),
|
|
57348
|
+
call: HeroCallSchema,
|
|
57349
|
+
valueArg: string()
|
|
57350
|
+
}),
|
|
57351
|
+
object({
|
|
57352
|
+
kind: literal("text"),
|
|
57353
|
+
id: string(),
|
|
57354
|
+
label: HeroTextSchema,
|
|
57355
|
+
value: string().nullable(),
|
|
57356
|
+
call: HeroCallSchema,
|
|
57357
|
+
valueArg: string()
|
|
56861
57358
|
})
|
|
56862
57359
|
]);
|
|
56863
57360
|
/** Declared by its interface: a `z.infer` of one more icon union pushes the cap's inferred type past what the compiler can print. */
|
|
@@ -57059,6 +57556,11 @@ var HeroModelSchema = object({
|
|
|
57059
57556
|
timedRun: HeroTimedRunSlotSchema.nullable(),
|
|
57060
57557
|
powerSupply: HeroPowerSupplySlotSchema.nullable(),
|
|
57061
57558
|
rows: array(HeroRowSchema),
|
|
57559
|
+
/**
|
|
57560
|
+
* The ONE measurement of a simple sensor, drawn once inside the scene in place of
|
|
57561
|
+
* the caption, tiles and value chips. Absent = the card draws as before.
|
|
57562
|
+
*/
|
|
57563
|
+
measurement: HeroMeasurementSchema.optional(),
|
|
57062
57564
|
/** Ids of parts that actuate the device, hidden from a session that may not act on it. */
|
|
57063
57565
|
gated: array(string()),
|
|
57064
57566
|
provenance: array(HeroProvenanceSchema)
|
|
@@ -57130,8 +57632,23 @@ var HeroRowModelSchema = object({
|
|
|
57130
57632
|
* the call. Absent or empty = `primary` alone.
|
|
57131
57633
|
*/
|
|
57132
57634
|
extras: array(HeroControlSchema).max(2).optional(),
|
|
57133
|
-
trailing: HeroFactSchema.nullable()
|
|
57635
|
+
trailing: HeroFactSchema.nullable(),
|
|
57636
|
+
/**
|
|
57637
|
+
* The simple sensor's one reading (the hero's `measurement`): the row draws its value
|
|
57638
|
+
* at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
|
|
57639
|
+
* older server or a device that is not a simple sensor: draw `trailing`.
|
|
57640
|
+
*/
|
|
57641
|
+
measurement: HeroMeasurementSchema.optional()
|
|
57134
57642
|
});
|
|
57643
|
+
new Set([
|
|
57644
|
+
"temperature",
|
|
57645
|
+
"humidity",
|
|
57646
|
+
"pressure",
|
|
57647
|
+
"illuminance",
|
|
57648
|
+
"reading",
|
|
57649
|
+
"air-quality",
|
|
57650
|
+
"valve"
|
|
57651
|
+
]);
|
|
57135
57652
|
DeviceType.Climate;
|
|
57136
57653
|
DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
|
|
57137
57654
|
/**
|
|
@@ -57448,6 +57965,12 @@ var IntegrationLiteSchema = object({
|
|
|
57448
57965
|
var AvailableIntegrationTypeSchema = object({
|
|
57449
57966
|
addonId: string(),
|
|
57450
57967
|
name: string(),
|
|
57968
|
+
/**
|
|
57969
|
+
* Product name a new integration is prefilled from (`<label> - Home`).
|
|
57970
|
+
* Absent: the client uses `name`. Set when the catalog title is not the
|
|
57971
|
+
* product (Bosch SHC, MQTT).
|
|
57972
|
+
*/
|
|
57973
|
+
providerLabel: string().optional(),
|
|
57451
57974
|
description: string(),
|
|
57452
57975
|
iconUrl: string().nullable(),
|
|
57453
57976
|
color: string(),
|
|
@@ -57959,13 +58482,32 @@ var IrSendResultSchema = object({
|
|
|
57959
58482
|
var IrTransmitterInfoSchema = object({
|
|
57960
58483
|
media: array(IrMediumSchema),
|
|
57961
58484
|
settable: array(TransmitSettingKeySchema),
|
|
57962
|
-
maxTimings: number$1().int().positive()
|
|
58485
|
+
maxTimings: number$1().int().positive(),
|
|
58486
|
+
/** The transmitter can learn a code (`learn`). */
|
|
58487
|
+
learn: boolean().default(false),
|
|
58488
|
+
/** Native code formats the transmitter replays verbatim (`send.native`). */
|
|
58489
|
+
formats: array(IrNativeFormatSchema).default([])
|
|
58490
|
+
});
|
|
58491
|
+
var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
|
|
58492
|
+
var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
|
|
58493
|
+
var IrLearnResultSchema = object({
|
|
58494
|
+
/** The code in the device's own format, when it reports one. */
|
|
58495
|
+
native: IrNativeCodeSchema.nullable(),
|
|
58496
|
+
timings: IrTimingsSchema,
|
|
58497
|
+
carrierHz: number$1().int().positive().nullable()
|
|
57963
58498
|
});
|
|
57964
58499
|
DeviceType.Generic, method(object({
|
|
57965
58500
|
deviceId: number$1().int().nonnegative(),
|
|
57966
|
-
timings: IrTimingsSchema,
|
|
58501
|
+
timings: IrTimingsSchema.optional(),
|
|
58502
|
+
native: IrNativeCodeSchema.optional(),
|
|
57967
58503
|
settings: TransmitSettingsSchema.optional()
|
|
57968
|
-
}), IrSendResultSchema, {
|
|
58504
|
+
}).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
|
|
58505
|
+
kind: "mutation",
|
|
58506
|
+
auth: "protected"
|
|
58507
|
+
}), method(object({
|
|
58508
|
+
deviceId: number$1().int().nonnegative(),
|
|
58509
|
+
timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
|
|
58510
|
+
}), IrLearnResultSchema, {
|
|
57969
58511
|
kind: "mutation",
|
|
57970
58512
|
auth: "protected"
|
|
57971
58513
|
}), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
|
|
@@ -67188,6 +67730,7 @@ var NcSystemEventKindSchema = _enum([
|
|
|
67188
67730
|
"recording-degraded",
|
|
67189
67731
|
"device-attention-required",
|
|
67190
67732
|
"device-attention-resolved",
|
|
67733
|
+
"device-command",
|
|
67191
67734
|
"storage-location-low",
|
|
67192
67735
|
"storage-location-critical",
|
|
67193
67736
|
"storage-location-ok",
|
|
@@ -67250,11 +67793,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
|
|
|
67250
67793
|
"alarm-sensor-bypass",
|
|
67251
67794
|
"alarm-disarmed"
|
|
67252
67795
|
];
|
|
67253
|
-
/**
|
|
67254
|
-
* One coherent system-event condition. `kinds` is the required opt-in safety
|
|
67255
|
-
* gate; the remaining lists are optional narrowing filters relevant to the
|
|
67256
|
-
* selected kinds.
|
|
67257
|
-
*/
|
|
67258
67796
|
var NcSystemEventConditionSchema = object({
|
|
67259
67797
|
kinds: array(NcSystemEventKindSchema).min(1),
|
|
67260
67798
|
deviceIds: array(number$1().int()).min(1).optional(),
|
|
@@ -67286,6 +67824,28 @@ var NcSystemEventConditionSchema = object({
|
|
|
67286
67824
|
nodeIds: array(string().min(1)).min(1).optional(),
|
|
67287
67825
|
packageNames: array(string().min(1)).min(1).optional(),
|
|
67288
67826
|
/**
|
|
67827
|
+
* `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
|
|
67828
|
+
* this rule speaks about - the same dictionary the automation action blocks
|
|
67829
|
+
* pick from. The hub refuses an id the action index does not know.
|
|
67830
|
+
*/
|
|
67831
|
+
commandActions: array(string().min(1)).min(1).optional(),
|
|
67832
|
+
/** `device-command` only: how the command settled. A device's own change is not a command. */
|
|
67833
|
+
commandOutcomes: array(_enum([
|
|
67834
|
+
"confirmed",
|
|
67835
|
+
"already",
|
|
67836
|
+
"unconfirmed",
|
|
67837
|
+
"failed"
|
|
67838
|
+
])).min(1).optional(),
|
|
67839
|
+
/** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
|
|
67840
|
+
commandActorKinds: array(_enum([
|
|
67841
|
+
"user",
|
|
67842
|
+
"addon",
|
|
67843
|
+
"action",
|
|
67844
|
+
"scheduler",
|
|
67845
|
+
"composition",
|
|
67846
|
+
"node"
|
|
67847
|
+
])).min(1).optional(),
|
|
67848
|
+
/**
|
|
67289
67849
|
* At or below this remaining-life %, a consumable is LOW for THIS rule
|
|
67290
67850
|
* (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
|
|
67291
67851
|
* {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
|
|
@@ -68266,6 +68826,13 @@ var NcRuleInputSchema = object({
|
|
|
68266
68826
|
*/
|
|
68267
68827
|
groupingSec: number$1().int().min(5).max(60).optional(),
|
|
68268
68828
|
/**
|
|
68829
|
+
* Hold deliveries of this rule to one target and, when two or more arrive
|
|
68830
|
+
* before the window ends, send them as one summary. Absent = the kind's
|
|
68831
|
+
* default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
|
|
68832
|
+
* other kind. `0` sends each delivery as it does today.
|
|
68833
|
+
*/
|
|
68834
|
+
groupWithinSec: number$1().int().min(0).max(300).optional(),
|
|
68835
|
+
/**
|
|
68269
68836
|
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
68270
68837
|
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
68271
68838
|
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
@@ -68702,7 +69269,12 @@ var NcHistoryEntrySchema = object({
|
|
|
68702
69269
|
* Assistant export) must render as "no image right now", never as a
|
|
68703
69270
|
* broken link.
|
|
68704
69271
|
*/
|
|
68705
|
-
artifactIds: array(string().min(1)).optional()
|
|
69272
|
+
artifactIds: array(string().min(1)).optional(),
|
|
69273
|
+
/**
|
|
69274
|
+
* When this row was folded into a group-window summary, the outbox id of
|
|
69275
|
+
* that one notification. Absent on a row that was sent as itself.
|
|
69276
|
+
*/
|
|
69277
|
+
groupedInto: string().min(1).optional()
|
|
68706
69278
|
});
|
|
68707
69279
|
/**
|
|
68708
69280
|
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
@@ -74165,10 +74737,15 @@ var RecordingSignalStatusSchema = object({
|
|
|
74165
74737
|
});
|
|
74166
74738
|
RecordingSignalStatusSchema.extend({ lastFetchedAt: number$1() });
|
|
74167
74739
|
DeviceType.Camera, method(object({ deviceId: number$1() }), RecordingSignalStatusSchema);
|
|
74168
|
-
var RemoteBindingSchema = object({ action:
|
|
74169
|
-
|
|
74170
|
-
|
|
74171
|
-
|
|
74740
|
+
var RemoteBindingSchema = object({ action: object({
|
|
74741
|
+
kind: literal("cap"),
|
|
74742
|
+
deviceId: number$1().int().nonnegative(),
|
|
74743
|
+
cap: string().min(1),
|
|
74744
|
+
method: string().min(1),
|
|
74745
|
+
args: record(string(), unknown()).optional(),
|
|
74746
|
+
/** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
|
|
74747
|
+
argUnits: record(string(), string().min(1)).optional()
|
|
74748
|
+
}) });
|
|
74172
74749
|
var RemoteCustomButtonSchema = object({
|
|
74173
74750
|
/** The slug after `custom:` in the role. */
|
|
74174
74751
|
key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
|
|
@@ -79602,6 +80179,13 @@ function contribution(cap, schema, build) {
|
|
|
79602
80179
|
}
|
|
79603
80180
|
};
|
|
79604
80181
|
}
|
|
80182
|
+
/** The fragment, carrying the cap's single measurement when it has one. */
|
|
80183
|
+
function measured(fragment, measurement) {
|
|
80184
|
+
return measurement === void 0 ? fragment : {
|
|
80185
|
+
...fragment,
|
|
80186
|
+
measurement
|
|
80187
|
+
};
|
|
80188
|
+
}
|
|
79605
80189
|
function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
|
|
79606
80190
|
return {
|
|
79607
80191
|
id,
|
|
@@ -80876,10 +81460,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
|
|
|
80876
81460
|
};
|
|
80877
81461
|
});
|
|
80878
81462
|
var CONTROL_LABEL = t("Value", "Valore");
|
|
80879
|
-
/**
|
|
81463
|
+
/**
|
|
81464
|
+
* A number with known bounds is a slider, one without a number field, a choice a picker,
|
|
81465
|
+
* free text a text field; a date stays read-only.
|
|
81466
|
+
*/
|
|
80880
81467
|
function controlRows(slice) {
|
|
80881
81468
|
if (slice.kind === "numeric" && typeof slice.value === "number") {
|
|
80882
|
-
if (slice.min === void 0 || slice.max === void 0) return [
|
|
81469
|
+
if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
|
|
81470
|
+
kind: "number",
|
|
81471
|
+
id: "control.value",
|
|
81472
|
+
label: CONTROL_LABEL,
|
|
81473
|
+
value: slice.value,
|
|
81474
|
+
step: slice.step ?? null,
|
|
81475
|
+
unit: "",
|
|
81476
|
+
call: {
|
|
81477
|
+
cap: "control",
|
|
81478
|
+
method: "setValue",
|
|
81479
|
+
args: { control: { kind: "numeric" } }
|
|
81480
|
+
},
|
|
81481
|
+
valueArg: "control.value"
|
|
81482
|
+
}])];
|
|
80883
81483
|
return [row$1("control", "sliders-horizontal", null, [{
|
|
80884
81484
|
kind: "slider",
|
|
80885
81485
|
id: "control.value",
|
|
@@ -80910,6 +81510,18 @@ function controlRows(slice) {
|
|
|
80910
81510
|
},
|
|
80911
81511
|
valueArg: "control.value"
|
|
80912
81512
|
}])];
|
|
81513
|
+
if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
|
|
81514
|
+
kind: "text",
|
|
81515
|
+
id: "control.value",
|
|
81516
|
+
label: CONTROL_LABEL,
|
|
81517
|
+
value: typeof slice.value === "string" ? slice.value : null,
|
|
81518
|
+
call: {
|
|
81519
|
+
cap: "control",
|
|
81520
|
+
method: "setValue",
|
|
81521
|
+
args: { control: { kind: "text" } }
|
|
81522
|
+
},
|
|
81523
|
+
valueArg: "control.value"
|
|
81524
|
+
}])];
|
|
80913
81525
|
return [];
|
|
80914
81526
|
}
|
|
80915
81527
|
var SENSORS_FAMILY_CONTRIBUTIONS = {
|
|
@@ -81265,15 +81877,15 @@ function sensorFragment(value, id, icon, en, it, text) {
|
|
|
81265
81877
|
tiles: { right: [tile$1(en, it, text)] }
|
|
81266
81878
|
};
|
|
81267
81879
|
}
|
|
81268
|
-
var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
|
|
81269
|
-
var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`));
|
|
81880
|
+
var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => measured(sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)), slice?.temperature == null ? void 0 : temperatureMeasurement(slice.temperature, slice.lastFetchedAt)));
|
|
81881
|
+
var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => measured(sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`), slice?.humidity == null ? void 0 : humidityMeasurement(slice.humidity, slice.lastFetchedAt)));
|
|
81270
81882
|
var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
|
|
81271
81883
|
var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
|
|
81272
81884
|
var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
|
|
81273
81885
|
var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
|
|
81274
81886
|
if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
|
|
81275
81887
|
if (slice.timestamp === true) return { reading: reading("sensor", "on") };
|
|
81276
|
-
return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
|
|
81888
|
+
return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
|
|
81277
81889
|
});
|
|
81278
81890
|
/** Index bands: the headline of an air-quality sensor is a word, not a number. */
|
|
81279
81891
|
function airQualityWord(aqi) {
|
|
@@ -84169,6 +84781,13 @@ Object.freeze({
|
|
|
84169
84781
|
access: "view",
|
|
84170
84782
|
role: "admin"
|
|
84171
84783
|
},
|
|
84784
|
+
"deviceExport.setExposedName": {
|
|
84785
|
+
capName: "device-export",
|
|
84786
|
+
capScope: "system",
|
|
84787
|
+
addonId: null,
|
|
84788
|
+
access: "create",
|
|
84789
|
+
role: "admin"
|
|
84790
|
+
},
|
|
84172
84791
|
"deviceExport.unexposeDevice": {
|
|
84173
84792
|
capName: "device-export",
|
|
84174
84793
|
capScope: "system",
|
|
@@ -86108,6 +86727,13 @@ Object.freeze({
|
|
|
86108
86727
|
access: "view",
|
|
86109
86728
|
role: "viewer"
|
|
86110
86729
|
},
|
|
86730
|
+
"irTransmitter.learn": {
|
|
86731
|
+
capName: "ir-transmitter",
|
|
86732
|
+
capScope: "device",
|
|
86733
|
+
addonId: null,
|
|
86734
|
+
access: "create",
|
|
86735
|
+
role: "viewer"
|
|
86736
|
+
},
|
|
86111
86737
|
"irTransmitter.send": {
|
|
86112
86738
|
capName: "ir-transmitter",
|
|
86113
86739
|
capScope: "device",
|
|
@@ -92626,48 +93252,6 @@ Object.freeze({
|
|
|
92626
93252
|
role: "admin"
|
|
92627
93253
|
}
|
|
92628
93254
|
});
|
|
92629
|
-
/**
|
|
92630
|
-
* "Do" actions an operator can pick for a device — presentation-free.
|
|
92631
|
-
*
|
|
92632
|
-
* The wire shape stays `{ cap, method, args }`. Since D920 this module no
|
|
92633
|
-
* longer HOLDS a catalogue: {@link DEVICE_DO_ACTIONS} is a projection of the
|
|
92634
|
-
* cap vocabulary (`cap-vocabulary/`), the one cap-keyed map of every action
|
|
92635
|
-
* and trigger — so a picker built on this module and one built on
|
|
92636
|
-
* `actionsForDevice` (the vocabulary resolver) can never disagree about what
|
|
92637
|
-
* a device can do. Ids, baked args and the matching of saved steps are the
|
|
92638
|
-
* vocabulary's; labels here are its English labels.
|
|
92639
|
-
*
|
|
92640
|
-
* Shared by the admin NC Sequences / rule Do editor and Automations; the
|
|
92641
|
-
* viewer can reuse the same catalogue once its step editor catches up.
|
|
92642
|
-
*/
|
|
92643
|
-
function openArgKind(offer) {
|
|
92644
|
-
if (offer.kind === "number") return "number";
|
|
92645
|
-
if (offer.kind === "dynamic" && offer.valueKind === "number") return "number";
|
|
92646
|
-
if (offer.kind === "enum" && offer.values.every((v) => typeof v.value === "number")) return "number";
|
|
92647
|
-
return "string";
|
|
92648
|
-
}
|
|
92649
|
-
function projectOpenArg(arg) {
|
|
92650
|
-
return {
|
|
92651
|
-
key: arg.key,
|
|
92652
|
-
label: arg.label.en,
|
|
92653
|
-
kind: openArgKind(arg.offer),
|
|
92654
|
-
offer: arg.offer,
|
|
92655
|
-
...arg.optional === true ? { optional: true } : {}
|
|
92656
|
-
};
|
|
92657
|
-
}
|
|
92658
|
-
function projectAction(cap, action) {
|
|
92659
|
-
const open = action.openArgs ?? [];
|
|
92660
|
-
return {
|
|
92661
|
-
id: action.id,
|
|
92662
|
-
label: action.label.en,
|
|
92663
|
-
cap,
|
|
92664
|
-
method: action.method,
|
|
92665
|
-
args: action.args ?? {},
|
|
92666
|
-
...open.length > 0 ? { openArgs: open.map(projectOpenArg) } : {}
|
|
92667
|
-
};
|
|
92668
|
-
}
|
|
92669
|
-
Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
|
|
92670
|
-
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, 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.HeatPump, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
92671
93255
|
DeviceFeature.BatteryOperated;
|
|
92672
93256
|
function bound(cap, methods = [], authority = "reported") {
|
|
92673
93257
|
return {
|
|
@@ -93984,6 +94568,11 @@ Object.freeze({
|
|
|
93984
94568
|
form: "single",
|
|
93985
94569
|
optional: false
|
|
93986
94570
|
}],
|
|
94571
|
+
"irTransmitter.learn": [{
|
|
94572
|
+
name: "deviceId",
|
|
94573
|
+
form: "single",
|
|
94574
|
+
optional: false
|
|
94575
|
+
}],
|
|
93987
94576
|
"irTransmitter.send": [{
|
|
93988
94577
|
name: "deviceId",
|
|
93989
94578
|
form: "single",
|
|
@@ -95923,7 +96512,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
|
|
|
95923
96512
|
"deviceTypes",
|
|
95924
96513
|
"nodeIds",
|
|
95925
96514
|
"packageNames",
|
|
95926
|
-
"consumableLowPercent"
|
|
96515
|
+
"consumableLowPercent",
|
|
96516
|
+
"commandActions",
|
|
96517
|
+
"commandOutcomes",
|
|
96518
|
+
"commandActorKinds"
|
|
95927
96519
|
];
|
|
95928
96520
|
new Map(Object.entries({
|
|
95929
96521
|
"device-online": "device-events",
|
|
@@ -95946,6 +96538,7 @@ new Map(Object.entries({
|
|
|
95946
96538
|
"recording-degraded": "device-events",
|
|
95947
96539
|
"device-attention-required": "device-events",
|
|
95948
96540
|
"device-attention-resolved": "device-events",
|
|
96541
|
+
"device-command": "device-events",
|
|
95949
96542
|
"node-online": "system",
|
|
95950
96543
|
"node-offline": "system",
|
|
95951
96544
|
"node-restarting": "system",
|
|
@@ -96046,6 +96639,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
|
|
|
96046
96639
|
label: "Needs attention",
|
|
96047
96640
|
kinds: ["device-attention-required", "device-attention-resolved"]
|
|
96048
96641
|
},
|
|
96642
|
+
{
|
|
96643
|
+
id: "device-command",
|
|
96644
|
+
family: "device-events",
|
|
96645
|
+
label: "Commands given to devices",
|
|
96646
|
+
kinds: ["device-command"]
|
|
96647
|
+
},
|
|
96049
96648
|
{
|
|
96050
96649
|
id: "nodes",
|
|
96051
96650
|
family: "system",
|
|
@@ -96123,6 +96722,15 @@ function systemEventKindsOfFamily(family) {
|
|
|
96123
96722
|
return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
|
|
96124
96723
|
}
|
|
96125
96724
|
NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
|
|
96725
|
+
new Set([
|
|
96726
|
+
"alarm.trigger",
|
|
96727
|
+
"alarm.disarm",
|
|
96728
|
+
"alarm.arm.home",
|
|
96729
|
+
"alarm.arm.away",
|
|
96730
|
+
"alarm.arm.night",
|
|
96731
|
+
"alarm.arm.vacation",
|
|
96732
|
+
"alarm.arm.custom_bypass"
|
|
96733
|
+
]);
|
|
96126
96734
|
/**
|
|
96127
96735
|
* WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
|
|
96128
96736
|
* persists (D640 "a sensor rule fires on the raise, the clear, or both").
|
|
@@ -96318,6 +96926,7 @@ var DEVICE_EVENTS = [
|
|
|
96318
96926
|
"recording-healthy",
|
|
96319
96927
|
"recording-degraded",
|
|
96320
96928
|
...DEVICE_ATTENTION,
|
|
96929
|
+
"device-command",
|
|
96321
96930
|
...ALARM
|
|
96322
96931
|
];
|
|
96323
96932
|
/** Every kind a summary may speak about — the two summarisable families. */
|
|
@@ -96471,6 +97080,9 @@ var STATE_SUMMARY_VARS = [
|
|
|
96471
97080
|
[...RULE_BODY_ONLY],
|
|
96472
97081
|
[...RULE_TEXT],
|
|
96473
97082
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
97083
|
+
[...RULE_TEXT],
|
|
97084
|
+
[...RULE_TEXT],
|
|
97085
|
+
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
96474
97086
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96475
97087
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96476
97088
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
@@ -105698,6 +106310,133 @@ function pickSkill(skills, lookup) {
|
|
|
105698
106310
|
return skills.find((s) => s.id === "export-alexa" && s.enabled) ?? null;
|
|
105699
106311
|
}
|
|
105700
106312
|
//#endregion
|
|
106313
|
+
//#region src/endpoints/alexa-name.ts
|
|
106314
|
+
/**
|
|
106315
|
+
* The Alexa naming rule (D875, amended by D1049): what a device may be called in Alexa.
|
|
106316
|
+
*
|
|
106317
|
+
* The name itself is the generic `device-export` exposed name (D1049): stored per skill
|
|
106318
|
+
* instance in this addon's per-device store, saved through `setExposedName`, and used as the
|
|
106319
|
+
* endpoint `friendlyName`. It never reaches the endpoint id (`<deviceId>__dev`), so renaming
|
|
106320
|
+
* updates the SAME Alexa device on the next AddOrUpdateReport instead of creating a duplicate.
|
|
106321
|
+
* This module holds only Amazon's rule, and the key of the retired Alexa-only name the
|
|
106322
|
+
* migration reads.
|
|
106323
|
+
*
|
|
106324
|
+
* Amazon's friendlyName rule (Alexa.Discovery objects, endpoint object): "Up
|
|
106325
|
+
* to 256 alphanumeric characters and spaces. Don't include special characters
|
|
106326
|
+
* or punctuation." Letters of any script count as alphanumeric, so an Italian
|
|
106327
|
+
* name keeps its accents. The validator rejects what Amazon would reject, with
|
|
106328
|
+
* a message the operator can act on.
|
|
106329
|
+
*/
|
|
106330
|
+
/**
|
|
106331
|
+
* Per-device store key of the RETIRED Alexa-only name (one per device, shared by every skill).
|
|
106332
|
+
* Only the migration `export-alexa/2026-11-12-alexa-name-to-exposed-name` reads it.
|
|
106333
|
+
*/
|
|
106334
|
+
var LEGACY_ALEXA_NAME_KEY = "alexaName";
|
|
106335
|
+
/** Amazon's rule, as the derived "Name on <skill>" field states it (D1049). */
|
|
106336
|
+
var ALEXA_NAME_RULE = `Amazon accepts letters, digits and spaces only (no punctuation), up to 256 characters.`;
|
|
106337
|
+
/** Letters (any script, with their combining marks), digits and spaces. */
|
|
106338
|
+
var ALLOWED_PATTERN = /^[\p{L}\p{M}\p{N} ]+$/u;
|
|
106339
|
+
/** Amazon's rule over a normalised, non-blank name. */
|
|
106340
|
+
var alexaNameValidator = (name) => {
|
|
106341
|
+
if (name.length > 256) return {
|
|
106342
|
+
ok: false,
|
|
106343
|
+
reason: `The Alexa name is ${name.length} characters; Amazon allows at most 256.`
|
|
106344
|
+
};
|
|
106345
|
+
if (!ALLOWED_PATTERN.test(name)) return {
|
|
106346
|
+
ok: false,
|
|
106347
|
+
reason: "The Alexa name may contain only letters, digits and spaces (Amazon rejects punctuation and special characters)."
|
|
106348
|
+
};
|
|
106349
|
+
return {
|
|
106350
|
+
ok: true,
|
|
106351
|
+
name
|
|
106352
|
+
};
|
|
106353
|
+
};
|
|
106354
|
+
/** Validate an operator-typed Alexa name. Blank clears it (`name: null`, the device name is used). */
|
|
106355
|
+
function validateAlexaName(raw) {
|
|
106356
|
+
return checkExposedName(raw, alexaNameValidator);
|
|
106357
|
+
}
|
|
106358
|
+
//#endregion
|
|
106359
|
+
//#region src/migrations/alexa-name-to-exposed-name.ts
|
|
106360
|
+
/**
|
|
106361
|
+
* The Alexa-only device name becomes the generic exposed name (D1049, amending D875).
|
|
106362
|
+
*
|
|
106363
|
+
* Before: one `alexaName` per device in this addon's per-device store (`addon-device-settings`,
|
|
106364
|
+
* row `export-alexa:<deviceId>.alexaName`), and every skill of the addon (planning#422) showed
|
|
106365
|
+
* it. After: the `device-export` exposed name of EVERY skill that exists, row
|
|
106366
|
+
* `export-alexa:<deviceId>.exposedNames` = `{ <skillId>: name, … }` — so each skill keeps calling
|
|
106367
|
+
* the device what it called it. A skill id that has no `skills` record (the default one on a hub
|
|
106368
|
+
* that never configured Alexa) gets nothing: no running skill would read it.
|
|
106369
|
+
*
|
|
106370
|
+
* One plan, so the copy and the delete commit together. A name is copied as Alexa read it
|
|
106371
|
+
* (normalised; a stored value Alexa would have refused was never used and is not copied). A name
|
|
106372
|
+
* already saved for a skill through the new field was saved by the build that reads it, so it is
|
|
106373
|
+
* never overwritten; the other skills of that device still get the old name. The legacy key is
|
|
106374
|
+
* deleted in every case: nothing reads it any more. A rerun finds no legacy key and does nothing.
|
|
106375
|
+
* A read that fails throws, nothing written.
|
|
106376
|
+
*/
|
|
106377
|
+
var OWNER = "export-alexa";
|
|
106378
|
+
/** The per-device settings table: one row per field, id `<addonId>:<deviceId>.<field>`. */
|
|
106379
|
+
var DEVICE_SETTINGS_TABLE = "addon-device-settings";
|
|
106380
|
+
var rowId$3 = (deviceId, field) => `${OWNER}:${deviceId}.${field}`;
|
|
106381
|
+
var rowOf = (deviceId, field, value) => ({
|
|
106382
|
+
addonId: OWNER,
|
|
106383
|
+
deviceId: String(deviceId),
|
|
106384
|
+
key: field,
|
|
106385
|
+
value
|
|
106386
|
+
});
|
|
106387
|
+
/** The held `exposedNames` blob as a record, or `{}` when it is not one. */
|
|
106388
|
+
function heldNames(value) {
|
|
106389
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
106390
|
+
return Object.fromEntries(Object.entries(value));
|
|
106391
|
+
}
|
|
106392
|
+
async function planAlexaNameToExposedName(ports) {
|
|
106393
|
+
const ids = await ports.listDeviceIds();
|
|
106394
|
+
if (ids.length === 0) return { edits: [] };
|
|
106395
|
+
const legacy = await ports.readDeviceField(ids, LEGACY_ALEXA_NAME_KEY);
|
|
106396
|
+
if (legacy.size === 0) return { edits: [] };
|
|
106397
|
+
const skills = await ports.listSkillIds();
|
|
106398
|
+
const held = await ports.readDeviceField([...legacy.keys()], EXPOSED_NAMES_STORE_KEY);
|
|
106399
|
+
const written = {};
|
|
106400
|
+
const expected = {};
|
|
106401
|
+
const retired = {};
|
|
106402
|
+
for (const [deviceId, stored] of legacy) {
|
|
106403
|
+
retired[rowId$3(deviceId, LEGACY_ALEXA_NAME_KEY)] = rowOf(deviceId, LEGACY_ALEXA_NAME_KEY, stored);
|
|
106404
|
+
const check = validateAlexaName(stored);
|
|
106405
|
+
if (!check.ok || check.name === null) continue;
|
|
106406
|
+
if (skills.length === 0) {
|
|
106407
|
+
ports.warn(`Alexa migration: device ${deviceId} had an Alexa name but no Alexa skill exists; it is not kept`);
|
|
106408
|
+
continue;
|
|
106409
|
+
}
|
|
106410
|
+
const before = held.has(deviceId) ? heldNames(held.get(deviceId)) : null;
|
|
106411
|
+
const merged = { ...before };
|
|
106412
|
+
for (const skillId of skills) {
|
|
106413
|
+
if (skillId in merged) {
|
|
106414
|
+
ports.warn(`Alexa migration: device ${deviceId} already has a name on skill ${skillId}; its old Alexa name is not copied there`);
|
|
106415
|
+
continue;
|
|
106416
|
+
}
|
|
106417
|
+
merged[skillId] = check.name;
|
|
106418
|
+
}
|
|
106419
|
+
if (before !== null && Object.keys(merged).length === Object.keys(before).length) continue;
|
|
106420
|
+
const id = rowId$3(deviceId, EXPOSED_NAMES_STORE_KEY);
|
|
106421
|
+
written[id] = rowOf(deviceId, EXPOSED_NAMES_STORE_KEY, merged);
|
|
106422
|
+
expected[id] = before === null ? null : rowOf(deviceId, EXPOSED_NAMES_STORE_KEY, held.get(deviceId));
|
|
106423
|
+
}
|
|
106424
|
+
const edits = [];
|
|
106425
|
+
if (Object.keys(written).length > 0) edits.push({
|
|
106426
|
+
op: "setKeys",
|
|
106427
|
+
scope: DEVICE_SETTINGS_TABLE,
|
|
106428
|
+
values: written,
|
|
106429
|
+
precondition: preconditionOf(expected)
|
|
106430
|
+
});
|
|
106431
|
+
edits.push({
|
|
106432
|
+
op: "deleteKeys",
|
|
106433
|
+
scope: DEVICE_SETTINGS_TABLE,
|
|
106434
|
+
keys: Object.keys(retired),
|
|
106435
|
+
precondition: preconditionOf(retired)
|
|
106436
|
+
});
|
|
106437
|
+
return { edits };
|
|
106438
|
+
}
|
|
106439
|
+
//#endregion
|
|
105701
106440
|
//#region src/migrations/drop-public-hub-url.ts
|
|
105702
106441
|
/**
|
|
105703
106442
|
* The hub's public URL is no longer a setting of this addon (planning#378): Alexa reads the
|
|
@@ -106297,6 +107036,7 @@ var EXPOSURE_TO_RECORD_ID = "export-alexa/2026-11-04-exposure-to-record";
|
|
|
106297
107036
|
var DROP_MOVED_EXPOSURE_ID = "export-alexa/2026-11-04-drop-moved-exposure";
|
|
106298
107037
|
var STATE_TO_INSTANCE_ID = "export-alexa/2026-11-04-state-to-instance";
|
|
106299
107038
|
var DROP_MOVED_STATE_ID = "export-alexa/2026-11-04-drop-moved-state";
|
|
107039
|
+
var ALEXA_NAME_TO_EXPOSED_NAME_ID = "export-alexa/2026-11-12-alexa-name-to-exposed-name";
|
|
106300
107040
|
var FIXTURE_MARK = "the endpoint sync state the migration does not know";
|
|
106301
107041
|
/**
|
|
106302
107042
|
* The `export-alexa` catalogue (D987): offered to the engine when the addon initialises. Every
|
|
@@ -106430,6 +107170,22 @@ var ADDON_MIGRATIONS = [
|
|
|
106430
107170
|
fixtureMark: FIXTURE_MARK
|
|
106431
107171
|
},
|
|
106432
107172
|
plan: planDropMovedState
|
|
107173
|
+
},
|
|
107174
|
+
{
|
|
107175
|
+
meta: {
|
|
107176
|
+
id: ALEXA_NAME_TO_EXPOSED_NAME_ID,
|
|
107177
|
+
owner: "export-alexa",
|
|
107178
|
+
level: "addon-state",
|
|
107179
|
+
seq: 9,
|
|
107180
|
+
dependsOn: [],
|
|
107181
|
+
store: "settings",
|
|
107182
|
+
scope: "cluster",
|
|
107183
|
+
onFailure: "tolerate",
|
|
107184
|
+
bodyKind: "plan",
|
|
107185
|
+
description: "Copy every device`s Alexa name to the exposed name of every Alexa skill and delete the alexaName key",
|
|
107186
|
+
fixtureMark: FIXTURE_MARK
|
|
107187
|
+
},
|
|
107188
|
+
plan: planAlexaNameToExposedName
|
|
106433
107189
|
}
|
|
106434
107190
|
];
|
|
106435
107191
|
//#endregion
|
|
@@ -107297,72 +108053,33 @@ var AlexaEgressPrewarm = class {
|
|
|
107297
108053
|
}
|
|
107298
108054
|
};
|
|
107299
108055
|
//#endregion
|
|
107300
|
-
//#region src/
|
|
107301
|
-
|
|
107302
|
-
|
|
107303
|
-
|
|
107304
|
-
|
|
107305
|
-
|
|
107306
|
-
|
|
107307
|
-
|
|
107308
|
-
|
|
107309
|
-
|
|
107310
|
-
|
|
107311
|
-
|
|
107312
|
-
|
|
107313
|
-
|
|
107314
|
-
|
|
107315
|
-
|
|
107316
|
-
|
|
107317
|
-
|
|
107318
|
-
|
|
107319
|
-
|
|
107320
|
-
|
|
107321
|
-
|
|
107322
|
-
|
|
107323
|
-
|
|
107324
|
-
|
|
107325
|
-
|
|
107326
|
-
|
|
107327
|
-
*/
|
|
107328
|
-
function validateAlexaName(raw) {
|
|
107329
|
-
if (raw === null || raw === void 0) return {
|
|
107330
|
-
ok: true,
|
|
107331
|
-
name: null
|
|
107332
|
-
};
|
|
107333
|
-
if (typeof raw !== "string") return {
|
|
107334
|
-
ok: false,
|
|
107335
|
-
error: "The Alexa name must be text."
|
|
107336
|
-
};
|
|
107337
|
-
const name = raw.trim().replace(/\s+/g, " ");
|
|
107338
|
-
if (name.length === 0) return {
|
|
107339
|
-
ok: true,
|
|
107340
|
-
name: null
|
|
107341
|
-
};
|
|
107342
|
-
if (name.length > 256) return {
|
|
107343
|
-
ok: false,
|
|
107344
|
-
error: `The Alexa name is ${name.length} characters; Amazon allows at most 256.`
|
|
107345
|
-
};
|
|
107346
|
-
if (!ALLOWED_PATTERN.test(name)) return {
|
|
107347
|
-
ok: false,
|
|
107348
|
-
error: "The Alexa name may contain only letters, digits and spaces (Amazon rejects punctuation and special characters)."
|
|
107349
|
-
};
|
|
107350
|
-
return {
|
|
107351
|
-
ok: true,
|
|
107352
|
-
name
|
|
107353
|
-
};
|
|
107354
|
-
}
|
|
107355
|
-
var StoredNameSchema = string();
|
|
107356
|
-
/**
|
|
107357
|
-
* The saved Alexa name in a per-device store blob, or null (never saved, or a
|
|
107358
|
-
* stored value that no longer validates: the device name is used rather than
|
|
107359
|
-
* pushing a name Amazon would refuse).
|
|
107360
|
-
*/
|
|
107361
|
-
function readAlexaName(store) {
|
|
107362
|
-
const parsed = StoredNameSchema.safeParse(store[ALEXA_NAME_KEY]);
|
|
107363
|
-
if (!parsed.success) return null;
|
|
107364
|
-
const check = validateAlexaName(parsed.data);
|
|
107365
|
-
return check.ok ? check.name : null;
|
|
108056
|
+
//#region src/exposed-name-rename.ts
|
|
108057
|
+
async function renameOnSkill(deps, deviceIdRaw, raw, options = {}) {
|
|
108058
|
+
const deviceId = Number.parseInt(deviceIdRaw, 10);
|
|
108059
|
+
if (!Number.isFinite(deviceId)) throw new Error(`export-alexa: deviceId must be numeric — got "${deviceIdRaw}"`);
|
|
108060
|
+
const saved = await saveExposedName({
|
|
108061
|
+
store: deps.store,
|
|
108062
|
+
deviceId,
|
|
108063
|
+
instanceId: deps.instanceId,
|
|
108064
|
+
raw,
|
|
108065
|
+
validate: alexaNameValidator,
|
|
108066
|
+
...options.dryRun === true ? { dryRun: true } : {}
|
|
108067
|
+
});
|
|
108068
|
+
if (!saved.changed) return;
|
|
108069
|
+
deps.logger.info("export-alexa: Alexa name saved", {
|
|
108070
|
+
tags: { deviceId },
|
|
108071
|
+
meta: {
|
|
108072
|
+
instanceId: deps.instanceId,
|
|
108073
|
+
name: saved.name
|
|
108074
|
+
}
|
|
108075
|
+
});
|
|
108076
|
+
if (!deps.isExposed(deviceId)) return;
|
|
108077
|
+
deps.push(deviceId).catch((err) => {
|
|
108078
|
+
deps.logger.warn("export-alexa: push after an Alexa name change failed", {
|
|
108079
|
+
tags: { deviceId },
|
|
108080
|
+
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
108081
|
+
});
|
|
108082
|
+
});
|
|
107366
108083
|
}
|
|
107367
108084
|
//#endregion
|
|
107368
108085
|
//#region src/stream-preference.ts
|
|
@@ -110417,7 +111134,7 @@ var SkillRuntime = class {
|
|
|
110417
111134
|
logger: this.ctx.logger,
|
|
110418
111135
|
snapshots: this.view.snapshots,
|
|
110419
111136
|
...this.view.detectionSensors ? { detectionClasses: async (id) => effectiveSensorClasses(await classesOf(id), parseSensorSelection(await vision.readPrefs(id))) } : {},
|
|
110420
|
-
alexaName: async (id) =>
|
|
111137
|
+
alexaName: async (id) => readExposedName(await vision.readPrefs(id), this.instanceId, alexaNameValidator),
|
|
110421
111138
|
...this.view.objectDetection ? { objectDetection: async (id) => vision.buildClasses(id, await classesOf(id)) } : {}
|
|
110422
111139
|
});
|
|
110423
111140
|
}
|
|
@@ -110863,27 +111580,11 @@ var SkillRuntime = class {
|
|
|
110863
111580
|
value: enabled,
|
|
110864
111581
|
immediate: true
|
|
110865
111582
|
},
|
|
110866
|
-
...opts.shared ? [await this.alexaNameField(deviceId, enabledKey)] : [],
|
|
110867
111583
|
...kind === "camera" ? this.cameraOnlyExportFields(deviceId, settings, enabledKey) : [],
|
|
110868
111584
|
...kind === "camera" && opts.shared ? await this.cameraDetectionFields(deviceId, enabledKey) : []
|
|
110869
111585
|
]
|
|
110870
111586
|
};
|
|
110871
111587
|
}
|
|
110872
|
-
/** D875: the "Alexa name" field, with the validation error of the saved value. */
|
|
110873
|
-
async alexaNameField(deviceId, enabledKey) {
|
|
110874
|
-
const saved = readAlexaName(await this.vision.readPrefs(deviceId));
|
|
110875
|
-
return {
|
|
110876
|
-
type: "text",
|
|
110877
|
-
key: alexaNameKey(deviceId),
|
|
110878
|
-
label: "Alexa name",
|
|
110879
|
-
description: `What Alexa calls this device. Leave empty to use the device name. Letters, digits and spaces only (no punctuation), up to 256 characters. Renaming updates the same Alexa device; it does not create a duplicate.`,
|
|
110880
|
-
value: saved ?? "",
|
|
110881
|
-
showWhen: {
|
|
110882
|
-
field: enabledKey,
|
|
110883
|
-
equals: true
|
|
110884
|
-
}
|
|
110885
|
-
};
|
|
110886
|
-
}
|
|
110887
111588
|
/**
|
|
110888
111589
|
* The camera's detection fields: which classes become Alexa sensors (D778;
|
|
110889
111590
|
* only the classes its pipeline produces are offered) and its object
|
|
@@ -110905,24 +111606,6 @@ var SkillRuntime = class {
|
|
|
110905
111606
|
})];
|
|
110906
111607
|
}
|
|
110907
111608
|
/**
|
|
110908
|
-
* D875: save the Alexa name from a device-settings patch. A name Amazon would
|
|
110909
|
-
* refuse throws BEFORE anything is written, so the form shows the reason and
|
|
110910
|
-
* the old name stays. True when the saved name changed.
|
|
110911
|
-
*/
|
|
110912
|
-
async applyAlexaNamePatch(deviceId, patch) {
|
|
110913
|
-
const key = alexaNameKey(deviceId);
|
|
110914
|
-
if (!(key in patch)) return false;
|
|
110915
|
-
const check = validateAlexaName(patch[key]);
|
|
110916
|
-
if (!check.ok) throw new Error(`export-alexa: ${check.error}`);
|
|
110917
|
-
if (readAlexaName(await this.vision.readPrefs(deviceId)) === check.name) return false;
|
|
110918
|
-
await this.vision.writePrefs(deviceId, { [ALEXA_NAME_KEY]: check.name ?? void 0 });
|
|
110919
|
-
this.ctx.logger.info("export-alexa: Alexa name saved", {
|
|
110920
|
-
tags: { deviceId },
|
|
110921
|
-
meta: { name: check.name }
|
|
110922
|
-
});
|
|
110923
|
-
return true;
|
|
110924
|
-
}
|
|
110925
|
-
/**
|
|
110926
111609
|
* Persist the camera's detection preferences from a device-settings patch
|
|
110927
111610
|
* into this addon's per-device store. True when anything changed — the
|
|
110928
111611
|
* camera's Alexa shape then needs a reconcile.
|
|
@@ -110973,15 +111656,32 @@ var SkillRuntime = class {
|
|
|
110973
111656
|
}];
|
|
110974
111657
|
}
|
|
110975
111658
|
/**
|
|
110976
|
-
* The device's own preferences in a patch (
|
|
110977
|
-
*
|
|
110978
|
-
*
|
|
111659
|
+
* The device's own preferences in a patch (detection classes, object detection): shared by
|
|
111660
|
+
* every skill, so they are saved ONCE, before any skill applies its own part (an expose in
|
|
111661
|
+
* the same patch then builds with them).
|
|
110979
111662
|
*/
|
|
110980
111663
|
async applySharedPrefs(deviceId, patch) {
|
|
110981
|
-
return {
|
|
110982
|
-
|
|
110983
|
-
|
|
110984
|
-
|
|
111664
|
+
return { prefsChanged: await this.applyDetectionPrefsPatch(deviceId, patch) };
|
|
111665
|
+
}
|
|
111666
|
+
/** D1049: this skill's exposed name for a device, or null (the device's own name). */
|
|
111667
|
+
async exposedNameOf(deviceId) {
|
|
111668
|
+
return readExposedName(await this.vision.readPrefs(deviceId), this.instanceId, alexaNameValidator);
|
|
111669
|
+
}
|
|
111670
|
+
/**
|
|
111671
|
+
* D1049: save this skill's name for a device (`device-export.setExposedName`); an exposed
|
|
111672
|
+
* device is pushed again under the same endpoint id. `renameOnSkill` holds the rule.
|
|
111673
|
+
*/
|
|
111674
|
+
async setExposedName(deviceIdRaw, raw, dryRun = false) {
|
|
111675
|
+
await renameOnSkill({
|
|
111676
|
+
instanceId: this.instanceId,
|
|
111677
|
+
store: {
|
|
111678
|
+
read: (id) => exposedNameStoreOf(this.ctx.settings, "export-alexa").read(id),
|
|
111679
|
+
write: (id, patch) => this.vision.writePrefs(id, patch)
|
|
111680
|
+
},
|
|
111681
|
+
logger: this.ctx.logger,
|
|
111682
|
+
isExposed: (id) => this.findEntry(id) !== null,
|
|
111683
|
+
push: (id) => this.requireSyncEngine().pushDevice(id)
|
|
111684
|
+
}, deviceIdRaw, raw, { dryRun });
|
|
110985
111685
|
}
|
|
110986
111686
|
/**
|
|
110987
111687
|
* Apply this skill's part of a patch produced by the device-details "Export" panel. Flips
|
|
@@ -110994,7 +111694,7 @@ var SkillRuntime = class {
|
|
|
110994
111694
|
* the new preference. See remaining-work notes in CLAUDE.md.
|
|
110995
111695
|
*/
|
|
110996
111696
|
async applyEntryPatch(deviceId, patch, shared) {
|
|
110997
|
-
const { prefsChanged
|
|
111697
|
+
const { prefsChanged } = shared;
|
|
110998
111698
|
const idStr = String(deviceId);
|
|
110999
111699
|
const current = this.findEntry(deviceId);
|
|
111000
111700
|
const wasEnabled = current !== null;
|
|
@@ -111023,12 +111723,6 @@ var SkillRuntime = class {
|
|
|
111023
111723
|
const currentAllow = current?.settings?.allowTranscode !== false;
|
|
111024
111724
|
await this.patchEntrySettings(deviceId, nextSettings);
|
|
111025
111725
|
const sourceChanged = currentPref !== streamPreference || currentAllow !== allowTranscode;
|
|
111026
|
-
if (nameChanged && !sourceChanged) this.requireSyncEngine().pushDevice(deviceId).catch((err) => {
|
|
111027
|
-
this.ctx.logger.warn("export-alexa: push after an Alexa name change failed", {
|
|
111028
|
-
tags: { deviceId },
|
|
111029
|
-
meta: { error: errMsg$1(err) }
|
|
111030
|
-
});
|
|
111031
|
-
});
|
|
111032
111726
|
if (prefsChanged && !sourceChanged) this.requireSyncEngine().reconcileDevice(deviceId).catch((err) => {
|
|
111033
111727
|
this.ctx.logger.warn("export-alexa: re-sync after a detection preference change failed", {
|
|
111034
111728
|
tags: { deviceId },
|
|
@@ -111574,15 +112268,30 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
111574
112268
|
instanceId: row.id,
|
|
111575
112269
|
name: row.body.name,
|
|
111576
112270
|
enabled: row.enabled,
|
|
111577
|
-
kind: "alexa-skill"
|
|
112271
|
+
kind: "alexa-skill",
|
|
112272
|
+
nameRule: ALEXA_NAME_RULE
|
|
111578
112273
|
}));
|
|
111579
112274
|
},
|
|
111580
112275
|
listSupportedDeviceKinds: async ({ instanceId }) => {
|
|
111581
112276
|
ownInstance(instanceId);
|
|
111582
112277
|
return [...SUPPORTED_KINDS];
|
|
111583
112278
|
},
|
|
111584
|
-
listExposedDevices: async ({ instanceId }) =>
|
|
111585
|
-
|
|
112279
|
+
listExposedDevices: async ({ instanceId }) => {
|
|
112280
|
+
const runtime = ownInstance(instanceId);
|
|
112281
|
+
return Promise.all(runtime.exposedDevices.map(async (e) => {
|
|
112282
|
+
const exposedName = await runtime.exposedNameOf(e.deviceId);
|
|
112283
|
+
return {
|
|
112284
|
+
deviceId: String(e.deviceId),
|
|
112285
|
+
...exposedName !== null ? { exposedName } : {}
|
|
112286
|
+
};
|
|
112287
|
+
}));
|
|
112288
|
+
},
|
|
112289
|
+
exposeDevice: async ({ instanceId, deviceId, exposedName }) => {
|
|
112290
|
+
const runtime = ownInstance(instanceId);
|
|
112291
|
+
if (exposedName !== void 0) await runtime.setExposedName(deviceId, exposedName);
|
|
112292
|
+
return runtime.exposeDevice(deviceId);
|
|
112293
|
+
},
|
|
112294
|
+
setExposedName: async ({ instanceId, deviceId, name, dryRun }) => ownInstance(instanceId).setExposedName(deviceId, name, dryRun === true),
|
|
111586
112295
|
unexposeDevice: async ({ instanceId, deviceId }) => ownInstance(instanceId).unexposeDevice(deviceId),
|
|
111587
112296
|
listSupportedEntityKinds: async () => ["device", "action"],
|
|
111588
112297
|
listExposedEntities: async ({ instanceId }) => {
|
|
@@ -111710,6 +112419,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
111710
112419
|
if (change === "deleted") {
|
|
111711
112420
|
await this.stopRuntime(id);
|
|
111712
112421
|
await this.deleteSkillRows(id);
|
|
112422
|
+
await this.pruneSkillNames(id);
|
|
111713
112423
|
return;
|
|
111714
112424
|
}
|
|
111715
112425
|
const row = await this.requireInstances().readResolved(id);
|
|
@@ -111725,6 +112435,16 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
111725
112435
|
await running.refreshRecords();
|
|
111726
112436
|
await running.applyShapeSwitches();
|
|
111727
112437
|
}
|
|
112438
|
+
/** A deleted skill's device names go too, so a skill that reuses the id inherits none (D1049). */
|
|
112439
|
+
async pruneSkillNames(id) {
|
|
112440
|
+
const settings = this.ctx.settings;
|
|
112441
|
+
if (settings === void 0) return;
|
|
112442
|
+
const pruned = await pruneExposedNames(settings, id);
|
|
112443
|
+
if (pruned.length > 0) this.ctx.logger.info("export-alexa: deleted skill names removed", { meta: {
|
|
112444
|
+
instanceId: id,
|
|
112445
|
+
devices: pruned.length
|
|
112446
|
+
} });
|
|
112447
|
+
}
|
|
111728
112448
|
/** What a deleted skill leaves behind: its links, its exposure and its hidden state. */
|
|
111729
112449
|
async deleteSkillRows(id) {
|
|
111730
112450
|
await deleteSkillRows(this.requireHandles(), id);
|
|
@@ -111803,6 +112523,19 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
111803
112523
|
readState: async () => (await stateHandle.getResolved("export-alexa"))?.data ?? null,
|
|
111804
112524
|
clearIngressTokenSecret: async () => {
|
|
111805
112525
|
await this.clearSecrets(["ingressToken"]);
|
|
112526
|
+
},
|
|
112527
|
+
listSkillIds: async () => (await this.requireInstances().listResolved()).map((r) => r.id),
|
|
112528
|
+
listDeviceIds: async () => {
|
|
112529
|
+
const settings = this.ctx.settings;
|
|
112530
|
+
if (settings === void 0) throw new Error("export-alexa: the settings store is unavailable");
|
|
112531
|
+
return settings.listDeviceStoreIds();
|
|
112532
|
+
},
|
|
112533
|
+
readDeviceField: async (deviceIds, field) => {
|
|
112534
|
+
const settings = this.ctx.settings;
|
|
112535
|
+
if (settings === void 0) throw new Error("export-alexa: the settings store is unavailable");
|
|
112536
|
+
const found = /* @__PURE__ */ new Map();
|
|
112537
|
+
for (const [deviceId, blob] of await settings.readDeviceStoreBatch(deviceIds)) if (field in blob) found.set(deviceId, blob[field]);
|
|
112538
|
+
return found;
|
|
111806
112539
|
}
|
|
111807
112540
|
};
|
|
111808
112541
|
}
|