@camstack/addon-export-hap 1.2.199 → 1.2.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/hap-export.addon.js +1594 -546
- package/dist/hap-export.addon.mjs +1594 -546
- package/package.json +2 -2
|
@@ -39,7 +39,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
39
39
|
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
40
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
41
41
|
//#endregion
|
|
42
|
-
//#region ../types/dist/event-category-
|
|
42
|
+
//#region ../types/dist/event-category-Dv-Gcv1f.mjs
|
|
43
43
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
44
44
|
EventCategory["SystemBoot"] = "system.boot";
|
|
45
45
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -480,6 +480,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
480
480
|
*/
|
|
481
481
|
EventCategory["DeviceStateChanged"] = "device.state-changed";
|
|
482
482
|
/**
|
|
483
|
+
* A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
|
|
484
|
+
* transition audit (D1022): confirmed, already in place, unconfirmed or
|
|
485
|
+
* failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
|
|
486
|
+
* (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
|
|
487
|
+
* the Notification Center `device-command` kind. Telemetry (D8): losing one
|
|
488
|
+
* costs a notification, never state; the audit row is the record.
|
|
489
|
+
*/
|
|
490
|
+
EventCategory["DeviceCommandSettled"] = "device.command-settled";
|
|
491
|
+
/**
|
|
483
492
|
* The NATIVE shadow of a cap a composition has claimed fields of moved
|
|
484
493
|
* (D663). Payload: `{ deviceId, capName, native }` — what the provider
|
|
485
494
|
* wrote, BEFORE the owned fields are overlaid. Owner-only (D224): it is for
|
|
@@ -6084,7 +6093,7 @@ var ZodIssueCode = {
|
|
|
6084
6093
|
var ZodFirstPartyTypeKind;
|
|
6085
6094
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6086
6095
|
//#endregion
|
|
6087
|
-
//#region ../types/dist/sleep-
|
|
6096
|
+
//#region ../types/dist/sleep-DyIxjZZt.mjs
|
|
6088
6097
|
/**
|
|
6089
6098
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6090
6099
|
* window to float samples (D455).
|
|
@@ -6767,6 +6776,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6767
6776
|
else skipped.push(id);
|
|
6768
6777
|
};
|
|
6769
6778
|
const selected = options.only === void 0 ? null : new Set(options.only);
|
|
6779
|
+
const deferred = /* @__PURE__ */ new Set();
|
|
6780
|
+
const deferredBy = (reason) => {
|
|
6781
|
+
if (selected === null || reason === null) return null;
|
|
6782
|
+
const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
|
|
6783
|
+
if (dep === void 0 || !byId.has(dep)) return null;
|
|
6784
|
+
return !selected.has(dep) || deferred.has(dep) ? dep : null;
|
|
6785
|
+
};
|
|
6770
6786
|
for (const step of declaration.steps) {
|
|
6771
6787
|
if (selected !== null && !selected.has(step.id)) continue;
|
|
6772
6788
|
const bound = byId.get(step.id);
|
|
@@ -6778,6 +6794,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6778
6794
|
try {
|
|
6779
6795
|
const gate = await host.startMigration({ id: step.id });
|
|
6780
6796
|
if (!gate.proceed) {
|
|
6797
|
+
const waitsFor = deferredBy(gate.reason);
|
|
6798
|
+
if (waitsFor !== null) {
|
|
6799
|
+
log.info("migration deferred: its predecessor runs in another phase of this owner", {
|
|
6800
|
+
tags,
|
|
6801
|
+
meta: {
|
|
6802
|
+
waitsFor,
|
|
6803
|
+
reason: gate.reason
|
|
6804
|
+
}
|
|
6805
|
+
});
|
|
6806
|
+
deferred.add(step.id);
|
|
6807
|
+
skipped.push(step.id);
|
|
6808
|
+
continue;
|
|
6809
|
+
}
|
|
6781
6810
|
log.warn("migration not run", {
|
|
6782
6811
|
tags,
|
|
6783
6812
|
meta: {
|
|
@@ -10227,6 +10256,13 @@ var DeviceTransitionSchema = object({
|
|
|
10227
10256
|
actor: TransitionActorSchema,
|
|
10228
10257
|
command: TransitionCommandSchema.optional()
|
|
10229
10258
|
});
|
|
10259
|
+
object({
|
|
10260
|
+
deviceId: number$1().int(),
|
|
10261
|
+
action: string(),
|
|
10262
|
+
outcome: TransitionOutcomeSchema,
|
|
10263
|
+
actor: TransitionActorSchema,
|
|
10264
|
+
at: number$1()
|
|
10265
|
+
});
|
|
10230
10266
|
var READING_QUANTITIES = [
|
|
10231
10267
|
"temperature",
|
|
10232
10268
|
"pressure",
|
|
@@ -12250,7 +12286,10 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
12250
12286
|
"ir-transmitter": {
|
|
12251
12287
|
scope: "device",
|
|
12252
12288
|
noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
|
|
12253
|
-
notOperatorFacing: {
|
|
12289
|
+
notOperatorFacing: {
|
|
12290
|
+
send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
|
|
12291
|
+
learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
|
|
12292
|
+
}
|
|
12254
12293
|
},
|
|
12255
12294
|
control: {
|
|
12256
12295
|
scope: "device",
|
|
@@ -15171,6 +15210,32 @@ var CAP_VOCABULARY_BY_NAME = {
|
|
|
15171
15210
|
...SYSTEM_CAP_VOCABULARY
|
|
15172
15211
|
};
|
|
15173
15212
|
/**
|
|
15213
|
+
* Vocabulary actions by id (D983). An action step names a vocabulary action
|
|
15214
|
+
* (`cover.open`), never a raw cap method; this is the one lookup that turns the
|
|
15215
|
+
* id into its cap, method and effect — and a persisted legacy `cap` + `method`
|
|
15216
|
+
* pair back into the action id when exactly one action matches.
|
|
15217
|
+
*/
|
|
15218
|
+
function buildIndex() {
|
|
15219
|
+
const byId = /* @__PURE__ */ new Map();
|
|
15220
|
+
for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
|
|
15221
|
+
if (entry.scope !== "device") continue;
|
|
15222
|
+
for (const action of entry.actions ?? []) byId.set(action.id, {
|
|
15223
|
+
cap,
|
|
15224
|
+
action
|
|
15225
|
+
});
|
|
15226
|
+
}
|
|
15227
|
+
return byId;
|
|
15228
|
+
}
|
|
15229
|
+
var index;
|
|
15230
|
+
function actionIndex() {
|
|
15231
|
+
index ??= buildIndex();
|
|
15232
|
+
return index;
|
|
15233
|
+
}
|
|
15234
|
+
/** The vocabulary action with this id, or `undefined`. */
|
|
15235
|
+
function findVocabAction(actionId) {
|
|
15236
|
+
return actionIndex().get(actionId);
|
|
15237
|
+
}
|
|
15238
|
+
/**
|
|
15174
15239
|
* `addon-pages-source` — collection cap exposing per-provider raw page
|
|
15175
15240
|
* declarations. Every addon that contributes a UI page registers a
|
|
15176
15241
|
* provider here. The hub-side singleton aggregator (`addon-pages` cap,
|
|
@@ -16253,6 +16318,10 @@ Object.freeze({
|
|
|
16253
16318
|
"path": "lastEvent.eventType",
|
|
16254
16319
|
"valueType": "string"
|
|
16255
16320
|
},
|
|
16321
|
+
{
|
|
16322
|
+
"path": "lastEvent.sourceId",
|
|
16323
|
+
"valueType": "string"
|
|
16324
|
+
},
|
|
16256
16325
|
{
|
|
16257
16326
|
"path": "lastEvent.timestamp",
|
|
16258
16327
|
"valueType": "number"
|
|
@@ -44661,6 +44730,41 @@ function macroOnly(macro) {
|
|
|
44661
44730
|
};
|
|
44662
44731
|
}
|
|
44663
44732
|
}
|
|
44733
|
+
var EventVocabularyKindSchema = _enum([
|
|
44734
|
+
"press",
|
|
44735
|
+
"long-press",
|
|
44736
|
+
"long-press-start",
|
|
44737
|
+
"release",
|
|
44738
|
+
"repeat",
|
|
44739
|
+
"double-press",
|
|
44740
|
+
"other"
|
|
44741
|
+
]);
|
|
44742
|
+
/** The part of the device an event comes from: a button, a channel. */
|
|
44743
|
+
var EventVocabularySourceSchema = object({
|
|
44744
|
+
id: string().min(1),
|
|
44745
|
+
label: string().min(1)
|
|
44746
|
+
});
|
|
44747
|
+
/** One scalar field of an event's `data`, by dotted path. */
|
|
44748
|
+
var EventVocabularyFieldSchema = object({
|
|
44749
|
+
path: string().min(1),
|
|
44750
|
+
kind: _enum([
|
|
44751
|
+
"string",
|
|
44752
|
+
"number",
|
|
44753
|
+
"boolean",
|
|
44754
|
+
"enum"
|
|
44755
|
+
]),
|
|
44756
|
+
enumValues: array(string()).optional(),
|
|
44757
|
+
label: string().min(1).optional()
|
|
44758
|
+
});
|
|
44759
|
+
var EventVocabularyEntrySchema = object({
|
|
44760
|
+
/** The native token, verbatim. */
|
|
44761
|
+
id: string().min(1),
|
|
44762
|
+
source: EventVocabularySourceSchema.optional(),
|
|
44763
|
+
label: string().min(1),
|
|
44764
|
+
description: string().optional(),
|
|
44765
|
+
kind: EventVocabularyKindSchema.optional(),
|
|
44766
|
+
payload: array(EventVocabularyFieldSchema).optional()
|
|
44767
|
+
});
|
|
44664
44768
|
Math.PI / 180;
|
|
44665
44769
|
/**
|
|
44666
44770
|
* WHEN something happens, as data (D983) — the one time vocabulary of the
|
|
@@ -44868,6 +44972,33 @@ var ScheduleLeafSchema = object({
|
|
|
44868
44972
|
/** @deprecated legacy cron — new schedules use `at`. */
|
|
44869
44973
|
cron: string().min(1).max(120).optional()
|
|
44870
44974
|
}).refine((leaf) => leaf.at === void 0 !== (leaf.cron === void 0), { message: "a schedule names exactly one of `at` (a time spec) and `cron` (legacy)" }).refine((leaf) => leaf.days === void 0 || leaf.at !== void 0, { message: "`days` goes with `at`; a cron expression carries its own days" });
|
|
44975
|
+
/**
|
|
44976
|
+
* One payload predicate of a `device-fired` row: the value at `path` inside
|
|
44977
|
+
* the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
|
|
44978
|
+
*/
|
|
44979
|
+
var DeviceFiredMatchSchema = object({
|
|
44980
|
+
path: string().min(1).max(120),
|
|
44981
|
+
equals: union([
|
|
44982
|
+
string(),
|
|
44983
|
+
number$1(),
|
|
44984
|
+
boolean()
|
|
44985
|
+
])
|
|
44986
|
+
});
|
|
44987
|
+
/**
|
|
44988
|
+
* "fires": one device of the `event-emitter` capability reported an event
|
|
44989
|
+
* (D1045). Every list is an OR, the lists together an AND; an absent list does
|
|
44990
|
+
* not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
|
|
44991
|
+
* the device (a button), `kinds` the shared press kinds of its vocabulary.
|
|
44992
|
+
*/
|
|
44993
|
+
var DeviceFiredLeafSchema = object({
|
|
44994
|
+
kind: literal("device-fired"),
|
|
44995
|
+
...eventLeafId,
|
|
44996
|
+
deviceId: number$1().int().nonnegative(),
|
|
44997
|
+
eventIds: array(string().min(1)).min(1).max(64).optional(),
|
|
44998
|
+
sourceIds: array(string().min(1)).min(1).max(64).optional(),
|
|
44999
|
+
kinds: array(EventVocabularyKindSchema).min(1).optional(),
|
|
45000
|
+
match: array(DeviceFiredMatchSchema).min(1).max(8).optional()
|
|
45001
|
+
});
|
|
44871
45002
|
var ManualLeafSchema = object({
|
|
44872
45003
|
kind: literal("manual"),
|
|
44873
45004
|
...eventLeafId
|
|
@@ -45009,6 +45140,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
45009
45140
|
}),
|
|
45010
45141
|
DeviceBecomesLeafSchema,
|
|
45011
45142
|
DeviceEventLeafSchema,
|
|
45143
|
+
DeviceFiredLeafSchema,
|
|
45012
45144
|
ScheduleLeafSchema,
|
|
45013
45145
|
ManualLeafSchema,
|
|
45014
45146
|
IntervalLeafSchema,
|
|
@@ -45023,6 +45155,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
45023
45155
|
var EVENT_KINDS = new Set([
|
|
45024
45156
|
"device-becomes",
|
|
45025
45157
|
"device-event",
|
|
45158
|
+
"device-fired",
|
|
45026
45159
|
"schedule",
|
|
45027
45160
|
"manual",
|
|
45028
45161
|
"interval",
|
|
@@ -45103,6 +45236,7 @@ function hasEmptyContainer(node) {
|
|
|
45103
45236
|
var LEAF_WORDS = {
|
|
45104
45237
|
"device-becomes": "a device value that becomes",
|
|
45105
45238
|
"device-event": "a device event",
|
|
45239
|
+
"device-fired": "a device firing an event",
|
|
45106
45240
|
schedule: "a schedule",
|
|
45107
45241
|
manual: "a manual run",
|
|
45108
45242
|
interval: "an interval",
|
|
@@ -45352,59 +45486,47 @@ function convertLegacyWhen(half) {
|
|
|
45352
45486
|
* (instants) and state leaves (durations). It replaces the flat trigger list
|
|
45353
45487
|
* plus the separate condition tree; the firing rule is in that file and in
|
|
45354
45488
|
* ADR "one tree".
|
|
45355
|
-
* - **Actions** — the `wait` and `
|
|
45489
|
+
* - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
|
|
45356
45490
|
* fragment of §3.2.2. See {@link AutomationActionSchema}.
|
|
45357
45491
|
*
|
|
45358
45492
|
* A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
|
|
45359
45493
|
* {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
|
|
45360
45494
|
*/
|
|
45361
45495
|
/**
|
|
45362
|
-
* One action step: `wait`, or a `
|
|
45496
|
+
* One action step: `wait`, or a device `command`.
|
|
45363
45497
|
*
|
|
45364
|
-
* A
|
|
45365
|
-
* `{ $var }` resolved from the run's
|
|
45366
|
-
*
|
|
45367
|
-
*
|
|
45368
|
-
*
|
|
45369
|
-
*
|
|
45498
|
+
* A command step names a VOCABULARY action (`cover.open`) and who it acts on
|
|
45499
|
+
* (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
|
|
45500
|
+
* variables). It never names a cap method: the step runner turns the action
|
|
45501
|
+
* id into its cap + method through the vocabulary index when the step runs
|
|
45502
|
+
* (`vocabCall`), the one place that mapping happens. The step runner
|
|
45503
|
+
* (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
|
|
45504
|
+
* variable substitution, once, for every caller — automations, Actions, and
|
|
45505
|
+
* the notification centre, which runs only Actions (planning#473).
|
|
45370
45506
|
*/
|
|
45507
|
+
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
45508
|
+
var WAIT_MAX_SECONDS = 3600;
|
|
45509
|
+
var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
|
|
45371
45510
|
var AutomationWaitStepSchema = object({
|
|
45372
45511
|
kind: literal("wait"),
|
|
45373
|
-
seconds: number$1().min(0).max(
|
|
45512
|
+
seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
45374
45513
|
});
|
|
45375
|
-
/** The legacy `deviceId` of a cap step: still READ, never written (D983). */
|
|
45376
|
-
var LegacyStepDeviceSchema = union([
|
|
45377
|
-
number$1().int(),
|
|
45378
|
-
array(number$1().int()).min(1),
|
|
45379
|
-
object({ $var: string().min(1) })
|
|
45380
|
-
]);
|
|
45381
45514
|
/**
|
|
45382
|
-
* The fields of a
|
|
45383
|
-
*
|
|
45384
|
-
* device); a step is {@link AutomationCapStepSchema}.
|
|
45515
|
+
* The fields of a command step, before the vocabulary check. A step is
|
|
45516
|
+
* {@link AutomationCommandStepSchema}.
|
|
45385
45517
|
*/
|
|
45386
|
-
var
|
|
45387
|
-
kind: literal("
|
|
45388
|
-
/**
|
|
45389
|
-
|
|
45390
|
-
|
|
45391
|
-
|
|
45392
|
-
* cap + method match exactly one vocabulary action.
|
|
45393
|
-
*/
|
|
45394
|
-
actionId: string().min(1).optional(),
|
|
45395
|
-
/** WHO the step acts on. The only shape that is written. */
|
|
45396
|
-
target: ActionTargetSchema.optional(),
|
|
45518
|
+
var AutomationCommandStepBaseSchema = object({
|
|
45519
|
+
kind: literal("command"),
|
|
45520
|
+
/** WHO the step acts on. */
|
|
45521
|
+
target: ActionTargetSchema,
|
|
45522
|
+
/** The vocabulary action this step performs (`cover.open`). */
|
|
45523
|
+
actionId: string().min(1),
|
|
45397
45524
|
/**
|
|
45398
|
-
*
|
|
45399
|
-
*
|
|
45400
|
-
*
|
|
45525
|
+
* The values of the action's OPEN args (`position`, `presetId`); the args
|
|
45526
|
+
* the vocabulary bakes into the action are added when the step runs. Values
|
|
45527
|
+
* may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
45528
|
+
* SUBSTITUTE and do not evaluate (§3.2.3).
|
|
45401
45529
|
*/
|
|
45402
|
-
deviceId: LegacyStepDeviceSchema.optional(),
|
|
45403
|
-
cap: string().min(1),
|
|
45404
|
-
method: string().min(1),
|
|
45405
|
-
/** Values may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
45406
|
-
* SUBSTITUTE and do not evaluate (§3.2.3). Anything beyond substitution is
|
|
45407
|
-
* the expression leaf. */
|
|
45408
45530
|
args: record(string(), unknown()).optional(),
|
|
45409
45531
|
/**
|
|
45410
45532
|
* The unit the person picked per arg (display only). `args` always hold the
|
|
@@ -45413,18 +45535,20 @@ var AutomationCapStepBaseSchema = object({
|
|
|
45413
45535
|
*/
|
|
45414
45536
|
argUnits: record(string(), string().min(1)).optional()
|
|
45415
45537
|
});
|
|
45538
|
+
/** The vocabulary check every command step passes: the action exists. */
|
|
45539
|
+
function refineKnownAction(step, ctx) {
|
|
45540
|
+
if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
|
|
45541
|
+
code: "custom",
|
|
45542
|
+
message: `"${step.actionId}" is not a vocabulary action id`,
|
|
45543
|
+
path: ["actionId"]
|
|
45544
|
+
});
|
|
45545
|
+
}
|
|
45416
45546
|
/**
|
|
45417
|
-
* The steps an internal Action may contain:
|
|
45547
|
+
* The steps an internal Action may contain: command and wait, and nothing that can
|
|
45418
45548
|
* call back into an Action — so an Action can never reach itself (no cycles).
|
|
45419
45549
|
* This is the LEAF shape: no condition of its own.
|
|
45420
45550
|
*/
|
|
45421
|
-
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema,
|
|
45422
|
-
message: "a cap step needs a target",
|
|
45423
|
-
path: ["target"]
|
|
45424
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
45425
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
45426
|
-
path: ["actionId"]
|
|
45427
|
-
})]);
|
|
45551
|
+
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
|
|
45428
45552
|
/**
|
|
45429
45553
|
* The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
|
|
45430
45554
|
* on the state mirror when the step is reached; `else` runs when it is false.
|
|
@@ -45440,39 +45564,209 @@ var elseNeedsIf = {
|
|
|
45440
45564
|
path: ["else"]
|
|
45441
45565
|
};
|
|
45442
45566
|
var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45443
|
-
var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
|
|
45444
|
-
message: "a cap step needs a target",
|
|
45445
|
-
path: ["target"]
|
|
45446
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
45447
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
45448
|
-
path: ["actionId"]
|
|
45449
|
-
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45450
45567
|
/**
|
|
45451
45568
|
* A step of a STANDALONE list (an action, a scheduler point, a preset): the
|
|
45452
45569
|
* same two step kinds an automation runs, minus a guard that reads the
|
|
45453
45570
|
* automation's trigger, which such a list does not have.
|
|
45454
45571
|
*/
|
|
45455
|
-
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema,
|
|
45572
|
+
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCommandStepBaseSchema.extend(stepGuardShape).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
|
|
45456
45573
|
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
45457
45574
|
code: "custom",
|
|
45458
45575
|
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
45459
45576
|
path: ["if"]
|
|
45460
45577
|
});
|
|
45461
45578
|
});
|
|
45579
|
+
/**
|
|
45580
|
+
* Flow control of an AUTOMATION's list (#500). A standalone list (an action, a
|
|
45581
|
+
* scheduler point, a preset) stays `wait` and `cap`: it has no run of its own
|
|
45582
|
+
* to end and no variable bag to write.
|
|
45583
|
+
*/
|
|
45584
|
+
var continueOnErrorShape = {
|
|
45585
|
+
/** A failure of this step is traced `failed-continued` and the next step runs. */
|
|
45586
|
+
continueOnError: literal(true).optional() };
|
|
45587
|
+
/** An automation's command step: the shared guarded command step, plus `continueOnError`. */
|
|
45588
|
+
var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
|
|
45589
|
+
...stepGuardShape,
|
|
45590
|
+
...continueOnErrorShape
|
|
45591
|
+
}).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45592
|
+
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
45593
|
+
var AutomationStopStepSchema = object({
|
|
45594
|
+
kind: literal("stop"),
|
|
45595
|
+
reason: string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
|
|
45596
|
+
/** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
|
|
45597
|
+
outcome: _enum(["ok", "failed"]),
|
|
45598
|
+
/** Stop only when this reads true; false or unknown does not stop. */
|
|
45599
|
+
if: AutomationWhenSchema.optional()
|
|
45600
|
+
});
|
|
45601
|
+
var SET_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,39}$/;
|
|
45602
|
+
/** Names the run itself writes and reads (`leaf` is what `triggered-by` judges): a step may not overwrite them. */
|
|
45603
|
+
var RESERVED_RUN_VARS = [
|
|
45604
|
+
"kind",
|
|
45605
|
+
"leaf",
|
|
45606
|
+
"at"
|
|
45607
|
+
];
|
|
45608
|
+
/**
|
|
45609
|
+
* Write variables into the run's bag, for the steps after it. SUBSTITUTION
|
|
45610
|
+
* only, never evaluation: a text value may carry `{{vars.x}}` slots.
|
|
45611
|
+
*/
|
|
45612
|
+
var AutomationSetStepSchema = object({
|
|
45613
|
+
kind: literal("set"),
|
|
45614
|
+
vars: record(string(), union([
|
|
45615
|
+
string().max(500),
|
|
45616
|
+
number$1(),
|
|
45617
|
+
boolean()
|
|
45618
|
+
])).refine((vars) => Object.keys(vars).every((name) => SET_VAR_NAME_RE.test(name)), { message: "a variable name is letters, digits and _, not starting with a digit (max 40)" }).refine((vars) => Object.keys(vars).length >= 1, { message: "set needs at least one variable" }).refine((vars) => Object.keys(vars).length <= 20, { message: `set holds at most 20 variables` }).refine((vars) => Object.keys(vars).every((name) => !RESERVED_RUN_VARS.includes(name)), { message: `the names ${RESERVED_RUN_VARS.join(", ")} belong to the run and cannot be set` }),
|
|
45619
|
+
/** Set only when this reads true; false or unknown leaves the bag as it is. */
|
|
45620
|
+
if: AutomationWhenSchema.optional()
|
|
45621
|
+
});
|
|
45622
|
+
var AutomationRunActionStepSchema = object({
|
|
45623
|
+
kind: literal("action"),
|
|
45624
|
+
/** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
|
|
45625
|
+
actionId: string().min(1),
|
|
45626
|
+
/** Values for the action's declared variables; the others take their default. */
|
|
45627
|
+
variables: record(string(), union([
|
|
45628
|
+
string(),
|
|
45629
|
+
number$1(),
|
|
45630
|
+
boolean()
|
|
45631
|
+
])).optional(),
|
|
45632
|
+
...continueOnErrorShape
|
|
45633
|
+
});
|
|
45634
|
+
/**
|
|
45635
|
+
* A step INSIDE a branch of a `choose`: a flow step with no condition of its
|
|
45636
|
+
* own (the branch is the condition) and no block inside it. Strict, so an `if`
|
|
45637
|
+
* written on such a step is refused rather than dropped.
|
|
45638
|
+
*/
|
|
45639
|
+
/** The longest a `wait-until` may wait: six hours. */
|
|
45640
|
+
var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
|
|
45641
|
+
/**
|
|
45642
|
+
* Pause the run until a condition is true (#500). The timeout is mandatory: a
|
|
45643
|
+
* run never waits without an end. `onTimeout` says what a wait that ran out
|
|
45644
|
+
* does: `continue` goes on to the next step, `stop` ends the run as a failure.
|
|
45645
|
+
* A condition that cannot be read is not "true": the wait goes on (D49).
|
|
45646
|
+
*/
|
|
45647
|
+
var AutomationWaitUntilStepSchema = object({
|
|
45648
|
+
kind: literal("wait-until"),
|
|
45649
|
+
when: AutomationWhenSchema,
|
|
45650
|
+
timeoutS: number$1().int().min(1, "a wait needs a timeout of at least one second").max(WAIT_UNTIL_TIMEOUT_MAX_S, `a wait for a condition is at most six hours (${WAIT_UNTIL_TIMEOUT_MAX_S} s)`),
|
|
45651
|
+
onTimeout: _enum(["continue", "stop"])
|
|
45652
|
+
}).strict();
|
|
45653
|
+
/** The step kinds that hold steps of their own, or pause on a condition: they nest two levels at most. */
|
|
45654
|
+
var BLOCK_STEP_KINDS = [
|
|
45655
|
+
"choose",
|
|
45656
|
+
"repeat",
|
|
45657
|
+
"parallel",
|
|
45658
|
+
"wait-until"
|
|
45659
|
+
];
|
|
45660
|
+
var NEST_TOO_DEEP = `steps nest two levels at most: a step inside a nested choose or repeat can be a plain step only`;
|
|
45661
|
+
function kindOf(input) {
|
|
45662
|
+
return typeof input === "object" && input !== null ? Reflect.get(input, "kind") : void 0;
|
|
45663
|
+
}
|
|
45664
|
+
/** Where the nesting ends, a block step is refused in words rather than as an unknown kind. */
|
|
45665
|
+
function nestTooDeep(issue) {
|
|
45666
|
+
const kind = kindOf(issue.input);
|
|
45667
|
+
return typeof kind === "string" && BLOCK_STEP_KINDS.includes(kind) ? NEST_TOO_DEEP : void 0;
|
|
45668
|
+
}
|
|
45669
|
+
var plainStepSchemas = [
|
|
45670
|
+
AutomationWaitStepSchema.strict(),
|
|
45671
|
+
AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
|
|
45672
|
+
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
45673
|
+
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
45674
|
+
AutomationRunActionStepSchema.strict()
|
|
45675
|
+
];
|
|
45676
|
+
/**
|
|
45677
|
+
* A plain step: a flow step with no condition of its own and no step inside
|
|
45678
|
+
* it. The second (last) level of nesting holds these only.
|
|
45679
|
+
*/
|
|
45680
|
+
var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
|
|
45681
|
+
/** A step that can run beside others: it writes no variable and does not end the run. */
|
|
45682
|
+
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");
|
|
45683
|
+
/**
|
|
45684
|
+
* Several steps at once (#500): all are started together and all are awaited.
|
|
45685
|
+
* A failure fails the run once the others finished, as in a sequence; a member
|
|
45686
|
+
* marked "continue if this fails" does not.
|
|
45687
|
+
*/
|
|
45688
|
+
var AutomationParallelStepSchema = object({
|
|
45689
|
+
kind: literal("parallel"),
|
|
45690
|
+
steps: array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
|
|
45691
|
+
}).strict();
|
|
45692
|
+
var REPEAT_NEEDS_MAX = "a repeat on a condition needs a maximum number of iterations";
|
|
45693
|
+
/** A loop on a condition: the bound is mandatory, so a run never loops without an end. */
|
|
45694
|
+
var repeatConditionShape = {
|
|
45695
|
+
when: AutomationWhenSchema,
|
|
45696
|
+
maxIterations: number$1({ error: REPEAT_NEEDS_MAX }).int().min(1, REPEAT_NEEDS_MAX).max(50, `a repeat on a condition runs at most 50 times`),
|
|
45697
|
+
/** A pause between two iterations, never after the last. */
|
|
45698
|
+
waitS: number$1().int().min(1).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG).optional()
|
|
45699
|
+
};
|
|
45700
|
+
/** What decides how many times a `repeat` runs. */
|
|
45701
|
+
var AutomationRepeatLoopSchema = discriminatedUnion("by", [
|
|
45702
|
+
object({
|
|
45703
|
+
by: literal("count"),
|
|
45704
|
+
count: number$1().int().min(1).max(20, `a repeat runs at most 20 times`)
|
|
45705
|
+
}).strict(),
|
|
45706
|
+
object({
|
|
45707
|
+
by: literal("while"),
|
|
45708
|
+
...repeatConditionShape
|
|
45709
|
+
}).strict(),
|
|
45710
|
+
object({
|
|
45711
|
+
by: literal("until"),
|
|
45712
|
+
...repeatConditionShape
|
|
45713
|
+
}).strict(),
|
|
45714
|
+
object({
|
|
45715
|
+
by: literal("forEach"),
|
|
45716
|
+
target: object({
|
|
45717
|
+
kind: literal("devices"),
|
|
45718
|
+
ids: array(number$1().int()).min(1, "a repeat over devices needs at least one device").max(50, `a repeat over devices takes at most 50 devices`)
|
|
45719
|
+
}).strict()
|
|
45720
|
+
}).strict()
|
|
45721
|
+
]);
|
|
45722
|
+
/**
|
|
45723
|
+
* The same steps several times (#500). Every form is bounded at save, so a
|
|
45724
|
+
* run cannot loop without an end. A failure or a `stop` in the steps ends the
|
|
45725
|
+
* loop and the run, as in a sequence.
|
|
45726
|
+
*/
|
|
45727
|
+
function repeatSchemaOf(step) {
|
|
45728
|
+
return object({
|
|
45729
|
+
kind: literal("repeat"),
|
|
45730
|
+
loop: AutomationRepeatLoopSchema,
|
|
45731
|
+
steps: array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
|
|
45732
|
+
}).strict();
|
|
45733
|
+
}
|
|
45734
|
+
/**
|
|
45735
|
+
* One step, several ways (#500): the branches are read in order and the FIRST
|
|
45736
|
+
* whose condition is true runs; `else` runs when every branch is false. A
|
|
45737
|
+
* branch that cannot be read ends the choice: nothing runs, not the branches
|
|
45738
|
+
* after it and not the else (D49). The #472 `if` / `else` of a wait or cap
|
|
45739
|
+
* step is the one-branch case and stays as it is stored.
|
|
45740
|
+
*/
|
|
45741
|
+
function chooseSchemaOf(step) {
|
|
45742
|
+
const steps = array(step).max(10);
|
|
45743
|
+
return object({
|
|
45744
|
+
kind: literal("choose"),
|
|
45745
|
+
branches: array(object({
|
|
45746
|
+
if: AutomationWhenSchema,
|
|
45747
|
+
steps: steps.min(1, "a branch needs at least one step")
|
|
45748
|
+
})).min(1, "a choose needs at least one branch").max(6, `a choose takes at most 6 branches`),
|
|
45749
|
+
else: steps.optional()
|
|
45750
|
+
});
|
|
45751
|
+
}
|
|
45752
|
+
var AutomationBodyStepSchema = discriminatedUnion("kind", [
|
|
45753
|
+
...plainStepSchemas,
|
|
45754
|
+
AutomationWaitUntilStepSchema,
|
|
45755
|
+
AutomationParallelStepSchema,
|
|
45756
|
+
chooseSchemaOf(AutomationBranchStepSchema),
|
|
45757
|
+
repeatSchemaOf(AutomationBranchStepSchema)
|
|
45758
|
+
]);
|
|
45759
|
+
var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
|
|
45462
45760
|
var AutomationActionSchema = discriminatedUnion("kind", [
|
|
45463
45761
|
GuardedWaitStepSchema,
|
|
45464
|
-
|
|
45465
|
-
|
|
45466
|
-
|
|
45467
|
-
|
|
45468
|
-
|
|
45469
|
-
|
|
45470
|
-
|
|
45471
|
-
|
|
45472
|
-
number$1(),
|
|
45473
|
-
boolean()
|
|
45474
|
-
])).optional()
|
|
45475
|
-
}),
|
|
45762
|
+
AutomationGuardedCommandStepSchema,
|
|
45763
|
+
AutomationStopStepSchema,
|
|
45764
|
+
AutomationSetStepSchema,
|
|
45765
|
+
chooseSchemaOf(AutomationBodyStepSchema),
|
|
45766
|
+
AutomationWaitUntilStepSchema,
|
|
45767
|
+
AutomationParallelStepSchema,
|
|
45768
|
+
AutomationRepeatStepSchema,
|
|
45769
|
+
AutomationRunActionStepSchema,
|
|
45476
45770
|
object({
|
|
45477
45771
|
kind: literal("code"),
|
|
45478
45772
|
/** Compiled into the automation's OWN block by esbuild — not a third
|
|
@@ -45535,44 +45829,7 @@ function convertLegacyRecipe(legacy) {
|
|
|
45535
45829
|
...rest
|
|
45536
45830
|
};
|
|
45537
45831
|
}
|
|
45538
|
-
/**
|
|
45539
|
-
* Where recipes are PARSED (the core-blocks cap, the MCP tool, the literal a
|
|
45540
|
-
* saved block carries): the new shape as it is, or the old shape converted to
|
|
45541
|
-
* it. The output type is always the new one.
|
|
45542
|
-
*/
|
|
45543
45832
|
var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
|
|
45544
|
-
var DETECTION_DESCRIPTIONS = {
|
|
45545
|
-
deviceId: "the camera that saw it",
|
|
45546
|
-
className: "what it saw",
|
|
45547
|
-
trackId: "the track",
|
|
45548
|
-
score: "how sure the detector was",
|
|
45549
|
-
label: "the label it matched (a name, a plate), empty when none"
|
|
45550
|
-
};
|
|
45551
|
-
var STATIONARY_DESCRIPTIONS = {
|
|
45552
|
-
deviceId: "the camera that saw it",
|
|
45553
|
-
className: "what it saw",
|
|
45554
|
-
zones: "the zones it is in",
|
|
45555
|
-
phase: "appeared or departed",
|
|
45556
|
-
entryId: "the stopped object"
|
|
45557
|
-
};
|
|
45558
|
-
var BECOMES_DESCRIPTIONS = {
|
|
45559
|
-
deviceId: "the device that changed",
|
|
45560
|
-
from: "the value before the change, empty when it is not known",
|
|
45561
|
-
to: "the value it changed to"
|
|
45562
|
-
};
|
|
45563
|
-
function describe$1(descriptions) {
|
|
45564
|
-
return Object.entries(descriptions).map(([name, description]) => ({
|
|
45565
|
-
name,
|
|
45566
|
-
description
|
|
45567
|
-
}));
|
|
45568
|
-
}
|
|
45569
|
-
describe$1(DETECTION_DESCRIPTIONS);
|
|
45570
|
-
describe$1(STATIONARY_DESCRIPTIONS);
|
|
45571
|
-
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45572
|
-
...v,
|
|
45573
|
-
hintKey: "becomesDeviceId"
|
|
45574
|
-
} : v);
|
|
45575
|
-
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
45576
45833
|
/**
|
|
45577
45834
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
45578
45835
|
*
|
|
@@ -45624,12 +45881,16 @@ var HoldOverrideSchema = discriminatedUnion("mode", [object({ mode: literal("res
|
|
|
45624
45881
|
})]);
|
|
45625
45882
|
/** A missed edge up to this late still runs. */
|
|
45626
45883
|
var DEFAULT_MAX_LATE_MS = 10 * 6e4;
|
|
45884
|
+
var SchedulerStepSchema = ActionStepSchema.refine((step) => step.kind !== "wait" || step.seconds <= 300, {
|
|
45885
|
+
message: `a scheduler point waits at most five minutes (300 s); put a longer wait in an action`,
|
|
45886
|
+
path: ["seconds"]
|
|
45887
|
+
});
|
|
45627
45888
|
var SchedulerPointSchema = object({
|
|
45628
45889
|
id: string().min(1).max(64),
|
|
45629
45890
|
at: SchedulerTimeSpecSchema,
|
|
45630
45891
|
mode: SchedulerPointModeSchema,
|
|
45631
45892
|
/** The actions of an `edge` or `hold`; a `release` has none. */
|
|
45632
|
-
steps: array(
|
|
45893
|
+
steps: array(SchedulerStepSchema).max(20).default([]),
|
|
45633
45894
|
/** Checked when the point runs (an edge) or is applied (a hold). */
|
|
45634
45895
|
conditions: SchedulerStateTreeSchema.optional(),
|
|
45635
45896
|
/** Hold only; absent means `respect`. */
|
|
@@ -45827,6 +46088,7 @@ var AutomationConditionTraceNodeSchema = object({
|
|
|
45827
46088
|
"triggered-by",
|
|
45828
46089
|
"device-becomes",
|
|
45829
46090
|
"device-event",
|
|
46091
|
+
"device-fired",
|
|
45830
46092
|
"schedule",
|
|
45831
46093
|
"interval",
|
|
45832
46094
|
"manual",
|
|
@@ -45897,18 +46159,46 @@ var StepTraceBaseSchema = object({
|
|
|
45897
46159
|
]).optional(),
|
|
45898
46160
|
/** Why the condition read what it read, in the evaluator's own words. */
|
|
45899
46161
|
conditionReason: string().optional(),
|
|
45900
|
-
/** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. */
|
|
46162
|
+
/** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. `failed-continued`: it failed and was marked to be passed over (#500). */
|
|
45901
46163
|
outcome: _enum([
|
|
45902
46164
|
"ok",
|
|
45903
46165
|
"error",
|
|
45904
46166
|
"not-run",
|
|
45905
46167
|
"empty",
|
|
45906
|
-
"skipped"
|
|
46168
|
+
"skipped",
|
|
46169
|
+
"failed-continued",
|
|
46170
|
+
"timed-out"
|
|
45907
46171
|
]),
|
|
45908
46172
|
message: string().optional()
|
|
45909
46173
|
});
|
|
46174
|
+
/** What a block step adds to its row: which list ran, what each branch read, how many rounds. */
|
|
46175
|
+
var blockTraceShape = {
|
|
46176
|
+
/** A `choose` step (#500): the list that ran, `branches.<n>` or `else`. Absent when none did. */
|
|
46177
|
+
branch: string().optional(),
|
|
46178
|
+
/** A `choose` step: what each branch read, in order, up to the one that decided. */
|
|
46179
|
+
branchChecks: array(object({
|
|
46180
|
+
condition: _enum([
|
|
46181
|
+
"true",
|
|
46182
|
+
"false",
|
|
46183
|
+
"unknown"
|
|
46184
|
+
]),
|
|
46185
|
+
conditionReason: string().optional()
|
|
46186
|
+
})).optional(),
|
|
46187
|
+
/** A `repeat` step (#500): how many times its steps ran. */
|
|
46188
|
+
iterations: number$1().int().optional()
|
|
46189
|
+
};
|
|
46190
|
+
/** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
|
|
46191
|
+
var NestedStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46192
|
+
...blockTraceShape,
|
|
46193
|
+
steps: array(StepTraceBaseSchema).optional()
|
|
46194
|
+
});
|
|
45910
46195
|
/** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
|
|
45911
|
-
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46196
|
+
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46197
|
+
else: array(StepTraceBaseSchema).optional(),
|
|
46198
|
+
...blockTraceShape,
|
|
46199
|
+
/** A `choose` step: the steps of the list that ran. A `parallel`: its members. A `repeat`: the LAST iteration. */
|
|
46200
|
+
steps: array(NestedStepTraceSchema).optional()
|
|
46201
|
+
});
|
|
45912
46202
|
var AutomationRunTraceSchema = object({
|
|
45913
46203
|
runId: string().min(1),
|
|
45914
46204
|
startedAt: number$1(),
|
|
@@ -45938,6 +46228,86 @@ var AutomationStateDocSchema = object({
|
|
|
45938
46228
|
lastRunStartedAt: number$1().nullable(),
|
|
45939
46229
|
traces: array(AutomationRunTraceSchema)
|
|
45940
46230
|
});
|
|
46231
|
+
var DETECTION_DESCRIPTIONS = {
|
|
46232
|
+
deviceId: "the camera that saw it",
|
|
46233
|
+
className: "what it saw",
|
|
46234
|
+
trackId: "the track",
|
|
46235
|
+
score: "how sure the detector was",
|
|
46236
|
+
label: "the label it matched (a name, a plate), empty when none"
|
|
46237
|
+
};
|
|
46238
|
+
var STATIONARY_DESCRIPTIONS = {
|
|
46239
|
+
deviceId: "the camera that saw it",
|
|
46240
|
+
className: "what it saw",
|
|
46241
|
+
zones: "the zones it is in",
|
|
46242
|
+
phase: "appeared or departed",
|
|
46243
|
+
entryId: "the stopped object"
|
|
46244
|
+
};
|
|
46245
|
+
var BECOMES_DESCRIPTIONS = {
|
|
46246
|
+
deviceId: "the device that changed",
|
|
46247
|
+
from: "the value before the change, empty when it is not known",
|
|
46248
|
+
to: "the value it changed to"
|
|
46249
|
+
};
|
|
46250
|
+
/**
|
|
46251
|
+
* A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
|
|
46252
|
+
* those names depend on the device, so they are not in this list.
|
|
46253
|
+
*/
|
|
46254
|
+
var FIRED_DESCRIPTIONS = {
|
|
46255
|
+
deviceId: "the device that fired",
|
|
46256
|
+
eventType: "the event, as the device names it",
|
|
46257
|
+
sourceId: "the part of the device that fired (a button), empty when it names none",
|
|
46258
|
+
eventKind: "the kind of press (press, long-press …), empty when the device declares none"
|
|
46259
|
+
};
|
|
46260
|
+
function describe$1(descriptions) {
|
|
46261
|
+
return Object.entries(descriptions).map(([name, description]) => ({
|
|
46262
|
+
name,
|
|
46263
|
+
description
|
|
46264
|
+
}));
|
|
46265
|
+
}
|
|
46266
|
+
describe$1(DETECTION_DESCRIPTIONS);
|
|
46267
|
+
describe$1(STATIONARY_DESCRIPTIONS);
|
|
46268
|
+
describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
46269
|
+
...v,
|
|
46270
|
+
hintKey: "firedDeviceId"
|
|
46271
|
+
} : v);
|
|
46272
|
+
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
46273
|
+
...v,
|
|
46274
|
+
hintKey: "becomesDeviceId"
|
|
46275
|
+
} : v);
|
|
46276
|
+
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
46277
|
+
/**
|
|
46278
|
+
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
46279
|
+
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
46280
|
+
* (NO normalization). Two shapes:
|
|
46281
|
+
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
46282
|
+
* declared set (e.g. press_short, press_long, …).
|
|
46283
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
46284
|
+
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
46285
|
+
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
46286
|
+
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
46287
|
+
* A fire names the part of the device it came from in `sourceId` when the
|
|
46288
|
+
* vocabulary declares sources (a remote's buttons).
|
|
46289
|
+
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
46290
|
+
*/
|
|
46291
|
+
var EventFireSchema = object({
|
|
46292
|
+
deviceId: number$1(),
|
|
46293
|
+
eventType: string(),
|
|
46294
|
+
sourceId: string().optional(),
|
|
46295
|
+
data: record(string(), unknown()).nullable(),
|
|
46296
|
+
timestamp: number$1().meta(readingMeta("none")),
|
|
46297
|
+
seq: number$1().meta(readingMeta("count"))
|
|
46298
|
+
});
|
|
46299
|
+
var EventEmitterStatusSchema = object({
|
|
46300
|
+
eventTypes: array(string()),
|
|
46301
|
+
/**
|
|
46302
|
+
* Required of a provider by the type. A status written before the field
|
|
46303
|
+
* existed still parses, as an empty vocabulary: read it through
|
|
46304
|
+
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
46305
|
+
*/
|
|
46306
|
+
vocabulary: array(EventVocabularyEntrySchema).default([]),
|
|
46307
|
+
lastEvent: EventFireSchema.nullable(),
|
|
46308
|
+
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
46309
|
+
});
|
|
46310
|
+
DeviceType.EventEmitter;
|
|
45941
46311
|
/**
|
|
45942
46312
|
* Actions — named, runnable things an operator (or an automation) can start,
|
|
45943
46313
|
* declared as LIST ENTRIES, never as devices.
|
|
@@ -46200,6 +46570,343 @@ function pruneDeletedEntities(selection, live, log, exporter) {
|
|
|
46200
46570
|
dropped
|
|
46201
46571
|
};
|
|
46202
46572
|
}
|
|
46573
|
+
/**
|
|
46574
|
+
* `device-export` — collection cap for addons that export camstack
|
|
46575
|
+
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
46576
|
+
* HomeKit/HAP, Alexa Smart Home, …).
|
|
46577
|
+
*
|
|
46578
|
+
* No `ecosystem` enum — the addon id identifies the export target.
|
|
46579
|
+
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
46580
|
+
* exposes only the COMMON surface: link state, supported device
|
|
46581
|
+
* kinds (so the UI can filter the device picker), and per-device
|
|
46582
|
+
* expose/unexpose.
|
|
46583
|
+
*
|
|
46584
|
+
* INSTANCES. One export addon can serve several independent targets (a
|
|
46585
|
+
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
46586
|
+
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
46587
|
+
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
46588
|
+
* default instance's); present = that instance; an id the provider does not
|
|
46589
|
+
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
46590
|
+
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
46591
|
+
* change always names the target it changes. A single-instance provider
|
|
46592
|
+
* accepts an absent id on a read or its own id, and refuses any other.
|
|
46593
|
+
*/
|
|
46594
|
+
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
46595
|
+
var InstanceIdSchema$1 = string().min(1);
|
|
46596
|
+
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
46597
|
+
/** One independent export target of an addon. */
|
|
46598
|
+
var ExportInstanceSchema = object({
|
|
46599
|
+
instanceId: InstanceIdSchema$1,
|
|
46600
|
+
name: string(),
|
|
46601
|
+
enabled: boolean(),
|
|
46602
|
+
kind: string().optional(),
|
|
46603
|
+
/**
|
|
46604
|
+
* What this instance's platform accepts as a device name, in one operator-facing sentence
|
|
46605
|
+
* (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
|
|
46606
|
+
* about the rule.
|
|
46607
|
+
*/
|
|
46608
|
+
nameRule: string().optional()
|
|
46609
|
+
});
|
|
46610
|
+
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
46611
|
+
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
46612
|
+
var ExportInstanceUnknownError = class extends Error {
|
|
46613
|
+
code = EXPORT_INSTANCE_UNKNOWN;
|
|
46614
|
+
instanceId;
|
|
46615
|
+
constructor(addon, instanceId) {
|
|
46616
|
+
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
46617
|
+
this.name = "ExportInstanceUnknownError";
|
|
46618
|
+
this.instanceId = instanceId;
|
|
46619
|
+
}
|
|
46620
|
+
};
|
|
46621
|
+
/**
|
|
46622
|
+
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
46623
|
+
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
46624
|
+
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
46625
|
+
*/
|
|
46626
|
+
function statusInstanceOf(input) {
|
|
46627
|
+
return "instanceId" in input ? input.instanceId : void 0;
|
|
46628
|
+
}
|
|
46629
|
+
var LinkStateSchema = _enum([
|
|
46630
|
+
"unlinked",
|
|
46631
|
+
"linked",
|
|
46632
|
+
"error"
|
|
46633
|
+
]);
|
|
46634
|
+
/**
|
|
46635
|
+
* A single label/value row surfaced in the export panel's "Setup"
|
|
46636
|
+
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
46637
|
+
* rows are masked by default with a reveal toggle (client ids,
|
|
46638
|
+
* secrets, …).
|
|
46639
|
+
*/
|
|
46640
|
+
var ExportSetupFieldSchema = object({
|
|
46641
|
+
label: string(),
|
|
46642
|
+
value: string(),
|
|
46643
|
+
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
46644
|
+
secret: boolean().optional()
|
|
46645
|
+
});
|
|
46646
|
+
/**
|
|
46647
|
+
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
46648
|
+
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
46649
|
+
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
46650
|
+
* the provider supplies and skips the section entirely when `setup`
|
|
46651
|
+
* is unset.
|
|
46652
|
+
*/
|
|
46653
|
+
var ExportSetupSchema = object({
|
|
46654
|
+
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
46655
|
+
qr: string().optional(),
|
|
46656
|
+
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
46657
|
+
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
46658
|
+
/** Free-form operator instructions rendered above the fields. */
|
|
46659
|
+
note: string().optional()
|
|
46660
|
+
});
|
|
46661
|
+
var DeviceExportStatusSchema = object({
|
|
46662
|
+
linkState: LinkStateSchema,
|
|
46663
|
+
exposedDeviceCount: number$1(),
|
|
46664
|
+
error: string().optional(),
|
|
46665
|
+
/**
|
|
46666
|
+
* Optional pairing/account info the panel renders in a generic
|
|
46667
|
+
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
46668
|
+
* export target, never an `ecosystem` key here.
|
|
46669
|
+
*/
|
|
46670
|
+
setup: ExportSetupSchema.optional()
|
|
46671
|
+
});
|
|
46672
|
+
var DeviceKindSchema = string();
|
|
46673
|
+
/**
|
|
46674
|
+
* EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
|
|
46675
|
+
* device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
|
|
46676
|
+
* store (D865), validated by the exporter against its platform's naming rules, and never reaches
|
|
46677
|
+
* the exported id — a rename updates the SAME device on the platform, never a second one.
|
|
46678
|
+
* Blank or `null` = the device's own name. A name the platform would refuse is refused with
|
|
46679
|
+
* `ExportNameRefusedError` (`export-name-refused`), whose message says why.
|
|
46680
|
+
*/
|
|
46681
|
+
var ExposedDeviceSchema = object({
|
|
46682
|
+
deviceId: string(),
|
|
46683
|
+
exposedAs: string().optional(),
|
|
46684
|
+
/** The operator's name for this device on this instance; absent = the device's own name. */
|
|
46685
|
+
exposedName: string().optional(),
|
|
46686
|
+
capabilities: array(string()).optional()
|
|
46687
|
+
});
|
|
46688
|
+
var ExposeInputSchema = object({
|
|
46689
|
+
instanceId: InstanceIdSchema$1,
|
|
46690
|
+
deviceId: string(),
|
|
46691
|
+
capabilities: array(string()).optional(),
|
|
46692
|
+
/** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
|
|
46693
|
+
exposedName: string().nullable().optional()
|
|
46694
|
+
});
|
|
46695
|
+
var SetExposedNameInputSchema = object({
|
|
46696
|
+
instanceId: InstanceIdSchema$1,
|
|
46697
|
+
deviceId: string(),
|
|
46698
|
+
/** Blank or null = the device's own name. */
|
|
46699
|
+
name: string().nullable(),
|
|
46700
|
+
/**
|
|
46701
|
+
* Validate only: refuse exactly as a real call would, write nothing. A caller saving several
|
|
46702
|
+
* names at once checks every one first, so one refusal writes none (D1049).
|
|
46703
|
+
*/
|
|
46704
|
+
dryRun: boolean().optional()
|
|
46705
|
+
});
|
|
46706
|
+
var EXPORT_NAME_REFUSED = "export-name-refused";
|
|
46707
|
+
/** A name the instance's platform would refuse. The message starts with the code, then the reason. */
|
|
46708
|
+
var ExportNameRefusedError = class extends Error {
|
|
46709
|
+
code = EXPORT_NAME_REFUSED;
|
|
46710
|
+
instanceId;
|
|
46711
|
+
reason;
|
|
46712
|
+
constructor(instanceId, reason) {
|
|
46713
|
+
super(`${EXPORT_NAME_REFUSED}: ${reason}`);
|
|
46714
|
+
this.name = "ExportNameRefusedError";
|
|
46715
|
+
this.instanceId = instanceId;
|
|
46716
|
+
this.reason = reason;
|
|
46717
|
+
}
|
|
46718
|
+
};
|
|
46719
|
+
var UnexposeInputSchema = object({
|
|
46720
|
+
instanceId: InstanceIdSchema$1,
|
|
46721
|
+
deviceId: string()
|
|
46722
|
+
});
|
|
46723
|
+
/**
|
|
46724
|
+
* What an exporter may expose besides devices (D968). An action and a
|
|
46725
|
+
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
46726
|
+
* exporter's own selection, not the device registry.
|
|
46727
|
+
*/
|
|
46728
|
+
var ExportEntityKindSchema = _enum([
|
|
46729
|
+
"device",
|
|
46730
|
+
"action",
|
|
46731
|
+
"notifier"
|
|
46732
|
+
]);
|
|
46733
|
+
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
46734
|
+
object({
|
|
46735
|
+
kind: literal("device"),
|
|
46736
|
+
deviceId: string()
|
|
46737
|
+
}),
|
|
46738
|
+
object({
|
|
46739
|
+
kind: literal("action"),
|
|
46740
|
+
actionId: string().min(1)
|
|
46741
|
+
}),
|
|
46742
|
+
object({
|
|
46743
|
+
kind: literal("notifier"),
|
|
46744
|
+
targetId: string().min(1)
|
|
46745
|
+
})
|
|
46746
|
+
]);
|
|
46747
|
+
var ExposedEntitySchema = object({
|
|
46748
|
+
entity: ExportEntityRefSchema,
|
|
46749
|
+
exposedAs: string().optional()
|
|
46750
|
+
});
|
|
46751
|
+
var ExposeEntityInputSchema = object({
|
|
46752
|
+
instanceId: InstanceIdSchema$1,
|
|
46753
|
+
entity: ExportEntityRefSchema
|
|
46754
|
+
});
|
|
46755
|
+
var UnexposeEntityInputSchema = object({
|
|
46756
|
+
instanceId: InstanceIdSchema$1,
|
|
46757
|
+
entity: ExportEntityRefSchema
|
|
46758
|
+
});
|
|
46759
|
+
var deviceExportCapability = {
|
|
46760
|
+
name: "device-export",
|
|
46761
|
+
scope: "system",
|
|
46762
|
+
mode: "collection",
|
|
46763
|
+
providerKind: "device-export",
|
|
46764
|
+
status: {
|
|
46765
|
+
schema: DeviceExportStatusSchema,
|
|
46766
|
+
kind: "poll"
|
|
46767
|
+
},
|
|
46768
|
+
/**
|
|
46769
|
+
* Each export provider MAY contribute its own per-device "Export" panel
|
|
46770
|
+
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
46771
|
+
* framework methods are mounted on the cap router when present.
|
|
46772
|
+
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
46773
|
+
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
46774
|
+
* never hand-written — D14 — and an exporter is not one of those).
|
|
46775
|
+
*/
|
|
46776
|
+
exposesDeviceSettings: true,
|
|
46777
|
+
methods: {
|
|
46778
|
+
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
46779
|
+
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
46780
|
+
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
46781
|
+
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
46782
|
+
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
46783
|
+
kind: "mutation",
|
|
46784
|
+
auth: "admin"
|
|
46785
|
+
}),
|
|
46786
|
+
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
46787
|
+
kind: "mutation",
|
|
46788
|
+
auth: "admin"
|
|
46789
|
+
}),
|
|
46790
|
+
setExposedName: method(SetExposedNameInputSchema, _void(), {
|
|
46791
|
+
kind: "mutation",
|
|
46792
|
+
auth: "admin"
|
|
46793
|
+
}),
|
|
46794
|
+
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
46795
|
+
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
46796
|
+
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
46797
|
+
kind: "mutation",
|
|
46798
|
+
auth: "admin"
|
|
46799
|
+
}),
|
|
46800
|
+
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
46801
|
+
kind: "mutation",
|
|
46802
|
+
auth: "admin"
|
|
46803
|
+
})
|
|
46804
|
+
}
|
|
46805
|
+
};
|
|
46806
|
+
/**
|
|
46807
|
+
* The exposed name of a device on one export instance (`device-export`, D1049).
|
|
46808
|
+
*
|
|
46809
|
+
* Every exporter keeps its names the same way: in ITS per-device store (D865), under
|
|
46810
|
+
* {@link EXPOSED_NAMES_STORE_KEY}, one entry per instance id. The store is cleared centrally
|
|
46811
|
+
* when the device is deleted, so no removal hook is needed for it. Each exporter supplies the
|
|
46812
|
+
* validator of its own platform; the normalisation, the store shape and the refusal are here so
|
|
46813
|
+
* the four exporters cannot drift apart.
|
|
46814
|
+
*
|
|
46815
|
+
* The name is a label only: no exporter derives the exported id from it, so a rename updates
|
|
46816
|
+
* the same device on the platform.
|
|
46817
|
+
*/
|
|
46818
|
+
/** The per-device store key holding `{ [instanceId]: name }`. */
|
|
46819
|
+
var EXPOSED_NAMES_STORE_KEY = "exposedNames";
|
|
46820
|
+
var ExposedNamesSchema = record(string(), string());
|
|
46821
|
+
/** Trim and collapse whitespace, then the platform rule. Blank or null clears (`name: null`). */
|
|
46822
|
+
function checkExposedName(raw, validate) {
|
|
46823
|
+
if (raw === null || raw === void 0) return {
|
|
46824
|
+
ok: true,
|
|
46825
|
+
name: null
|
|
46826
|
+
};
|
|
46827
|
+
if (typeof raw !== "string") return {
|
|
46828
|
+
ok: false,
|
|
46829
|
+
reason: "The name must be text."
|
|
46830
|
+
};
|
|
46831
|
+
const name = raw.trim().replace(/\s+/g, " ");
|
|
46832
|
+
if (name.length === 0) return {
|
|
46833
|
+
ok: true,
|
|
46834
|
+
name: null
|
|
46835
|
+
};
|
|
46836
|
+
return validate(name);
|
|
46837
|
+
}
|
|
46838
|
+
/** Every saved name of a device, by instance id. A malformed blob reads as none. */
|
|
46839
|
+
function readExposedNames(store) {
|
|
46840
|
+
const parsed = ExposedNamesSchema.safeParse(store[EXPOSED_NAMES_STORE_KEY]);
|
|
46841
|
+
return parsed.success ? parsed.data : {};
|
|
46842
|
+
}
|
|
46843
|
+
/**
|
|
46844
|
+
* The saved name of one instance, or null: never saved, or a stored value the platform would
|
|
46845
|
+
* now refuse (the device's own name is used rather than pushing a name the platform rejects).
|
|
46846
|
+
*/
|
|
46847
|
+
function readExposedName(store, instanceId, validate) {
|
|
46848
|
+
const saved = readExposedNames(store)[instanceId];
|
|
46849
|
+
if (saved === void 0) return null;
|
|
46850
|
+
const check = checkExposedName(saved, validate);
|
|
46851
|
+
return check.ok ? check.name : null;
|
|
46852
|
+
}
|
|
46853
|
+
/** The store patch that sets (or, with null, clears) one instance's name and keeps the others. */
|
|
46854
|
+
function exposedNamePatch(store, instanceId, name) {
|
|
46855
|
+
const others = Object.fromEntries(Object.entries(readExposedNames(store)).filter(([id]) => id !== instanceId));
|
|
46856
|
+
return { [EXPOSED_NAMES_STORE_KEY]: name === null ? others : {
|
|
46857
|
+
...others,
|
|
46858
|
+
[instanceId]: name
|
|
46859
|
+
} };
|
|
46860
|
+
}
|
|
46861
|
+
/**
|
|
46862
|
+
* Validate and save one instance's name. A name the platform would refuse throws
|
|
46863
|
+
* {@link ExportNameRefusedError} BEFORE anything is written, so the old name stays.
|
|
46864
|
+
*/
|
|
46865
|
+
async function saveExposedName(input) {
|
|
46866
|
+
const check = checkExposedName(input.raw, input.validate);
|
|
46867
|
+
if (!check.ok) throw new ExportNameRefusedError(input.instanceId, check.reason);
|
|
46868
|
+
if (input.dryRun === true) return {
|
|
46869
|
+
changed: false,
|
|
46870
|
+
name: check.name
|
|
46871
|
+
};
|
|
46872
|
+
const store = await input.store.read(input.deviceId);
|
|
46873
|
+
if ((readExposedNames(store)[input.instanceId] ?? null) === check.name) return {
|
|
46874
|
+
changed: false,
|
|
46875
|
+
name: check.name
|
|
46876
|
+
};
|
|
46877
|
+
await input.store.write(input.deviceId, exposedNamePatch(store, input.instanceId, check.name));
|
|
46878
|
+
return {
|
|
46879
|
+
changed: true,
|
|
46880
|
+
name: check.name
|
|
46881
|
+
};
|
|
46882
|
+
}
|
|
46883
|
+
/** The exporter's per-device store as an {@link ExposedNameStore}; throws when settings are absent. */
|
|
46884
|
+
function exposedNameStoreOf(settings, owner) {
|
|
46885
|
+
const access = () => {
|
|
46886
|
+
if (settings === void 0) throw new Error(`${owner}: settings are not available`);
|
|
46887
|
+
return settings;
|
|
46888
|
+
};
|
|
46889
|
+
return {
|
|
46890
|
+
read: (deviceId) => access().readDeviceStore(deviceId),
|
|
46891
|
+
write: (deviceId, patch) => access().writeDeviceStore(deviceId, patch)
|
|
46892
|
+
};
|
|
46893
|
+
}
|
|
46894
|
+
/**
|
|
46895
|
+
* Remove every name saved for `instanceId` (the instance was deleted), so a later instance that
|
|
46896
|
+
* reuses the id does not inherit them. Returns the device ids that lost a name. A store that
|
|
46897
|
+
* cannot be read throws; nothing is written for the devices not reached.
|
|
46898
|
+
*/
|
|
46899
|
+
async function pruneExposedNames(settings, instanceId) {
|
|
46900
|
+
const ids = await settings.listDeviceStoreIds();
|
|
46901
|
+
if (ids.length === 0) return [];
|
|
46902
|
+
const pruned = [];
|
|
46903
|
+
for (const [deviceId, store] of await settings.readDeviceStoreBatch(ids)) {
|
|
46904
|
+
if (readExposedNames(store)[instanceId] === void 0) continue;
|
|
46905
|
+
await settings.writeDeviceStore(deviceId, exposedNamePatch(store, instanceId, null));
|
|
46906
|
+
pruned.push(deviceId);
|
|
46907
|
+
}
|
|
46908
|
+
return pruned;
|
|
46909
|
+
}
|
|
46203
46910
|
_enum([
|
|
46204
46911
|
"automation",
|
|
46205
46912
|
"action",
|
|
@@ -46398,7 +47105,9 @@ var AddonHttpRouteSchema = object({
|
|
|
46398
47105
|
]).optional(),
|
|
46399
47106
|
description: string().optional(),
|
|
46400
47107
|
/** The hub limits this route per client address before the handler runs. */
|
|
46401
|
-
rateLimit: _enum(["auth"]).optional()
|
|
47108
|
+
rateLimit: _enum(["auth"]).optional(),
|
|
47109
|
+
/** Served once per integration instance; the handler reads `instanceId`. */
|
|
47110
|
+
perInstance: boolean().optional()
|
|
46402
47111
|
});
|
|
46403
47112
|
/**
|
|
46404
47113
|
* Cross-process route invocation envelope. The hub captures the
|
|
@@ -46415,6 +47124,8 @@ var InvokeRequestSchema = object({
|
|
|
46415
47124
|
query: record(string(), string()),
|
|
46416
47125
|
body: unknown(),
|
|
46417
47126
|
headers: record(string(), string()),
|
|
47127
|
+
/** The instance the hub resolved for a `perInstance` route. */
|
|
47128
|
+
instanceId: string().optional(),
|
|
46418
47129
|
user: object({
|
|
46419
47130
|
id: string(),
|
|
46420
47131
|
username: string(),
|
|
@@ -50463,11 +51174,13 @@ var IrCodecError = class extends Error {
|
|
|
50463
51174
|
this.code = code;
|
|
50464
51175
|
}
|
|
50465
51176
|
};
|
|
51177
|
+
/** Maximum number of mark/space entries one pulse train may carry. */
|
|
51178
|
+
var IR_TIMINGS_MAX = 1024;
|
|
50466
51179
|
/**
|
|
50467
51180
|
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
50468
51181
|
* alternating, no zeros, 2..1024 entries.
|
|
50469
51182
|
*/
|
|
50470
|
-
var IrTimingsSchema = array(number$1().int()).min(2).max(
|
|
51183
|
+
var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
|
|
50471
51184
|
timings.forEach((value, index) => {
|
|
50472
51185
|
const expectMark = index % 2 === 0;
|
|
50473
51186
|
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
@@ -50514,15 +51227,186 @@ function decodePronto(code) {
|
|
|
50514
51227
|
carrierHz: Math.round(1e6 / unitUs)
|
|
50515
51228
|
};
|
|
50516
51229
|
}
|
|
50517
|
-
/**
|
|
50518
|
-
|
|
50519
|
-
|
|
50520
|
-
|
|
50521
|
-
|
|
50522
|
-
|
|
50523
|
-
|
|
50524
|
-
|
|
50525
|
-
|
|
51230
|
+
/**
|
|
51231
|
+
* FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
|
|
51232
|
+
* literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
|
|
51233
|
+
* is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
|
|
51234
|
+
* between the low 5 bits and the next byte.
|
|
51235
|
+
*/
|
|
51236
|
+
var MAX_DISTANCE = 8192;
|
|
51237
|
+
var MAX_LITERAL_RUN = 32;
|
|
51238
|
+
var MIN_MATCH = 3;
|
|
51239
|
+
var MAX_MATCH = 264;
|
|
51240
|
+
/**
|
|
51241
|
+
* Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
|
|
51242
|
+
* can expand ~130x, so the decoder checks this bound before every write.
|
|
51243
|
+
*/
|
|
51244
|
+
var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
|
|
51245
|
+
function fastlzDecompress(input) {
|
|
51246
|
+
const out = [];
|
|
51247
|
+
let ip = 0;
|
|
51248
|
+
const room = (count) => {
|
|
51249
|
+
if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
|
|
51250
|
+
};
|
|
51251
|
+
const next = () => {
|
|
51252
|
+
const byte = input[ip++];
|
|
51253
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
|
|
51254
|
+
return byte;
|
|
51255
|
+
};
|
|
51256
|
+
while (ip < input.length) {
|
|
51257
|
+
const ctrl = next();
|
|
51258
|
+
if (ctrl < 32) {
|
|
51259
|
+
room(ctrl + 1);
|
|
51260
|
+
for (let i = 0; i <= ctrl; i++) out.push(next());
|
|
51261
|
+
continue;
|
|
51262
|
+
}
|
|
51263
|
+
let len = (ctrl >> 5) - 1;
|
|
51264
|
+
if (len === 6) len += next();
|
|
51265
|
+
const distance = ((ctrl & 31) << 8) + next() + 1;
|
|
51266
|
+
const start = out.length - distance;
|
|
51267
|
+
if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
|
|
51268
|
+
room(len + 3);
|
|
51269
|
+
for (let i = 0; i < len + 3; i++) {
|
|
51270
|
+
const byte = out[start + i];
|
|
51271
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
|
|
51272
|
+
out.push(byte);
|
|
51273
|
+
}
|
|
51274
|
+
}
|
|
51275
|
+
return Uint8Array.from(out);
|
|
51276
|
+
}
|
|
51277
|
+
function fastlzCompress(input) {
|
|
51278
|
+
const out = [];
|
|
51279
|
+
const lastSeen = /* @__PURE__ */ new Map();
|
|
51280
|
+
let literalStart = 0;
|
|
51281
|
+
const flushLiterals = (end) => {
|
|
51282
|
+
for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
|
|
51283
|
+
const to = Math.min(from + MAX_LITERAL_RUN, end);
|
|
51284
|
+
out.push(to - from - 1);
|
|
51285
|
+
for (let i = from; i < to; i++) out.push(input[i] ?? 0);
|
|
51286
|
+
}
|
|
51287
|
+
};
|
|
51288
|
+
let pos = 0;
|
|
51289
|
+
while (pos < input.length) {
|
|
51290
|
+
let matchLen = 0;
|
|
51291
|
+
let matchDistance = 0;
|
|
51292
|
+
if (pos + MIN_MATCH <= input.length) {
|
|
51293
|
+
const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
|
|
51294
|
+
const candidate = lastSeen.get(key);
|
|
51295
|
+
lastSeen.set(key, pos);
|
|
51296
|
+
if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
|
|
51297
|
+
let len = 0;
|
|
51298
|
+
while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
|
|
51299
|
+
if (len >= MIN_MATCH) {
|
|
51300
|
+
matchLen = len;
|
|
51301
|
+
matchDistance = pos - candidate - 1;
|
|
51302
|
+
}
|
|
51303
|
+
}
|
|
51304
|
+
}
|
|
51305
|
+
if (matchLen === 0) {
|
|
51306
|
+
pos++;
|
|
51307
|
+
continue;
|
|
51308
|
+
}
|
|
51309
|
+
flushLiterals(pos);
|
|
51310
|
+
const enc = matchLen - 2;
|
|
51311
|
+
if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
|
|
51312
|
+
else out.push(224 | matchDistance >> 8, enc - 7);
|
|
51313
|
+
out.push(matchDistance & 255);
|
|
51314
|
+
pos += matchLen;
|
|
51315
|
+
literalStart = pos;
|
|
51316
|
+
}
|
|
51317
|
+
flushLiterals(input.length);
|
|
51318
|
+
return Uint8Array.from(out);
|
|
51319
|
+
}
|
|
51320
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
51321
|
+
var MAX_DURATION_US = 65535;
|
|
51322
|
+
function toBase64(bytes) {
|
|
51323
|
+
let out = "";
|
|
51324
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
51325
|
+
const a = bytes[i] ?? 0;
|
|
51326
|
+
const b = bytes[i + 1] ?? 0;
|
|
51327
|
+
const c = bytes[i + 2] ?? 0;
|
|
51328
|
+
const word = a << 16 | b << 8 | c;
|
|
51329
|
+
out += ALPHABET[word >> 18 & 63];
|
|
51330
|
+
out += ALPHABET[word >> 12 & 63];
|
|
51331
|
+
out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
|
|
51332
|
+
out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
|
|
51333
|
+
}
|
|
51334
|
+
return out;
|
|
51335
|
+
}
|
|
51336
|
+
function fromBase64(text) {
|
|
51337
|
+
const clean = text.trim().replace(/=+$/, "");
|
|
51338
|
+
if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51339
|
+
const out = [];
|
|
51340
|
+
let bits = 0;
|
|
51341
|
+
let acc = 0;
|
|
51342
|
+
for (const ch of clean) {
|
|
51343
|
+
const value = ALPHABET.indexOf(ch);
|
|
51344
|
+
if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51345
|
+
acc = acc << 6 | value;
|
|
51346
|
+
bits += 6;
|
|
51347
|
+
if (bits >= 8) {
|
|
51348
|
+
bits -= 8;
|
|
51349
|
+
out.push(acc >> bits & 255);
|
|
51350
|
+
}
|
|
51351
|
+
}
|
|
51352
|
+
return Uint8Array.from(out);
|
|
51353
|
+
}
|
|
51354
|
+
/** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
|
|
51355
|
+
function encodeTuya(timings) {
|
|
51356
|
+
const bytes = new Uint8Array(timings.length * 2);
|
|
51357
|
+
timings.forEach((value, index) => {
|
|
51358
|
+
const duration = Math.abs(value);
|
|
51359
|
+
if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
|
|
51360
|
+
bytes[index * 2] = duration & 255;
|
|
51361
|
+
bytes[index * 2 + 1] = duration >> 8;
|
|
51362
|
+
});
|
|
51363
|
+
return toBase64(fastlzCompress(bytes));
|
|
51364
|
+
}
|
|
51365
|
+
/** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
|
|
51366
|
+
function decodeTuya(code) {
|
|
51367
|
+
const bytes = fastlzDecompress(fromBase64(code));
|
|
51368
|
+
if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
|
|
51369
|
+
const timings = [];
|
|
51370
|
+
for (let i = 0; i < bytes.length; i += 2) {
|
|
51371
|
+
const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
|
|
51372
|
+
timings.push(i / 2 % 2 === 0 ? duration : -duration);
|
|
51373
|
+
}
|
|
51374
|
+
const checked = IrTimingsSchema.safeParse(timings);
|
|
51375
|
+
if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
|
|
51376
|
+
return checked.data;
|
|
51377
|
+
}
|
|
51378
|
+
/** Device-native IR code formats a transmitter can replay verbatim. */
|
|
51379
|
+
var IrNativeFormatSchema = _enum(["tuya"]);
|
|
51380
|
+
/**
|
|
51381
|
+
* Longest native code accepted: base64 of the worst-case compressed stream
|
|
51382
|
+
* (every decoded byte as a literal, plus one control byte per 32), with margin.
|
|
51383
|
+
*/
|
|
51384
|
+
var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
|
|
51385
|
+
var IrNativeCodeSchema = object({
|
|
51386
|
+
format: IrNativeFormatSchema,
|
|
51387
|
+
code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
|
|
51388
|
+
});
|
|
51389
|
+
var IR_NATIVE_CODECS = { tuya: {
|
|
51390
|
+
encode: encodeTuya,
|
|
51391
|
+
decode: decodeTuya
|
|
51392
|
+
} };
|
|
51393
|
+
/** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
|
|
51394
|
+
var IrPayloadSchema = discriminatedUnion("kind", [
|
|
51395
|
+
object({
|
|
51396
|
+
kind: literal("raw"),
|
|
51397
|
+
timings: array(number$1().int()),
|
|
51398
|
+
settings: TransmitSettingsSchema.optional()
|
|
51399
|
+
}),
|
|
51400
|
+
object({
|
|
51401
|
+
kind: literal("pronto"),
|
|
51402
|
+
code: string()
|
|
51403
|
+
}),
|
|
51404
|
+
object({
|
|
51405
|
+
kind: literal("native"),
|
|
51406
|
+
format: IrNativeFormatSchema,
|
|
51407
|
+
code: string()
|
|
51408
|
+
})
|
|
51409
|
+
]);
|
|
50526
51410
|
/** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
|
|
50527
51411
|
function toTimings(payload) {
|
|
50528
51412
|
if (payload.kind === "pronto") {
|
|
@@ -50532,6 +51416,10 @@ function toTimings(payload) {
|
|
|
50532
51416
|
settings: { carrierHz: decoded.carrierHz }
|
|
50533
51417
|
};
|
|
50534
51418
|
}
|
|
51419
|
+
if (payload.kind === "native") return {
|
|
51420
|
+
timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
|
|
51421
|
+
settings: {}
|
|
51422
|
+
};
|
|
50535
51423
|
const checked = IrTimingsSchema.safeParse(payload.timings);
|
|
50536
51424
|
if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
|
|
50537
51425
|
return {
|
|
@@ -52672,193 +53560,6 @@ method(object({
|
|
|
52672
53560
|
kind: "mutation",
|
|
52673
53561
|
auth: "admin"
|
|
52674
53562
|
});
|
|
52675
|
-
/**
|
|
52676
|
-
* `device-export` — collection cap for addons that export camstack
|
|
52677
|
-
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
52678
|
-
* HomeKit/HAP, Alexa Smart Home, …).
|
|
52679
|
-
*
|
|
52680
|
-
* No `ecosystem` enum — the addon id identifies the export target.
|
|
52681
|
-
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
52682
|
-
* exposes only the COMMON surface: link state, supported device
|
|
52683
|
-
* kinds (so the UI can filter the device picker), and per-device
|
|
52684
|
-
* expose/unexpose.
|
|
52685
|
-
*
|
|
52686
|
-
* INSTANCES. One export addon can serve several independent targets (a
|
|
52687
|
-
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
52688
|
-
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
52689
|
-
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
52690
|
-
* default instance's); present = that instance; an id the provider does not
|
|
52691
|
-
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
52692
|
-
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
52693
|
-
* change always names the target it changes. A single-instance provider
|
|
52694
|
-
* accepts an absent id on a read or its own id, and refuses any other.
|
|
52695
|
-
*/
|
|
52696
|
-
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
52697
|
-
var InstanceIdSchema$1 = string().min(1);
|
|
52698
|
-
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
52699
|
-
/** One independent export target of an addon. */
|
|
52700
|
-
var ExportInstanceSchema = object({
|
|
52701
|
-
instanceId: InstanceIdSchema$1,
|
|
52702
|
-
name: string(),
|
|
52703
|
-
enabled: boolean(),
|
|
52704
|
-
kind: string().optional()
|
|
52705
|
-
});
|
|
52706
|
-
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
52707
|
-
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
52708
|
-
var ExportInstanceUnknownError = class extends Error {
|
|
52709
|
-
code = EXPORT_INSTANCE_UNKNOWN;
|
|
52710
|
-
instanceId;
|
|
52711
|
-
constructor(addon, instanceId) {
|
|
52712
|
-
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
52713
|
-
this.name = "ExportInstanceUnknownError";
|
|
52714
|
-
this.instanceId = instanceId;
|
|
52715
|
-
}
|
|
52716
|
-
};
|
|
52717
|
-
/**
|
|
52718
|
-
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
52719
|
-
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
52720
|
-
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
52721
|
-
*/
|
|
52722
|
-
function statusInstanceOf(input) {
|
|
52723
|
-
return "instanceId" in input ? input.instanceId : void 0;
|
|
52724
|
-
}
|
|
52725
|
-
var LinkStateSchema = _enum([
|
|
52726
|
-
"unlinked",
|
|
52727
|
-
"linked",
|
|
52728
|
-
"error"
|
|
52729
|
-
]);
|
|
52730
|
-
/**
|
|
52731
|
-
* A single label/value row surfaced in the export panel's "Setup"
|
|
52732
|
-
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
52733
|
-
* rows are masked by default with a reveal toggle (client ids,
|
|
52734
|
-
* secrets, …).
|
|
52735
|
-
*/
|
|
52736
|
-
var ExportSetupFieldSchema = object({
|
|
52737
|
-
label: string(),
|
|
52738
|
-
value: string(),
|
|
52739
|
-
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
52740
|
-
secret: boolean().optional()
|
|
52741
|
-
});
|
|
52742
|
-
/**
|
|
52743
|
-
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
52744
|
-
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
52745
|
-
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
52746
|
-
* the provider supplies and skips the section entirely when `setup`
|
|
52747
|
-
* is unset.
|
|
52748
|
-
*/
|
|
52749
|
-
var ExportSetupSchema = object({
|
|
52750
|
-
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
52751
|
-
qr: string().optional(),
|
|
52752
|
-
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
52753
|
-
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
52754
|
-
/** Free-form operator instructions rendered above the fields. */
|
|
52755
|
-
note: string().optional()
|
|
52756
|
-
});
|
|
52757
|
-
var DeviceExportStatusSchema = object({
|
|
52758
|
-
linkState: LinkStateSchema,
|
|
52759
|
-
exposedDeviceCount: number$1(),
|
|
52760
|
-
error: string().optional(),
|
|
52761
|
-
/**
|
|
52762
|
-
* Optional pairing/account info the panel renders in a generic
|
|
52763
|
-
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
52764
|
-
* export target, never an `ecosystem` key here.
|
|
52765
|
-
*/
|
|
52766
|
-
setup: ExportSetupSchema.optional()
|
|
52767
|
-
});
|
|
52768
|
-
var DeviceKindSchema = string();
|
|
52769
|
-
var ExposedDeviceSchema = object({
|
|
52770
|
-
deviceId: string(),
|
|
52771
|
-
exposedAs: string().optional(),
|
|
52772
|
-
capabilities: array(string()).optional()
|
|
52773
|
-
});
|
|
52774
|
-
var ExposeInputSchema = object({
|
|
52775
|
-
instanceId: InstanceIdSchema$1,
|
|
52776
|
-
deviceId: string(),
|
|
52777
|
-
capabilities: array(string()).optional()
|
|
52778
|
-
});
|
|
52779
|
-
var UnexposeInputSchema = object({
|
|
52780
|
-
instanceId: InstanceIdSchema$1,
|
|
52781
|
-
deviceId: string()
|
|
52782
|
-
});
|
|
52783
|
-
/**
|
|
52784
|
-
* What an exporter may expose besides devices (D968). An action and a
|
|
52785
|
-
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
52786
|
-
* exporter's own selection, not the device registry.
|
|
52787
|
-
*/
|
|
52788
|
-
var ExportEntityKindSchema = _enum([
|
|
52789
|
-
"device",
|
|
52790
|
-
"action",
|
|
52791
|
-
"notifier"
|
|
52792
|
-
]);
|
|
52793
|
-
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
52794
|
-
object({
|
|
52795
|
-
kind: literal("device"),
|
|
52796
|
-
deviceId: string()
|
|
52797
|
-
}),
|
|
52798
|
-
object({
|
|
52799
|
-
kind: literal("action"),
|
|
52800
|
-
actionId: string().min(1)
|
|
52801
|
-
}),
|
|
52802
|
-
object({
|
|
52803
|
-
kind: literal("notifier"),
|
|
52804
|
-
targetId: string().min(1)
|
|
52805
|
-
})
|
|
52806
|
-
]);
|
|
52807
|
-
var ExposedEntitySchema = object({
|
|
52808
|
-
entity: ExportEntityRefSchema,
|
|
52809
|
-
exposedAs: string().optional()
|
|
52810
|
-
});
|
|
52811
|
-
var ExposeEntityInputSchema = object({
|
|
52812
|
-
instanceId: InstanceIdSchema$1,
|
|
52813
|
-
entity: ExportEntityRefSchema
|
|
52814
|
-
});
|
|
52815
|
-
var UnexposeEntityInputSchema = object({
|
|
52816
|
-
instanceId: InstanceIdSchema$1,
|
|
52817
|
-
entity: ExportEntityRefSchema
|
|
52818
|
-
});
|
|
52819
|
-
var deviceExportCapability = {
|
|
52820
|
-
name: "device-export",
|
|
52821
|
-
scope: "system",
|
|
52822
|
-
mode: "collection",
|
|
52823
|
-
providerKind: "device-export",
|
|
52824
|
-
status: {
|
|
52825
|
-
schema: DeviceExportStatusSchema,
|
|
52826
|
-
kind: "poll"
|
|
52827
|
-
},
|
|
52828
|
-
/**
|
|
52829
|
-
* Each export provider MAY contribute its own per-device "Export" panel
|
|
52830
|
-
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
52831
|
-
* framework methods are mounted on the cap router when present.
|
|
52832
|
-
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
52833
|
-
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
52834
|
-
* never hand-written — D14 — and an exporter is not one of those).
|
|
52835
|
-
*/
|
|
52836
|
-
exposesDeviceSettings: true,
|
|
52837
|
-
methods: {
|
|
52838
|
-
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
52839
|
-
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
52840
|
-
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
52841
|
-
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
52842
|
-
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
52843
|
-
kind: "mutation",
|
|
52844
|
-
auth: "admin"
|
|
52845
|
-
}),
|
|
52846
|
-
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
52847
|
-
kind: "mutation",
|
|
52848
|
-
auth: "admin"
|
|
52849
|
-
}),
|
|
52850
|
-
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
52851
|
-
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
52852
|
-
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
52853
|
-
kind: "mutation",
|
|
52854
|
-
auth: "admin"
|
|
52855
|
-
}),
|
|
52856
|
-
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
52857
|
-
kind: "mutation",
|
|
52858
|
-
auth: "admin"
|
|
52859
|
-
})
|
|
52860
|
-
}
|
|
52861
|
-
};
|
|
52862
53563
|
var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
52863
53564
|
var DeviceTemplateSchema = string().min(1).max(4096);
|
|
52864
53565
|
/** One value a caller hands the renderer for `thisDevice`. */
|
|
@@ -55709,29 +56410,6 @@ var EnumSensorStatusSchema = object({
|
|
|
55709
56410
|
lastFetchedAt: number$1()
|
|
55710
56411
|
});
|
|
55711
56412
|
DeviceType.Sensor;
|
|
55712
|
-
/**
|
|
55713
|
-
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
55714
|
-
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
55715
|
-
* (NO normalization). Two shapes:
|
|
55716
|
-
* - structured source (HA `event.*` entity) → `eventTypes` is the fixed
|
|
55717
|
-
* declared vocabulary (e.g. ['press_short','press_long',...]).
|
|
55718
|
-
* - generic/legacy source (HA bus events, e.g. zha_event) → `eventTypes`
|
|
55719
|
-
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
55720
|
-
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
55721
|
-
*/
|
|
55722
|
-
var EventFireSchema = object({
|
|
55723
|
-
deviceId: number$1(),
|
|
55724
|
-
eventType: string(),
|
|
55725
|
-
data: record(string(), unknown()).nullable(),
|
|
55726
|
-
timestamp: number$1().meta(readingMeta("none")),
|
|
55727
|
-
seq: number$1().meta(readingMeta("count"))
|
|
55728
|
-
});
|
|
55729
|
-
var EventEmitterStatusSchema = object({
|
|
55730
|
-
eventTypes: array(string()),
|
|
55731
|
-
lastEvent: EventFireSchema.nullable(),
|
|
55732
|
-
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
55733
|
-
});
|
|
55734
|
-
DeviceType.EventEmitter;
|
|
55735
56413
|
var IdentitySchema = object({
|
|
55736
56414
|
id: string(),
|
|
55737
56415
|
name: string(),
|
|
@@ -57030,6 +57708,128 @@ var StateLookSchema = object({
|
|
|
57030
57708
|
background: _enum(HERO_BACKGROUNDS),
|
|
57031
57709
|
animation: HeroAnimationSchema
|
|
57032
57710
|
});
|
|
57711
|
+
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
57712
|
+
var HeroTextSchema = object({
|
|
57713
|
+
en: string(),
|
|
57714
|
+
it: string()
|
|
57715
|
+
});
|
|
57716
|
+
/**
|
|
57717
|
+
* The ONE measurement a simple sensor shows (card wave, phase 1).
|
|
57718
|
+
*
|
|
57719
|
+
* A sensor that measures a single quantity (a temperature, a humidity, a power,
|
|
57720
|
+
* a contact, a text state) is drawn as that reading, once, big, inside a scene
|
|
57721
|
+
* whose motion says what the number means: heat rising when hot, flakes when
|
|
57722
|
+
* cold, a wire flowing at the speed of the power, a ring while a window is
|
|
57723
|
+
* open. Everything the card draws is decided here; a client only paints it.
|
|
57724
|
+
*/
|
|
57725
|
+
var HERO_MEASUREMENT_QUANTITIES = [
|
|
57726
|
+
"temperature",
|
|
57727
|
+
"humidity",
|
|
57728
|
+
"power",
|
|
57729
|
+
"contact",
|
|
57730
|
+
"text"
|
|
57731
|
+
];
|
|
57732
|
+
/** How a temperature reads to a person; drives the heat or the cold scene. */
|
|
57733
|
+
var HERO_MEASUREMENT_BANDS = [
|
|
57734
|
+
"hot",
|
|
57735
|
+
"mild",
|
|
57736
|
+
"cold"
|
|
57737
|
+
];
|
|
57738
|
+
/** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
|
|
57739
|
+
var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
|
|
57740
|
+
var HeroMeasurementReadingSchema = object({
|
|
57741
|
+
value: number$1(),
|
|
57742
|
+
quantity: ReadingQuantitySchema
|
|
57743
|
+
});
|
|
57744
|
+
var HeroMeasurementSchema = object({
|
|
57745
|
+
quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
|
|
57746
|
+
reading: HeroMeasurementReadingSchema.nullable(),
|
|
57747
|
+
icon: IconKeySchema.nullable(),
|
|
57748
|
+
value: HeroTextSchema,
|
|
57749
|
+
unit: string().nullable(),
|
|
57750
|
+
band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
|
|
57751
|
+
level: number$1().min(0).max(1).nullable(),
|
|
57752
|
+
word: HeroTextSchema,
|
|
57753
|
+
tone: _enum(HERO_TONES),
|
|
57754
|
+
since: number$1().nullable(),
|
|
57755
|
+
sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
|
|
57756
|
+
historyKey: string().nullable()
|
|
57757
|
+
});
|
|
57758
|
+
var same$2 = (text) => t(text, text);
|
|
57759
|
+
var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
|
|
57760
|
+
var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
|
|
57761
|
+
function temperatureBand(celsius) {
|
|
57762
|
+
if (celsius < 12) return "cold";
|
|
57763
|
+
if (celsius > 28) return "hot";
|
|
57764
|
+
return "mild";
|
|
57765
|
+
}
|
|
57766
|
+
var BAND_WORD = {
|
|
57767
|
+
hot: t("Hot", "Caldo"),
|
|
57768
|
+
mild: t("Normal", "Normale"),
|
|
57769
|
+
cold: t("Cold", "Freddo")
|
|
57770
|
+
};
|
|
57771
|
+
var BAND_TONE = {
|
|
57772
|
+
hot: "warning",
|
|
57773
|
+
mild: "muted",
|
|
57774
|
+
cold: "info"
|
|
57775
|
+
};
|
|
57776
|
+
function temperatureMeasurement(celsius, since) {
|
|
57777
|
+
const band = temperatureBand(celsius);
|
|
57778
|
+
return {
|
|
57779
|
+
quantity: "temperature",
|
|
57780
|
+
reading: {
|
|
57781
|
+
value: celsius,
|
|
57782
|
+
quantity: "temperature"
|
|
57783
|
+
},
|
|
57784
|
+
icon: "thermometer",
|
|
57785
|
+
value: same$2(trimmed(celsius, 1)),
|
|
57786
|
+
unit: "°C",
|
|
57787
|
+
band,
|
|
57788
|
+
level: null,
|
|
57789
|
+
word: BAND_WORD[band],
|
|
57790
|
+
tone: BAND_TONE[band],
|
|
57791
|
+
since,
|
|
57792
|
+
sinceKind: "updated",
|
|
57793
|
+
historyKey: "cap:temperature-sensor.temperature"
|
|
57794
|
+
};
|
|
57795
|
+
}
|
|
57796
|
+
function humidityMeasurement(percent, since) {
|
|
57797
|
+
const dry = percent < 30;
|
|
57798
|
+
const humid = percent > 70;
|
|
57799
|
+
return {
|
|
57800
|
+
quantity: "humidity",
|
|
57801
|
+
reading: {
|
|
57802
|
+
value: percent,
|
|
57803
|
+
quantity: "humidity"
|
|
57804
|
+
},
|
|
57805
|
+
icon: "droplets",
|
|
57806
|
+
value: same$2(String(Math.round(percent))),
|
|
57807
|
+
unit: "%",
|
|
57808
|
+
band: null,
|
|
57809
|
+
level: clamp01$1(percent / 100),
|
|
57810
|
+
word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
|
|
57811
|
+
tone: dry || humid ? "warning" : "info",
|
|
57812
|
+
since,
|
|
57813
|
+
sinceKind: "updated",
|
|
57814
|
+
historyKey: "cap:humidity-sensor.humidity"
|
|
57815
|
+
};
|
|
57816
|
+
}
|
|
57817
|
+
function textMeasurement(text, since) {
|
|
57818
|
+
return {
|
|
57819
|
+
quantity: "text",
|
|
57820
|
+
reading: null,
|
|
57821
|
+
icon: null,
|
|
57822
|
+
value: same$2(text),
|
|
57823
|
+
unit: null,
|
|
57824
|
+
band: null,
|
|
57825
|
+
level: null,
|
|
57826
|
+
word: t("Changed", "Cambiato"),
|
|
57827
|
+
tone: "muted",
|
|
57828
|
+
since,
|
|
57829
|
+
sinceKind: "updated",
|
|
57830
|
+
historyKey: null
|
|
57831
|
+
};
|
|
57832
|
+
}
|
|
57033
57833
|
/** The scene as the model carries it. `null` = the device did not say (never a guess). */
|
|
57034
57834
|
var HeroSceneSchema = object({
|
|
57035
57835
|
id: _enum([
|
|
@@ -57081,11 +57881,6 @@ var HeroSceneSchema = object({
|
|
|
57081
57881
|
});
|
|
57082
57882
|
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;
|
|
57083
57883
|
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;
|
|
57084
|
-
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
57085
|
-
var HeroTextSchema = object({
|
|
57086
|
-
en: string(),
|
|
57087
|
-
it: string()
|
|
57088
|
-
});
|
|
57089
57884
|
var HeroRowIdSchema = _enum([
|
|
57090
57885
|
"progress",
|
|
57091
57886
|
"run-for",
|
|
@@ -57191,6 +57986,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
|
|
|
57191
57986
|
optionLabels: record(string(), HeroTextSchema).optional(),
|
|
57192
57987
|
call: HeroCallSchema,
|
|
57193
57988
|
valueArg: string()
|
|
57989
|
+
}),
|
|
57990
|
+
object({
|
|
57991
|
+
kind: literal("number"),
|
|
57992
|
+
id: string(),
|
|
57993
|
+
label: HeroTextSchema,
|
|
57994
|
+
value: number$1().nullable(),
|
|
57995
|
+
/** `null` = any number; the device rounds what it does not accept. */
|
|
57996
|
+
step: number$1().nullable(),
|
|
57997
|
+
unit: string(),
|
|
57998
|
+
call: HeroCallSchema,
|
|
57999
|
+
valueArg: string()
|
|
58000
|
+
}),
|
|
58001
|
+
object({
|
|
58002
|
+
kind: literal("text"),
|
|
58003
|
+
id: string(),
|
|
58004
|
+
label: HeroTextSchema,
|
|
58005
|
+
value: string().nullable(),
|
|
58006
|
+
call: HeroCallSchema,
|
|
58007
|
+
valueArg: string()
|
|
57194
58008
|
})
|
|
57195
58009
|
]);
|
|
57196
58010
|
/** Declared by its interface: a `z.infer` of one more icon union pushes the cap's inferred type past what the compiler can print. */
|
|
@@ -57392,6 +58206,11 @@ var HeroModelSchema = object({
|
|
|
57392
58206
|
timedRun: HeroTimedRunSlotSchema.nullable(),
|
|
57393
58207
|
powerSupply: HeroPowerSupplySlotSchema.nullable(),
|
|
57394
58208
|
rows: array(HeroRowSchema),
|
|
58209
|
+
/**
|
|
58210
|
+
* The ONE measurement of a simple sensor, drawn once inside the scene in place of
|
|
58211
|
+
* the caption, tiles and value chips. Absent = the card draws as before.
|
|
58212
|
+
*/
|
|
58213
|
+
measurement: HeroMeasurementSchema.optional(),
|
|
57395
58214
|
/** Ids of parts that actuate the device, hidden from a session that may not act on it. */
|
|
57396
58215
|
gated: array(string()),
|
|
57397
58216
|
provenance: array(HeroProvenanceSchema)
|
|
@@ -57463,8 +58282,23 @@ var HeroRowModelSchema = object({
|
|
|
57463
58282
|
* the call. Absent or empty = `primary` alone.
|
|
57464
58283
|
*/
|
|
57465
58284
|
extras: array(HeroControlSchema).max(2).optional(),
|
|
57466
|
-
trailing: HeroFactSchema.nullable()
|
|
58285
|
+
trailing: HeroFactSchema.nullable(),
|
|
58286
|
+
/**
|
|
58287
|
+
* The simple sensor's one reading (the hero's `measurement`): the row draws its value
|
|
58288
|
+
* at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
|
|
58289
|
+
* older server or a device that is not a simple sensor: draw `trailing`.
|
|
58290
|
+
*/
|
|
58291
|
+
measurement: HeroMeasurementSchema.optional()
|
|
57467
58292
|
});
|
|
58293
|
+
new Set([
|
|
58294
|
+
"temperature",
|
|
58295
|
+
"humidity",
|
|
58296
|
+
"pressure",
|
|
58297
|
+
"illuminance",
|
|
58298
|
+
"reading",
|
|
58299
|
+
"air-quality",
|
|
58300
|
+
"valve"
|
|
58301
|
+
]);
|
|
57468
58302
|
DeviceType.Climate;
|
|
57469
58303
|
DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
|
|
57470
58304
|
/**
|
|
@@ -57781,6 +58615,12 @@ var IntegrationLiteSchema = object({
|
|
|
57781
58615
|
var AvailableIntegrationTypeSchema = object({
|
|
57782
58616
|
addonId: string(),
|
|
57783
58617
|
name: string(),
|
|
58618
|
+
/**
|
|
58619
|
+
* Product name a new integration is prefilled from (`<label> - Home`).
|
|
58620
|
+
* Absent: the client uses `name`. Set when the catalog title is not the
|
|
58621
|
+
* product (Bosch SHC, MQTT).
|
|
58622
|
+
*/
|
|
58623
|
+
providerLabel: string().optional(),
|
|
57784
58624
|
description: string(),
|
|
57785
58625
|
iconUrl: string().nullable(),
|
|
57786
58626
|
color: string(),
|
|
@@ -58292,13 +59132,32 @@ var IrSendResultSchema = object({
|
|
|
58292
59132
|
var IrTransmitterInfoSchema = object({
|
|
58293
59133
|
media: array(IrMediumSchema),
|
|
58294
59134
|
settable: array(TransmitSettingKeySchema),
|
|
58295
|
-
maxTimings: number$1().int().positive()
|
|
59135
|
+
maxTimings: number$1().int().positive(),
|
|
59136
|
+
/** The transmitter can learn a code (`learn`). */
|
|
59137
|
+
learn: boolean().default(false),
|
|
59138
|
+
/** Native code formats the transmitter replays verbatim (`send.native`). */
|
|
59139
|
+
formats: array(IrNativeFormatSchema).default([])
|
|
59140
|
+
});
|
|
59141
|
+
var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
|
|
59142
|
+
var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
|
|
59143
|
+
var IrLearnResultSchema = object({
|
|
59144
|
+
/** The code in the device's own format, when it reports one. */
|
|
59145
|
+
native: IrNativeCodeSchema.nullable(),
|
|
59146
|
+
timings: IrTimingsSchema,
|
|
59147
|
+
carrierHz: number$1().int().positive().nullable()
|
|
58296
59148
|
});
|
|
58297
59149
|
DeviceType.Generic, method(object({
|
|
58298
59150
|
deviceId: number$1().int().nonnegative(),
|
|
58299
|
-
timings: IrTimingsSchema,
|
|
59151
|
+
timings: IrTimingsSchema.optional(),
|
|
59152
|
+
native: IrNativeCodeSchema.optional(),
|
|
58300
59153
|
settings: TransmitSettingsSchema.optional()
|
|
58301
|
-
}), IrSendResultSchema, {
|
|
59154
|
+
}).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
|
|
59155
|
+
kind: "mutation",
|
|
59156
|
+
auth: "protected"
|
|
59157
|
+
}), method(object({
|
|
59158
|
+
deviceId: number$1().int().nonnegative(),
|
|
59159
|
+
timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
|
|
59160
|
+
}), IrLearnResultSchema, {
|
|
58302
59161
|
kind: "mutation",
|
|
58303
59162
|
auth: "protected"
|
|
58304
59163
|
}), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
|
|
@@ -67521,6 +68380,7 @@ var NcSystemEventKindSchema = _enum([
|
|
|
67521
68380
|
"recording-degraded",
|
|
67522
68381
|
"device-attention-required",
|
|
67523
68382
|
"device-attention-resolved",
|
|
68383
|
+
"device-command",
|
|
67524
68384
|
"storage-location-low",
|
|
67525
68385
|
"storage-location-critical",
|
|
67526
68386
|
"storage-location-ok",
|
|
@@ -67583,11 +68443,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
|
|
|
67583
68443
|
"alarm-sensor-bypass",
|
|
67584
68444
|
"alarm-disarmed"
|
|
67585
68445
|
];
|
|
67586
|
-
/**
|
|
67587
|
-
* One coherent system-event condition. `kinds` is the required opt-in safety
|
|
67588
|
-
* gate; the remaining lists are optional narrowing filters relevant to the
|
|
67589
|
-
* selected kinds.
|
|
67590
|
-
*/
|
|
67591
68446
|
var NcSystemEventConditionSchema = object({
|
|
67592
68447
|
kinds: array(NcSystemEventKindSchema).min(1),
|
|
67593
68448
|
deviceIds: array(number$1().int()).min(1).optional(),
|
|
@@ -67619,6 +68474,28 @@ var NcSystemEventConditionSchema = object({
|
|
|
67619
68474
|
nodeIds: array(string().min(1)).min(1).optional(),
|
|
67620
68475
|
packageNames: array(string().min(1)).min(1).optional(),
|
|
67621
68476
|
/**
|
|
68477
|
+
* `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
|
|
68478
|
+
* this rule speaks about - the same dictionary the automation action blocks
|
|
68479
|
+
* pick from. The hub refuses an id the action index does not know.
|
|
68480
|
+
*/
|
|
68481
|
+
commandActions: array(string().min(1)).min(1).optional(),
|
|
68482
|
+
/** `device-command` only: how the command settled. A device's own change is not a command. */
|
|
68483
|
+
commandOutcomes: array(_enum([
|
|
68484
|
+
"confirmed",
|
|
68485
|
+
"already",
|
|
68486
|
+
"unconfirmed",
|
|
68487
|
+
"failed"
|
|
68488
|
+
])).min(1).optional(),
|
|
68489
|
+
/** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
|
|
68490
|
+
commandActorKinds: array(_enum([
|
|
68491
|
+
"user",
|
|
68492
|
+
"addon",
|
|
68493
|
+
"action",
|
|
68494
|
+
"scheduler",
|
|
68495
|
+
"composition",
|
|
68496
|
+
"node"
|
|
68497
|
+
])).min(1).optional(),
|
|
68498
|
+
/**
|
|
67622
68499
|
* At or below this remaining-life %, a consumable is LOW for THIS rule
|
|
67623
68500
|
* (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
|
|
67624
68501
|
* {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
|
|
@@ -68599,6 +69476,13 @@ var NcRuleInputSchema = object({
|
|
|
68599
69476
|
*/
|
|
68600
69477
|
groupingSec: number$1().int().min(5).max(60).optional(),
|
|
68601
69478
|
/**
|
|
69479
|
+
* Hold deliveries of this rule to one target and, when two or more arrive
|
|
69480
|
+
* before the window ends, send them as one summary. Absent = the kind's
|
|
69481
|
+
* default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
|
|
69482
|
+
* other kind. `0` sends each delivery as it does today.
|
|
69483
|
+
*/
|
|
69484
|
+
groupWithinSec: number$1().int().min(0).max(300).optional(),
|
|
69485
|
+
/**
|
|
68602
69486
|
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
68603
69487
|
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
68604
69488
|
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
@@ -69035,7 +69919,12 @@ var NcHistoryEntrySchema = object({
|
|
|
69035
69919
|
* Assistant export) must render as "no image right now", never as a
|
|
69036
69920
|
* broken link.
|
|
69037
69921
|
*/
|
|
69038
|
-
artifactIds: array(string().min(1)).optional()
|
|
69922
|
+
artifactIds: array(string().min(1)).optional(),
|
|
69923
|
+
/**
|
|
69924
|
+
* When this row was folded into a group-window summary, the outbox id of
|
|
69925
|
+
* that one notification. Absent on a row that was sent as itself.
|
|
69926
|
+
*/
|
|
69927
|
+
groupedInto: string().min(1).optional()
|
|
69039
69928
|
});
|
|
69040
69929
|
/**
|
|
69041
69930
|
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
@@ -69922,7 +70811,18 @@ var OauthIntegrationDescriptorSchema = object({
|
|
|
69922
70811
|
* The value is baked into the authorization code at `/authorize` and travels
|
|
69923
70812
|
* on the tokens, so editing this field changes FUTURE links only.
|
|
69924
70813
|
*/
|
|
69925
|
-
refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional()
|
|
70814
|
+
refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional(),
|
|
70815
|
+
/**
|
|
70816
|
+
* The integration instances an account can be linked to (planning#415),
|
|
70817
|
+
* beside the default one. `/api/oauth2/authorize?instance=<id>` is accepted
|
|
70818
|
+
* only for an id listed here; with no `instance=` the link is made to the
|
|
70819
|
+
* default instance, which is never listed and always accepted — it is the
|
|
70820
|
+
* address third parties already hold. Omit for a single-instance integration.
|
|
70821
|
+
*/
|
|
70822
|
+
instances: array(object({
|
|
70823
|
+
id: string(),
|
|
70824
|
+
displayName: string()
|
|
70825
|
+
})).optional()
|
|
69926
70826
|
});
|
|
69927
70827
|
method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
|
|
69928
70828
|
/**
|
|
@@ -74664,10 +75564,15 @@ var RecordingSignalStatusSchema = object({
|
|
|
74664
75564
|
});
|
|
74665
75565
|
RecordingSignalStatusSchema.extend({ lastFetchedAt: number$1() });
|
|
74666
75566
|
DeviceType.Camera, method(object({ deviceId: number$1() }), RecordingSignalStatusSchema);
|
|
74667
|
-
var RemoteBindingSchema = object({ action:
|
|
74668
|
-
|
|
74669
|
-
|
|
74670
|
-
|
|
75567
|
+
var RemoteBindingSchema = object({ action: object({
|
|
75568
|
+
kind: literal("cap"),
|
|
75569
|
+
deviceId: number$1().int().nonnegative(),
|
|
75570
|
+
cap: string().min(1),
|
|
75571
|
+
method: string().min(1),
|
|
75572
|
+
args: record(string(), unknown()).optional(),
|
|
75573
|
+
/** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
|
|
75574
|
+
argUnits: record(string(), string().min(1)).optional()
|
|
75575
|
+
}) });
|
|
74671
75576
|
var RemoteCustomButtonSchema = object({
|
|
74672
75577
|
/** The slug after `custom:` in the role. */
|
|
74673
75578
|
key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
|
|
@@ -76244,6 +77149,13 @@ var SsoBridgeClaimsSchema = object({
|
|
|
76244
77149
|
/** OAuth authorization-code binding — set only on `oauth-code` tokens. */
|
|
76245
77150
|
redirectUri: string().optional(),
|
|
76246
77151
|
integrationId: string().optional(),
|
|
77152
|
+
/**
|
|
77153
|
+
* The integration INSTANCE an OAuth link was made for (planning#415). Set on
|
|
77154
|
+
* `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
|
|
77155
|
+
* with `instance=`; absent on a link to the default instance. A cloud relay
|
|
77156
|
+
* reads it off the access token to route; the hub answers from the session.
|
|
77157
|
+
*/
|
|
77158
|
+
instanceId: string().optional(),
|
|
76247
77159
|
/** JWT ID — unique per issued code; consumed-set enforces single-use. */
|
|
76248
77160
|
jti: string().optional(),
|
|
76249
77161
|
/** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
|
|
@@ -78325,6 +79237,8 @@ var OauthSessionSummarySchema = object({
|
|
|
78325
79237
|
userId: string(),
|
|
78326
79238
|
username: string(),
|
|
78327
79239
|
integrationId: string(),
|
|
79240
|
+
/** The instance the link was made for; `null` = the default instance. */
|
|
79241
|
+
instanceId: string().nullable().optional(),
|
|
78328
79242
|
scopes: array(TokenScopeSchema),
|
|
78329
79243
|
createdAt: number$1(),
|
|
78330
79244
|
lastUsedAt: number$1(),
|
|
@@ -78424,6 +79338,9 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
|
|
|
78424
79338
|
access: "view"
|
|
78425
79339
|
}), method(object({
|
|
78426
79340
|
integrationId: string(),
|
|
79341
|
+
/** The integration instance the link is for. Omit for the default
|
|
79342
|
+
* instance — never pass the addon id to mean it. */
|
|
79343
|
+
instanceId: string().optional(),
|
|
78427
79344
|
userId: string(),
|
|
78428
79345
|
username: string(),
|
|
78429
79346
|
scopes: array(TokenScopeSchema),
|
|
@@ -78462,7 +79379,13 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
|
|
|
78462
79379
|
}), method(object({ token: string() }), object({
|
|
78463
79380
|
userId: string(),
|
|
78464
79381
|
username: string(),
|
|
78465
|
-
scopes: array(TokenScopeSchema)
|
|
79382
|
+
scopes: array(TokenScopeSchema),
|
|
79383
|
+
/** The instance the link was made for, read from the SESSION.
|
|
79384
|
+
* Absent = the default instance. `oauthLinkServesInstance` is the
|
|
79385
|
+
* helper a per-instance route calls to compare it with the instance
|
|
79386
|
+
* of its path; no route declares `perInstance` yet (the Alexa
|
|
79387
|
+
* per-instance route, T3, is the first consumer). */
|
|
79388
|
+
instanceId: string().optional()
|
|
78466
79389
|
}).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
|
|
78467
79390
|
userId: string(),
|
|
78468
79391
|
issuer: string()
|
|
@@ -80076,6 +80999,13 @@ function contribution(cap, schema, build) {
|
|
|
80076
80999
|
}
|
|
80077
81000
|
};
|
|
80078
81001
|
}
|
|
81002
|
+
/** The fragment, carrying the cap's single measurement when it has one. */
|
|
81003
|
+
function measured(fragment, measurement) {
|
|
81004
|
+
return measurement === void 0 ? fragment : {
|
|
81005
|
+
...fragment,
|
|
81006
|
+
measurement
|
|
81007
|
+
};
|
|
81008
|
+
}
|
|
80079
81009
|
function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
|
|
80080
81010
|
return {
|
|
80081
81011
|
id,
|
|
@@ -81350,10 +82280,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
|
|
|
81350
82280
|
};
|
|
81351
82281
|
});
|
|
81352
82282
|
var CONTROL_LABEL = t("Value", "Valore");
|
|
81353
|
-
/**
|
|
82283
|
+
/**
|
|
82284
|
+
* A number with known bounds is a slider, one without a number field, a choice a picker,
|
|
82285
|
+
* free text a text field; a date stays read-only.
|
|
82286
|
+
*/
|
|
81354
82287
|
function controlRows(slice) {
|
|
81355
82288
|
if (slice.kind === "numeric" && typeof slice.value === "number") {
|
|
81356
|
-
if (slice.min === void 0 || slice.max === void 0) return [
|
|
82289
|
+
if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
|
|
82290
|
+
kind: "number",
|
|
82291
|
+
id: "control.value",
|
|
82292
|
+
label: CONTROL_LABEL,
|
|
82293
|
+
value: slice.value,
|
|
82294
|
+
step: slice.step ?? null,
|
|
82295
|
+
unit: "",
|
|
82296
|
+
call: {
|
|
82297
|
+
cap: "control",
|
|
82298
|
+
method: "setValue",
|
|
82299
|
+
args: { control: { kind: "numeric" } }
|
|
82300
|
+
},
|
|
82301
|
+
valueArg: "control.value"
|
|
82302
|
+
}])];
|
|
81357
82303
|
return [row$1("control", "sliders-horizontal", null, [{
|
|
81358
82304
|
kind: "slider",
|
|
81359
82305
|
id: "control.value",
|
|
@@ -81384,6 +82330,18 @@ function controlRows(slice) {
|
|
|
81384
82330
|
},
|
|
81385
82331
|
valueArg: "control.value"
|
|
81386
82332
|
}])];
|
|
82333
|
+
if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
|
|
82334
|
+
kind: "text",
|
|
82335
|
+
id: "control.value",
|
|
82336
|
+
label: CONTROL_LABEL,
|
|
82337
|
+
value: typeof slice.value === "string" ? slice.value : null,
|
|
82338
|
+
call: {
|
|
82339
|
+
cap: "control",
|
|
82340
|
+
method: "setValue",
|
|
82341
|
+
args: { control: { kind: "text" } }
|
|
82342
|
+
},
|
|
82343
|
+
valueArg: "control.value"
|
|
82344
|
+
}])];
|
|
81387
82345
|
return [];
|
|
81388
82346
|
}
|
|
81389
82347
|
var SENSORS_FAMILY_CONTRIBUTIONS = {
|
|
@@ -81739,15 +82697,15 @@ function sensorFragment(value, id, icon, en, it, text) {
|
|
|
81739
82697
|
tiles: { right: [tile$1(en, it, text)] }
|
|
81740
82698
|
};
|
|
81741
82699
|
}
|
|
81742
|
-
var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
|
|
81743
|
-
var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`));
|
|
82700
|
+
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)));
|
|
82701
|
+
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)));
|
|
81744
82702
|
var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
|
|
81745
82703
|
var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
|
|
81746
82704
|
var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
|
|
81747
82705
|
var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
|
|
81748
82706
|
if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
|
|
81749
82707
|
if (slice.timestamp === true) return { reading: reading("sensor", "on") };
|
|
81750
|
-
return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
|
|
82708
|
+
return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
|
|
81751
82709
|
});
|
|
81752
82710
|
/** Index bands: the headline of an air-quality sensor is a word, not a number. */
|
|
81753
82711
|
function airQualityWord(aqi) {
|
|
@@ -84643,6 +85601,13 @@ Object.freeze({
|
|
|
84643
85601
|
access: "view",
|
|
84644
85602
|
role: "admin"
|
|
84645
85603
|
},
|
|
85604
|
+
"deviceExport.setExposedName": {
|
|
85605
|
+
capName: "device-export",
|
|
85606
|
+
capScope: "system",
|
|
85607
|
+
addonId: null,
|
|
85608
|
+
access: "create",
|
|
85609
|
+
role: "admin"
|
|
85610
|
+
},
|
|
84646
85611
|
"deviceExport.unexposeDevice": {
|
|
84647
85612
|
capName: "device-export",
|
|
84648
85613
|
capScope: "system",
|
|
@@ -86582,6 +87547,13 @@ Object.freeze({
|
|
|
86582
87547
|
access: "view",
|
|
86583
87548
|
role: "viewer"
|
|
86584
87549
|
},
|
|
87550
|
+
"irTransmitter.learn": {
|
|
87551
|
+
capName: "ir-transmitter",
|
|
87552
|
+
capScope: "device",
|
|
87553
|
+
addonId: null,
|
|
87554
|
+
access: "create",
|
|
87555
|
+
role: "viewer"
|
|
87556
|
+
},
|
|
86585
87557
|
"irTransmitter.send": {
|
|
86586
87558
|
capName: "ir-transmitter",
|
|
86587
87559
|
capScope: "device",
|
|
@@ -93100,48 +94072,6 @@ Object.freeze({
|
|
|
93100
94072
|
role: "admin"
|
|
93101
94073
|
}
|
|
93102
94074
|
});
|
|
93103
|
-
/**
|
|
93104
|
-
* "Do" actions an operator can pick for a device — presentation-free.
|
|
93105
|
-
*
|
|
93106
|
-
* The wire shape stays `{ cap, method, args }`. Since D920 this module no
|
|
93107
|
-
* longer HOLDS a catalogue: {@link DEVICE_DO_ACTIONS} is a projection of the
|
|
93108
|
-
* cap vocabulary (`cap-vocabulary/`), the one cap-keyed map of every action
|
|
93109
|
-
* and trigger — so a picker built on this module and one built on
|
|
93110
|
-
* `actionsForDevice` (the vocabulary resolver) can never disagree about what
|
|
93111
|
-
* a device can do. Ids, baked args and the matching of saved steps are the
|
|
93112
|
-
* vocabulary's; labels here are its English labels.
|
|
93113
|
-
*
|
|
93114
|
-
* Shared by the admin NC Sequences / rule Do editor and Automations; the
|
|
93115
|
-
* viewer can reuse the same catalogue once its step editor catches up.
|
|
93116
|
-
*/
|
|
93117
|
-
function openArgKind(offer) {
|
|
93118
|
-
if (offer.kind === "number") return "number";
|
|
93119
|
-
if (offer.kind === "dynamic" && offer.valueKind === "number") return "number";
|
|
93120
|
-
if (offer.kind === "enum" && offer.values.every((v) => typeof v.value === "number")) return "number";
|
|
93121
|
-
return "string";
|
|
93122
|
-
}
|
|
93123
|
-
function projectOpenArg(arg) {
|
|
93124
|
-
return {
|
|
93125
|
-
key: arg.key,
|
|
93126
|
-
label: arg.label.en,
|
|
93127
|
-
kind: openArgKind(arg.offer),
|
|
93128
|
-
offer: arg.offer,
|
|
93129
|
-
...arg.optional === true ? { optional: true } : {}
|
|
93130
|
-
};
|
|
93131
|
-
}
|
|
93132
|
-
function projectAction(cap, action) {
|
|
93133
|
-
const open = action.openArgs ?? [];
|
|
93134
|
-
return {
|
|
93135
|
-
id: action.id,
|
|
93136
|
-
label: action.label.en,
|
|
93137
|
-
cap,
|
|
93138
|
-
method: action.method,
|
|
93139
|
-
args: action.args ?? {},
|
|
93140
|
-
...open.length > 0 ? { openArgs: open.map(projectOpenArg) } : {}
|
|
93141
|
-
};
|
|
93142
|
-
}
|
|
93143
|
-
Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
|
|
93144
|
-
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;
|
|
93145
94075
|
DeviceFeature.BatteryOperated;
|
|
93146
94076
|
function bound(cap, methods = [], authority = "reported") {
|
|
93147
94077
|
return {
|
|
@@ -94458,6 +95388,11 @@ Object.freeze({
|
|
|
94458
95388
|
form: "single",
|
|
94459
95389
|
optional: false
|
|
94460
95390
|
}],
|
|
95391
|
+
"irTransmitter.learn": [{
|
|
95392
|
+
name: "deviceId",
|
|
95393
|
+
form: "single",
|
|
95394
|
+
optional: false
|
|
95395
|
+
}],
|
|
94461
95396
|
"irTransmitter.send": [{
|
|
94462
95397
|
name: "deviceId",
|
|
94463
95398
|
form: "single",
|
|
@@ -96397,7 +97332,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
|
|
|
96397
97332
|
"deviceTypes",
|
|
96398
97333
|
"nodeIds",
|
|
96399
97334
|
"packageNames",
|
|
96400
|
-
"consumableLowPercent"
|
|
97335
|
+
"consumableLowPercent",
|
|
97336
|
+
"commandActions",
|
|
97337
|
+
"commandOutcomes",
|
|
97338
|
+
"commandActorKinds"
|
|
96401
97339
|
];
|
|
96402
97340
|
new Map(Object.entries({
|
|
96403
97341
|
"device-online": "device-events",
|
|
@@ -96420,6 +97358,7 @@ new Map(Object.entries({
|
|
|
96420
97358
|
"recording-degraded": "device-events",
|
|
96421
97359
|
"device-attention-required": "device-events",
|
|
96422
97360
|
"device-attention-resolved": "device-events",
|
|
97361
|
+
"device-command": "device-events",
|
|
96423
97362
|
"node-online": "system",
|
|
96424
97363
|
"node-offline": "system",
|
|
96425
97364
|
"node-restarting": "system",
|
|
@@ -96520,6 +97459,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
|
|
|
96520
97459
|
label: "Needs attention",
|
|
96521
97460
|
kinds: ["device-attention-required", "device-attention-resolved"]
|
|
96522
97461
|
},
|
|
97462
|
+
{
|
|
97463
|
+
id: "device-command",
|
|
97464
|
+
family: "device-events",
|
|
97465
|
+
label: "Commands given to devices",
|
|
97466
|
+
kinds: ["device-command"]
|
|
97467
|
+
},
|
|
96523
97468
|
{
|
|
96524
97469
|
id: "nodes",
|
|
96525
97470
|
family: "system",
|
|
@@ -96597,6 +97542,15 @@ function systemEventKindsOfFamily(family) {
|
|
|
96597
97542
|
return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
|
|
96598
97543
|
}
|
|
96599
97544
|
NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
|
|
97545
|
+
new Set([
|
|
97546
|
+
"alarm.trigger",
|
|
97547
|
+
"alarm.disarm",
|
|
97548
|
+
"alarm.arm.home",
|
|
97549
|
+
"alarm.arm.away",
|
|
97550
|
+
"alarm.arm.night",
|
|
97551
|
+
"alarm.arm.vacation",
|
|
97552
|
+
"alarm.arm.custom_bypass"
|
|
97553
|
+
]);
|
|
96600
97554
|
/**
|
|
96601
97555
|
* WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
|
|
96602
97556
|
* persists (D640 "a sensor rule fires on the raise, the clear, or both").
|
|
@@ -96792,6 +97746,7 @@ var DEVICE_EVENTS = [
|
|
|
96792
97746
|
"recording-healthy",
|
|
96793
97747
|
"recording-degraded",
|
|
96794
97748
|
...DEVICE_ATTENTION,
|
|
97749
|
+
"device-command",
|
|
96795
97750
|
...ALARM
|
|
96796
97751
|
];
|
|
96797
97752
|
/** Every kind a summary may speak about — the two summarisable families. */
|
|
@@ -96945,6 +97900,9 @@ var STATE_SUMMARY_VARS = [
|
|
|
96945
97900
|
[...RULE_BODY_ONLY],
|
|
96946
97901
|
[...RULE_TEXT],
|
|
96947
97902
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
97903
|
+
[...RULE_TEXT],
|
|
97904
|
+
[...RULE_TEXT],
|
|
97905
|
+
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
96948
97906
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96949
97907
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96950
97908
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
@@ -145072,6 +146030,160 @@ function carryForward(base, existing, keys) {
|
|
|
145072
146030
|
}
|
|
145073
146031
|
return out;
|
|
145074
146032
|
}
|
|
146033
|
+
/**
|
|
146034
|
+
* hap-nodejs' `checkName` regex, verbatim.
|
|
146035
|
+
*
|
|
146036
|
+
* Duplicated rather than imported because it is `@private Private API` in that
|
|
146037
|
+
* package and not exported. Duplicating a private regex is a liability, so the
|
|
146038
|
+
* guard against drift is behavioural, not textual: `service-naming.spec.ts`
|
|
146039
|
+
* builds real services and asserts hap-nodejs emits ZERO characteristic
|
|
146040
|
+
* warnings — if this expression ever diverges from theirs, that test fails.
|
|
146041
|
+
*/
|
|
146042
|
+
var HAP_NAME_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N}\p{Zs}’'&!._:;()/,-]*[\p{L}\p{N}]$/u;
|
|
146043
|
+
/** Characters HAP tolerates INSIDE a name. Anything else becomes a space. */
|
|
146044
|
+
var HAP_NAME_INNER = /[^\p{L}\p{N}\p{Zs}’'&!._:;()/,-]/gu;
|
|
146045
|
+
/** Would hap-nodejs accept this as a `Name` characteristic value? */
|
|
146046
|
+
function isHapServiceName(value) {
|
|
146047
|
+
return HAP_NAME_PATTERN.test(value);
|
|
146048
|
+
}
|
|
146049
|
+
/**
|
|
146050
|
+
* Build one HAP-valid service name from device-derived parts.
|
|
146051
|
+
*
|
|
146052
|
+
* Empty and absent parts are dropped rather than joined, so a missing role
|
|
146053
|
+
* never produces a double space. `fallback` is used ONLY when nothing
|
|
146054
|
+
* device-derived survives sanitisation — it is the last resort, not the
|
|
146055
|
+
* default, because a name that says nothing about the device is the defect
|
|
146056
|
+
* this module exists to end.
|
|
146057
|
+
*/
|
|
146058
|
+
function hapServiceName(parts, fallback) {
|
|
146059
|
+
const trimmed = trimToHapName(parts.map((part) => typeof part === "string" ? part : "").map((part) => part.replace(HAP_NAME_INNER, " ")).join(" ").replace(/\s+/gu, " ").trim());
|
|
146060
|
+
if (trimmed !== null) return trimmed;
|
|
146061
|
+
return trimToHapName(fallback.replace(HAP_NAME_INNER, " ").replace(/\s+/gu, " ").trim()) ?? "";
|
|
146062
|
+
}
|
|
146063
|
+
/**
|
|
146064
|
+
* The privacy-mask switch.
|
|
146065
|
+
*
|
|
146066
|
+
* Just "Privacy". The camera name is NOT prefixed: this service lives inside
|
|
146067
|
+
* the camera's own accessory, iOS already renders it under the camera, and a
|
|
146068
|
+
* round that prefixed it gave the operator "Camera front door Privacy"
|
|
146069
|
+
* sitting inside a tile titled "Camera front door".
|
|
146070
|
+
*
|
|
146071
|
+
* The prefix was added for a real reason — two cameras publishing a switch
|
|
146072
|
+
* called "Privacy" — but that was a symptom of the label being the ONLY thing
|
|
146073
|
+
* shown, which stopped being true once `ConfiguredName` made the service
|
|
146074
|
+
* render in its accessory's context. Uniqueness is required WITHIN one
|
|
146075
|
+
* accessory, not across the bridge, and one camera has one privacy switch.
|
|
146076
|
+
*/
|
|
146077
|
+
function privacyServiceName() {
|
|
146078
|
+
return hapServiceName([PRIVACY_SUFFIX], PRIVACY_SUFFIX);
|
|
146079
|
+
}
|
|
146080
|
+
/**
|
|
146081
|
+
* Deliberately not localised, and deliberately not a translation table.
|
|
146082
|
+
*
|
|
146083
|
+
* The device half of the name is the operator's own text and arrives in the
|
|
146084
|
+
* operator's language. This half names a camstack capability (`privacy-mask`)
|
|
146085
|
+
* and there is no locale in an addon's context to resolve it against; the word
|
|
146086
|
+
* is also identical in the operator's language. A translation layer for one
|
|
146087
|
+
* word would be the kind of leftover that reads as verification.
|
|
146088
|
+
*/
|
|
146089
|
+
var PRIVACY_SUFFIX = "Privacy";
|
|
146090
|
+
/**
|
|
146091
|
+
* An accessory child (siren, floodlight, spotlight) rendered as a service on
|
|
146092
|
+
* the parent camera.
|
|
146093
|
+
*
|
|
146094
|
+
* The child's OWN stored name wins. It is the string the operator typed, in
|
|
146095
|
+
* the operator's language, and an early rule threw it away: `role` was
|
|
146096
|
+
* consulted first and title-cased, so every siren on the fleet published as
|
|
146097
|
+
* the English word "Siren" no matter what the operator had called it.
|
|
146098
|
+
*
|
|
146099
|
+
* Providers name children both ways — "Sirena" and "Camera kitchen
|
|
146100
|
+
* Sirena". The parent half is now REMOVED rather than added, because the
|
|
146101
|
+
* service is published inside the parent camera's own accessory and iOS
|
|
146102
|
+
* already shows it there. The result must be one form, not two.
|
|
146103
|
+
*/
|
|
146104
|
+
function childServiceName(parentName, child) {
|
|
146105
|
+
const own = withoutParent(child.name.trim(), parentName);
|
|
146106
|
+
if (own.length > 0) return hapServiceName([own], own);
|
|
146107
|
+
return hapServiceName([typeof child.role === "string" ? titleCase(child.role) : ""], CHILD_FALLBACK);
|
|
146108
|
+
}
|
|
146109
|
+
/**
|
|
146110
|
+
* Last resort for a child that carries neither a name nor a role. Better than
|
|
146111
|
+
* the parent's name, which would publish a service indistinguishable from the
|
|
146112
|
+
* accessory holding it — the exact defect this module keeps being asked to fix.
|
|
146113
|
+
*
|
|
146114
|
+
* English, like the role slugs it stands in for ("Floodlight", "Siren"): the
|
|
146115
|
+
* only strings this module invents are English, and inventing one Italian word
|
|
146116
|
+
* would be a localisation layer that localises nothing.
|
|
146117
|
+
*/
|
|
146118
|
+
var CHILD_FALLBACK = "Accessory";
|
|
146119
|
+
/**
|
|
146120
|
+
* A PTZ action switch: the bare action, "Preset front door" / "Pan Left" /
|
|
146121
|
+
* "Autotrack".
|
|
146122
|
+
*
|
|
146123
|
+
* The labels themselves stay in `ptz-labels.ts` — they name a HomeKit control,
|
|
146124
|
+
* not a device. This function exists only to put the operator-typed half of a
|
|
146125
|
+
* preset name through the same sanitisation everything else gets; it no longer
|
|
146126
|
+
* qualifies the label with the camera, because all eight PTZ services live on
|
|
146127
|
+
* that camera's accessory and are unique among themselves.
|
|
146128
|
+
*/
|
|
146129
|
+
function ptzServiceName(actionLabel) {
|
|
146130
|
+
return hapServiceName([actionLabel], actionLabel);
|
|
146131
|
+
}
|
|
146132
|
+
/**
|
|
146133
|
+
* Drop `parentName` from the front of `name`.
|
|
146134
|
+
*
|
|
146135
|
+
* A PREFIX only. "Camera kitchen Sirena" → "Sirena"; "Sirena" is already
|
|
146136
|
+
* bare and untouched. A parent name appearing anywhere else in the child's
|
|
146137
|
+
* name is left alone — cutting from the middle of a string the operator typed
|
|
146138
|
+
* would mangle it, and this function must never make a label WORSE.
|
|
146139
|
+
*
|
|
146140
|
+
* Returns `name` unchanged when stripping would leave nothing: a child the
|
|
146141
|
+
* operator called exactly what the camera is called still needs a label.
|
|
146142
|
+
*/
|
|
146143
|
+
function withoutParent(name, parentName) {
|
|
146144
|
+
const needle = parentName.trim();
|
|
146145
|
+
if (needle.length === 0) return name;
|
|
146146
|
+
if (!name.toLowerCase().startsWith(needle.toLowerCase())) return name;
|
|
146147
|
+
const rest = name.slice(needle.length).trim();
|
|
146148
|
+
return rest.length > 0 ? rest : name;
|
|
146149
|
+
}
|
|
146150
|
+
/**
|
|
146151
|
+
* Truncate to the HAP ceiling and shave any leading/trailing character the
|
|
146152
|
+
* pattern forbids. Returns `null` when nothing usable is left — the caller
|
|
146153
|
+
* decides what to do with that, because "fall back" and "drop the part" are
|
|
146154
|
+
* different answers.
|
|
146155
|
+
*/
|
|
146156
|
+
function trimToHapName(value) {
|
|
146157
|
+
let out = value.length > 64 ? value.slice(0, 64) : value;
|
|
146158
|
+
while (out.length > 0 && !isAlphanumeric(out[out.length - 1])) out = out.slice(0, -1);
|
|
146159
|
+
while (out.length > 0 && !isAlphanumeric(out[0])) out = out.slice(1);
|
|
146160
|
+
return isHapServiceName(out) ? out : null;
|
|
146161
|
+
}
|
|
146162
|
+
function isAlphanumeric(ch) {
|
|
146163
|
+
return ch !== void 0 && /[\p{L}\p{N}]/u.test(ch);
|
|
146164
|
+
}
|
|
146165
|
+
function titleCase(raw) {
|
|
146166
|
+
return raw.split(/[-_\s]+/u).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
146167
|
+
}
|
|
146168
|
+
//#endregion
|
|
146169
|
+
//#region src/exposed-name.ts
|
|
146170
|
+
/** Apple's rule: at most 64 characters, begins and ends with a letter or digit, HAP punctuation only. */
|
|
146171
|
+
/** HomeKit's rule, as the derived "Name on <bridge>" field states it (D1049). */
|
|
146172
|
+
var HAP_NAME_RULE = `HomeKit takes up to 64 characters, starting and ending with a letter or digit; inside, only letters, digits, spaces and ' & ! . _ : ; ( ) / , -.`;
|
|
146173
|
+
var hapNameValidator = (name) => {
|
|
146174
|
+
if (name.length > 64) return {
|
|
146175
|
+
ok: false,
|
|
146176
|
+
reason: `The HomeKit name is ${name.length} characters; HomeKit allows at most 64.`
|
|
146177
|
+
};
|
|
146178
|
+
if (!isHapServiceName(name)) return {
|
|
146179
|
+
ok: false,
|
|
146180
|
+
reason: "The HomeKit name must begin and end with a letter or digit and may contain only letters, digits, spaces and ' & ! . _ : ; ( ) / , -"
|
|
146181
|
+
};
|
|
146182
|
+
return {
|
|
146183
|
+
ok: true,
|
|
146184
|
+
name
|
|
146185
|
+
};
|
|
146186
|
+
};
|
|
145075
146187
|
//#endregion
|
|
145076
146188
|
//#region src/hap-export-records.ts
|
|
145077
146189
|
/**
|
|
@@ -147592,141 +148704,6 @@ function reader(schema, toUpdates) {
|
|
|
147592
148704
|
function applyUpdates(service, updates) {
|
|
147593
148705
|
for (const update of updates) service.updateCharacteristic(update.characteristic, update.value);
|
|
147594
148706
|
}
|
|
147595
|
-
/**
|
|
147596
|
-
* hap-nodejs' `checkName` regex, verbatim.
|
|
147597
|
-
*
|
|
147598
|
-
* Duplicated rather than imported because it is `@private Private API` in that
|
|
147599
|
-
* package and not exported. Duplicating a private regex is a liability, so the
|
|
147600
|
-
* guard against drift is behavioural, not textual: `service-naming.spec.ts`
|
|
147601
|
-
* builds real services and asserts hap-nodejs emits ZERO characteristic
|
|
147602
|
-
* warnings — if this expression ever diverges from theirs, that test fails.
|
|
147603
|
-
*/
|
|
147604
|
-
var HAP_NAME_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N}\p{Zs}’'&!._:;()/,-]*[\p{L}\p{N}]$/u;
|
|
147605
|
-
/** Characters HAP tolerates INSIDE a name. Anything else becomes a space. */
|
|
147606
|
-
var HAP_NAME_INNER = /[^\p{L}\p{N}\p{Zs}’'&!._:;()/,-]/gu;
|
|
147607
|
-
/** Would hap-nodejs accept this as a `Name` characteristic value? */
|
|
147608
|
-
function isHapServiceName(value) {
|
|
147609
|
-
return HAP_NAME_PATTERN.test(value);
|
|
147610
|
-
}
|
|
147611
|
-
/**
|
|
147612
|
-
* Build one HAP-valid service name from device-derived parts.
|
|
147613
|
-
*
|
|
147614
|
-
* Empty and absent parts are dropped rather than joined, so a missing role
|
|
147615
|
-
* never produces a double space. `fallback` is used ONLY when nothing
|
|
147616
|
-
* device-derived survives sanitisation — it is the last resort, not the
|
|
147617
|
-
* default, because a name that says nothing about the device is the defect
|
|
147618
|
-
* this module exists to end.
|
|
147619
|
-
*/
|
|
147620
|
-
function hapServiceName(parts, fallback) {
|
|
147621
|
-
const trimmed = trimToHapName(parts.map((part) => typeof part === "string" ? part : "").map((part) => part.replace(HAP_NAME_INNER, " ")).join(" ").replace(/\s+/gu, " ").trim());
|
|
147622
|
-
if (trimmed !== null) return trimmed;
|
|
147623
|
-
return trimToHapName(fallback.replace(HAP_NAME_INNER, " ").replace(/\s+/gu, " ").trim()) ?? "";
|
|
147624
|
-
}
|
|
147625
|
-
/**
|
|
147626
|
-
* The privacy-mask switch.
|
|
147627
|
-
*
|
|
147628
|
-
* Just "Privacy". The camera name is NOT prefixed: this service lives inside
|
|
147629
|
-
* the camera's own accessory, iOS already renders it under the camera, and a
|
|
147630
|
-
* round that prefixed it gave the operator "Camera front door Privacy"
|
|
147631
|
-
* sitting inside a tile titled "Camera front door".
|
|
147632
|
-
*
|
|
147633
|
-
* The prefix was added for a real reason — two cameras publishing a switch
|
|
147634
|
-
* called "Privacy" — but that was a symptom of the label being the ONLY thing
|
|
147635
|
-
* shown, which stopped being true once `ConfiguredName` made the service
|
|
147636
|
-
* render in its accessory's context. Uniqueness is required WITHIN one
|
|
147637
|
-
* accessory, not across the bridge, and one camera has one privacy switch.
|
|
147638
|
-
*/
|
|
147639
|
-
function privacyServiceName() {
|
|
147640
|
-
return hapServiceName([PRIVACY_SUFFIX], PRIVACY_SUFFIX);
|
|
147641
|
-
}
|
|
147642
|
-
/**
|
|
147643
|
-
* Deliberately not localised, and deliberately not a translation table.
|
|
147644
|
-
*
|
|
147645
|
-
* The device half of the name is the operator's own text and arrives in the
|
|
147646
|
-
* operator's language. This half names a camstack capability (`privacy-mask`)
|
|
147647
|
-
* and there is no locale in an addon's context to resolve it against; the word
|
|
147648
|
-
* is also identical in the operator's language. A translation layer for one
|
|
147649
|
-
* word would be the kind of leftover that reads as verification.
|
|
147650
|
-
*/
|
|
147651
|
-
var PRIVACY_SUFFIX = "Privacy";
|
|
147652
|
-
/**
|
|
147653
|
-
* An accessory child (siren, floodlight, spotlight) rendered as a service on
|
|
147654
|
-
* the parent camera.
|
|
147655
|
-
*
|
|
147656
|
-
* The child's OWN stored name wins. It is the string the operator typed, in
|
|
147657
|
-
* the operator's language, and an early rule threw it away: `role` was
|
|
147658
|
-
* consulted first and title-cased, so every siren on the fleet published as
|
|
147659
|
-
* the English word "Siren" no matter what the operator had called it.
|
|
147660
|
-
*
|
|
147661
|
-
* Providers name children both ways — "Sirena" and "Camera kitchen
|
|
147662
|
-
* Sirena". The parent half is now REMOVED rather than added, because the
|
|
147663
|
-
* service is published inside the parent camera's own accessory and iOS
|
|
147664
|
-
* already shows it there. The result must be one form, not two.
|
|
147665
|
-
*/
|
|
147666
|
-
function childServiceName(parentName, child) {
|
|
147667
|
-
const own = withoutParent(child.name.trim(), parentName);
|
|
147668
|
-
if (own.length > 0) return hapServiceName([own], own);
|
|
147669
|
-
return hapServiceName([typeof child.role === "string" ? titleCase(child.role) : ""], CHILD_FALLBACK);
|
|
147670
|
-
}
|
|
147671
|
-
/**
|
|
147672
|
-
* Last resort for a child that carries neither a name nor a role. Better than
|
|
147673
|
-
* the parent's name, which would publish a service indistinguishable from the
|
|
147674
|
-
* accessory holding it — the exact defect this module keeps being asked to fix.
|
|
147675
|
-
*
|
|
147676
|
-
* English, like the role slugs it stands in for ("Floodlight", "Siren"): the
|
|
147677
|
-
* only strings this module invents are English, and inventing one Italian word
|
|
147678
|
-
* would be a localisation layer that localises nothing.
|
|
147679
|
-
*/
|
|
147680
|
-
var CHILD_FALLBACK = "Accessory";
|
|
147681
|
-
/**
|
|
147682
|
-
* A PTZ action switch: the bare action, "Preset front door" / "Pan Left" /
|
|
147683
|
-
* "Autotrack".
|
|
147684
|
-
*
|
|
147685
|
-
* The labels themselves stay in `ptz-labels.ts` — they name a HomeKit control,
|
|
147686
|
-
* not a device. This function exists only to put the operator-typed half of a
|
|
147687
|
-
* preset name through the same sanitisation everything else gets; it no longer
|
|
147688
|
-
* qualifies the label with the camera, because all eight PTZ services live on
|
|
147689
|
-
* that camera's accessory and are unique among themselves.
|
|
147690
|
-
*/
|
|
147691
|
-
function ptzServiceName(actionLabel) {
|
|
147692
|
-
return hapServiceName([actionLabel], actionLabel);
|
|
147693
|
-
}
|
|
147694
|
-
/**
|
|
147695
|
-
* Drop `parentName` from the front of `name`.
|
|
147696
|
-
*
|
|
147697
|
-
* A PREFIX only. "Camera kitchen Sirena" → "Sirena"; "Sirena" is already
|
|
147698
|
-
* bare and untouched. A parent name appearing anywhere else in the child's
|
|
147699
|
-
* name is left alone — cutting from the middle of a string the operator typed
|
|
147700
|
-
* would mangle it, and this function must never make a label WORSE.
|
|
147701
|
-
*
|
|
147702
|
-
* Returns `name` unchanged when stripping would leave nothing: a child the
|
|
147703
|
-
* operator called exactly what the camera is called still needs a label.
|
|
147704
|
-
*/
|
|
147705
|
-
function withoutParent(name, parentName) {
|
|
147706
|
-
const needle = parentName.trim();
|
|
147707
|
-
if (needle.length === 0) return name;
|
|
147708
|
-
if (!name.toLowerCase().startsWith(needle.toLowerCase())) return name;
|
|
147709
|
-
const rest = name.slice(needle.length).trim();
|
|
147710
|
-
return rest.length > 0 ? rest : name;
|
|
147711
|
-
}
|
|
147712
|
-
/**
|
|
147713
|
-
* Truncate to the HAP ceiling and shave any leading/trailing character the
|
|
147714
|
-
* pattern forbids. Returns `null` when nothing usable is left — the caller
|
|
147715
|
-
* decides what to do with that, because "fall back" and "drop the part" are
|
|
147716
|
-
* different answers.
|
|
147717
|
-
*/
|
|
147718
|
-
function trimToHapName(value) {
|
|
147719
|
-
let out = value.length > 64 ? value.slice(0, 64) : value;
|
|
147720
|
-
while (out.length > 0 && !isAlphanumeric(out[out.length - 1])) out = out.slice(0, -1);
|
|
147721
|
-
while (out.length > 0 && !isAlphanumeric(out[0])) out = out.slice(1);
|
|
147722
|
-
return isHapServiceName(out) ? out : null;
|
|
147723
|
-
}
|
|
147724
|
-
function isAlphanumeric(ch) {
|
|
147725
|
-
return ch !== void 0 && /[\p{L}\p{N}]/u.test(ch);
|
|
147726
|
-
}
|
|
147727
|
-
function titleCase(raw) {
|
|
147728
|
-
return raw.split(/[-_\s]+/u).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
147729
|
-
}
|
|
147730
148707
|
//#endregion
|
|
147731
148708
|
//#region src/mappers/builders/service-label.ts
|
|
147732
148709
|
/**
|
|
@@ -165191,8 +166168,19 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165191
166168
|
for (const uuid of uuids) clearPairingFiles(uuid, this.ctx.logger);
|
|
165192
166169
|
await this.exposureHandle().delete(id);
|
|
165193
166170
|
if (id === "export-hap") await this.exportSyncState.set({});
|
|
166171
|
+
await this.pruneBridgeNames(id);
|
|
165194
166172
|
this.ctx.logger.info("export-hap: bridge removed", { meta: { instanceId: id } });
|
|
165195
166173
|
}
|
|
166174
|
+
/** A removed bridge's device names go too, so a bridge that reuses the id inherits none (D1049). */
|
|
166175
|
+
async pruneBridgeNames(id) {
|
|
166176
|
+
const settings = this.ctx.settings;
|
|
166177
|
+
if (settings === void 0) return;
|
|
166178
|
+
const pruned = await pruneExposedNames(settings, id);
|
|
166179
|
+
if (pruned.length > 0) this.ctx.logger.info("export-hap: removed bridge names deleted", { meta: {
|
|
166180
|
+
instanceId: id,
|
|
166181
|
+
devices: pruned.length
|
|
166182
|
+
} });
|
|
166183
|
+
}
|
|
165196
166184
|
/**
|
|
165197
166185
|
* "Regenerate" (operator decision): a new setup code, every pairing of this bridge cleared and
|
|
165198
166186
|
* the bridge republished. Every controller has to pair again; the instance and its exposed
|
|
@@ -165288,21 +166276,33 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165288
166276
|
instanceId: row.id,
|
|
165289
166277
|
name: row.body.name,
|
|
165290
166278
|
enabled: row.enabled,
|
|
165291
|
-
kind: "hap-bridge"
|
|
166279
|
+
kind: "hap-bridge",
|
|
166280
|
+
nameRule: HAP_NAME_RULE
|
|
165292
166281
|
})),
|
|
165293
166282
|
listSupportedDeviceKinds: async ({ instanceId }) => {
|
|
165294
166283
|
this.bridgesOf(instanceId);
|
|
165295
166284
|
return [...HAP_EXPORTABLE_DEVICE_TYPES];
|
|
165296
166285
|
},
|
|
165297
|
-
listExposedDevices: async ({ instanceId }) =>
|
|
165298
|
-
const
|
|
165299
|
-
|
|
165300
|
-
deviceId
|
|
165301
|
-
|
|
165302
|
-
|
|
165303
|
-
|
|
165304
|
-
|
|
165305
|
-
|
|
166286
|
+
listExposedDevices: async ({ instanceId }) => {
|
|
166287
|
+
const out = [];
|
|
166288
|
+
for (const inst of this.bridgesOf(instanceId)) for (const [deviceId, m] of inst.exposed.entries()) {
|
|
166289
|
+
const entry = inst.exposure.devices.find((e) => e.deviceId === deviceId);
|
|
166290
|
+
const exposedName = await this.exposedNameOf(inst.id, deviceId);
|
|
166291
|
+
out.push({
|
|
166292
|
+
deviceId,
|
|
166293
|
+
exposedAs: m.accessory.displayName,
|
|
166294
|
+
...exposedName !== null ? { exposedName } : {},
|
|
166295
|
+
...entry?.capabilities ? { capabilities: [...entry.capabilities] } : {}
|
|
166296
|
+
});
|
|
166297
|
+
}
|
|
166298
|
+
return out;
|
|
166299
|
+
},
|
|
166300
|
+
exposeDevice: async ({ instanceId, deviceId, capabilities, exposedName }) => {
|
|
166301
|
+
const inst = this.requireBridge(instanceId);
|
|
166302
|
+
if (exposedName !== void 0) await this.saveExposedName(inst, deviceId, exposedName);
|
|
166303
|
+
return this.exposeDevice(inst, deviceId, capabilities);
|
|
166304
|
+
},
|
|
166305
|
+
setExposedName: async ({ instanceId, deviceId, name, dryRun }) => this.setExposedName(this.requireBridge(instanceId), deviceId, name, dryRun === true),
|
|
165306
166306
|
unexposeDevice: async ({ instanceId, deviceId }) => this.unexposeDevice(this.requireBridge(instanceId), deviceId),
|
|
165307
166307
|
listSupportedEntityKinds: async () => ["device", "action"],
|
|
165308
166308
|
listExposedEntities: async ({ instanceId }) => {
|
|
@@ -165445,7 +166445,7 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165445
166445
|
const summary = await this.fetchDeviceSummary(numericId);
|
|
165446
166446
|
const mapperKind = pickMapperKind(summary?.type);
|
|
165447
166447
|
if (!mapperKind) throw new Error(`export-hap: device ${numericId} has type '${summary?.type ?? "unknown"}', which HomeKit export does not support`);
|
|
165448
|
-
const displayName = summary?.name ?? `Device ${deviceId}`;
|
|
166448
|
+
const displayName = await this.exposedNameOf(inst.id, deviceId) ?? summary?.name ?? `Device ${deviceId}`;
|
|
165449
166449
|
const previous = inst.exposure.devices.find((e) => e.deviceId === deviceId);
|
|
165450
166450
|
const rebuilt = {
|
|
165451
166451
|
deviceId,
|
|
@@ -165477,6 +166477,54 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165477
166477
|
childCount: attached.childAccessoryUuids.length
|
|
165478
166478
|
} });
|
|
165479
166479
|
}
|
|
166480
|
+
nameStore() {
|
|
166481
|
+
return exposedNameStoreOf(this.ctx.settings, "export-hap");
|
|
166482
|
+
}
|
|
166483
|
+
async exposedNameOf(instanceId, deviceId) {
|
|
166484
|
+
const numericId = Number.parseInt(deviceId, 10);
|
|
166485
|
+
if (!Number.isFinite(numericId)) return null;
|
|
166486
|
+
try {
|
|
166487
|
+
return readExposedName(await this.nameStore().read(numericId), instanceId, hapNameValidator);
|
|
166488
|
+
} catch (err) {
|
|
166489
|
+
this.ctx.logger.warn("export-hap: HomeKit name unreadable", {
|
|
166490
|
+
tags: { deviceId: numericId },
|
|
166491
|
+
meta: {
|
|
166492
|
+
instanceId,
|
|
166493
|
+
error: err instanceof Error ? err.message : String(err)
|
|
166494
|
+
}
|
|
166495
|
+
});
|
|
166496
|
+
return null;
|
|
166497
|
+
}
|
|
166498
|
+
}
|
|
166499
|
+
/** Validate and store the HomeKit name; a refusal throws before anything is written. */
|
|
166500
|
+
async saveExposedName(inst, deviceIdStr, raw, dryRun = false) {
|
|
166501
|
+
const deviceId = Number.parseInt(deviceIdStr, 10);
|
|
166502
|
+
if (!Number.isFinite(deviceId)) throw new Error(`export-hap: invalid device id '${deviceIdStr}'`);
|
|
166503
|
+
const saved = await saveExposedName({
|
|
166504
|
+
store: this.nameStore(),
|
|
166505
|
+
deviceId,
|
|
166506
|
+
instanceId: inst.id,
|
|
166507
|
+
raw,
|
|
166508
|
+
validate: hapNameValidator,
|
|
166509
|
+
...dryRun ? { dryRun: true } : {}
|
|
166510
|
+
});
|
|
166511
|
+
if (saved.changed) this.ctx.logger.info("export-hap: HomeKit name saved", {
|
|
166512
|
+
tags: { deviceId },
|
|
166513
|
+
meta: {
|
|
166514
|
+
instanceId: inst.id,
|
|
166515
|
+
name: saved.name
|
|
166516
|
+
}
|
|
166517
|
+
});
|
|
166518
|
+
return saved.changed;
|
|
166519
|
+
}
|
|
166520
|
+
/**
|
|
166521
|
+
* Rename on HomeKit (D1049). An exposed device is re-exposed in place — the same accessory
|
|
166522
|
+
* UUID, the pairing untouched (no unexpose, which would wipe it) — so Home shows the new name
|
|
166523
|
+
* on the same tile. A dry run only validates.
|
|
166524
|
+
*/
|
|
166525
|
+
async setExposedName(inst, deviceIdStr, raw, dryRun = false) {
|
|
166526
|
+
if (await this.saveExposedName(inst, deviceIdStr, raw, dryRun) && inst.exposed.has(deviceIdStr)) await this.exposeDevice(inst, deviceIdStr);
|
|
166527
|
+
}
|
|
165480
166528
|
async unexposeDevice(inst, deviceId, options = {}) {
|
|
165481
166529
|
const numericId = Number.parseInt(deviceId, 10);
|
|
165482
166530
|
const log = this.ctx.logger.withTags({ deviceId: numericId });
|