@camstack/addon-export-alexa 1.2.195 → 1.2.197
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 +13 -0
- package/dist/export-alexa.addon.js +1420 -558
- package/dist/export-alexa.addon.mjs +1420 -558
- 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
|
|
@@ -808,7 +817,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
808
817
|
return EventCategory;
|
|
809
818
|
}({});
|
|
810
819
|
//#endregion
|
|
811
|
-
//#region ../types/dist/composed-stable-id-
|
|
820
|
+
//#region ../types/dist/composed-stable-id-iddnCQ51.mjs
|
|
812
821
|
/**
|
|
813
822
|
import { errMsg } from '@camstack/types'
|
|
814
823
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -1150,6 +1159,11 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1150
1159
|
* with the switch's on/off only. Speed or oscillation appear only when the
|
|
1151
1160
|
* device also has a fan cap (D1033). */
|
|
1152
1161
|
DeviceRole["SwitchFan"] = "switch-fan";
|
|
1162
|
+
/** A relay driving an on/off-only lamp: drawn as a light (bulb and glow, no
|
|
1163
|
+
* slider), presented to the exports as a light with power only. Not a
|
|
1164
|
+
* `light` type: the provider owns the type, and a light implies brightness
|
|
1165
|
+
* or colour this relay lacks. */
|
|
1166
|
+
DeviceRole["SwitchLight"] = "switch-light";
|
|
1153
1167
|
/** Air conditioner / split unit: cooling, fan speed, louvres. */
|
|
1154
1168
|
DeviceRole["ClimateAc"] = "climate-ac";
|
|
1155
1169
|
/** Room thermostat: a setpoint and a room temperature. The default. */
|
|
@@ -6050,7 +6064,7 @@ var ZodIssueCode = {
|
|
|
6050
6064
|
var ZodFirstPartyTypeKind;
|
|
6051
6065
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6052
6066
|
//#endregion
|
|
6053
|
-
//#region ../types/dist/sleep-
|
|
6067
|
+
//#region ../types/dist/sleep-BvVGLl30.mjs
|
|
6054
6068
|
/**
|
|
6055
6069
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6056
6070
|
* window to float samples (D455).
|
|
@@ -6733,6 +6747,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6733
6747
|
else skipped.push(id);
|
|
6734
6748
|
};
|
|
6735
6749
|
const selected = options.only === void 0 ? null : new Set(options.only);
|
|
6750
|
+
const deferred = /* @__PURE__ */ new Set();
|
|
6751
|
+
const deferredBy = (reason) => {
|
|
6752
|
+
if (selected === null || reason === null) return null;
|
|
6753
|
+
const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
|
|
6754
|
+
if (dep === void 0 || !byId.has(dep)) return null;
|
|
6755
|
+
return !selected.has(dep) || deferred.has(dep) ? dep : null;
|
|
6756
|
+
};
|
|
6736
6757
|
for (const step of declaration.steps) {
|
|
6737
6758
|
if (selected !== null && !selected.has(step.id)) continue;
|
|
6738
6759
|
const bound = byId.get(step.id);
|
|
@@ -6744,6 +6765,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6744
6765
|
try {
|
|
6745
6766
|
const gate = await host.startMigration({ id: step.id });
|
|
6746
6767
|
if (!gate.proceed) {
|
|
6768
|
+
const waitsFor = deferredBy(gate.reason);
|
|
6769
|
+
if (waitsFor !== null) {
|
|
6770
|
+
log.info("migration deferred: its predecessor runs in another phase of this owner", {
|
|
6771
|
+
tags,
|
|
6772
|
+
meta: {
|
|
6773
|
+
waitsFor,
|
|
6774
|
+
reason: gate.reason
|
|
6775
|
+
}
|
|
6776
|
+
});
|
|
6777
|
+
deferred.add(step.id);
|
|
6778
|
+
skipped.push(step.id);
|
|
6779
|
+
continue;
|
|
6780
|
+
}
|
|
6747
6781
|
log.warn("migration not run", {
|
|
6748
6782
|
tags,
|
|
6749
6783
|
meta: {
|
|
@@ -7788,7 +7822,7 @@ async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
|
7788
7822
|
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
7789
7823
|
return out;
|
|
7790
7824
|
}
|
|
7791
|
-
function rowId$
|
|
7825
|
+
function rowId$4(row, idKey) {
|
|
7792
7826
|
const raw = row[idKey];
|
|
7793
7827
|
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
7794
7828
|
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
@@ -7805,7 +7839,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7805
7839
|
}
|
|
7806
7840
|
const storedById = /* @__PURE__ */ new Map();
|
|
7807
7841
|
for (const row of storedRows) {
|
|
7808
|
-
const id = rowId$
|
|
7842
|
+
const id = rowId$4(row, node.idKey);
|
|
7809
7843
|
if (id !== null) storedById.set(id, row);
|
|
7810
7844
|
}
|
|
7811
7845
|
const kept = /* @__PURE__ */ new Set();
|
|
@@ -7815,13 +7849,13 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7815
7849
|
rows.push(row);
|
|
7816
7850
|
continue;
|
|
7817
7851
|
}
|
|
7818
|
-
const id = rowId$
|
|
7852
|
+
const id = rowId$4(row, node.idKey) ?? ctx.mintId();
|
|
7819
7853
|
kept.add(id);
|
|
7820
7854
|
const withId = {
|
|
7821
7855
|
...row,
|
|
7822
7856
|
[node.idKey]: row[node.idKey] ?? id
|
|
7823
7857
|
};
|
|
7824
|
-
if (rowId$
|
|
7858
|
+
if (rowId$4(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
7825
7859
|
const storedRow = storedById.get(id) ?? {};
|
|
7826
7860
|
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
7827
7861
|
}
|
|
@@ -10193,6 +10227,13 @@ var DeviceTransitionSchema = object({
|
|
|
10193
10227
|
actor: TransitionActorSchema,
|
|
10194
10228
|
command: TransitionCommandSchema.optional()
|
|
10195
10229
|
});
|
|
10230
|
+
object({
|
|
10231
|
+
deviceId: number$1().int(),
|
|
10232
|
+
action: string(),
|
|
10233
|
+
outcome: TransitionOutcomeSchema,
|
|
10234
|
+
actor: TransitionActorSchema,
|
|
10235
|
+
at: number$1()
|
|
10236
|
+
});
|
|
10196
10237
|
var READING_QUANTITIES = [
|
|
10197
10238
|
"temperature",
|
|
10198
10239
|
"pressure",
|
|
@@ -10736,6 +10777,13 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
10736
10777
|
},
|
|
10737
10778
|
state: { on: { icon: "lightbulb" } }
|
|
10738
10779
|
},
|
|
10780
|
+
[DeviceRole.SwitchLight]: {
|
|
10781
|
+
actions: {
|
|
10782
|
+
"switch.on": { icon: "lightbulb" },
|
|
10783
|
+
"switch.off": { icon: "lightbulb-off" }
|
|
10784
|
+
},
|
|
10785
|
+
state: { on: { icon: "lightbulb" } }
|
|
10786
|
+
},
|
|
10739
10787
|
[DeviceRole.Chime]: { actions: {
|
|
10740
10788
|
"switch.on": {
|
|
10741
10789
|
label: t("Enable chime", "Attiva il campanello"),
|
|
@@ -12216,7 +12264,10 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
12216
12264
|
"ir-transmitter": {
|
|
12217
12265
|
scope: "device",
|
|
12218
12266
|
noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
|
|
12219
|
-
notOperatorFacing: {
|
|
12267
|
+
notOperatorFacing: {
|
|
12268
|
+
send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
|
|
12269
|
+
learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
|
|
12270
|
+
}
|
|
12220
12271
|
},
|
|
12221
12272
|
control: {
|
|
12222
12273
|
scope: "device",
|
|
@@ -15137,6 +15188,32 @@ var CAP_VOCABULARY_BY_NAME = {
|
|
|
15137
15188
|
...SYSTEM_CAP_VOCABULARY
|
|
15138
15189
|
};
|
|
15139
15190
|
/**
|
|
15191
|
+
* Vocabulary actions by id (D983). An action step names a vocabulary action
|
|
15192
|
+
* (`cover.open`), never a raw cap method; this is the one lookup that turns the
|
|
15193
|
+
* id into its cap, method and effect — and a persisted legacy `cap` + `method`
|
|
15194
|
+
* pair back into the action id when exactly one action matches.
|
|
15195
|
+
*/
|
|
15196
|
+
function buildIndex() {
|
|
15197
|
+
const byId = /* @__PURE__ */ new Map();
|
|
15198
|
+
for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
|
|
15199
|
+
if (entry.scope !== "device") continue;
|
|
15200
|
+
for (const action of entry.actions ?? []) byId.set(action.id, {
|
|
15201
|
+
cap,
|
|
15202
|
+
action
|
|
15203
|
+
});
|
|
15204
|
+
}
|
|
15205
|
+
return byId;
|
|
15206
|
+
}
|
|
15207
|
+
var index;
|
|
15208
|
+
function actionIndex() {
|
|
15209
|
+
index ??= buildIndex();
|
|
15210
|
+
return index;
|
|
15211
|
+
}
|
|
15212
|
+
/** The vocabulary action with this id, or `undefined`. */
|
|
15213
|
+
function findVocabAction(actionId) {
|
|
15214
|
+
return actionIndex().get(actionId);
|
|
15215
|
+
}
|
|
15216
|
+
/**
|
|
15140
15217
|
* `addon-pages-source` — collection cap exposing per-provider raw page
|
|
15141
15218
|
* declarations. Every addon that contributes a UI page registers a
|
|
15142
15219
|
* provider here. The hub-side singleton aggregator (`addon-pages` cap,
|
|
@@ -17427,7 +17504,7 @@ Object.freeze({
|
|
|
17427
17504
|
}
|
|
17428
17505
|
});
|
|
17429
17506
|
//#endregion
|
|
17430
|
-
//#region ../types/dist/implemented-methods-
|
|
17507
|
+
//#region ../types/dist/implemented-methods-CSTk6zYK.mjs
|
|
17431
17508
|
/**
|
|
17432
17509
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
17433
17510
|
*
|
|
@@ -17481,6 +17558,52 @@ function portable(target) {
|
|
|
17481
17558
|
}
|
|
17482
17559
|
portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac64"), `${BASE$1}${FFMPEG_RELEASE}`;
|
|
17483
17560
|
/**
|
|
17561
|
+
* A device's KIND is its type plus its role (D1033): the type is the set of
|
|
17562
|
+
* controls it has, the role says which thing it is among the devices that
|
|
17563
|
+
* share those controls. A plug-in heater is a `switch` with role
|
|
17564
|
+
* `switch-heater`; an air conditioner and a radiator valve are both `climate`,
|
|
17565
|
+
* told apart by their `climate-*` role.
|
|
17566
|
+
*/
|
|
17567
|
+
/**
|
|
17568
|
+
* Type values a persisted row may still carry after the type was retired, and
|
|
17569
|
+
* the type each one is read as. The row is rewritten by the next registration
|
|
17570
|
+
* of the device (its provider stamps the live type), so this is a read alias,
|
|
17571
|
+
* not a migration.
|
|
17572
|
+
*
|
|
17573
|
+
* `heater` is deliberately absent: the only heaters were composed devices the
|
|
17574
|
+
* operator deletes. Such a row stays an unknown type, which every reader
|
|
17575
|
+
* treats as a generic device.
|
|
17576
|
+
*/
|
|
17577
|
+
var RETIRED_DEVICE_TYPES = { thermostat: DeviceType.Climate };
|
|
17578
|
+
/** The live type a stored `type` value stands for (itself unless retired). */
|
|
17579
|
+
function canonicalStoredDeviceType(stored) {
|
|
17580
|
+
return RETIRED_DEVICE_TYPES[stored] ?? stored;
|
|
17581
|
+
}
|
|
17582
|
+
preprocess((value) => typeof value === "string" ? canonicalStoredDeviceType(value) : value, _enum(DeviceType));
|
|
17583
|
+
DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
|
|
17584
|
+
/**
|
|
17585
|
+
* A relay driving an on/off-only lamp (a `switch` with role `switch-light`):
|
|
17586
|
+
* drawn and exported as a light, with the switch's power only. The one place
|
|
17587
|
+
* that reads the role for it — a consumer asks this, never the role string.
|
|
17588
|
+
*/
|
|
17589
|
+
function isSwitchLight(type, role) {
|
|
17590
|
+
return type === DeviceType.Switch && role === DeviceRole.SwitchLight;
|
|
17591
|
+
}
|
|
17592
|
+
/**
|
|
17593
|
+
* A smart plug (a `switch` with role `outlet`, D875): exported as a plug /
|
|
17594
|
+
* outlet. Exports ask this, never the role string.
|
|
17595
|
+
*/
|
|
17596
|
+
function isOutlet(type, role) {
|
|
17597
|
+
return type === DeviceType.Switch && role === DeviceRole.Outlet;
|
|
17598
|
+
}
|
|
17599
|
+
/**
|
|
17600
|
+
* A plain fan behind a switch (a `switch` with role `switch-fan`): exported as
|
|
17601
|
+
* a fan with the switch's on/off only — no speed it does not have.
|
|
17602
|
+
*/
|
|
17603
|
+
function isSwitchFan(type, role) {
|
|
17604
|
+
return type === DeviceType.Switch && role === DeviceRole.SwitchFan;
|
|
17605
|
+
}
|
|
17606
|
+
/**
|
|
17484
17607
|
* THE table "which boolean of this device type counts as HIGH", and the
|
|
17485
17608
|
* pure evaluator of its EDGE.
|
|
17486
17609
|
*
|
|
@@ -23484,7 +23607,7 @@ var DeviceTokenScopeSchema = object({
|
|
|
23484
23607
|
function migrateLegacyTokenScope(raw) {
|
|
23485
23608
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
23486
23609
|
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
23487
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
23610
|
+
if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
|
|
23488
23611
|
const targets = Reflect.get(raw, "targets");
|
|
23489
23612
|
if (!Array.isArray(targets)) return raw;
|
|
23490
23613
|
return {
|
|
@@ -23496,6 +23619,27 @@ function migrateLegacyTokenScope(raw) {
|
|
|
23496
23619
|
access: Reflect.get(raw, "access")
|
|
23497
23620
|
};
|
|
23498
23621
|
}
|
|
23622
|
+
/**
|
|
23623
|
+
* A stored `types` selector may name a type D1033 retired (`thermostat`). The
|
|
23624
|
+
* grant is read back through this same preprocess, so the retired name is
|
|
23625
|
+
* rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
|
|
23626
|
+
* stays a strict enum on the wire.
|
|
23627
|
+
*/
|
|
23628
|
+
function canonicalSelectorTypes(raw) {
|
|
23629
|
+
const selector = Reflect.get(raw, "selector");
|
|
23630
|
+
if (selector === null || typeof selector !== "object") return raw;
|
|
23631
|
+
if (Reflect.get(selector, "kind") !== "types") return raw;
|
|
23632
|
+
const types = Reflect.get(selector, "types");
|
|
23633
|
+
if (!Array.isArray(types)) return raw;
|
|
23634
|
+
const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
|
|
23635
|
+
return {
|
|
23636
|
+
...raw,
|
|
23637
|
+
selector: {
|
|
23638
|
+
...selector,
|
|
23639
|
+
types: canonical
|
|
23640
|
+
}
|
|
23641
|
+
};
|
|
23642
|
+
}
|
|
23499
23643
|
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
23500
23644
|
object({
|
|
23501
23645
|
type: literal("category"),
|
|
@@ -44808,21 +44952,23 @@ function convertLegacyWhen(half) {
|
|
|
44808
44952
|
* (instants) and state leaves (durations). It replaces the flat trigger list
|
|
44809
44953
|
* plus the separate condition tree; the firing rule is in that file and in
|
|
44810
44954
|
* ADR "one tree".
|
|
44811
|
-
* - **Actions** — the `wait` and `
|
|
44955
|
+
* - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
|
|
44812
44956
|
* fragment of §3.2.2. See {@link AutomationActionSchema}.
|
|
44813
44957
|
*
|
|
44814
44958
|
* A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
|
|
44815
44959
|
* {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
|
|
44816
44960
|
*/
|
|
44817
44961
|
/**
|
|
44818
|
-
* One action step: `wait`, or a `
|
|
44962
|
+
* One action step: `wait`, or a device `command`.
|
|
44819
44963
|
*
|
|
44820
|
-
* A
|
|
44821
|
-
* `{ $var }` resolved from the run's
|
|
44822
|
-
*
|
|
44823
|
-
*
|
|
44824
|
-
*
|
|
44825
|
-
*
|
|
44964
|
+
* A command step names a VOCABULARY action (`cover.open`) and who it acts on
|
|
44965
|
+
* (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
|
|
44966
|
+
* variables). It never names a cap method: the step runner turns the action
|
|
44967
|
+
* id into its cap + method through the vocabulary index when the step runs
|
|
44968
|
+
* (`vocabCall`), the one place that mapping happens. The step runner
|
|
44969
|
+
* (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
|
|
44970
|
+
* variable substitution, once, for every caller — automations, Actions, and
|
|
44971
|
+
* the notification centre, which runs only Actions (planning#473).
|
|
44826
44972
|
*/
|
|
44827
44973
|
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
44828
44974
|
var WAIT_MAX_SECONDS = 3600;
|
|
@@ -44831,39 +44977,22 @@ var AutomationWaitStepSchema = object({
|
|
|
44831
44977
|
kind: literal("wait"),
|
|
44832
44978
|
seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
44833
44979
|
});
|
|
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
44980
|
/**
|
|
44841
|
-
* The fields of a
|
|
44842
|
-
*
|
|
44843
|
-
* device); a step is {@link AutomationCapStepSchema}.
|
|
44981
|
+
* The fields of a command step, before the vocabulary check. A step is
|
|
44982
|
+
* {@link AutomationCommandStepSchema}.
|
|
44844
44983
|
*/
|
|
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(),
|
|
44984
|
+
var AutomationCommandStepBaseSchema = object({
|
|
44985
|
+
kind: literal("command"),
|
|
44986
|
+
/** WHO the step acts on. */
|
|
44987
|
+
target: ActionTargetSchema,
|
|
44988
|
+
/** The vocabulary action this step performs (`cover.open`). */
|
|
44989
|
+
actionId: string().min(1),
|
|
44856
44990
|
/**
|
|
44857
|
-
*
|
|
44858
|
-
*
|
|
44859
|
-
*
|
|
44991
|
+
* The values of the action's OPEN args (`position`, `presetId`); the args
|
|
44992
|
+
* the vocabulary bakes into the action are added when the step runs. Values
|
|
44993
|
+
* may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
44994
|
+
* SUBSTITUTE and do not evaluate (§3.2.3).
|
|
44860
44995
|
*/
|
|
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
44996
|
args: record(string(), unknown()).optional(),
|
|
44868
44997
|
/**
|
|
44869
44998
|
* The unit the person picked per arg (display only). `args` always hold the
|
|
@@ -44872,18 +45001,20 @@ var AutomationCapStepBaseSchema = object({
|
|
|
44872
45001
|
*/
|
|
44873
45002
|
argUnits: record(string(), string().min(1)).optional()
|
|
44874
45003
|
});
|
|
45004
|
+
/** The vocabulary check every command step passes: the action exists. */
|
|
45005
|
+
function refineKnownAction(step, ctx) {
|
|
45006
|
+
if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
|
|
45007
|
+
code: "custom",
|
|
45008
|
+
message: `"${step.actionId}" is not a vocabulary action id`,
|
|
45009
|
+
path: ["actionId"]
|
|
45010
|
+
});
|
|
45011
|
+
}
|
|
44875
45012
|
/**
|
|
44876
|
-
* The steps an internal Action may contain:
|
|
45013
|
+
* The steps an internal Action may contain: command and wait, and nothing that can
|
|
44877
45014
|
* call back into an Action — so an Action can never reach itself (no cycles).
|
|
44878
45015
|
* This is the LEAF shape: no condition of its own.
|
|
44879
45016
|
*/
|
|
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
|
-
})]);
|
|
45017
|
+
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
|
|
44887
45018
|
/**
|
|
44888
45019
|
* The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
|
|
44889
45020
|
* on the state mirror when the step is reached; `else` runs when it is false.
|
|
@@ -44904,13 +45035,7 @@ var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refi
|
|
|
44904
45035
|
* same two step kinds an automation runs, minus a guard that reads the
|
|
44905
45036
|
* automation's trigger, which such a list does not have.
|
|
44906
45037
|
*/
|
|
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) => {
|
|
45038
|
+
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
45039
|
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
44915
45040
|
code: "custom",
|
|
44916
45041
|
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
@@ -44925,17 +45050,11 @@ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, Automa
|
|
|
44925
45050
|
var continueOnErrorShape = {
|
|
44926
45051
|
/** A failure of this step is traced `failed-continued` and the next step runs. */
|
|
44927
45052
|
continueOnError: literal(true).optional() };
|
|
44928
|
-
/** An automation's
|
|
44929
|
-
var
|
|
45053
|
+
/** An automation's command step: the shared guarded command step, plus `continueOnError`. */
|
|
45054
|
+
var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
|
|
44930
45055
|
...stepGuardShape,
|
|
44931
45056
|
...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);
|
|
45057
|
+
}).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
44939
45058
|
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
44940
45059
|
var AutomationStopStepSchema = object({
|
|
44941
45060
|
kind: literal("stop"),
|
|
@@ -45015,13 +45134,7 @@ function nestTooDeep(issue) {
|
|
|
45015
45134
|
}
|
|
45016
45135
|
var plainStepSchemas = [
|
|
45017
45136
|
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
|
-
}),
|
|
45137
|
+
AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
|
|
45025
45138
|
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
45026
45139
|
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
45027
45140
|
AutomationRunActionStepSchema.strict()
|
|
@@ -45032,7 +45145,7 @@ var plainStepSchemas = [
|
|
|
45032
45145
|
*/
|
|
45033
45146
|
var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
|
|
45034
45147
|
/** 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 === "
|
|
45148
|
+
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
45149
|
/**
|
|
45037
45150
|
* Several steps at once (#500): all are started together and all are awaited.
|
|
45038
45151
|
* A failure fails the run once the others finished, as in a sequence; a member
|
|
@@ -45112,7 +45225,7 @@ var AutomationBodyStepSchema = discriminatedUnion("kind", [
|
|
|
45112
45225
|
var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
|
|
45113
45226
|
var AutomationActionSchema = discriminatedUnion("kind", [
|
|
45114
45227
|
GuardedWaitStepSchema,
|
|
45115
|
-
|
|
45228
|
+
AutomationGuardedCommandStepSchema,
|
|
45116
45229
|
AutomationStopStepSchema,
|
|
45117
45230
|
AutomationSetStepSchema,
|
|
45118
45231
|
chooseSchemaOf(AutomationBodyStepSchema),
|
|
@@ -45183,86 +45296,6 @@ function convertLegacyRecipe(legacy) {
|
|
|
45183
45296
|
};
|
|
45184
45297
|
}
|
|
45185
45298
|
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
45299
|
/**
|
|
45267
45300
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
45268
45301
|
*
|
|
@@ -45661,6 +45694,86 @@ var AutomationStateDocSchema = object({
|
|
|
45661
45694
|
lastRunStartedAt: number$1().nullable(),
|
|
45662
45695
|
traces: array(AutomationRunTraceSchema)
|
|
45663
45696
|
});
|
|
45697
|
+
var DETECTION_DESCRIPTIONS = {
|
|
45698
|
+
deviceId: "the camera that saw it",
|
|
45699
|
+
className: "what it saw",
|
|
45700
|
+
trackId: "the track",
|
|
45701
|
+
score: "how sure the detector was",
|
|
45702
|
+
label: "the label it matched (a name, a plate), empty when none"
|
|
45703
|
+
};
|
|
45704
|
+
var STATIONARY_DESCRIPTIONS = {
|
|
45705
|
+
deviceId: "the camera that saw it",
|
|
45706
|
+
className: "what it saw",
|
|
45707
|
+
zones: "the zones it is in",
|
|
45708
|
+
phase: "appeared or departed",
|
|
45709
|
+
entryId: "the stopped object"
|
|
45710
|
+
};
|
|
45711
|
+
var BECOMES_DESCRIPTIONS = {
|
|
45712
|
+
deviceId: "the device that changed",
|
|
45713
|
+
from: "the value before the change, empty when it is not known",
|
|
45714
|
+
to: "the value it changed to"
|
|
45715
|
+
};
|
|
45716
|
+
/**
|
|
45717
|
+
* A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
|
|
45718
|
+
* those names depend on the device, so they are not in this list.
|
|
45719
|
+
*/
|
|
45720
|
+
var FIRED_DESCRIPTIONS = {
|
|
45721
|
+
deviceId: "the device that fired",
|
|
45722
|
+
eventType: "the event, as the device names it",
|
|
45723
|
+
sourceId: "the part of the device that fired (a button), empty when it names none",
|
|
45724
|
+
eventKind: "the kind of press (press, long-press …), empty when the device declares none"
|
|
45725
|
+
};
|
|
45726
|
+
function describe$1(descriptions) {
|
|
45727
|
+
return Object.entries(descriptions).map(([name, description]) => ({
|
|
45728
|
+
name,
|
|
45729
|
+
description
|
|
45730
|
+
}));
|
|
45731
|
+
}
|
|
45732
|
+
describe$1(DETECTION_DESCRIPTIONS);
|
|
45733
|
+
describe$1(STATIONARY_DESCRIPTIONS);
|
|
45734
|
+
describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45735
|
+
...v,
|
|
45736
|
+
hintKey: "firedDeviceId"
|
|
45737
|
+
} : v);
|
|
45738
|
+
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45739
|
+
...v,
|
|
45740
|
+
hintKey: "becomesDeviceId"
|
|
45741
|
+
} : v);
|
|
45742
|
+
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
45743
|
+
/**
|
|
45744
|
+
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
45745
|
+
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
45746
|
+
* (NO normalization). Two shapes:
|
|
45747
|
+
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
45748
|
+
* declared set (e.g. press_short, press_long, …).
|
|
45749
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
45750
|
+
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
45751
|
+
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
45752
|
+
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
45753
|
+
* A fire names the part of the device it came from in `sourceId` when the
|
|
45754
|
+
* vocabulary declares sources (a remote's buttons).
|
|
45755
|
+
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
45756
|
+
*/
|
|
45757
|
+
var EventFireSchema = object({
|
|
45758
|
+
deviceId: number$1(),
|
|
45759
|
+
eventType: string(),
|
|
45760
|
+
sourceId: string().optional(),
|
|
45761
|
+
data: record(string(), unknown()).nullable(),
|
|
45762
|
+
timestamp: number$1().meta(readingMeta("none")),
|
|
45763
|
+
seq: number$1().meta(readingMeta("count"))
|
|
45764
|
+
});
|
|
45765
|
+
var EventEmitterStatusSchema = object({
|
|
45766
|
+
eventTypes: array(string()),
|
|
45767
|
+
/**
|
|
45768
|
+
* Required of a provider by the type. A status written before the field
|
|
45769
|
+
* existed still parses, as an empty vocabulary: read it through
|
|
45770
|
+
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
45771
|
+
*/
|
|
45772
|
+
vocabulary: array(EventVocabularyEntrySchema).default([]),
|
|
45773
|
+
lastEvent: EventFireSchema.nullable(),
|
|
45774
|
+
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
45775
|
+
});
|
|
45776
|
+
DeviceType.EventEmitter;
|
|
45664
45777
|
/**
|
|
45665
45778
|
* Actions — named, runnable things an operator (or an automation) can start,
|
|
45666
45779
|
* declared as LIST ENTRIES, never as devices.
|
|
@@ -45923,6 +46036,343 @@ function pruneDeletedEntities(selection, live, log, exporter) {
|
|
|
45923
46036
|
dropped
|
|
45924
46037
|
};
|
|
45925
46038
|
}
|
|
46039
|
+
/**
|
|
46040
|
+
* `device-export` — collection cap for addons that export camstack
|
|
46041
|
+
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
46042
|
+
* HomeKit/HAP, Alexa Smart Home, …).
|
|
46043
|
+
*
|
|
46044
|
+
* No `ecosystem` enum — the addon id identifies the export target.
|
|
46045
|
+
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
46046
|
+
* exposes only the COMMON surface: link state, supported device
|
|
46047
|
+
* kinds (so the UI can filter the device picker), and per-device
|
|
46048
|
+
* expose/unexpose.
|
|
46049
|
+
*
|
|
46050
|
+
* INSTANCES. One export addon can serve several independent targets (a
|
|
46051
|
+
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
46052
|
+
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
46053
|
+
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
46054
|
+
* default instance's); present = that instance; an id the provider does not
|
|
46055
|
+
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
46056
|
+
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
46057
|
+
* change always names the target it changes. A single-instance provider
|
|
46058
|
+
* accepts an absent id on a read or its own id, and refuses any other.
|
|
46059
|
+
*/
|
|
46060
|
+
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
46061
|
+
var InstanceIdSchema$1 = string().min(1);
|
|
46062
|
+
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
46063
|
+
/** One independent export target of an addon. */
|
|
46064
|
+
var ExportInstanceSchema = object({
|
|
46065
|
+
instanceId: InstanceIdSchema$1,
|
|
46066
|
+
name: string(),
|
|
46067
|
+
enabled: boolean(),
|
|
46068
|
+
kind: string().optional(),
|
|
46069
|
+
/**
|
|
46070
|
+
* What this instance's platform accepts as a device name, in one operator-facing sentence
|
|
46071
|
+
* (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
|
|
46072
|
+
* about the rule.
|
|
46073
|
+
*/
|
|
46074
|
+
nameRule: string().optional()
|
|
46075
|
+
});
|
|
46076
|
+
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
46077
|
+
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
46078
|
+
var ExportInstanceUnknownError = class extends Error {
|
|
46079
|
+
code = EXPORT_INSTANCE_UNKNOWN;
|
|
46080
|
+
instanceId;
|
|
46081
|
+
constructor(addon, instanceId) {
|
|
46082
|
+
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
46083
|
+
this.name = "ExportInstanceUnknownError";
|
|
46084
|
+
this.instanceId = instanceId;
|
|
46085
|
+
}
|
|
46086
|
+
};
|
|
46087
|
+
/**
|
|
46088
|
+
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
46089
|
+
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
46090
|
+
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
46091
|
+
*/
|
|
46092
|
+
function statusInstanceOf(input) {
|
|
46093
|
+
return "instanceId" in input ? input.instanceId : void 0;
|
|
46094
|
+
}
|
|
46095
|
+
var LinkStateSchema = _enum([
|
|
46096
|
+
"unlinked",
|
|
46097
|
+
"linked",
|
|
46098
|
+
"error"
|
|
46099
|
+
]);
|
|
46100
|
+
/**
|
|
46101
|
+
* A single label/value row surfaced in the export panel's "Setup"
|
|
46102
|
+
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
46103
|
+
* rows are masked by default with a reveal toggle (client ids,
|
|
46104
|
+
* secrets, …).
|
|
46105
|
+
*/
|
|
46106
|
+
var ExportSetupFieldSchema = object({
|
|
46107
|
+
label: string(),
|
|
46108
|
+
value: string(),
|
|
46109
|
+
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
46110
|
+
secret: boolean().optional()
|
|
46111
|
+
});
|
|
46112
|
+
/**
|
|
46113
|
+
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
46114
|
+
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
46115
|
+
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
46116
|
+
* the provider supplies and skips the section entirely when `setup`
|
|
46117
|
+
* is unset.
|
|
46118
|
+
*/
|
|
46119
|
+
var ExportSetupSchema = object({
|
|
46120
|
+
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
46121
|
+
qr: string().optional(),
|
|
46122
|
+
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
46123
|
+
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
46124
|
+
/** Free-form operator instructions rendered above the fields. */
|
|
46125
|
+
note: string().optional()
|
|
46126
|
+
});
|
|
46127
|
+
var DeviceExportStatusSchema = object({
|
|
46128
|
+
linkState: LinkStateSchema,
|
|
46129
|
+
exposedDeviceCount: number$1(),
|
|
46130
|
+
error: string().optional(),
|
|
46131
|
+
/**
|
|
46132
|
+
* Optional pairing/account info the panel renders in a generic
|
|
46133
|
+
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
46134
|
+
* export target, never an `ecosystem` key here.
|
|
46135
|
+
*/
|
|
46136
|
+
setup: ExportSetupSchema.optional()
|
|
46137
|
+
});
|
|
46138
|
+
var DeviceKindSchema = string();
|
|
46139
|
+
/**
|
|
46140
|
+
* EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
|
|
46141
|
+
* device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
|
|
46142
|
+
* store (D865), validated by the exporter against its platform's naming rules, and never reaches
|
|
46143
|
+
* the exported id — a rename updates the SAME device on the platform, never a second one.
|
|
46144
|
+
* Blank or `null` = the device's own name. A name the platform would refuse is refused with
|
|
46145
|
+
* `ExportNameRefusedError` (`export-name-refused`), whose message says why.
|
|
46146
|
+
*/
|
|
46147
|
+
var ExposedDeviceSchema = object({
|
|
46148
|
+
deviceId: string(),
|
|
46149
|
+
exposedAs: string().optional(),
|
|
46150
|
+
/** The operator's name for this device on this instance; absent = the device's own name. */
|
|
46151
|
+
exposedName: string().optional(),
|
|
46152
|
+
capabilities: array(string()).optional()
|
|
46153
|
+
});
|
|
46154
|
+
var ExposeInputSchema = object({
|
|
46155
|
+
instanceId: InstanceIdSchema$1,
|
|
46156
|
+
deviceId: string(),
|
|
46157
|
+
capabilities: array(string()).optional(),
|
|
46158
|
+
/** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
|
|
46159
|
+
exposedName: string().nullable().optional()
|
|
46160
|
+
});
|
|
46161
|
+
var SetExposedNameInputSchema = object({
|
|
46162
|
+
instanceId: InstanceIdSchema$1,
|
|
46163
|
+
deviceId: string(),
|
|
46164
|
+
/** Blank or null = the device's own name. */
|
|
46165
|
+
name: string().nullable(),
|
|
46166
|
+
/**
|
|
46167
|
+
* Validate only: refuse exactly as a real call would, write nothing. A caller saving several
|
|
46168
|
+
* names at once checks every one first, so one refusal writes none (D1049).
|
|
46169
|
+
*/
|
|
46170
|
+
dryRun: boolean().optional()
|
|
46171
|
+
});
|
|
46172
|
+
var EXPORT_NAME_REFUSED = "export-name-refused";
|
|
46173
|
+
/** A name the instance's platform would refuse. The message starts with the code, then the reason. */
|
|
46174
|
+
var ExportNameRefusedError = class extends Error {
|
|
46175
|
+
code = EXPORT_NAME_REFUSED;
|
|
46176
|
+
instanceId;
|
|
46177
|
+
reason;
|
|
46178
|
+
constructor(instanceId, reason) {
|
|
46179
|
+
super(`${EXPORT_NAME_REFUSED}: ${reason}`);
|
|
46180
|
+
this.name = "ExportNameRefusedError";
|
|
46181
|
+
this.instanceId = instanceId;
|
|
46182
|
+
this.reason = reason;
|
|
46183
|
+
}
|
|
46184
|
+
};
|
|
46185
|
+
var UnexposeInputSchema = object({
|
|
46186
|
+
instanceId: InstanceIdSchema$1,
|
|
46187
|
+
deviceId: string()
|
|
46188
|
+
});
|
|
46189
|
+
/**
|
|
46190
|
+
* What an exporter may expose besides devices (D968). An action and a
|
|
46191
|
+
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
46192
|
+
* exporter's own selection, not the device registry.
|
|
46193
|
+
*/
|
|
46194
|
+
var ExportEntityKindSchema = _enum([
|
|
46195
|
+
"device",
|
|
46196
|
+
"action",
|
|
46197
|
+
"notifier"
|
|
46198
|
+
]);
|
|
46199
|
+
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
46200
|
+
object({
|
|
46201
|
+
kind: literal("device"),
|
|
46202
|
+
deviceId: string()
|
|
46203
|
+
}),
|
|
46204
|
+
object({
|
|
46205
|
+
kind: literal("action"),
|
|
46206
|
+
actionId: string().min(1)
|
|
46207
|
+
}),
|
|
46208
|
+
object({
|
|
46209
|
+
kind: literal("notifier"),
|
|
46210
|
+
targetId: string().min(1)
|
|
46211
|
+
})
|
|
46212
|
+
]);
|
|
46213
|
+
var ExposedEntitySchema = object({
|
|
46214
|
+
entity: ExportEntityRefSchema,
|
|
46215
|
+
exposedAs: string().optional()
|
|
46216
|
+
});
|
|
46217
|
+
var ExposeEntityInputSchema = object({
|
|
46218
|
+
instanceId: InstanceIdSchema$1,
|
|
46219
|
+
entity: ExportEntityRefSchema
|
|
46220
|
+
});
|
|
46221
|
+
var UnexposeEntityInputSchema = object({
|
|
46222
|
+
instanceId: InstanceIdSchema$1,
|
|
46223
|
+
entity: ExportEntityRefSchema
|
|
46224
|
+
});
|
|
46225
|
+
var deviceExportCapability = {
|
|
46226
|
+
name: "device-export",
|
|
46227
|
+
scope: "system",
|
|
46228
|
+
mode: "collection",
|
|
46229
|
+
providerKind: "device-export",
|
|
46230
|
+
status: {
|
|
46231
|
+
schema: DeviceExportStatusSchema,
|
|
46232
|
+
kind: "poll"
|
|
46233
|
+
},
|
|
46234
|
+
/**
|
|
46235
|
+
* Each export provider MAY contribute its own per-device "Export" panel
|
|
46236
|
+
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
46237
|
+
* framework methods are mounted on the cap router when present.
|
|
46238
|
+
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
46239
|
+
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
46240
|
+
* never hand-written — D14 — and an exporter is not one of those).
|
|
46241
|
+
*/
|
|
46242
|
+
exposesDeviceSettings: true,
|
|
46243
|
+
methods: {
|
|
46244
|
+
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
46245
|
+
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
46246
|
+
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
46247
|
+
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
46248
|
+
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
46249
|
+
kind: "mutation",
|
|
46250
|
+
auth: "admin"
|
|
46251
|
+
}),
|
|
46252
|
+
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
46253
|
+
kind: "mutation",
|
|
46254
|
+
auth: "admin"
|
|
46255
|
+
}),
|
|
46256
|
+
setExposedName: method(SetExposedNameInputSchema, _void(), {
|
|
46257
|
+
kind: "mutation",
|
|
46258
|
+
auth: "admin"
|
|
46259
|
+
}),
|
|
46260
|
+
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
46261
|
+
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
46262
|
+
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
46263
|
+
kind: "mutation",
|
|
46264
|
+
auth: "admin"
|
|
46265
|
+
}),
|
|
46266
|
+
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
46267
|
+
kind: "mutation",
|
|
46268
|
+
auth: "admin"
|
|
46269
|
+
})
|
|
46270
|
+
}
|
|
46271
|
+
};
|
|
46272
|
+
/**
|
|
46273
|
+
* The exposed name of a device on one export instance (`device-export`, D1049).
|
|
46274
|
+
*
|
|
46275
|
+
* Every exporter keeps its names the same way: in ITS per-device store (D865), under
|
|
46276
|
+
* {@link EXPOSED_NAMES_STORE_KEY}, one entry per instance id. The store is cleared centrally
|
|
46277
|
+
* when the device is deleted, so no removal hook is needed for it. Each exporter supplies the
|
|
46278
|
+
* validator of its own platform; the normalisation, the store shape and the refusal are here so
|
|
46279
|
+
* the four exporters cannot drift apart.
|
|
46280
|
+
*
|
|
46281
|
+
* The name is a label only: no exporter derives the exported id from it, so a rename updates
|
|
46282
|
+
* the same device on the platform.
|
|
46283
|
+
*/
|
|
46284
|
+
/** The per-device store key holding `{ [instanceId]: name }`. */
|
|
46285
|
+
var EXPOSED_NAMES_STORE_KEY = "exposedNames";
|
|
46286
|
+
var ExposedNamesSchema = record(string(), string());
|
|
46287
|
+
/** Trim and collapse whitespace, then the platform rule. Blank or null clears (`name: null`). */
|
|
46288
|
+
function checkExposedName(raw, validate) {
|
|
46289
|
+
if (raw === null || raw === void 0) return {
|
|
46290
|
+
ok: true,
|
|
46291
|
+
name: null
|
|
46292
|
+
};
|
|
46293
|
+
if (typeof raw !== "string") return {
|
|
46294
|
+
ok: false,
|
|
46295
|
+
reason: "The name must be text."
|
|
46296
|
+
};
|
|
46297
|
+
const name = raw.trim().replace(/\s+/g, " ");
|
|
46298
|
+
if (name.length === 0) return {
|
|
46299
|
+
ok: true,
|
|
46300
|
+
name: null
|
|
46301
|
+
};
|
|
46302
|
+
return validate(name);
|
|
46303
|
+
}
|
|
46304
|
+
/** Every saved name of a device, by instance id. A malformed blob reads as none. */
|
|
46305
|
+
function readExposedNames(store) {
|
|
46306
|
+
const parsed = ExposedNamesSchema.safeParse(store[EXPOSED_NAMES_STORE_KEY]);
|
|
46307
|
+
return parsed.success ? parsed.data : {};
|
|
46308
|
+
}
|
|
46309
|
+
/**
|
|
46310
|
+
* The saved name of one instance, or null: never saved, or a stored value the platform would
|
|
46311
|
+
* now refuse (the device's own name is used rather than pushing a name the platform rejects).
|
|
46312
|
+
*/
|
|
46313
|
+
function readExposedName(store, instanceId, validate) {
|
|
46314
|
+
const saved = readExposedNames(store)[instanceId];
|
|
46315
|
+
if (saved === void 0) return null;
|
|
46316
|
+
const check = checkExposedName(saved, validate);
|
|
46317
|
+
return check.ok ? check.name : null;
|
|
46318
|
+
}
|
|
46319
|
+
/** The store patch that sets (or, with null, clears) one instance's name and keeps the others. */
|
|
46320
|
+
function exposedNamePatch(store, instanceId, name) {
|
|
46321
|
+
const others = Object.fromEntries(Object.entries(readExposedNames(store)).filter(([id]) => id !== instanceId));
|
|
46322
|
+
return { [EXPOSED_NAMES_STORE_KEY]: name === null ? others : {
|
|
46323
|
+
...others,
|
|
46324
|
+
[instanceId]: name
|
|
46325
|
+
} };
|
|
46326
|
+
}
|
|
46327
|
+
/**
|
|
46328
|
+
* Validate and save one instance's name. A name the platform would refuse throws
|
|
46329
|
+
* {@link ExportNameRefusedError} BEFORE anything is written, so the old name stays.
|
|
46330
|
+
*/
|
|
46331
|
+
async function saveExposedName(input) {
|
|
46332
|
+
const check = checkExposedName(input.raw, input.validate);
|
|
46333
|
+
if (!check.ok) throw new ExportNameRefusedError(input.instanceId, check.reason);
|
|
46334
|
+
if (input.dryRun === true) return {
|
|
46335
|
+
changed: false,
|
|
46336
|
+
name: check.name
|
|
46337
|
+
};
|
|
46338
|
+
const store = await input.store.read(input.deviceId);
|
|
46339
|
+
if ((readExposedNames(store)[input.instanceId] ?? null) === check.name) return {
|
|
46340
|
+
changed: false,
|
|
46341
|
+
name: check.name
|
|
46342
|
+
};
|
|
46343
|
+
await input.store.write(input.deviceId, exposedNamePatch(store, input.instanceId, check.name));
|
|
46344
|
+
return {
|
|
46345
|
+
changed: true,
|
|
46346
|
+
name: check.name
|
|
46347
|
+
};
|
|
46348
|
+
}
|
|
46349
|
+
/** The exporter's per-device store as an {@link ExposedNameStore}; throws when settings are absent. */
|
|
46350
|
+
function exposedNameStoreOf(settings, owner) {
|
|
46351
|
+
const access = () => {
|
|
46352
|
+
if (settings === void 0) throw new Error(`${owner}: settings are not available`);
|
|
46353
|
+
return settings;
|
|
46354
|
+
};
|
|
46355
|
+
return {
|
|
46356
|
+
read: (deviceId) => access().readDeviceStore(deviceId),
|
|
46357
|
+
write: (deviceId, patch) => access().writeDeviceStore(deviceId, patch)
|
|
46358
|
+
};
|
|
46359
|
+
}
|
|
46360
|
+
/**
|
|
46361
|
+
* Remove every name saved for `instanceId` (the instance was deleted), so a later instance that
|
|
46362
|
+
* reuses the id does not inherit them. Returns the device ids that lost a name. A store that
|
|
46363
|
+
* cannot be read throws; nothing is written for the devices not reached.
|
|
46364
|
+
*/
|
|
46365
|
+
async function pruneExposedNames(settings, instanceId) {
|
|
46366
|
+
const ids = await settings.listDeviceStoreIds();
|
|
46367
|
+
if (ids.length === 0) return [];
|
|
46368
|
+
const pruned = [];
|
|
46369
|
+
for (const [deviceId, store] of await settings.readDeviceStoreBatch(ids)) {
|
|
46370
|
+
if (readExposedNames(store)[instanceId] === void 0) continue;
|
|
46371
|
+
await settings.writeDeviceStore(deviceId, exposedNamePatch(store, instanceId, null));
|
|
46372
|
+
pruned.push(deviceId);
|
|
46373
|
+
}
|
|
46374
|
+
return pruned;
|
|
46375
|
+
}
|
|
45926
46376
|
_enum([
|
|
45927
46377
|
"automation",
|
|
45928
46378
|
"action",
|
|
@@ -50209,11 +50659,13 @@ var IrCodecError = class extends Error {
|
|
|
50209
50659
|
this.code = code;
|
|
50210
50660
|
}
|
|
50211
50661
|
};
|
|
50662
|
+
/** Maximum number of mark/space entries one pulse train may carry. */
|
|
50663
|
+
var IR_TIMINGS_MAX = 1024;
|
|
50212
50664
|
/**
|
|
50213
50665
|
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
50214
50666
|
* alternating, no zeros, 2..1024 entries.
|
|
50215
50667
|
*/
|
|
50216
|
-
var IrTimingsSchema = array(number$1().int()).min(2).max(
|
|
50668
|
+
var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
|
|
50217
50669
|
timings.forEach((value, index) => {
|
|
50218
50670
|
const expectMark = index % 2 === 0;
|
|
50219
50671
|
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
@@ -50260,15 +50712,186 @@ function decodePronto(code) {
|
|
|
50260
50712
|
carrierHz: Math.round(1e6 / unitUs)
|
|
50261
50713
|
};
|
|
50262
50714
|
}
|
|
50263
|
-
/**
|
|
50264
|
-
|
|
50265
|
-
|
|
50266
|
-
|
|
50267
|
-
|
|
50268
|
-
|
|
50269
|
-
|
|
50270
|
-
|
|
50271
|
-
|
|
50715
|
+
/**
|
|
50716
|
+
* FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
|
|
50717
|
+
* literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
|
|
50718
|
+
* is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
|
|
50719
|
+
* between the low 5 bits and the next byte.
|
|
50720
|
+
*/
|
|
50721
|
+
var MAX_DISTANCE = 8192;
|
|
50722
|
+
var MAX_LITERAL_RUN = 32;
|
|
50723
|
+
var MIN_MATCH = 3;
|
|
50724
|
+
var MAX_MATCH = 264;
|
|
50725
|
+
/**
|
|
50726
|
+
* Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
|
|
50727
|
+
* can expand ~130x, so the decoder checks this bound before every write.
|
|
50728
|
+
*/
|
|
50729
|
+
var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
|
|
50730
|
+
function fastlzDecompress(input) {
|
|
50731
|
+
const out = [];
|
|
50732
|
+
let ip = 0;
|
|
50733
|
+
const room = (count) => {
|
|
50734
|
+
if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
|
|
50735
|
+
};
|
|
50736
|
+
const next = () => {
|
|
50737
|
+
const byte = input[ip++];
|
|
50738
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
|
|
50739
|
+
return byte;
|
|
50740
|
+
};
|
|
50741
|
+
while (ip < input.length) {
|
|
50742
|
+
const ctrl = next();
|
|
50743
|
+
if (ctrl < 32) {
|
|
50744
|
+
room(ctrl + 1);
|
|
50745
|
+
for (let i = 0; i <= ctrl; i++) out.push(next());
|
|
50746
|
+
continue;
|
|
50747
|
+
}
|
|
50748
|
+
let len = (ctrl >> 5) - 1;
|
|
50749
|
+
if (len === 6) len += next();
|
|
50750
|
+
const distance = ((ctrl & 31) << 8) + next() + 1;
|
|
50751
|
+
const start = out.length - distance;
|
|
50752
|
+
if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
|
|
50753
|
+
room(len + 3);
|
|
50754
|
+
for (let i = 0; i < len + 3; i++) {
|
|
50755
|
+
const byte = out[start + i];
|
|
50756
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
|
|
50757
|
+
out.push(byte);
|
|
50758
|
+
}
|
|
50759
|
+
}
|
|
50760
|
+
return Uint8Array.from(out);
|
|
50761
|
+
}
|
|
50762
|
+
function fastlzCompress(input) {
|
|
50763
|
+
const out = [];
|
|
50764
|
+
const lastSeen = /* @__PURE__ */ new Map();
|
|
50765
|
+
let literalStart = 0;
|
|
50766
|
+
const flushLiterals = (end) => {
|
|
50767
|
+
for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
|
|
50768
|
+
const to = Math.min(from + MAX_LITERAL_RUN, end);
|
|
50769
|
+
out.push(to - from - 1);
|
|
50770
|
+
for (let i = from; i < to; i++) out.push(input[i] ?? 0);
|
|
50771
|
+
}
|
|
50772
|
+
};
|
|
50773
|
+
let pos = 0;
|
|
50774
|
+
while (pos < input.length) {
|
|
50775
|
+
let matchLen = 0;
|
|
50776
|
+
let matchDistance = 0;
|
|
50777
|
+
if (pos + MIN_MATCH <= input.length) {
|
|
50778
|
+
const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
|
|
50779
|
+
const candidate = lastSeen.get(key);
|
|
50780
|
+
lastSeen.set(key, pos);
|
|
50781
|
+
if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
|
|
50782
|
+
let len = 0;
|
|
50783
|
+
while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
|
|
50784
|
+
if (len >= MIN_MATCH) {
|
|
50785
|
+
matchLen = len;
|
|
50786
|
+
matchDistance = pos - candidate - 1;
|
|
50787
|
+
}
|
|
50788
|
+
}
|
|
50789
|
+
}
|
|
50790
|
+
if (matchLen === 0) {
|
|
50791
|
+
pos++;
|
|
50792
|
+
continue;
|
|
50793
|
+
}
|
|
50794
|
+
flushLiterals(pos);
|
|
50795
|
+
const enc = matchLen - 2;
|
|
50796
|
+
if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
|
|
50797
|
+
else out.push(224 | matchDistance >> 8, enc - 7);
|
|
50798
|
+
out.push(matchDistance & 255);
|
|
50799
|
+
pos += matchLen;
|
|
50800
|
+
literalStart = pos;
|
|
50801
|
+
}
|
|
50802
|
+
flushLiterals(input.length);
|
|
50803
|
+
return Uint8Array.from(out);
|
|
50804
|
+
}
|
|
50805
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
50806
|
+
var MAX_DURATION_US = 65535;
|
|
50807
|
+
function toBase64(bytes) {
|
|
50808
|
+
let out = "";
|
|
50809
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
50810
|
+
const a = bytes[i] ?? 0;
|
|
50811
|
+
const b = bytes[i + 1] ?? 0;
|
|
50812
|
+
const c = bytes[i + 2] ?? 0;
|
|
50813
|
+
const word = a << 16 | b << 8 | c;
|
|
50814
|
+
out += ALPHABET[word >> 18 & 63];
|
|
50815
|
+
out += ALPHABET[word >> 12 & 63];
|
|
50816
|
+
out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
|
|
50817
|
+
out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
|
|
50818
|
+
}
|
|
50819
|
+
return out;
|
|
50820
|
+
}
|
|
50821
|
+
function fromBase64(text) {
|
|
50822
|
+
const clean = text.trim().replace(/=+$/, "");
|
|
50823
|
+
if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
50824
|
+
const out = [];
|
|
50825
|
+
let bits = 0;
|
|
50826
|
+
let acc = 0;
|
|
50827
|
+
for (const ch of clean) {
|
|
50828
|
+
const value = ALPHABET.indexOf(ch);
|
|
50829
|
+
if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
50830
|
+
acc = acc << 6 | value;
|
|
50831
|
+
bits += 6;
|
|
50832
|
+
if (bits >= 8) {
|
|
50833
|
+
bits -= 8;
|
|
50834
|
+
out.push(acc >> bits & 255);
|
|
50835
|
+
}
|
|
50836
|
+
}
|
|
50837
|
+
return Uint8Array.from(out);
|
|
50838
|
+
}
|
|
50839
|
+
/** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
|
|
50840
|
+
function encodeTuya(timings) {
|
|
50841
|
+
const bytes = new Uint8Array(timings.length * 2);
|
|
50842
|
+
timings.forEach((value, index) => {
|
|
50843
|
+
const duration = Math.abs(value);
|
|
50844
|
+
if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
|
|
50845
|
+
bytes[index * 2] = duration & 255;
|
|
50846
|
+
bytes[index * 2 + 1] = duration >> 8;
|
|
50847
|
+
});
|
|
50848
|
+
return toBase64(fastlzCompress(bytes));
|
|
50849
|
+
}
|
|
50850
|
+
/** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
|
|
50851
|
+
function decodeTuya(code) {
|
|
50852
|
+
const bytes = fastlzDecompress(fromBase64(code));
|
|
50853
|
+
if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
|
|
50854
|
+
const timings = [];
|
|
50855
|
+
for (let i = 0; i < bytes.length; i += 2) {
|
|
50856
|
+
const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
|
|
50857
|
+
timings.push(i / 2 % 2 === 0 ? duration : -duration);
|
|
50858
|
+
}
|
|
50859
|
+
const checked = IrTimingsSchema.safeParse(timings);
|
|
50860
|
+
if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
|
|
50861
|
+
return checked.data;
|
|
50862
|
+
}
|
|
50863
|
+
/** Device-native IR code formats a transmitter can replay verbatim. */
|
|
50864
|
+
var IrNativeFormatSchema = _enum(["tuya"]);
|
|
50865
|
+
/**
|
|
50866
|
+
* Longest native code accepted: base64 of the worst-case compressed stream
|
|
50867
|
+
* (every decoded byte as a literal, plus one control byte per 32), with margin.
|
|
50868
|
+
*/
|
|
50869
|
+
var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
|
|
50870
|
+
var IrNativeCodeSchema = object({
|
|
50871
|
+
format: IrNativeFormatSchema,
|
|
50872
|
+
code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
|
|
50873
|
+
});
|
|
50874
|
+
var IR_NATIVE_CODECS = { tuya: {
|
|
50875
|
+
encode: encodeTuya,
|
|
50876
|
+
decode: decodeTuya
|
|
50877
|
+
} };
|
|
50878
|
+
/** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
|
|
50879
|
+
var IrPayloadSchema = discriminatedUnion("kind", [
|
|
50880
|
+
object({
|
|
50881
|
+
kind: literal("raw"),
|
|
50882
|
+
timings: array(number$1().int()),
|
|
50883
|
+
settings: TransmitSettingsSchema.optional()
|
|
50884
|
+
}),
|
|
50885
|
+
object({
|
|
50886
|
+
kind: literal("pronto"),
|
|
50887
|
+
code: string()
|
|
50888
|
+
}),
|
|
50889
|
+
object({
|
|
50890
|
+
kind: literal("native"),
|
|
50891
|
+
format: IrNativeFormatSchema,
|
|
50892
|
+
code: string()
|
|
50893
|
+
})
|
|
50894
|
+
]);
|
|
50272
50895
|
/** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
|
|
50273
50896
|
function toTimings(payload) {
|
|
50274
50897
|
if (payload.kind === "pronto") {
|
|
@@ -50278,6 +50901,10 @@ function toTimings(payload) {
|
|
|
50278
50901
|
settings: { carrierHz: decoded.carrierHz }
|
|
50279
50902
|
};
|
|
50280
50903
|
}
|
|
50904
|
+
if (payload.kind === "native") return {
|
|
50905
|
+
timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
|
|
50906
|
+
settings: {}
|
|
50907
|
+
};
|
|
50281
50908
|
const checked = IrTimingsSchema.safeParse(payload.timings);
|
|
50282
50909
|
if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
|
|
50283
50910
|
return {
|
|
@@ -51086,8 +51713,8 @@ function actuator(input) {
|
|
|
51086
51713
|
};
|
|
51087
51714
|
}
|
|
51088
51715
|
new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
|
|
51089
|
-
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
51090
51716
|
DeviceType.Camera;
|
|
51717
|
+
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
51091
51718
|
var PowerSourceRefusalReasonSchema = _enum([
|
|
51092
51719
|
"no-power-source",
|
|
51093
51720
|
"switch-missing",
|
|
@@ -52362,193 +52989,6 @@ method(object({
|
|
|
52362
52989
|
kind: "mutation",
|
|
52363
52990
|
auth: "admin"
|
|
52364
52991
|
});
|
|
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
52992
|
var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
52553
52993
|
var DeviceTemplateSchema = string().min(1).max(4096);
|
|
52554
52994
|
/** One value a caller hands the renderer for `thisDevice`. */
|
|
@@ -56697,6 +57137,128 @@ var StateLookSchema = object({
|
|
|
56697
57137
|
background: _enum(HERO_BACKGROUNDS),
|
|
56698
57138
|
animation: HeroAnimationSchema
|
|
56699
57139
|
});
|
|
57140
|
+
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
57141
|
+
var HeroTextSchema = object({
|
|
57142
|
+
en: string(),
|
|
57143
|
+
it: string()
|
|
57144
|
+
});
|
|
57145
|
+
/**
|
|
57146
|
+
* The ONE measurement a simple sensor shows (card wave, phase 1).
|
|
57147
|
+
*
|
|
57148
|
+
* A sensor that measures a single quantity (a temperature, a humidity, a power,
|
|
57149
|
+
* a contact, a text state) is drawn as that reading, once, big, inside a scene
|
|
57150
|
+
* whose motion says what the number means: heat rising when hot, flakes when
|
|
57151
|
+
* cold, a wire flowing at the speed of the power, a ring while a window is
|
|
57152
|
+
* open. Everything the card draws is decided here; a client only paints it.
|
|
57153
|
+
*/
|
|
57154
|
+
var HERO_MEASUREMENT_QUANTITIES = [
|
|
57155
|
+
"temperature",
|
|
57156
|
+
"humidity",
|
|
57157
|
+
"power",
|
|
57158
|
+
"contact",
|
|
57159
|
+
"text"
|
|
57160
|
+
];
|
|
57161
|
+
/** How a temperature reads to a person; drives the heat or the cold scene. */
|
|
57162
|
+
var HERO_MEASUREMENT_BANDS = [
|
|
57163
|
+
"hot",
|
|
57164
|
+
"mild",
|
|
57165
|
+
"cold"
|
|
57166
|
+
];
|
|
57167
|
+
/** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
|
|
57168
|
+
var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
|
|
57169
|
+
var HeroMeasurementReadingSchema = object({
|
|
57170
|
+
value: number$1(),
|
|
57171
|
+
quantity: ReadingQuantitySchema
|
|
57172
|
+
});
|
|
57173
|
+
var HeroMeasurementSchema = object({
|
|
57174
|
+
quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
|
|
57175
|
+
reading: HeroMeasurementReadingSchema.nullable(),
|
|
57176
|
+
icon: IconKeySchema.nullable(),
|
|
57177
|
+
value: HeroTextSchema,
|
|
57178
|
+
unit: string().nullable(),
|
|
57179
|
+
band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
|
|
57180
|
+
level: number$1().min(0).max(1).nullable(),
|
|
57181
|
+
word: HeroTextSchema,
|
|
57182
|
+
tone: _enum(HERO_TONES),
|
|
57183
|
+
since: number$1().nullable(),
|
|
57184
|
+
sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
|
|
57185
|
+
historyKey: string().nullable()
|
|
57186
|
+
});
|
|
57187
|
+
var same$2 = (text) => t(text, text);
|
|
57188
|
+
var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
|
|
57189
|
+
var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
|
|
57190
|
+
function temperatureBand(celsius) {
|
|
57191
|
+
if (celsius < 12) return "cold";
|
|
57192
|
+
if (celsius > 28) return "hot";
|
|
57193
|
+
return "mild";
|
|
57194
|
+
}
|
|
57195
|
+
var BAND_WORD = {
|
|
57196
|
+
hot: t("Hot", "Caldo"),
|
|
57197
|
+
mild: t("Normal", "Normale"),
|
|
57198
|
+
cold: t("Cold", "Freddo")
|
|
57199
|
+
};
|
|
57200
|
+
var BAND_TONE = {
|
|
57201
|
+
hot: "warning",
|
|
57202
|
+
mild: "muted",
|
|
57203
|
+
cold: "info"
|
|
57204
|
+
};
|
|
57205
|
+
function temperatureMeasurement(celsius, since) {
|
|
57206
|
+
const band = temperatureBand(celsius);
|
|
57207
|
+
return {
|
|
57208
|
+
quantity: "temperature",
|
|
57209
|
+
reading: {
|
|
57210
|
+
value: celsius,
|
|
57211
|
+
quantity: "temperature"
|
|
57212
|
+
},
|
|
57213
|
+
icon: "thermometer",
|
|
57214
|
+
value: same$2(trimmed(celsius, 1)),
|
|
57215
|
+
unit: "°C",
|
|
57216
|
+
band,
|
|
57217
|
+
level: null,
|
|
57218
|
+
word: BAND_WORD[band],
|
|
57219
|
+
tone: BAND_TONE[band],
|
|
57220
|
+
since,
|
|
57221
|
+
sinceKind: "updated",
|
|
57222
|
+
historyKey: "cap:temperature-sensor.temperature"
|
|
57223
|
+
};
|
|
57224
|
+
}
|
|
57225
|
+
function humidityMeasurement(percent, since) {
|
|
57226
|
+
const dry = percent < 30;
|
|
57227
|
+
const humid = percent > 70;
|
|
57228
|
+
return {
|
|
57229
|
+
quantity: "humidity",
|
|
57230
|
+
reading: {
|
|
57231
|
+
value: percent,
|
|
57232
|
+
quantity: "humidity"
|
|
57233
|
+
},
|
|
57234
|
+
icon: "droplets",
|
|
57235
|
+
value: same$2(String(Math.round(percent))),
|
|
57236
|
+
unit: "%",
|
|
57237
|
+
band: null,
|
|
57238
|
+
level: clamp01$1(percent / 100),
|
|
57239
|
+
word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
|
|
57240
|
+
tone: dry || humid ? "warning" : "info",
|
|
57241
|
+
since,
|
|
57242
|
+
sinceKind: "updated",
|
|
57243
|
+
historyKey: "cap:humidity-sensor.humidity"
|
|
57244
|
+
};
|
|
57245
|
+
}
|
|
57246
|
+
function textMeasurement(text, since) {
|
|
57247
|
+
return {
|
|
57248
|
+
quantity: "text",
|
|
57249
|
+
reading: null,
|
|
57250
|
+
icon: null,
|
|
57251
|
+
value: same$2(text),
|
|
57252
|
+
unit: null,
|
|
57253
|
+
band: null,
|
|
57254
|
+
level: null,
|
|
57255
|
+
word: t("Changed", "Cambiato"),
|
|
57256
|
+
tone: "muted",
|
|
57257
|
+
since,
|
|
57258
|
+
sinceKind: "updated",
|
|
57259
|
+
historyKey: null
|
|
57260
|
+
};
|
|
57261
|
+
}
|
|
56700
57262
|
/** The scene as the model carries it. `null` = the device did not say (never a guess). */
|
|
56701
57263
|
var HeroSceneSchema = object({
|
|
56702
57264
|
id: _enum([
|
|
@@ -56747,12 +57309,7 @@ var HeroSceneSchema = object({
|
|
|
56747
57309
|
level: number$1().min(0).max(1).nullable()
|
|
56748
57310
|
});
|
|
56749
57311
|
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
|
-
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
|
-
});
|
|
57312
|
+
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.SwitchLight, 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;
|
|
56756
57313
|
var HeroRowIdSchema = _enum([
|
|
56757
57314
|
"progress",
|
|
56758
57315
|
"run-for",
|
|
@@ -56858,6 +57415,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
|
|
|
56858
57415
|
optionLabels: record(string(), HeroTextSchema).optional(),
|
|
56859
57416
|
call: HeroCallSchema,
|
|
56860
57417
|
valueArg: string()
|
|
57418
|
+
}),
|
|
57419
|
+
object({
|
|
57420
|
+
kind: literal("number"),
|
|
57421
|
+
id: string(),
|
|
57422
|
+
label: HeroTextSchema,
|
|
57423
|
+
value: number$1().nullable(),
|
|
57424
|
+
/** `null` = any number; the device rounds what it does not accept. */
|
|
57425
|
+
step: number$1().nullable(),
|
|
57426
|
+
unit: string(),
|
|
57427
|
+
call: HeroCallSchema,
|
|
57428
|
+
valueArg: string()
|
|
57429
|
+
}),
|
|
57430
|
+
object({
|
|
57431
|
+
kind: literal("text"),
|
|
57432
|
+
id: string(),
|
|
57433
|
+
label: HeroTextSchema,
|
|
57434
|
+
value: string().nullable(),
|
|
57435
|
+
call: HeroCallSchema,
|
|
57436
|
+
valueArg: string()
|
|
56861
57437
|
})
|
|
56862
57438
|
]);
|
|
56863
57439
|
/** 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 +57635,11 @@ var HeroModelSchema = object({
|
|
|
57059
57635
|
timedRun: HeroTimedRunSlotSchema.nullable(),
|
|
57060
57636
|
powerSupply: HeroPowerSupplySlotSchema.nullable(),
|
|
57061
57637
|
rows: array(HeroRowSchema),
|
|
57638
|
+
/**
|
|
57639
|
+
* The ONE measurement of a simple sensor, drawn once inside the scene in place of
|
|
57640
|
+
* the caption, tiles and value chips. Absent = the card draws as before.
|
|
57641
|
+
*/
|
|
57642
|
+
measurement: HeroMeasurementSchema.optional(),
|
|
57062
57643
|
/** Ids of parts that actuate the device, hidden from a session that may not act on it. */
|
|
57063
57644
|
gated: array(string()),
|
|
57064
57645
|
provenance: array(HeroProvenanceSchema)
|
|
@@ -57130,8 +57711,23 @@ var HeroRowModelSchema = object({
|
|
|
57130
57711
|
* the call. Absent or empty = `primary` alone.
|
|
57131
57712
|
*/
|
|
57132
57713
|
extras: array(HeroControlSchema).max(2).optional(),
|
|
57133
|
-
trailing: HeroFactSchema.nullable()
|
|
57714
|
+
trailing: HeroFactSchema.nullable(),
|
|
57715
|
+
/**
|
|
57716
|
+
* The simple sensor's one reading (the hero's `measurement`): the row draws its value
|
|
57717
|
+
* at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
|
|
57718
|
+
* older server or a device that is not a simple sensor: draw `trailing`.
|
|
57719
|
+
*/
|
|
57720
|
+
measurement: HeroMeasurementSchema.optional()
|
|
57134
57721
|
});
|
|
57722
|
+
new Set([
|
|
57723
|
+
"temperature",
|
|
57724
|
+
"humidity",
|
|
57725
|
+
"pressure",
|
|
57726
|
+
"illuminance",
|
|
57727
|
+
"reading",
|
|
57728
|
+
"air-quality",
|
|
57729
|
+
"valve"
|
|
57730
|
+
]);
|
|
57135
57731
|
DeviceType.Climate;
|
|
57136
57732
|
DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
|
|
57137
57733
|
/**
|
|
@@ -57448,6 +58044,12 @@ var IntegrationLiteSchema = object({
|
|
|
57448
58044
|
var AvailableIntegrationTypeSchema = object({
|
|
57449
58045
|
addonId: string(),
|
|
57450
58046
|
name: string(),
|
|
58047
|
+
/**
|
|
58048
|
+
* Product name a new integration is prefilled from (`<label> - Home`).
|
|
58049
|
+
* Absent: the client uses `name`. Set when the catalog title is not the
|
|
58050
|
+
* product (Bosch SHC, MQTT).
|
|
58051
|
+
*/
|
|
58052
|
+
providerLabel: string().optional(),
|
|
57451
58053
|
description: string(),
|
|
57452
58054
|
iconUrl: string().nullable(),
|
|
57453
58055
|
color: string(),
|
|
@@ -57959,13 +58561,32 @@ var IrSendResultSchema = object({
|
|
|
57959
58561
|
var IrTransmitterInfoSchema = object({
|
|
57960
58562
|
media: array(IrMediumSchema),
|
|
57961
58563
|
settable: array(TransmitSettingKeySchema),
|
|
57962
|
-
maxTimings: number$1().int().positive()
|
|
58564
|
+
maxTimings: number$1().int().positive(),
|
|
58565
|
+
/** The transmitter can learn a code (`learn`). */
|
|
58566
|
+
learn: boolean().default(false),
|
|
58567
|
+
/** Native code formats the transmitter replays verbatim (`send.native`). */
|
|
58568
|
+
formats: array(IrNativeFormatSchema).default([])
|
|
58569
|
+
});
|
|
58570
|
+
var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
|
|
58571
|
+
var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
|
|
58572
|
+
var IrLearnResultSchema = object({
|
|
58573
|
+
/** The code in the device's own format, when it reports one. */
|
|
58574
|
+
native: IrNativeCodeSchema.nullable(),
|
|
58575
|
+
timings: IrTimingsSchema,
|
|
58576
|
+
carrierHz: number$1().int().positive().nullable()
|
|
57963
58577
|
});
|
|
57964
58578
|
DeviceType.Generic, method(object({
|
|
57965
58579
|
deviceId: number$1().int().nonnegative(),
|
|
57966
|
-
timings: IrTimingsSchema,
|
|
58580
|
+
timings: IrTimingsSchema.optional(),
|
|
58581
|
+
native: IrNativeCodeSchema.optional(),
|
|
57967
58582
|
settings: TransmitSettingsSchema.optional()
|
|
57968
|
-
}), IrSendResultSchema, {
|
|
58583
|
+
}).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
|
|
58584
|
+
kind: "mutation",
|
|
58585
|
+
auth: "protected"
|
|
58586
|
+
}), method(object({
|
|
58587
|
+
deviceId: number$1().int().nonnegative(),
|
|
58588
|
+
timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
|
|
58589
|
+
}), IrLearnResultSchema, {
|
|
57969
58590
|
kind: "mutation",
|
|
57970
58591
|
auth: "protected"
|
|
57971
58592
|
}), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
|
|
@@ -67188,6 +67809,7 @@ var NcSystemEventKindSchema = _enum([
|
|
|
67188
67809
|
"recording-degraded",
|
|
67189
67810
|
"device-attention-required",
|
|
67190
67811
|
"device-attention-resolved",
|
|
67812
|
+
"device-command",
|
|
67191
67813
|
"storage-location-low",
|
|
67192
67814
|
"storage-location-critical",
|
|
67193
67815
|
"storage-location-ok",
|
|
@@ -67250,11 +67872,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
|
|
|
67250
67872
|
"alarm-sensor-bypass",
|
|
67251
67873
|
"alarm-disarmed"
|
|
67252
67874
|
];
|
|
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
67875
|
var NcSystemEventConditionSchema = object({
|
|
67259
67876
|
kinds: array(NcSystemEventKindSchema).min(1),
|
|
67260
67877
|
deviceIds: array(number$1().int()).min(1).optional(),
|
|
@@ -67286,6 +67903,28 @@ var NcSystemEventConditionSchema = object({
|
|
|
67286
67903
|
nodeIds: array(string().min(1)).min(1).optional(),
|
|
67287
67904
|
packageNames: array(string().min(1)).min(1).optional(),
|
|
67288
67905
|
/**
|
|
67906
|
+
* `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
|
|
67907
|
+
* this rule speaks about - the same dictionary the automation action blocks
|
|
67908
|
+
* pick from. The hub refuses an id the action index does not know.
|
|
67909
|
+
*/
|
|
67910
|
+
commandActions: array(string().min(1)).min(1).optional(),
|
|
67911
|
+
/** `device-command` only: how the command settled. A device's own change is not a command. */
|
|
67912
|
+
commandOutcomes: array(_enum([
|
|
67913
|
+
"confirmed",
|
|
67914
|
+
"already",
|
|
67915
|
+
"unconfirmed",
|
|
67916
|
+
"failed"
|
|
67917
|
+
])).min(1).optional(),
|
|
67918
|
+
/** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
|
|
67919
|
+
commandActorKinds: array(_enum([
|
|
67920
|
+
"user",
|
|
67921
|
+
"addon",
|
|
67922
|
+
"action",
|
|
67923
|
+
"scheduler",
|
|
67924
|
+
"composition",
|
|
67925
|
+
"node"
|
|
67926
|
+
])).min(1).optional(),
|
|
67927
|
+
/**
|
|
67289
67928
|
* At or below this remaining-life %, a consumable is LOW for THIS rule
|
|
67290
67929
|
* (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
|
|
67291
67930
|
* {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
|
|
@@ -68266,6 +68905,13 @@ var NcRuleInputSchema = object({
|
|
|
68266
68905
|
*/
|
|
68267
68906
|
groupingSec: number$1().int().min(5).max(60).optional(),
|
|
68268
68907
|
/**
|
|
68908
|
+
* Hold deliveries of this rule to one target and, when two or more arrive
|
|
68909
|
+
* before the window ends, send them as one summary. Absent = the kind's
|
|
68910
|
+
* default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
|
|
68911
|
+
* other kind. `0` sends each delivery as it does today.
|
|
68912
|
+
*/
|
|
68913
|
+
groupWithinSec: number$1().int().min(0).max(300).optional(),
|
|
68914
|
+
/**
|
|
68269
68915
|
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
68270
68916
|
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
68271
68917
|
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
@@ -68702,7 +69348,12 @@ var NcHistoryEntrySchema = object({
|
|
|
68702
69348
|
* Assistant export) must render as "no image right now", never as a
|
|
68703
69349
|
* broken link.
|
|
68704
69350
|
*/
|
|
68705
|
-
artifactIds: array(string().min(1)).optional()
|
|
69351
|
+
artifactIds: array(string().min(1)).optional(),
|
|
69352
|
+
/**
|
|
69353
|
+
* When this row was folded into a group-window summary, the outbox id of
|
|
69354
|
+
* that one notification. Absent on a row that was sent as itself.
|
|
69355
|
+
*/
|
|
69356
|
+
groupedInto: string().min(1).optional()
|
|
68706
69357
|
});
|
|
68707
69358
|
/**
|
|
68708
69359
|
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
@@ -74165,10 +74816,15 @@ var RecordingSignalStatusSchema = object({
|
|
|
74165
74816
|
});
|
|
74166
74817
|
RecordingSignalStatusSchema.extend({ lastFetchedAt: number$1() });
|
|
74167
74818
|
DeviceType.Camera, method(object({ deviceId: number$1() }), RecordingSignalStatusSchema);
|
|
74168
|
-
var RemoteBindingSchema = object({ action:
|
|
74169
|
-
|
|
74170
|
-
|
|
74171
|
-
|
|
74819
|
+
var RemoteBindingSchema = object({ action: object({
|
|
74820
|
+
kind: literal("cap"),
|
|
74821
|
+
deviceId: number$1().int().nonnegative(),
|
|
74822
|
+
cap: string().min(1),
|
|
74823
|
+
method: string().min(1),
|
|
74824
|
+
args: record(string(), unknown()).optional(),
|
|
74825
|
+
/** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
|
|
74826
|
+
argUnits: record(string(), string().min(1)).optional()
|
|
74827
|
+
}) });
|
|
74172
74828
|
var RemoteCustomButtonSchema = object({
|
|
74173
74829
|
/** The slug after `custom:` in the role. */
|
|
74174
74830
|
key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
|
|
@@ -79588,8 +80244,6 @@ var AccessoryKind = {
|
|
|
79588
80244
|
};
|
|
79589
80245
|
AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
|
|
79590
80246
|
DeviceType.HeatPump;
|
|
79591
|
-
DeviceType.Climate;
|
|
79592
|
-
DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
|
|
79593
80247
|
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
79594
80248
|
new Set(Object.values(DeviceType));
|
|
79595
80249
|
/** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
|
|
@@ -79602,6 +80256,13 @@ function contribution(cap, schema, build) {
|
|
|
79602
80256
|
}
|
|
79603
80257
|
};
|
|
79604
80258
|
}
|
|
80259
|
+
/** The fragment, carrying the cap's single measurement when it has one. */
|
|
80260
|
+
function measured(fragment, measurement) {
|
|
80261
|
+
return measurement === void 0 ? fragment : {
|
|
80262
|
+
...fragment,
|
|
80263
|
+
measurement
|
|
80264
|
+
};
|
|
80265
|
+
}
|
|
79605
80266
|
function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
|
|
79606
80267
|
return {
|
|
79607
80268
|
id,
|
|
@@ -80876,10 +81537,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
|
|
|
80876
81537
|
};
|
|
80877
81538
|
});
|
|
80878
81539
|
var CONTROL_LABEL = t("Value", "Valore");
|
|
80879
|
-
/**
|
|
81540
|
+
/**
|
|
81541
|
+
* A number with known bounds is a slider, one without a number field, a choice a picker,
|
|
81542
|
+
* free text a text field; a date stays read-only.
|
|
81543
|
+
*/
|
|
80880
81544
|
function controlRows(slice) {
|
|
80881
81545
|
if (slice.kind === "numeric" && typeof slice.value === "number") {
|
|
80882
|
-
if (slice.min === void 0 || slice.max === void 0) return [
|
|
81546
|
+
if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
|
|
81547
|
+
kind: "number",
|
|
81548
|
+
id: "control.value",
|
|
81549
|
+
label: CONTROL_LABEL,
|
|
81550
|
+
value: slice.value,
|
|
81551
|
+
step: slice.step ?? null,
|
|
81552
|
+
unit: "",
|
|
81553
|
+
call: {
|
|
81554
|
+
cap: "control",
|
|
81555
|
+
method: "setValue",
|
|
81556
|
+
args: { control: { kind: "numeric" } }
|
|
81557
|
+
},
|
|
81558
|
+
valueArg: "control.value"
|
|
81559
|
+
}])];
|
|
80883
81560
|
return [row$1("control", "sliders-horizontal", null, [{
|
|
80884
81561
|
kind: "slider",
|
|
80885
81562
|
id: "control.value",
|
|
@@ -80910,6 +81587,18 @@ function controlRows(slice) {
|
|
|
80910
81587
|
},
|
|
80911
81588
|
valueArg: "control.value"
|
|
80912
81589
|
}])];
|
|
81590
|
+
if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
|
|
81591
|
+
kind: "text",
|
|
81592
|
+
id: "control.value",
|
|
81593
|
+
label: CONTROL_LABEL,
|
|
81594
|
+
value: typeof slice.value === "string" ? slice.value : null,
|
|
81595
|
+
call: {
|
|
81596
|
+
cap: "control",
|
|
81597
|
+
method: "setValue",
|
|
81598
|
+
args: { control: { kind: "text" } }
|
|
81599
|
+
},
|
|
81600
|
+
valueArg: "control.value"
|
|
81601
|
+
}])];
|
|
80913
81602
|
return [];
|
|
80914
81603
|
}
|
|
80915
81604
|
var SENSORS_FAMILY_CONTRIBUTIONS = {
|
|
@@ -81265,15 +81954,15 @@ function sensorFragment(value, id, icon, en, it, text) {
|
|
|
81265
81954
|
tiles: { right: [tile$1(en, it, text)] }
|
|
81266
81955
|
};
|
|
81267
81956
|
}
|
|
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)}%`));
|
|
81957
|
+
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)));
|
|
81958
|
+
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
81959
|
var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
|
|
81271
81960
|
var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
|
|
81272
81961
|
var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
|
|
81273
81962
|
var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
|
|
81274
81963
|
if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
|
|
81275
81964
|
if (slice.timestamp === true) return { reading: reading("sensor", "on") };
|
|
81276
|
-
return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
|
|
81965
|
+
return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
|
|
81277
81966
|
});
|
|
81278
81967
|
/** Index bands: the headline of an air-quality sensor is a word, not a number. */
|
|
81279
81968
|
function airQualityWord(aqi) {
|
|
@@ -82242,7 +82931,7 @@ lookOf({
|
|
|
82242
82931
|
});
|
|
82243
82932
|
DeviceType.Climate;
|
|
82244
82933
|
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;
|
|
82245
|
-
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;
|
|
82934
|
+
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.SwitchLight, 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;
|
|
82246
82935
|
Object.freeze({
|
|
82247
82936
|
"accessories.getStatus": {
|
|
82248
82937
|
capName: "accessories",
|
|
@@ -84169,6 +84858,13 @@ Object.freeze({
|
|
|
84169
84858
|
access: "view",
|
|
84170
84859
|
role: "admin"
|
|
84171
84860
|
},
|
|
84861
|
+
"deviceExport.setExposedName": {
|
|
84862
|
+
capName: "device-export",
|
|
84863
|
+
capScope: "system",
|
|
84864
|
+
addonId: null,
|
|
84865
|
+
access: "create",
|
|
84866
|
+
role: "admin"
|
|
84867
|
+
},
|
|
84172
84868
|
"deviceExport.unexposeDevice": {
|
|
84173
84869
|
capName: "device-export",
|
|
84174
84870
|
capScope: "system",
|
|
@@ -86108,6 +86804,13 @@ Object.freeze({
|
|
|
86108
86804
|
access: "view",
|
|
86109
86805
|
role: "viewer"
|
|
86110
86806
|
},
|
|
86807
|
+
"irTransmitter.learn": {
|
|
86808
|
+
capName: "ir-transmitter",
|
|
86809
|
+
capScope: "device",
|
|
86810
|
+
addonId: null,
|
|
86811
|
+
access: "create",
|
|
86812
|
+
role: "viewer"
|
|
86813
|
+
},
|
|
86111
86814
|
"irTransmitter.send": {
|
|
86112
86815
|
capName: "ir-transmitter",
|
|
86113
86816
|
capScope: "device",
|
|
@@ -92626,48 +93329,6 @@ Object.freeze({
|
|
|
92626
93329
|
role: "admin"
|
|
92627
93330
|
}
|
|
92628
93331
|
});
|
|
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
93332
|
DeviceFeature.BatteryOperated;
|
|
92672
93333
|
function bound(cap, methods = [], authority = "reported") {
|
|
92673
93334
|
return {
|
|
@@ -93984,6 +94645,11 @@ Object.freeze({
|
|
|
93984
94645
|
form: "single",
|
|
93985
94646
|
optional: false
|
|
93986
94647
|
}],
|
|
94648
|
+
"irTransmitter.learn": [{
|
|
94649
|
+
name: "deviceId",
|
|
94650
|
+
form: "single",
|
|
94651
|
+
optional: false
|
|
94652
|
+
}],
|
|
93987
94653
|
"irTransmitter.send": [{
|
|
93988
94654
|
name: "deviceId",
|
|
93989
94655
|
form: "single",
|
|
@@ -95923,7 +96589,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
|
|
|
95923
96589
|
"deviceTypes",
|
|
95924
96590
|
"nodeIds",
|
|
95925
96591
|
"packageNames",
|
|
95926
|
-
"consumableLowPercent"
|
|
96592
|
+
"consumableLowPercent",
|
|
96593
|
+
"commandActions",
|
|
96594
|
+
"commandOutcomes",
|
|
96595
|
+
"commandActorKinds"
|
|
95927
96596
|
];
|
|
95928
96597
|
new Map(Object.entries({
|
|
95929
96598
|
"device-online": "device-events",
|
|
@@ -95946,6 +96615,7 @@ new Map(Object.entries({
|
|
|
95946
96615
|
"recording-degraded": "device-events",
|
|
95947
96616
|
"device-attention-required": "device-events",
|
|
95948
96617
|
"device-attention-resolved": "device-events",
|
|
96618
|
+
"device-command": "device-events",
|
|
95949
96619
|
"node-online": "system",
|
|
95950
96620
|
"node-offline": "system",
|
|
95951
96621
|
"node-restarting": "system",
|
|
@@ -96046,6 +96716,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
|
|
|
96046
96716
|
label: "Needs attention",
|
|
96047
96717
|
kinds: ["device-attention-required", "device-attention-resolved"]
|
|
96048
96718
|
},
|
|
96719
|
+
{
|
|
96720
|
+
id: "device-command",
|
|
96721
|
+
family: "device-events",
|
|
96722
|
+
label: "Commands given to devices",
|
|
96723
|
+
kinds: ["device-command"]
|
|
96724
|
+
},
|
|
96049
96725
|
{
|
|
96050
96726
|
id: "nodes",
|
|
96051
96727
|
family: "system",
|
|
@@ -96123,6 +96799,15 @@ function systemEventKindsOfFamily(family) {
|
|
|
96123
96799
|
return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
|
|
96124
96800
|
}
|
|
96125
96801
|
NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
|
|
96802
|
+
new Set([
|
|
96803
|
+
"alarm.trigger",
|
|
96804
|
+
"alarm.disarm",
|
|
96805
|
+
"alarm.arm.home",
|
|
96806
|
+
"alarm.arm.away",
|
|
96807
|
+
"alarm.arm.night",
|
|
96808
|
+
"alarm.arm.vacation",
|
|
96809
|
+
"alarm.arm.custom_bypass"
|
|
96810
|
+
]);
|
|
96126
96811
|
/**
|
|
96127
96812
|
* WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
|
|
96128
96813
|
* persists (D640 "a sensor rule fires on the raise, the clear, or both").
|
|
@@ -96318,6 +97003,7 @@ var DEVICE_EVENTS = [
|
|
|
96318
97003
|
"recording-healthy",
|
|
96319
97004
|
"recording-degraded",
|
|
96320
97005
|
...DEVICE_ATTENTION,
|
|
97006
|
+
"device-command",
|
|
96321
97007
|
...ALARM
|
|
96322
97008
|
];
|
|
96323
97009
|
/** Every kind a summary may speak about — the two summarisable families. */
|
|
@@ -96471,6 +97157,9 @@ var STATE_SUMMARY_VARS = [
|
|
|
96471
97157
|
[...RULE_BODY_ONLY],
|
|
96472
97158
|
[...RULE_TEXT],
|
|
96473
97159
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
97160
|
+
[...RULE_TEXT],
|
|
97161
|
+
[...RULE_TEXT],
|
|
97162
|
+
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
96474
97163
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96475
97164
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96476
97165
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
@@ -101219,10 +101908,24 @@ var BRIGHTNESS_DIRECTIVE = {
|
|
|
101219
101908
|
needsReachableDevice: true,
|
|
101220
101909
|
handle: (c) => handleSetBrightness(c.header, c.endpoint, c.payload, c.deps.brightnessController, c.identity)
|
|
101221
101910
|
};
|
|
101222
|
-
/**
|
|
101223
|
-
*
|
|
101911
|
+
/**
|
|
101912
|
+
* A switch's category comes from its sub-role, read only through the
|
|
101913
|
+
* `@camstack/types` accessors (operator decision 2026-11-12: every switch
|
|
101914
|
+
* sub-role is exported as its own category):
|
|
101915
|
+
* - an outlet (D875, e.g. HA `device_class: outlet`) is a SMARTPLUG;
|
|
101916
|
+
* - a relay driving a lamp (`switch-light`) is a LIGHT with power only;
|
|
101917
|
+
* - a plain fan behind a switch (`switch-fan`) is a FAN with power only;
|
|
101918
|
+
* - a plug-in heater (`switch-heater`) stays a SWITCH: Alexa has no heater
|
|
101919
|
+
* category with power only, and THERMOSTAT would promise a setpoint and a
|
|
101920
|
+
* temperature the device does not have;
|
|
101921
|
+
* - a helper boolean (`binary-helper`) and a role-less switch stay a SWITCH:
|
|
101922
|
+
* a helper is not a physical thing, SWITCH is exactly what it is.
|
|
101923
|
+
*/
|
|
101224
101924
|
function switchCategory(device) {
|
|
101225
|
-
|
|
101925
|
+
if (isSwitchLight(device.type, device.role)) return "LIGHT";
|
|
101926
|
+
if (isOutlet(device.type, device.role)) return "SMARTPLUG";
|
|
101927
|
+
if (isSwitchFan(device.type, device.role)) return "FAN";
|
|
101928
|
+
return "SWITCH";
|
|
101226
101929
|
}
|
|
101227
101930
|
//#endregion
|
|
101228
101931
|
//#region src/endpoints/adapters/index.ts
|
|
@@ -102370,6 +103073,29 @@ function alarmArmModeForAlexa(armState, availableModes) {
|
|
|
102370
103073
|
}
|
|
102371
103074
|
//#endregion
|
|
102372
103075
|
//#region src/endpoints/builder.ts
|
|
103076
|
+
/**
|
|
103077
|
+
* Build the Alexa Smart Home endpoint payload for a single camstack
|
|
103078
|
+
* device. The Discovery handler aggregates these into an
|
|
103079
|
+
* `Alexa.Discovery/Discover.Response`.
|
|
103080
|
+
*
|
|
103081
|
+
* Endpoint topology:
|
|
103082
|
+
* - Each exposed camera produces ONE parent endpoint with
|
|
103083
|
+
* `endpointId = String(deviceId)` carrying the streaming +
|
|
103084
|
+
* directive surfaces (CameraStream, RTCSession, Doorbell when the
|
|
103085
|
+
* camera has a doorbell, ModeController for PTZ presets when the
|
|
103086
|
+
* camera reports them).
|
|
103087
|
+
* - Each child accessory of the camera (siren / floodlight / PIR /
|
|
103088
|
+
* etc.) becomes a SEPARATE endpoint with
|
|
103089
|
+
* `endpointId = ${parentId}__${childId}` carrying PowerController +
|
|
103090
|
+
* BrightnessController (when applicable). The `__` separator lets
|
|
103091
|
+
* directive handlers decode the routing target cheaply.
|
|
103092
|
+
* - PTZ autotrack — when the parent camera exposes the
|
|
103093
|
+
* `ptz-autotrack` cap — becomes a synthetic child endpoint
|
|
103094
|
+
* `${parentId}__autotrack` with PowerController. We don't model it
|
|
103095
|
+
* as a true child device on the camstack side; the autotrack toggle
|
|
103096
|
+
* lives on the camera's own cap, so the Alexa endpoint id encodes
|
|
103097
|
+
* the routing.
|
|
103098
|
+
*/
|
|
102373
103099
|
var DEFAULT_RESOLUTIONS = [{
|
|
102374
103100
|
width: 1920,
|
|
102375
103101
|
height: 1080
|
|
@@ -102741,6 +103467,28 @@ function buildParentCameraEndpoint(input) {
|
|
|
102741
103467
|
};
|
|
102742
103468
|
}
|
|
102743
103469
|
/**
|
|
103470
|
+
* Which endpoint a child switch becomes, from its type and role. A switch
|
|
103471
|
+
* sub-role is read only through the `@camstack/types` accessors; a heater
|
|
103472
|
+
* (`switch-heater`) and a helper boolean stay a plain switch for the reasons
|
|
103473
|
+
* written on `switchCategory` (`adapters/switch.ts`).
|
|
103474
|
+
*/
|
|
103475
|
+
function classifyChildKind(deviceType, role) {
|
|
103476
|
+
if (role === "floodlight" || role === "spotlight" || role === "nightvision") return "light";
|
|
103477
|
+
if (role === "siren") return "siren";
|
|
103478
|
+
if (deviceType === "light" || isSwitchLight(deviceType, role)) return "light";
|
|
103479
|
+
if (deviceType === "siren") return "siren";
|
|
103480
|
+
if (isOutlet(deviceType, role)) return "outlet";
|
|
103481
|
+
if (isSwitchFan(deviceType, role)) return "fan";
|
|
103482
|
+
return "switch";
|
|
103483
|
+
}
|
|
103484
|
+
var CHILD_CATEGORY = {
|
|
103485
|
+
light: "LIGHT",
|
|
103486
|
+
switch: "SWITCH",
|
|
103487
|
+
siren: "SWITCH",
|
|
103488
|
+
outlet: "SMARTPLUG",
|
|
103489
|
+
fan: "FAN"
|
|
103490
|
+
};
|
|
103491
|
+
/**
|
|
102744
103492
|
* Compose a child accessory's Alexa friendly name. camstack child devices
|
|
102745
103493
|
* are usually already named with their parent prefix (e.g. parent
|
|
102746
103494
|
* "Camera hall" → child "Camera hall Siren"), so blindly
|
|
@@ -102756,7 +103504,7 @@ function composeChildFriendlyName(parentName, childName, childDeviceId) {
|
|
|
102756
103504
|
return `${parent} — ${child}`;
|
|
102757
103505
|
}
|
|
102758
103506
|
function buildChildAccessoryEndpoint(input) {
|
|
102759
|
-
const displayCategories = input.kind
|
|
103507
|
+
const displayCategories = [CHILD_CATEGORY[input.kind]];
|
|
102760
103508
|
const capabilities = [ALEXA_BASE_CAPABILITY, POWER_CONTROLLER];
|
|
102761
103509
|
if (input.hasBrightness) capabilities.push(BRIGHTNESS_CONTROLLER);
|
|
102762
103510
|
const friendlyName = composeChildFriendlyName(input.parentName, input.childName, input.childDeviceId);
|
|
@@ -103659,13 +104407,6 @@ async function loadBoundDeviceInfo(device, api) {
|
|
|
103659
104407
|
async function fetchPtzPresetNames(deviceId, api) {
|
|
103660
104408
|
return (await api.ptz.getPresets.query({ deviceId })).filter(isAlexaRecallablePreset).map((p) => p.name).filter((n) => n.length > 0);
|
|
103661
104409
|
}
|
|
103662
|
-
function classifyChildKind(deviceType, role) {
|
|
103663
|
-
if (role === "floodlight" || role === "spotlight" || role === "nightvision") return "light";
|
|
103664
|
-
if (role === "siren") return "siren";
|
|
103665
|
-
if (deviceType === "light") return "light";
|
|
103666
|
-
if (deviceType === "siren") return "siren";
|
|
103667
|
-
return "switch";
|
|
103668
|
-
}
|
|
103669
104410
|
function discoveryResponse(header, endpoints) {
|
|
103670
104411
|
return { event: {
|
|
103671
104412
|
header: {
|
|
@@ -105698,6 +106439,133 @@ function pickSkill(skills, lookup) {
|
|
|
105698
106439
|
return skills.find((s) => s.id === "export-alexa" && s.enabled) ?? null;
|
|
105699
106440
|
}
|
|
105700
106441
|
//#endregion
|
|
106442
|
+
//#region src/endpoints/alexa-name.ts
|
|
106443
|
+
/**
|
|
106444
|
+
* The Alexa naming rule (D875, amended by D1049): what a device may be called in Alexa.
|
|
106445
|
+
*
|
|
106446
|
+
* The name itself is the generic `device-export` exposed name (D1049): stored per skill
|
|
106447
|
+
* instance in this addon's per-device store, saved through `setExposedName`, and used as the
|
|
106448
|
+
* endpoint `friendlyName`. It never reaches the endpoint id (`<deviceId>__dev`), so renaming
|
|
106449
|
+
* updates the SAME Alexa device on the next AddOrUpdateReport instead of creating a duplicate.
|
|
106450
|
+
* This module holds only Amazon's rule, and the key of the retired Alexa-only name the
|
|
106451
|
+
* migration reads.
|
|
106452
|
+
*
|
|
106453
|
+
* Amazon's friendlyName rule (Alexa.Discovery objects, endpoint object): "Up
|
|
106454
|
+
* to 256 alphanumeric characters and spaces. Don't include special characters
|
|
106455
|
+
* or punctuation." Letters of any script count as alphanumeric, so an Italian
|
|
106456
|
+
* name keeps its accents. The validator rejects what Amazon would reject, with
|
|
106457
|
+
* a message the operator can act on.
|
|
106458
|
+
*/
|
|
106459
|
+
/**
|
|
106460
|
+
* Per-device store key of the RETIRED Alexa-only name (one per device, shared by every skill).
|
|
106461
|
+
* Only the migration `export-alexa/2026-11-12-alexa-name-to-exposed-name` reads it.
|
|
106462
|
+
*/
|
|
106463
|
+
var LEGACY_ALEXA_NAME_KEY = "alexaName";
|
|
106464
|
+
/** Amazon's rule, as the derived "Name on <skill>" field states it (D1049). */
|
|
106465
|
+
var ALEXA_NAME_RULE = `Amazon accepts letters, digits and spaces only (no punctuation), up to 256 characters.`;
|
|
106466
|
+
/** Letters (any script, with their combining marks), digits and spaces. */
|
|
106467
|
+
var ALLOWED_PATTERN = /^[\p{L}\p{M}\p{N} ]+$/u;
|
|
106468
|
+
/** Amazon's rule over a normalised, non-blank name. */
|
|
106469
|
+
var alexaNameValidator = (name) => {
|
|
106470
|
+
if (name.length > 256) return {
|
|
106471
|
+
ok: false,
|
|
106472
|
+
reason: `The Alexa name is ${name.length} characters; Amazon allows at most 256.`
|
|
106473
|
+
};
|
|
106474
|
+
if (!ALLOWED_PATTERN.test(name)) return {
|
|
106475
|
+
ok: false,
|
|
106476
|
+
reason: "The Alexa name may contain only letters, digits and spaces (Amazon rejects punctuation and special characters)."
|
|
106477
|
+
};
|
|
106478
|
+
return {
|
|
106479
|
+
ok: true,
|
|
106480
|
+
name
|
|
106481
|
+
};
|
|
106482
|
+
};
|
|
106483
|
+
/** Validate an operator-typed Alexa name. Blank clears it (`name: null`, the device name is used). */
|
|
106484
|
+
function validateAlexaName(raw) {
|
|
106485
|
+
return checkExposedName(raw, alexaNameValidator);
|
|
106486
|
+
}
|
|
106487
|
+
//#endregion
|
|
106488
|
+
//#region src/migrations/alexa-name-to-exposed-name.ts
|
|
106489
|
+
/**
|
|
106490
|
+
* The Alexa-only device name becomes the generic exposed name (D1049, amending D875).
|
|
106491
|
+
*
|
|
106492
|
+
* Before: one `alexaName` per device in this addon's per-device store (`addon-device-settings`,
|
|
106493
|
+
* row `export-alexa:<deviceId>.alexaName`), and every skill of the addon (planning#422) showed
|
|
106494
|
+
* it. After: the `device-export` exposed name of EVERY skill that exists, row
|
|
106495
|
+
* `export-alexa:<deviceId>.exposedNames` = `{ <skillId>: name, … }` — so each skill keeps calling
|
|
106496
|
+
* the device what it called it. A skill id that has no `skills` record (the default one on a hub
|
|
106497
|
+
* that never configured Alexa) gets nothing: no running skill would read it.
|
|
106498
|
+
*
|
|
106499
|
+
* One plan, so the copy and the delete commit together. A name is copied as Alexa read it
|
|
106500
|
+
* (normalised; a stored value Alexa would have refused was never used and is not copied). A name
|
|
106501
|
+
* already saved for a skill through the new field was saved by the build that reads it, so it is
|
|
106502
|
+
* never overwritten; the other skills of that device still get the old name. The legacy key is
|
|
106503
|
+
* deleted in every case: nothing reads it any more. A rerun finds no legacy key and does nothing.
|
|
106504
|
+
* A read that fails throws, nothing written.
|
|
106505
|
+
*/
|
|
106506
|
+
var OWNER = "export-alexa";
|
|
106507
|
+
/** The per-device settings table: one row per field, id `<addonId>:<deviceId>.<field>`. */
|
|
106508
|
+
var DEVICE_SETTINGS_TABLE = "addon-device-settings";
|
|
106509
|
+
var rowId$3 = (deviceId, field) => `${OWNER}:${deviceId}.${field}`;
|
|
106510
|
+
var rowOf = (deviceId, field, value) => ({
|
|
106511
|
+
addonId: OWNER,
|
|
106512
|
+
deviceId: String(deviceId),
|
|
106513
|
+
key: field,
|
|
106514
|
+
value
|
|
106515
|
+
});
|
|
106516
|
+
/** The held `exposedNames` blob as a record, or `{}` when it is not one. */
|
|
106517
|
+
function heldNames(value) {
|
|
106518
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
106519
|
+
return Object.fromEntries(Object.entries(value));
|
|
106520
|
+
}
|
|
106521
|
+
async function planAlexaNameToExposedName(ports) {
|
|
106522
|
+
const ids = await ports.listDeviceIds();
|
|
106523
|
+
if (ids.length === 0) return { edits: [] };
|
|
106524
|
+
const legacy = await ports.readDeviceField(ids, LEGACY_ALEXA_NAME_KEY);
|
|
106525
|
+
if (legacy.size === 0) return { edits: [] };
|
|
106526
|
+
const skills = await ports.listSkillIds();
|
|
106527
|
+
const held = await ports.readDeviceField([...legacy.keys()], EXPOSED_NAMES_STORE_KEY);
|
|
106528
|
+
const written = {};
|
|
106529
|
+
const expected = {};
|
|
106530
|
+
const retired = {};
|
|
106531
|
+
for (const [deviceId, stored] of legacy) {
|
|
106532
|
+
retired[rowId$3(deviceId, LEGACY_ALEXA_NAME_KEY)] = rowOf(deviceId, LEGACY_ALEXA_NAME_KEY, stored);
|
|
106533
|
+
const check = validateAlexaName(stored);
|
|
106534
|
+
if (!check.ok || check.name === null) continue;
|
|
106535
|
+
if (skills.length === 0) {
|
|
106536
|
+
ports.warn(`Alexa migration: device ${deviceId} had an Alexa name but no Alexa skill exists; it is not kept`);
|
|
106537
|
+
continue;
|
|
106538
|
+
}
|
|
106539
|
+
const before = held.has(deviceId) ? heldNames(held.get(deviceId)) : null;
|
|
106540
|
+
const merged = { ...before };
|
|
106541
|
+
for (const skillId of skills) {
|
|
106542
|
+
if (skillId in merged) {
|
|
106543
|
+
ports.warn(`Alexa migration: device ${deviceId} already has a name on skill ${skillId}; its old Alexa name is not copied there`);
|
|
106544
|
+
continue;
|
|
106545
|
+
}
|
|
106546
|
+
merged[skillId] = check.name;
|
|
106547
|
+
}
|
|
106548
|
+
if (before !== null && Object.keys(merged).length === Object.keys(before).length) continue;
|
|
106549
|
+
const id = rowId$3(deviceId, EXPOSED_NAMES_STORE_KEY);
|
|
106550
|
+
written[id] = rowOf(deviceId, EXPOSED_NAMES_STORE_KEY, merged);
|
|
106551
|
+
expected[id] = before === null ? null : rowOf(deviceId, EXPOSED_NAMES_STORE_KEY, held.get(deviceId));
|
|
106552
|
+
}
|
|
106553
|
+
const edits = [];
|
|
106554
|
+
if (Object.keys(written).length > 0) edits.push({
|
|
106555
|
+
op: "setKeys",
|
|
106556
|
+
scope: DEVICE_SETTINGS_TABLE,
|
|
106557
|
+
values: written,
|
|
106558
|
+
precondition: preconditionOf(expected)
|
|
106559
|
+
});
|
|
106560
|
+
edits.push({
|
|
106561
|
+
op: "deleteKeys",
|
|
106562
|
+
scope: DEVICE_SETTINGS_TABLE,
|
|
106563
|
+
keys: Object.keys(retired),
|
|
106564
|
+
precondition: preconditionOf(retired)
|
|
106565
|
+
});
|
|
106566
|
+
return { edits };
|
|
106567
|
+
}
|
|
106568
|
+
//#endregion
|
|
105701
106569
|
//#region src/migrations/drop-public-hub-url.ts
|
|
105702
106570
|
/**
|
|
105703
106571
|
* The hub's public URL is no longer a setting of this addon (planning#378): Alexa reads the
|
|
@@ -106297,6 +107165,7 @@ var EXPOSURE_TO_RECORD_ID = "export-alexa/2026-11-04-exposure-to-record";
|
|
|
106297
107165
|
var DROP_MOVED_EXPOSURE_ID = "export-alexa/2026-11-04-drop-moved-exposure";
|
|
106298
107166
|
var STATE_TO_INSTANCE_ID = "export-alexa/2026-11-04-state-to-instance";
|
|
106299
107167
|
var DROP_MOVED_STATE_ID = "export-alexa/2026-11-04-drop-moved-state";
|
|
107168
|
+
var ALEXA_NAME_TO_EXPOSED_NAME_ID = "export-alexa/2026-11-12-alexa-name-to-exposed-name";
|
|
106300
107169
|
var FIXTURE_MARK = "the endpoint sync state the migration does not know";
|
|
106301
107170
|
/**
|
|
106302
107171
|
* The `export-alexa` catalogue (D987): offered to the engine when the addon initialises. Every
|
|
@@ -106430,6 +107299,22 @@ var ADDON_MIGRATIONS = [
|
|
|
106430
107299
|
fixtureMark: FIXTURE_MARK
|
|
106431
107300
|
},
|
|
106432
107301
|
plan: planDropMovedState
|
|
107302
|
+
},
|
|
107303
|
+
{
|
|
107304
|
+
meta: {
|
|
107305
|
+
id: ALEXA_NAME_TO_EXPOSED_NAME_ID,
|
|
107306
|
+
owner: "export-alexa",
|
|
107307
|
+
level: "addon-state",
|
|
107308
|
+
seq: 9,
|
|
107309
|
+
dependsOn: [],
|
|
107310
|
+
store: "settings",
|
|
107311
|
+
scope: "cluster",
|
|
107312
|
+
onFailure: "tolerate",
|
|
107313
|
+
bodyKind: "plan",
|
|
107314
|
+
description: "Copy every device`s Alexa name to the exposed name of every Alexa skill and delete the alexaName key",
|
|
107315
|
+
fixtureMark: FIXTURE_MARK
|
|
107316
|
+
},
|
|
107317
|
+
plan: planAlexaNameToExposedName
|
|
106433
107318
|
}
|
|
106434
107319
|
];
|
|
106435
107320
|
//#endregion
|
|
@@ -107297,72 +108182,33 @@ var AlexaEgressPrewarm = class {
|
|
|
107297
108182
|
}
|
|
107298
108183
|
};
|
|
107299
108184
|
//#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;
|
|
108185
|
+
//#region src/exposed-name-rename.ts
|
|
108186
|
+
async function renameOnSkill(deps, deviceIdRaw, raw, options = {}) {
|
|
108187
|
+
const deviceId = Number.parseInt(deviceIdRaw, 10);
|
|
108188
|
+
if (!Number.isFinite(deviceId)) throw new Error(`export-alexa: deviceId must be numeric — got "${deviceIdRaw}"`);
|
|
108189
|
+
const saved = await saveExposedName({
|
|
108190
|
+
store: deps.store,
|
|
108191
|
+
deviceId,
|
|
108192
|
+
instanceId: deps.instanceId,
|
|
108193
|
+
raw,
|
|
108194
|
+
validate: alexaNameValidator,
|
|
108195
|
+
...options.dryRun === true ? { dryRun: true } : {}
|
|
108196
|
+
});
|
|
108197
|
+
if (!saved.changed) return;
|
|
108198
|
+
deps.logger.info("export-alexa: Alexa name saved", {
|
|
108199
|
+
tags: { deviceId },
|
|
108200
|
+
meta: {
|
|
108201
|
+
instanceId: deps.instanceId,
|
|
108202
|
+
name: saved.name
|
|
108203
|
+
}
|
|
108204
|
+
});
|
|
108205
|
+
if (!deps.isExposed(deviceId)) return;
|
|
108206
|
+
deps.push(deviceId).catch((err) => {
|
|
108207
|
+
deps.logger.warn("export-alexa: push after an Alexa name change failed", {
|
|
108208
|
+
tags: { deviceId },
|
|
108209
|
+
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
108210
|
+
});
|
|
108211
|
+
});
|
|
107366
108212
|
}
|
|
107367
108213
|
//#endregion
|
|
107368
108214
|
//#region src/stream-preference.ts
|
|
@@ -110417,7 +111263,7 @@ var SkillRuntime = class {
|
|
|
110417
111263
|
logger: this.ctx.logger,
|
|
110418
111264
|
snapshots: this.view.snapshots,
|
|
110419
111265
|
...this.view.detectionSensors ? { detectionClasses: async (id) => effectiveSensorClasses(await classesOf(id), parseSensorSelection(await vision.readPrefs(id))) } : {},
|
|
110420
|
-
alexaName: async (id) =>
|
|
111266
|
+
alexaName: async (id) => readExposedName(await vision.readPrefs(id), this.instanceId, alexaNameValidator),
|
|
110421
111267
|
...this.view.objectDetection ? { objectDetection: async (id) => vision.buildClasses(id, await classesOf(id)) } : {}
|
|
110422
111268
|
});
|
|
110423
111269
|
}
|
|
@@ -110863,27 +111709,11 @@ var SkillRuntime = class {
|
|
|
110863
111709
|
value: enabled,
|
|
110864
111710
|
immediate: true
|
|
110865
111711
|
},
|
|
110866
|
-
...opts.shared ? [await this.alexaNameField(deviceId, enabledKey)] : [],
|
|
110867
111712
|
...kind === "camera" ? this.cameraOnlyExportFields(deviceId, settings, enabledKey) : [],
|
|
110868
111713
|
...kind === "camera" && opts.shared ? await this.cameraDetectionFields(deviceId, enabledKey) : []
|
|
110869
111714
|
]
|
|
110870
111715
|
};
|
|
110871
111716
|
}
|
|
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
111717
|
/**
|
|
110888
111718
|
* The camera's detection fields: which classes become Alexa sensors (D778;
|
|
110889
111719
|
* only the classes its pipeline produces are offered) and its object
|
|
@@ -110905,24 +111735,6 @@ var SkillRuntime = class {
|
|
|
110905
111735
|
})];
|
|
110906
111736
|
}
|
|
110907
111737
|
/**
|
|
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
111738
|
* Persist the camera's detection preferences from a device-settings patch
|
|
110927
111739
|
* into this addon's per-device store. True when anything changed — the
|
|
110928
111740
|
* camera's Alexa shape then needs a reconcile.
|
|
@@ -110973,15 +111785,32 @@ var SkillRuntime = class {
|
|
|
110973
111785
|
}];
|
|
110974
111786
|
}
|
|
110975
111787
|
/**
|
|
110976
|
-
* The device's own preferences in a patch (
|
|
110977
|
-
*
|
|
110978
|
-
*
|
|
111788
|
+
* The device's own preferences in a patch (detection classes, object detection): shared by
|
|
111789
|
+
* every skill, so they are saved ONCE, before any skill applies its own part (an expose in
|
|
111790
|
+
* the same patch then builds with them).
|
|
110979
111791
|
*/
|
|
110980
111792
|
async applySharedPrefs(deviceId, patch) {
|
|
110981
|
-
return {
|
|
110982
|
-
|
|
110983
|
-
|
|
110984
|
-
|
|
111793
|
+
return { prefsChanged: await this.applyDetectionPrefsPatch(deviceId, patch) };
|
|
111794
|
+
}
|
|
111795
|
+
/** D1049: this skill's exposed name for a device, or null (the device's own name). */
|
|
111796
|
+
async exposedNameOf(deviceId) {
|
|
111797
|
+
return readExposedName(await this.vision.readPrefs(deviceId), this.instanceId, alexaNameValidator);
|
|
111798
|
+
}
|
|
111799
|
+
/**
|
|
111800
|
+
* D1049: save this skill's name for a device (`device-export.setExposedName`); an exposed
|
|
111801
|
+
* device is pushed again under the same endpoint id. `renameOnSkill` holds the rule.
|
|
111802
|
+
*/
|
|
111803
|
+
async setExposedName(deviceIdRaw, raw, dryRun = false) {
|
|
111804
|
+
await renameOnSkill({
|
|
111805
|
+
instanceId: this.instanceId,
|
|
111806
|
+
store: {
|
|
111807
|
+
read: (id) => exposedNameStoreOf(this.ctx.settings, "export-alexa").read(id),
|
|
111808
|
+
write: (id, patch) => this.vision.writePrefs(id, patch)
|
|
111809
|
+
},
|
|
111810
|
+
logger: this.ctx.logger,
|
|
111811
|
+
isExposed: (id) => this.findEntry(id) !== null,
|
|
111812
|
+
push: (id) => this.requireSyncEngine().pushDevice(id)
|
|
111813
|
+
}, deviceIdRaw, raw, { dryRun });
|
|
110985
111814
|
}
|
|
110986
111815
|
/**
|
|
110987
111816
|
* Apply this skill's part of a patch produced by the device-details "Export" panel. Flips
|
|
@@ -110994,7 +111823,7 @@ var SkillRuntime = class {
|
|
|
110994
111823
|
* the new preference. See remaining-work notes in CLAUDE.md.
|
|
110995
111824
|
*/
|
|
110996
111825
|
async applyEntryPatch(deviceId, patch, shared) {
|
|
110997
|
-
const { prefsChanged
|
|
111826
|
+
const { prefsChanged } = shared;
|
|
110998
111827
|
const idStr = String(deviceId);
|
|
110999
111828
|
const current = this.findEntry(deviceId);
|
|
111000
111829
|
const wasEnabled = current !== null;
|
|
@@ -111023,12 +111852,6 @@ var SkillRuntime = class {
|
|
|
111023
111852
|
const currentAllow = current?.settings?.allowTranscode !== false;
|
|
111024
111853
|
await this.patchEntrySettings(deviceId, nextSettings);
|
|
111025
111854
|
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
111855
|
if (prefsChanged && !sourceChanged) this.requireSyncEngine().reconcileDevice(deviceId).catch((err) => {
|
|
111033
111856
|
this.ctx.logger.warn("export-alexa: re-sync after a detection preference change failed", {
|
|
111034
111857
|
tags: { deviceId },
|
|
@@ -111574,15 +112397,30 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
111574
112397
|
instanceId: row.id,
|
|
111575
112398
|
name: row.body.name,
|
|
111576
112399
|
enabled: row.enabled,
|
|
111577
|
-
kind: "alexa-skill"
|
|
112400
|
+
kind: "alexa-skill",
|
|
112401
|
+
nameRule: ALEXA_NAME_RULE
|
|
111578
112402
|
}));
|
|
111579
112403
|
},
|
|
111580
112404
|
listSupportedDeviceKinds: async ({ instanceId }) => {
|
|
111581
112405
|
ownInstance(instanceId);
|
|
111582
112406
|
return [...SUPPORTED_KINDS];
|
|
111583
112407
|
},
|
|
111584
|
-
listExposedDevices: async ({ instanceId }) =>
|
|
111585
|
-
|
|
112408
|
+
listExposedDevices: async ({ instanceId }) => {
|
|
112409
|
+
const runtime = ownInstance(instanceId);
|
|
112410
|
+
return Promise.all(runtime.exposedDevices.map(async (e) => {
|
|
112411
|
+
const exposedName = await runtime.exposedNameOf(e.deviceId);
|
|
112412
|
+
return {
|
|
112413
|
+
deviceId: String(e.deviceId),
|
|
112414
|
+
...exposedName !== null ? { exposedName } : {}
|
|
112415
|
+
};
|
|
112416
|
+
}));
|
|
112417
|
+
},
|
|
112418
|
+
exposeDevice: async ({ instanceId, deviceId, exposedName }) => {
|
|
112419
|
+
const runtime = ownInstance(instanceId);
|
|
112420
|
+
if (exposedName !== void 0) await runtime.setExposedName(deviceId, exposedName);
|
|
112421
|
+
return runtime.exposeDevice(deviceId);
|
|
112422
|
+
},
|
|
112423
|
+
setExposedName: async ({ instanceId, deviceId, name, dryRun }) => ownInstance(instanceId).setExposedName(deviceId, name, dryRun === true),
|
|
111586
112424
|
unexposeDevice: async ({ instanceId, deviceId }) => ownInstance(instanceId).unexposeDevice(deviceId),
|
|
111587
112425
|
listSupportedEntityKinds: async () => ["device", "action"],
|
|
111588
112426
|
listExposedEntities: async ({ instanceId }) => {
|
|
@@ -111710,6 +112548,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
111710
112548
|
if (change === "deleted") {
|
|
111711
112549
|
await this.stopRuntime(id);
|
|
111712
112550
|
await this.deleteSkillRows(id);
|
|
112551
|
+
await this.pruneSkillNames(id);
|
|
111713
112552
|
return;
|
|
111714
112553
|
}
|
|
111715
112554
|
const row = await this.requireInstances().readResolved(id);
|
|
@@ -111725,6 +112564,16 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
111725
112564
|
await running.refreshRecords();
|
|
111726
112565
|
await running.applyShapeSwitches();
|
|
111727
112566
|
}
|
|
112567
|
+
/** A deleted skill's device names go too, so a skill that reuses the id inherits none (D1049). */
|
|
112568
|
+
async pruneSkillNames(id) {
|
|
112569
|
+
const settings = this.ctx.settings;
|
|
112570
|
+
if (settings === void 0) return;
|
|
112571
|
+
const pruned = await pruneExposedNames(settings, id);
|
|
112572
|
+
if (pruned.length > 0) this.ctx.logger.info("export-alexa: deleted skill names removed", { meta: {
|
|
112573
|
+
instanceId: id,
|
|
112574
|
+
devices: pruned.length
|
|
112575
|
+
} });
|
|
112576
|
+
}
|
|
111728
112577
|
/** What a deleted skill leaves behind: its links, its exposure and its hidden state. */
|
|
111729
112578
|
async deleteSkillRows(id) {
|
|
111730
112579
|
await deleteSkillRows(this.requireHandles(), id);
|
|
@@ -111803,6 +112652,19 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
111803
112652
|
readState: async () => (await stateHandle.getResolved("export-alexa"))?.data ?? null,
|
|
111804
112653
|
clearIngressTokenSecret: async () => {
|
|
111805
112654
|
await this.clearSecrets(["ingressToken"]);
|
|
112655
|
+
},
|
|
112656
|
+
listSkillIds: async () => (await this.requireInstances().listResolved()).map((r) => r.id),
|
|
112657
|
+
listDeviceIds: async () => {
|
|
112658
|
+
const settings = this.ctx.settings;
|
|
112659
|
+
if (settings === void 0) throw new Error("export-alexa: the settings store is unavailable");
|
|
112660
|
+
return settings.listDeviceStoreIds();
|
|
112661
|
+
},
|
|
112662
|
+
readDeviceField: async (deviceIds, field) => {
|
|
112663
|
+
const settings = this.ctx.settings;
|
|
112664
|
+
if (settings === void 0) throw new Error("export-alexa: the settings store is unavailable");
|
|
112665
|
+
const found = /* @__PURE__ */ new Map();
|
|
112666
|
+
for (const [deviceId, blob] of await settings.readDeviceStoreBatch(deviceIds)) if (field in blob) found.set(deviceId, blob[field]);
|
|
112667
|
+
return found;
|
|
111806
112668
|
}
|
|
111807
112669
|
};
|
|
111808
112670
|
}
|