@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
package/dist/hap-export.addon.js
CHANGED
|
@@ -49,7 +49,7 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
49
49
|
node_fs_promises = __toESM(node_fs_promises, 1);
|
|
50
50
|
let node_events = require("node:events");
|
|
51
51
|
let node_dgram = require("node:dgram");
|
|
52
|
-
//#region ../types/dist/event-category-
|
|
52
|
+
//#region ../types/dist/event-category-Dv-Gcv1f.mjs
|
|
53
53
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
54
54
|
EventCategory["SystemBoot"] = "system.boot";
|
|
55
55
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -490,6 +490,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
490
490
|
*/
|
|
491
491
|
EventCategory["DeviceStateChanged"] = "device.state-changed";
|
|
492
492
|
/**
|
|
493
|
+
* A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
|
|
494
|
+
* transition audit (D1022): confirmed, already in place, unconfirmed or
|
|
495
|
+
* failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
|
|
496
|
+
* (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
|
|
497
|
+
* the Notification Center `device-command` kind. Telemetry (D8): losing one
|
|
498
|
+
* costs a notification, never state; the audit row is the record.
|
|
499
|
+
*/
|
|
500
|
+
EventCategory["DeviceCommandSettled"] = "device.command-settled";
|
|
501
|
+
/**
|
|
493
502
|
* The NATIVE shadow of a cap a composition has claimed fields of moved
|
|
494
503
|
* (D663). Payload: `{ deviceId, capName, native }` — what the provider
|
|
495
504
|
* wrote, BEFORE the owned fields are overlaid. Owner-only (D224): it is for
|
|
@@ -6094,7 +6103,7 @@ var ZodIssueCode = {
|
|
|
6094
6103
|
var ZodFirstPartyTypeKind;
|
|
6095
6104
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6096
6105
|
//#endregion
|
|
6097
|
-
//#region ../types/dist/sleep-
|
|
6106
|
+
//#region ../types/dist/sleep-DyIxjZZt.mjs
|
|
6098
6107
|
/**
|
|
6099
6108
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6100
6109
|
* window to float samples (D455).
|
|
@@ -6777,6 +6786,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6777
6786
|
else skipped.push(id);
|
|
6778
6787
|
};
|
|
6779
6788
|
const selected = options.only === void 0 ? null : new Set(options.only);
|
|
6789
|
+
const deferred = /* @__PURE__ */ new Set();
|
|
6790
|
+
const deferredBy = (reason) => {
|
|
6791
|
+
if (selected === null || reason === null) return null;
|
|
6792
|
+
const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
|
|
6793
|
+
if (dep === void 0 || !byId.has(dep)) return null;
|
|
6794
|
+
return !selected.has(dep) || deferred.has(dep) ? dep : null;
|
|
6795
|
+
};
|
|
6780
6796
|
for (const step of declaration.steps) {
|
|
6781
6797
|
if (selected !== null && !selected.has(step.id)) continue;
|
|
6782
6798
|
const bound = byId.get(step.id);
|
|
@@ -6788,6 +6804,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6788
6804
|
try {
|
|
6789
6805
|
const gate = await host.startMigration({ id: step.id });
|
|
6790
6806
|
if (!gate.proceed) {
|
|
6807
|
+
const waitsFor = deferredBy(gate.reason);
|
|
6808
|
+
if (waitsFor !== null) {
|
|
6809
|
+
log.info("migration deferred: its predecessor runs in another phase of this owner", {
|
|
6810
|
+
tags,
|
|
6811
|
+
meta: {
|
|
6812
|
+
waitsFor,
|
|
6813
|
+
reason: gate.reason
|
|
6814
|
+
}
|
|
6815
|
+
});
|
|
6816
|
+
deferred.add(step.id);
|
|
6817
|
+
skipped.push(step.id);
|
|
6818
|
+
continue;
|
|
6819
|
+
}
|
|
6791
6820
|
log.warn("migration not run", {
|
|
6792
6821
|
tags,
|
|
6793
6822
|
meta: {
|
|
@@ -10237,6 +10266,13 @@ var DeviceTransitionSchema = object({
|
|
|
10237
10266
|
actor: TransitionActorSchema,
|
|
10238
10267
|
command: TransitionCommandSchema.optional()
|
|
10239
10268
|
});
|
|
10269
|
+
object({
|
|
10270
|
+
deviceId: number$1().int(),
|
|
10271
|
+
action: string(),
|
|
10272
|
+
outcome: TransitionOutcomeSchema,
|
|
10273
|
+
actor: TransitionActorSchema,
|
|
10274
|
+
at: number$1()
|
|
10275
|
+
});
|
|
10240
10276
|
var READING_QUANTITIES = [
|
|
10241
10277
|
"temperature",
|
|
10242
10278
|
"pressure",
|
|
@@ -12260,7 +12296,10 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
12260
12296
|
"ir-transmitter": {
|
|
12261
12297
|
scope: "device",
|
|
12262
12298
|
noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
|
|
12263
|
-
notOperatorFacing: {
|
|
12299
|
+
notOperatorFacing: {
|
|
12300
|
+
send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
|
|
12301
|
+
learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
|
|
12302
|
+
}
|
|
12264
12303
|
},
|
|
12265
12304
|
control: {
|
|
12266
12305
|
scope: "device",
|
|
@@ -15181,6 +15220,32 @@ var CAP_VOCABULARY_BY_NAME = {
|
|
|
15181
15220
|
...SYSTEM_CAP_VOCABULARY
|
|
15182
15221
|
};
|
|
15183
15222
|
/**
|
|
15223
|
+
* Vocabulary actions by id (D983). An action step names a vocabulary action
|
|
15224
|
+
* (`cover.open`), never a raw cap method; this is the one lookup that turns the
|
|
15225
|
+
* id into its cap, method and effect — and a persisted legacy `cap` + `method`
|
|
15226
|
+
* pair back into the action id when exactly one action matches.
|
|
15227
|
+
*/
|
|
15228
|
+
function buildIndex() {
|
|
15229
|
+
const byId = /* @__PURE__ */ new Map();
|
|
15230
|
+
for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
|
|
15231
|
+
if (entry.scope !== "device") continue;
|
|
15232
|
+
for (const action of entry.actions ?? []) byId.set(action.id, {
|
|
15233
|
+
cap,
|
|
15234
|
+
action
|
|
15235
|
+
});
|
|
15236
|
+
}
|
|
15237
|
+
return byId;
|
|
15238
|
+
}
|
|
15239
|
+
var index;
|
|
15240
|
+
function actionIndex() {
|
|
15241
|
+
index ??= buildIndex();
|
|
15242
|
+
return index;
|
|
15243
|
+
}
|
|
15244
|
+
/** The vocabulary action with this id, or `undefined`. */
|
|
15245
|
+
function findVocabAction(actionId) {
|
|
15246
|
+
return actionIndex().get(actionId);
|
|
15247
|
+
}
|
|
15248
|
+
/**
|
|
15184
15249
|
* `addon-pages-source` — collection cap exposing per-provider raw page
|
|
15185
15250
|
* declarations. Every addon that contributes a UI page registers a
|
|
15186
15251
|
* provider here. The hub-side singleton aggregator (`addon-pages` cap,
|
|
@@ -16263,6 +16328,10 @@ Object.freeze({
|
|
|
16263
16328
|
"path": "lastEvent.eventType",
|
|
16264
16329
|
"valueType": "string"
|
|
16265
16330
|
},
|
|
16331
|
+
{
|
|
16332
|
+
"path": "lastEvent.sourceId",
|
|
16333
|
+
"valueType": "string"
|
|
16334
|
+
},
|
|
16266
16335
|
{
|
|
16267
16336
|
"path": "lastEvent.timestamp",
|
|
16268
16337
|
"valueType": "number"
|
|
@@ -44671,6 +44740,41 @@ function macroOnly(macro) {
|
|
|
44671
44740
|
};
|
|
44672
44741
|
}
|
|
44673
44742
|
}
|
|
44743
|
+
var EventVocabularyKindSchema = _enum([
|
|
44744
|
+
"press",
|
|
44745
|
+
"long-press",
|
|
44746
|
+
"long-press-start",
|
|
44747
|
+
"release",
|
|
44748
|
+
"repeat",
|
|
44749
|
+
"double-press",
|
|
44750
|
+
"other"
|
|
44751
|
+
]);
|
|
44752
|
+
/** The part of the device an event comes from: a button, a channel. */
|
|
44753
|
+
var EventVocabularySourceSchema = object({
|
|
44754
|
+
id: string().min(1),
|
|
44755
|
+
label: string().min(1)
|
|
44756
|
+
});
|
|
44757
|
+
/** One scalar field of an event's `data`, by dotted path. */
|
|
44758
|
+
var EventVocabularyFieldSchema = object({
|
|
44759
|
+
path: string().min(1),
|
|
44760
|
+
kind: _enum([
|
|
44761
|
+
"string",
|
|
44762
|
+
"number",
|
|
44763
|
+
"boolean",
|
|
44764
|
+
"enum"
|
|
44765
|
+
]),
|
|
44766
|
+
enumValues: array(string()).optional(),
|
|
44767
|
+
label: string().min(1).optional()
|
|
44768
|
+
});
|
|
44769
|
+
var EventVocabularyEntrySchema = object({
|
|
44770
|
+
/** The native token, verbatim. */
|
|
44771
|
+
id: string().min(1),
|
|
44772
|
+
source: EventVocabularySourceSchema.optional(),
|
|
44773
|
+
label: string().min(1),
|
|
44774
|
+
description: string().optional(),
|
|
44775
|
+
kind: EventVocabularyKindSchema.optional(),
|
|
44776
|
+
payload: array(EventVocabularyFieldSchema).optional()
|
|
44777
|
+
});
|
|
44674
44778
|
Math.PI / 180;
|
|
44675
44779
|
/**
|
|
44676
44780
|
* WHEN something happens, as data (D983) — the one time vocabulary of the
|
|
@@ -44878,6 +44982,33 @@ var ScheduleLeafSchema = object({
|
|
|
44878
44982
|
/** @deprecated legacy cron — new schedules use `at`. */
|
|
44879
44983
|
cron: string().min(1).max(120).optional()
|
|
44880
44984
|
}).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" });
|
|
44985
|
+
/**
|
|
44986
|
+
* One payload predicate of a `device-fired` row: the value at `path` inside
|
|
44987
|
+
* the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
|
|
44988
|
+
*/
|
|
44989
|
+
var DeviceFiredMatchSchema = object({
|
|
44990
|
+
path: string().min(1).max(120),
|
|
44991
|
+
equals: union([
|
|
44992
|
+
string(),
|
|
44993
|
+
number$1(),
|
|
44994
|
+
boolean()
|
|
44995
|
+
])
|
|
44996
|
+
});
|
|
44997
|
+
/**
|
|
44998
|
+
* "fires": one device of the `event-emitter` capability reported an event
|
|
44999
|
+
* (D1045). Every list is an OR, the lists together an AND; an absent list does
|
|
45000
|
+
* not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
|
|
45001
|
+
* the device (a button), `kinds` the shared press kinds of its vocabulary.
|
|
45002
|
+
*/
|
|
45003
|
+
var DeviceFiredLeafSchema = object({
|
|
45004
|
+
kind: literal("device-fired"),
|
|
45005
|
+
...eventLeafId,
|
|
45006
|
+
deviceId: number$1().int().nonnegative(),
|
|
45007
|
+
eventIds: array(string().min(1)).min(1).max(64).optional(),
|
|
45008
|
+
sourceIds: array(string().min(1)).min(1).max(64).optional(),
|
|
45009
|
+
kinds: array(EventVocabularyKindSchema).min(1).optional(),
|
|
45010
|
+
match: array(DeviceFiredMatchSchema).min(1).max(8).optional()
|
|
45011
|
+
});
|
|
44881
45012
|
var ManualLeafSchema = object({
|
|
44882
45013
|
kind: literal("manual"),
|
|
44883
45014
|
...eventLeafId
|
|
@@ -45019,6 +45150,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
45019
45150
|
}),
|
|
45020
45151
|
DeviceBecomesLeafSchema,
|
|
45021
45152
|
DeviceEventLeafSchema,
|
|
45153
|
+
DeviceFiredLeafSchema,
|
|
45022
45154
|
ScheduleLeafSchema,
|
|
45023
45155
|
ManualLeafSchema,
|
|
45024
45156
|
IntervalLeafSchema,
|
|
@@ -45033,6 +45165,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
45033
45165
|
var EVENT_KINDS = new Set([
|
|
45034
45166
|
"device-becomes",
|
|
45035
45167
|
"device-event",
|
|
45168
|
+
"device-fired",
|
|
45036
45169
|
"schedule",
|
|
45037
45170
|
"manual",
|
|
45038
45171
|
"interval",
|
|
@@ -45113,6 +45246,7 @@ function hasEmptyContainer(node) {
|
|
|
45113
45246
|
var LEAF_WORDS = {
|
|
45114
45247
|
"device-becomes": "a device value that becomes",
|
|
45115
45248
|
"device-event": "a device event",
|
|
45249
|
+
"device-fired": "a device firing an event",
|
|
45116
45250
|
schedule: "a schedule",
|
|
45117
45251
|
manual: "a manual run",
|
|
45118
45252
|
interval: "an interval",
|
|
@@ -45362,59 +45496,47 @@ function convertLegacyWhen(half) {
|
|
|
45362
45496
|
* (instants) and state leaves (durations). It replaces the flat trigger list
|
|
45363
45497
|
* plus the separate condition tree; the firing rule is in that file and in
|
|
45364
45498
|
* ADR "one tree".
|
|
45365
|
-
* - **Actions** — the `wait` and `
|
|
45499
|
+
* - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
|
|
45366
45500
|
* fragment of §3.2.2. See {@link AutomationActionSchema}.
|
|
45367
45501
|
*
|
|
45368
45502
|
* A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
|
|
45369
45503
|
* {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
|
|
45370
45504
|
*/
|
|
45371
45505
|
/**
|
|
45372
|
-
* One action step: `wait`, or a `
|
|
45506
|
+
* One action step: `wait`, or a device `command`.
|
|
45373
45507
|
*
|
|
45374
|
-
* A
|
|
45375
|
-
* `{ $var }` resolved from the run's
|
|
45376
|
-
*
|
|
45377
|
-
*
|
|
45378
|
-
*
|
|
45379
|
-
*
|
|
45508
|
+
* A command step names a VOCABULARY action (`cover.open`) and who it acts on
|
|
45509
|
+
* (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
|
|
45510
|
+
* variables). It never names a cap method: the step runner turns the action
|
|
45511
|
+
* id into its cap + method through the vocabulary index when the step runs
|
|
45512
|
+
* (`vocabCall`), the one place that mapping happens. The step runner
|
|
45513
|
+
* (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
|
|
45514
|
+
* variable substitution, once, for every caller — automations, Actions, and
|
|
45515
|
+
* the notification centre, which runs only Actions (planning#473).
|
|
45380
45516
|
*/
|
|
45517
|
+
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
45518
|
+
var WAIT_MAX_SECONDS = 3600;
|
|
45519
|
+
var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
|
|
45381
45520
|
var AutomationWaitStepSchema = object({
|
|
45382
45521
|
kind: literal("wait"),
|
|
45383
|
-
seconds: number$1().min(0).max(
|
|
45522
|
+
seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
45384
45523
|
});
|
|
45385
|
-
/** The legacy `deviceId` of a cap step: still READ, never written (D983). */
|
|
45386
|
-
var LegacyStepDeviceSchema = union([
|
|
45387
|
-
number$1().int(),
|
|
45388
|
-
array(number$1().int()).min(1),
|
|
45389
|
-
object({ $var: string().min(1) })
|
|
45390
|
-
]);
|
|
45391
45524
|
/**
|
|
45392
|
-
* The fields of a
|
|
45393
|
-
*
|
|
45394
|
-
* device); a step is {@link AutomationCapStepSchema}.
|
|
45525
|
+
* The fields of a command step, before the vocabulary check. A step is
|
|
45526
|
+
* {@link AutomationCommandStepSchema}.
|
|
45395
45527
|
*/
|
|
45396
|
-
var
|
|
45397
|
-
kind: literal("
|
|
45398
|
-
/**
|
|
45399
|
-
|
|
45400
|
-
|
|
45401
|
-
|
|
45402
|
-
* cap + method match exactly one vocabulary action.
|
|
45403
|
-
*/
|
|
45404
|
-
actionId: string().min(1).optional(),
|
|
45405
|
-
/** WHO the step acts on. The only shape that is written. */
|
|
45406
|
-
target: ActionTargetSchema.optional(),
|
|
45528
|
+
var AutomationCommandStepBaseSchema = object({
|
|
45529
|
+
kind: literal("command"),
|
|
45530
|
+
/** WHO the step acts on. */
|
|
45531
|
+
target: ActionTargetSchema,
|
|
45532
|
+
/** The vocabulary action this step performs (`cover.open`). */
|
|
45533
|
+
actionId: string().min(1),
|
|
45407
45534
|
/**
|
|
45408
|
-
*
|
|
45409
|
-
*
|
|
45410
|
-
*
|
|
45535
|
+
* The values of the action's OPEN args (`position`, `presetId`); the args
|
|
45536
|
+
* the vocabulary bakes into the action are added when the step runs. Values
|
|
45537
|
+
* may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
45538
|
+
* SUBSTITUTE and do not evaluate (§3.2.3).
|
|
45411
45539
|
*/
|
|
45412
|
-
deviceId: LegacyStepDeviceSchema.optional(),
|
|
45413
|
-
cap: string().min(1),
|
|
45414
|
-
method: string().min(1),
|
|
45415
|
-
/** Values may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
45416
|
-
* SUBSTITUTE and do not evaluate (§3.2.3). Anything beyond substitution is
|
|
45417
|
-
* the expression leaf. */
|
|
45418
45540
|
args: record(string(), unknown()).optional(),
|
|
45419
45541
|
/**
|
|
45420
45542
|
* The unit the person picked per arg (display only). `args` always hold the
|
|
@@ -45423,18 +45545,20 @@ var AutomationCapStepBaseSchema = object({
|
|
|
45423
45545
|
*/
|
|
45424
45546
|
argUnits: record(string(), string().min(1)).optional()
|
|
45425
45547
|
});
|
|
45548
|
+
/** The vocabulary check every command step passes: the action exists. */
|
|
45549
|
+
function refineKnownAction(step, ctx) {
|
|
45550
|
+
if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
|
|
45551
|
+
code: "custom",
|
|
45552
|
+
message: `"${step.actionId}" is not a vocabulary action id`,
|
|
45553
|
+
path: ["actionId"]
|
|
45554
|
+
});
|
|
45555
|
+
}
|
|
45426
45556
|
/**
|
|
45427
|
-
* The steps an internal Action may contain:
|
|
45557
|
+
* The steps an internal Action may contain: command and wait, and nothing that can
|
|
45428
45558
|
* call back into an Action — so an Action can never reach itself (no cycles).
|
|
45429
45559
|
* This is the LEAF shape: no condition of its own.
|
|
45430
45560
|
*/
|
|
45431
|
-
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema,
|
|
45432
|
-
message: "a cap step needs a target",
|
|
45433
|
-
path: ["target"]
|
|
45434
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
45435
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
45436
|
-
path: ["actionId"]
|
|
45437
|
-
})]);
|
|
45561
|
+
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
|
|
45438
45562
|
/**
|
|
45439
45563
|
* The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
|
|
45440
45564
|
* on the state mirror when the step is reached; `else` runs when it is false.
|
|
@@ -45450,39 +45574,209 @@ var elseNeedsIf = {
|
|
|
45450
45574
|
path: ["else"]
|
|
45451
45575
|
};
|
|
45452
45576
|
var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45453
|
-
var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
|
|
45454
|
-
message: "a cap step needs a target",
|
|
45455
|
-
path: ["target"]
|
|
45456
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
45457
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
45458
|
-
path: ["actionId"]
|
|
45459
|
-
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45460
45577
|
/**
|
|
45461
45578
|
* A step of a STANDALONE list (an action, a scheduler point, a preset): the
|
|
45462
45579
|
* same two step kinds an automation runs, minus a guard that reads the
|
|
45463
45580
|
* automation's trigger, which such a list does not have.
|
|
45464
45581
|
*/
|
|
45465
|
-
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema,
|
|
45582
|
+
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCommandStepBaseSchema.extend(stepGuardShape).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
|
|
45466
45583
|
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
45467
45584
|
code: "custom",
|
|
45468
45585
|
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
45469
45586
|
path: ["if"]
|
|
45470
45587
|
});
|
|
45471
45588
|
});
|
|
45589
|
+
/**
|
|
45590
|
+
* Flow control of an AUTOMATION's list (#500). A standalone list (an action, a
|
|
45591
|
+
* scheduler point, a preset) stays `wait` and `cap`: it has no run of its own
|
|
45592
|
+
* to end and no variable bag to write.
|
|
45593
|
+
*/
|
|
45594
|
+
var continueOnErrorShape = {
|
|
45595
|
+
/** A failure of this step is traced `failed-continued` and the next step runs. */
|
|
45596
|
+
continueOnError: literal(true).optional() };
|
|
45597
|
+
/** An automation's command step: the shared guarded command step, plus `continueOnError`. */
|
|
45598
|
+
var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
|
|
45599
|
+
...stepGuardShape,
|
|
45600
|
+
...continueOnErrorShape
|
|
45601
|
+
}).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45602
|
+
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
45603
|
+
var AutomationStopStepSchema = object({
|
|
45604
|
+
kind: literal("stop"),
|
|
45605
|
+
reason: string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
|
|
45606
|
+
/** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
|
|
45607
|
+
outcome: _enum(["ok", "failed"]),
|
|
45608
|
+
/** Stop only when this reads true; false or unknown does not stop. */
|
|
45609
|
+
if: AutomationWhenSchema.optional()
|
|
45610
|
+
});
|
|
45611
|
+
var SET_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,39}$/;
|
|
45612
|
+
/** Names the run itself writes and reads (`leaf` is what `triggered-by` judges): a step may not overwrite them. */
|
|
45613
|
+
var RESERVED_RUN_VARS = [
|
|
45614
|
+
"kind",
|
|
45615
|
+
"leaf",
|
|
45616
|
+
"at"
|
|
45617
|
+
];
|
|
45618
|
+
/**
|
|
45619
|
+
* Write variables into the run's bag, for the steps after it. SUBSTITUTION
|
|
45620
|
+
* only, never evaluation: a text value may carry `{{vars.x}}` slots.
|
|
45621
|
+
*/
|
|
45622
|
+
var AutomationSetStepSchema = object({
|
|
45623
|
+
kind: literal("set"),
|
|
45624
|
+
vars: record(string(), union([
|
|
45625
|
+
string().max(500),
|
|
45626
|
+
number$1(),
|
|
45627
|
+
boolean()
|
|
45628
|
+
])).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` }),
|
|
45629
|
+
/** Set only when this reads true; false or unknown leaves the bag as it is. */
|
|
45630
|
+
if: AutomationWhenSchema.optional()
|
|
45631
|
+
});
|
|
45632
|
+
var AutomationRunActionStepSchema = object({
|
|
45633
|
+
kind: literal("action"),
|
|
45634
|
+
/** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
|
|
45635
|
+
actionId: string().min(1),
|
|
45636
|
+
/** Values for the action's declared variables; the others take their default. */
|
|
45637
|
+
variables: record(string(), union([
|
|
45638
|
+
string(),
|
|
45639
|
+
number$1(),
|
|
45640
|
+
boolean()
|
|
45641
|
+
])).optional(),
|
|
45642
|
+
...continueOnErrorShape
|
|
45643
|
+
});
|
|
45644
|
+
/**
|
|
45645
|
+
* A step INSIDE a branch of a `choose`: a flow step with no condition of its
|
|
45646
|
+
* own (the branch is the condition) and no block inside it. Strict, so an `if`
|
|
45647
|
+
* written on such a step is refused rather than dropped.
|
|
45648
|
+
*/
|
|
45649
|
+
/** The longest a `wait-until` may wait: six hours. */
|
|
45650
|
+
var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
|
|
45651
|
+
/**
|
|
45652
|
+
* Pause the run until a condition is true (#500). The timeout is mandatory: a
|
|
45653
|
+
* run never waits without an end. `onTimeout` says what a wait that ran out
|
|
45654
|
+
* does: `continue` goes on to the next step, `stop` ends the run as a failure.
|
|
45655
|
+
* A condition that cannot be read is not "true": the wait goes on (D49).
|
|
45656
|
+
*/
|
|
45657
|
+
var AutomationWaitUntilStepSchema = object({
|
|
45658
|
+
kind: literal("wait-until"),
|
|
45659
|
+
when: AutomationWhenSchema,
|
|
45660
|
+
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)`),
|
|
45661
|
+
onTimeout: _enum(["continue", "stop"])
|
|
45662
|
+
}).strict();
|
|
45663
|
+
/** The step kinds that hold steps of their own, or pause on a condition: they nest two levels at most. */
|
|
45664
|
+
var BLOCK_STEP_KINDS = [
|
|
45665
|
+
"choose",
|
|
45666
|
+
"repeat",
|
|
45667
|
+
"parallel",
|
|
45668
|
+
"wait-until"
|
|
45669
|
+
];
|
|
45670
|
+
var NEST_TOO_DEEP = `steps nest two levels at most: a step inside a nested choose or repeat can be a plain step only`;
|
|
45671
|
+
function kindOf(input) {
|
|
45672
|
+
return typeof input === "object" && input !== null ? Reflect.get(input, "kind") : void 0;
|
|
45673
|
+
}
|
|
45674
|
+
/** Where the nesting ends, a block step is refused in words rather than as an unknown kind. */
|
|
45675
|
+
function nestTooDeep(issue) {
|
|
45676
|
+
const kind = kindOf(issue.input);
|
|
45677
|
+
return typeof kind === "string" && BLOCK_STEP_KINDS.includes(kind) ? NEST_TOO_DEEP : void 0;
|
|
45678
|
+
}
|
|
45679
|
+
var plainStepSchemas = [
|
|
45680
|
+
AutomationWaitStepSchema.strict(),
|
|
45681
|
+
AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
|
|
45682
|
+
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
45683
|
+
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
45684
|
+
AutomationRunActionStepSchema.strict()
|
|
45685
|
+
];
|
|
45686
|
+
/**
|
|
45687
|
+
* A plain step: a flow step with no condition of its own and no step inside
|
|
45688
|
+
* it. The second (last) level of nesting holds these only.
|
|
45689
|
+
*/
|
|
45690
|
+
var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
|
|
45691
|
+
/** A step that can run beside others: it writes no variable and does not end the run. */
|
|
45692
|
+
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");
|
|
45693
|
+
/**
|
|
45694
|
+
* Several steps at once (#500): all are started together and all are awaited.
|
|
45695
|
+
* A failure fails the run once the others finished, as in a sequence; a member
|
|
45696
|
+
* marked "continue if this fails" does not.
|
|
45697
|
+
*/
|
|
45698
|
+
var AutomationParallelStepSchema = object({
|
|
45699
|
+
kind: literal("parallel"),
|
|
45700
|
+
steps: array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
|
|
45701
|
+
}).strict();
|
|
45702
|
+
var REPEAT_NEEDS_MAX = "a repeat on a condition needs a maximum number of iterations";
|
|
45703
|
+
/** A loop on a condition: the bound is mandatory, so a run never loops without an end. */
|
|
45704
|
+
var repeatConditionShape = {
|
|
45705
|
+
when: AutomationWhenSchema,
|
|
45706
|
+
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`),
|
|
45707
|
+
/** A pause between two iterations, never after the last. */
|
|
45708
|
+
waitS: number$1().int().min(1).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG).optional()
|
|
45709
|
+
};
|
|
45710
|
+
/** What decides how many times a `repeat` runs. */
|
|
45711
|
+
var AutomationRepeatLoopSchema = discriminatedUnion("by", [
|
|
45712
|
+
object({
|
|
45713
|
+
by: literal("count"),
|
|
45714
|
+
count: number$1().int().min(1).max(20, `a repeat runs at most 20 times`)
|
|
45715
|
+
}).strict(),
|
|
45716
|
+
object({
|
|
45717
|
+
by: literal("while"),
|
|
45718
|
+
...repeatConditionShape
|
|
45719
|
+
}).strict(),
|
|
45720
|
+
object({
|
|
45721
|
+
by: literal("until"),
|
|
45722
|
+
...repeatConditionShape
|
|
45723
|
+
}).strict(),
|
|
45724
|
+
object({
|
|
45725
|
+
by: literal("forEach"),
|
|
45726
|
+
target: object({
|
|
45727
|
+
kind: literal("devices"),
|
|
45728
|
+
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`)
|
|
45729
|
+
}).strict()
|
|
45730
|
+
}).strict()
|
|
45731
|
+
]);
|
|
45732
|
+
/**
|
|
45733
|
+
* The same steps several times (#500). Every form is bounded at save, so a
|
|
45734
|
+
* run cannot loop without an end. A failure or a `stop` in the steps ends the
|
|
45735
|
+
* loop and the run, as in a sequence.
|
|
45736
|
+
*/
|
|
45737
|
+
function repeatSchemaOf(step) {
|
|
45738
|
+
return object({
|
|
45739
|
+
kind: literal("repeat"),
|
|
45740
|
+
loop: AutomationRepeatLoopSchema,
|
|
45741
|
+
steps: array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
|
|
45742
|
+
}).strict();
|
|
45743
|
+
}
|
|
45744
|
+
/**
|
|
45745
|
+
* One step, several ways (#500): the branches are read in order and the FIRST
|
|
45746
|
+
* whose condition is true runs; `else` runs when every branch is false. A
|
|
45747
|
+
* branch that cannot be read ends the choice: nothing runs, not the branches
|
|
45748
|
+
* after it and not the else (D49). The #472 `if` / `else` of a wait or cap
|
|
45749
|
+
* step is the one-branch case and stays as it is stored.
|
|
45750
|
+
*/
|
|
45751
|
+
function chooseSchemaOf(step) {
|
|
45752
|
+
const steps = array(step).max(10);
|
|
45753
|
+
return object({
|
|
45754
|
+
kind: literal("choose"),
|
|
45755
|
+
branches: array(object({
|
|
45756
|
+
if: AutomationWhenSchema,
|
|
45757
|
+
steps: steps.min(1, "a branch needs at least one step")
|
|
45758
|
+
})).min(1, "a choose needs at least one branch").max(6, `a choose takes at most 6 branches`),
|
|
45759
|
+
else: steps.optional()
|
|
45760
|
+
});
|
|
45761
|
+
}
|
|
45762
|
+
var AutomationBodyStepSchema = discriminatedUnion("kind", [
|
|
45763
|
+
...plainStepSchemas,
|
|
45764
|
+
AutomationWaitUntilStepSchema,
|
|
45765
|
+
AutomationParallelStepSchema,
|
|
45766
|
+
chooseSchemaOf(AutomationBranchStepSchema),
|
|
45767
|
+
repeatSchemaOf(AutomationBranchStepSchema)
|
|
45768
|
+
]);
|
|
45769
|
+
var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
|
|
45472
45770
|
var AutomationActionSchema = discriminatedUnion("kind", [
|
|
45473
45771
|
GuardedWaitStepSchema,
|
|
45474
|
-
|
|
45475
|
-
|
|
45476
|
-
|
|
45477
|
-
|
|
45478
|
-
|
|
45479
|
-
|
|
45480
|
-
|
|
45481
|
-
|
|
45482
|
-
number$1(),
|
|
45483
|
-
boolean()
|
|
45484
|
-
])).optional()
|
|
45485
|
-
}),
|
|
45772
|
+
AutomationGuardedCommandStepSchema,
|
|
45773
|
+
AutomationStopStepSchema,
|
|
45774
|
+
AutomationSetStepSchema,
|
|
45775
|
+
chooseSchemaOf(AutomationBodyStepSchema),
|
|
45776
|
+
AutomationWaitUntilStepSchema,
|
|
45777
|
+
AutomationParallelStepSchema,
|
|
45778
|
+
AutomationRepeatStepSchema,
|
|
45779
|
+
AutomationRunActionStepSchema,
|
|
45486
45780
|
object({
|
|
45487
45781
|
kind: literal("code"),
|
|
45488
45782
|
/** Compiled into the automation's OWN block by esbuild — not a third
|
|
@@ -45545,44 +45839,7 @@ function convertLegacyRecipe(legacy) {
|
|
|
45545
45839
|
...rest
|
|
45546
45840
|
};
|
|
45547
45841
|
}
|
|
45548
|
-
/**
|
|
45549
|
-
* Where recipes are PARSED (the core-blocks cap, the MCP tool, the literal a
|
|
45550
|
-
* saved block carries): the new shape as it is, or the old shape converted to
|
|
45551
|
-
* it. The output type is always the new one.
|
|
45552
|
-
*/
|
|
45553
45842
|
var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
|
|
45554
|
-
var DETECTION_DESCRIPTIONS = {
|
|
45555
|
-
deviceId: "the camera that saw it",
|
|
45556
|
-
className: "what it saw",
|
|
45557
|
-
trackId: "the track",
|
|
45558
|
-
score: "how sure the detector was",
|
|
45559
|
-
label: "the label it matched (a name, a plate), empty when none"
|
|
45560
|
-
};
|
|
45561
|
-
var STATIONARY_DESCRIPTIONS = {
|
|
45562
|
-
deviceId: "the camera that saw it",
|
|
45563
|
-
className: "what it saw",
|
|
45564
|
-
zones: "the zones it is in",
|
|
45565
|
-
phase: "appeared or departed",
|
|
45566
|
-
entryId: "the stopped object"
|
|
45567
|
-
};
|
|
45568
|
-
var BECOMES_DESCRIPTIONS = {
|
|
45569
|
-
deviceId: "the device that changed",
|
|
45570
|
-
from: "the value before the change, empty when it is not known",
|
|
45571
|
-
to: "the value it changed to"
|
|
45572
|
-
};
|
|
45573
|
-
function describe$1(descriptions) {
|
|
45574
|
-
return Object.entries(descriptions).map(([name, description]) => ({
|
|
45575
|
-
name,
|
|
45576
|
-
description
|
|
45577
|
-
}));
|
|
45578
|
-
}
|
|
45579
|
-
describe$1(DETECTION_DESCRIPTIONS);
|
|
45580
|
-
describe$1(STATIONARY_DESCRIPTIONS);
|
|
45581
|
-
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45582
|
-
...v,
|
|
45583
|
-
hintKey: "becomesDeviceId"
|
|
45584
|
-
} : v);
|
|
45585
|
-
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
45586
45843
|
/**
|
|
45587
45844
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
45588
45845
|
*
|
|
@@ -45634,12 +45891,16 @@ var HoldOverrideSchema = discriminatedUnion("mode", [object({ mode: literal("res
|
|
|
45634
45891
|
})]);
|
|
45635
45892
|
/** A missed edge up to this late still runs. */
|
|
45636
45893
|
var DEFAULT_MAX_LATE_MS = 10 * 6e4;
|
|
45894
|
+
var SchedulerStepSchema = ActionStepSchema.refine((step) => step.kind !== "wait" || step.seconds <= 300, {
|
|
45895
|
+
message: `a scheduler point waits at most five minutes (300 s); put a longer wait in an action`,
|
|
45896
|
+
path: ["seconds"]
|
|
45897
|
+
});
|
|
45637
45898
|
var SchedulerPointSchema = object({
|
|
45638
45899
|
id: string().min(1).max(64),
|
|
45639
45900
|
at: SchedulerTimeSpecSchema,
|
|
45640
45901
|
mode: SchedulerPointModeSchema,
|
|
45641
45902
|
/** The actions of an `edge` or `hold`; a `release` has none. */
|
|
45642
|
-
steps: array(
|
|
45903
|
+
steps: array(SchedulerStepSchema).max(20).default([]),
|
|
45643
45904
|
/** Checked when the point runs (an edge) or is applied (a hold). */
|
|
45644
45905
|
conditions: SchedulerStateTreeSchema.optional(),
|
|
45645
45906
|
/** Hold only; absent means `respect`. */
|
|
@@ -45837,6 +46098,7 @@ var AutomationConditionTraceNodeSchema = object({
|
|
|
45837
46098
|
"triggered-by",
|
|
45838
46099
|
"device-becomes",
|
|
45839
46100
|
"device-event",
|
|
46101
|
+
"device-fired",
|
|
45840
46102
|
"schedule",
|
|
45841
46103
|
"interval",
|
|
45842
46104
|
"manual",
|
|
@@ -45907,18 +46169,46 @@ var StepTraceBaseSchema = object({
|
|
|
45907
46169
|
]).optional(),
|
|
45908
46170
|
/** Why the condition read what it read, in the evaluator's own words. */
|
|
45909
46171
|
conditionReason: string().optional(),
|
|
45910
|
-
/** `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. */
|
|
46172
|
+
/** `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). */
|
|
45911
46173
|
outcome: _enum([
|
|
45912
46174
|
"ok",
|
|
45913
46175
|
"error",
|
|
45914
46176
|
"not-run",
|
|
45915
46177
|
"empty",
|
|
45916
|
-
"skipped"
|
|
46178
|
+
"skipped",
|
|
46179
|
+
"failed-continued",
|
|
46180
|
+
"timed-out"
|
|
45917
46181
|
]),
|
|
45918
46182
|
message: string().optional()
|
|
45919
46183
|
});
|
|
46184
|
+
/** What a block step adds to its row: which list ran, what each branch read, how many rounds. */
|
|
46185
|
+
var blockTraceShape = {
|
|
46186
|
+
/** A `choose` step (#500): the list that ran, `branches.<n>` or `else`. Absent when none did. */
|
|
46187
|
+
branch: string().optional(),
|
|
46188
|
+
/** A `choose` step: what each branch read, in order, up to the one that decided. */
|
|
46189
|
+
branchChecks: array(object({
|
|
46190
|
+
condition: _enum([
|
|
46191
|
+
"true",
|
|
46192
|
+
"false",
|
|
46193
|
+
"unknown"
|
|
46194
|
+
]),
|
|
46195
|
+
conditionReason: string().optional()
|
|
46196
|
+
})).optional(),
|
|
46197
|
+
/** A `repeat` step (#500): how many times its steps ran. */
|
|
46198
|
+
iterations: number$1().int().optional()
|
|
46199
|
+
};
|
|
46200
|
+
/** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
|
|
46201
|
+
var NestedStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46202
|
+
...blockTraceShape,
|
|
46203
|
+
steps: array(StepTraceBaseSchema).optional()
|
|
46204
|
+
});
|
|
45920
46205
|
/** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
|
|
45921
|
-
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46206
|
+
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46207
|
+
else: array(StepTraceBaseSchema).optional(),
|
|
46208
|
+
...blockTraceShape,
|
|
46209
|
+
/** A `choose` step: the steps of the list that ran. A `parallel`: its members. A `repeat`: the LAST iteration. */
|
|
46210
|
+
steps: array(NestedStepTraceSchema).optional()
|
|
46211
|
+
});
|
|
45922
46212
|
var AutomationRunTraceSchema = object({
|
|
45923
46213
|
runId: string().min(1),
|
|
45924
46214
|
startedAt: number$1(),
|
|
@@ -45948,6 +46238,86 @@ var AutomationStateDocSchema = object({
|
|
|
45948
46238
|
lastRunStartedAt: number$1().nullable(),
|
|
45949
46239
|
traces: array(AutomationRunTraceSchema)
|
|
45950
46240
|
});
|
|
46241
|
+
var DETECTION_DESCRIPTIONS = {
|
|
46242
|
+
deviceId: "the camera that saw it",
|
|
46243
|
+
className: "what it saw",
|
|
46244
|
+
trackId: "the track",
|
|
46245
|
+
score: "how sure the detector was",
|
|
46246
|
+
label: "the label it matched (a name, a plate), empty when none"
|
|
46247
|
+
};
|
|
46248
|
+
var STATIONARY_DESCRIPTIONS = {
|
|
46249
|
+
deviceId: "the camera that saw it",
|
|
46250
|
+
className: "what it saw",
|
|
46251
|
+
zones: "the zones it is in",
|
|
46252
|
+
phase: "appeared or departed",
|
|
46253
|
+
entryId: "the stopped object"
|
|
46254
|
+
};
|
|
46255
|
+
var BECOMES_DESCRIPTIONS = {
|
|
46256
|
+
deviceId: "the device that changed",
|
|
46257
|
+
from: "the value before the change, empty when it is not known",
|
|
46258
|
+
to: "the value it changed to"
|
|
46259
|
+
};
|
|
46260
|
+
/**
|
|
46261
|
+
* A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
|
|
46262
|
+
* those names depend on the device, so they are not in this list.
|
|
46263
|
+
*/
|
|
46264
|
+
var FIRED_DESCRIPTIONS = {
|
|
46265
|
+
deviceId: "the device that fired",
|
|
46266
|
+
eventType: "the event, as the device names it",
|
|
46267
|
+
sourceId: "the part of the device that fired (a button), empty when it names none",
|
|
46268
|
+
eventKind: "the kind of press (press, long-press …), empty when the device declares none"
|
|
46269
|
+
};
|
|
46270
|
+
function describe$1(descriptions) {
|
|
46271
|
+
return Object.entries(descriptions).map(([name, description]) => ({
|
|
46272
|
+
name,
|
|
46273
|
+
description
|
|
46274
|
+
}));
|
|
46275
|
+
}
|
|
46276
|
+
describe$1(DETECTION_DESCRIPTIONS);
|
|
46277
|
+
describe$1(STATIONARY_DESCRIPTIONS);
|
|
46278
|
+
describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
46279
|
+
...v,
|
|
46280
|
+
hintKey: "firedDeviceId"
|
|
46281
|
+
} : v);
|
|
46282
|
+
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
46283
|
+
...v,
|
|
46284
|
+
hintKey: "becomesDeviceId"
|
|
46285
|
+
} : v);
|
|
46286
|
+
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
46287
|
+
/**
|
|
46288
|
+
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
46289
|
+
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
46290
|
+
* (NO normalization). Two shapes:
|
|
46291
|
+
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
46292
|
+
* declared set (e.g. press_short, press_long, …).
|
|
46293
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
46294
|
+
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
46295
|
+
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
46296
|
+
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
46297
|
+
* A fire names the part of the device it came from in `sourceId` when the
|
|
46298
|
+
* vocabulary declares sources (a remote's buttons).
|
|
46299
|
+
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
46300
|
+
*/
|
|
46301
|
+
var EventFireSchema = object({
|
|
46302
|
+
deviceId: number$1(),
|
|
46303
|
+
eventType: string(),
|
|
46304
|
+
sourceId: string().optional(),
|
|
46305
|
+
data: record(string(), unknown()).nullable(),
|
|
46306
|
+
timestamp: number$1().meta(readingMeta("none")),
|
|
46307
|
+
seq: number$1().meta(readingMeta("count"))
|
|
46308
|
+
});
|
|
46309
|
+
var EventEmitterStatusSchema = object({
|
|
46310
|
+
eventTypes: array(string()),
|
|
46311
|
+
/**
|
|
46312
|
+
* Required of a provider by the type. A status written before the field
|
|
46313
|
+
* existed still parses, as an empty vocabulary: read it through
|
|
46314
|
+
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
46315
|
+
*/
|
|
46316
|
+
vocabulary: array(EventVocabularyEntrySchema).default([]),
|
|
46317
|
+
lastEvent: EventFireSchema.nullable(),
|
|
46318
|
+
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
46319
|
+
});
|
|
46320
|
+
DeviceType.EventEmitter;
|
|
45951
46321
|
/**
|
|
45952
46322
|
* Actions — named, runnable things an operator (or an automation) can start,
|
|
45953
46323
|
* declared as LIST ENTRIES, never as devices.
|
|
@@ -46210,6 +46580,343 @@ function pruneDeletedEntities(selection, live, log, exporter) {
|
|
|
46210
46580
|
dropped
|
|
46211
46581
|
};
|
|
46212
46582
|
}
|
|
46583
|
+
/**
|
|
46584
|
+
* `device-export` — collection cap for addons that export camstack
|
|
46585
|
+
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
46586
|
+
* HomeKit/HAP, Alexa Smart Home, …).
|
|
46587
|
+
*
|
|
46588
|
+
* No `ecosystem` enum — the addon id identifies the export target.
|
|
46589
|
+
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
46590
|
+
* exposes only the COMMON surface: link state, supported device
|
|
46591
|
+
* kinds (so the UI can filter the device picker), and per-device
|
|
46592
|
+
* expose/unexpose.
|
|
46593
|
+
*
|
|
46594
|
+
* INSTANCES. One export addon can serve several independent targets (a
|
|
46595
|
+
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
46596
|
+
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
46597
|
+
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
46598
|
+
* default instance's); present = that instance; an id the provider does not
|
|
46599
|
+
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
46600
|
+
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
46601
|
+
* change always names the target it changes. A single-instance provider
|
|
46602
|
+
* accepts an absent id on a read or its own id, and refuses any other.
|
|
46603
|
+
*/
|
|
46604
|
+
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
46605
|
+
var InstanceIdSchema$1 = string().min(1);
|
|
46606
|
+
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
46607
|
+
/** One independent export target of an addon. */
|
|
46608
|
+
var ExportInstanceSchema = object({
|
|
46609
|
+
instanceId: InstanceIdSchema$1,
|
|
46610
|
+
name: string(),
|
|
46611
|
+
enabled: boolean(),
|
|
46612
|
+
kind: string().optional(),
|
|
46613
|
+
/**
|
|
46614
|
+
* What this instance's platform accepts as a device name, in one operator-facing sentence
|
|
46615
|
+
* (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
|
|
46616
|
+
* about the rule.
|
|
46617
|
+
*/
|
|
46618
|
+
nameRule: string().optional()
|
|
46619
|
+
});
|
|
46620
|
+
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
46621
|
+
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
46622
|
+
var ExportInstanceUnknownError = class extends Error {
|
|
46623
|
+
code = EXPORT_INSTANCE_UNKNOWN;
|
|
46624
|
+
instanceId;
|
|
46625
|
+
constructor(addon, instanceId) {
|
|
46626
|
+
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
46627
|
+
this.name = "ExportInstanceUnknownError";
|
|
46628
|
+
this.instanceId = instanceId;
|
|
46629
|
+
}
|
|
46630
|
+
};
|
|
46631
|
+
/**
|
|
46632
|
+
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
46633
|
+
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
46634
|
+
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
46635
|
+
*/
|
|
46636
|
+
function statusInstanceOf(input) {
|
|
46637
|
+
return "instanceId" in input ? input.instanceId : void 0;
|
|
46638
|
+
}
|
|
46639
|
+
var LinkStateSchema = _enum([
|
|
46640
|
+
"unlinked",
|
|
46641
|
+
"linked",
|
|
46642
|
+
"error"
|
|
46643
|
+
]);
|
|
46644
|
+
/**
|
|
46645
|
+
* A single label/value row surfaced in the export panel's "Setup"
|
|
46646
|
+
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
46647
|
+
* rows are masked by default with a reveal toggle (client ids,
|
|
46648
|
+
* secrets, …).
|
|
46649
|
+
*/
|
|
46650
|
+
var ExportSetupFieldSchema = object({
|
|
46651
|
+
label: string(),
|
|
46652
|
+
value: string(),
|
|
46653
|
+
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
46654
|
+
secret: boolean().optional()
|
|
46655
|
+
});
|
|
46656
|
+
/**
|
|
46657
|
+
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
46658
|
+
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
46659
|
+
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
46660
|
+
* the provider supplies and skips the section entirely when `setup`
|
|
46661
|
+
* is unset.
|
|
46662
|
+
*/
|
|
46663
|
+
var ExportSetupSchema = object({
|
|
46664
|
+
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
46665
|
+
qr: string().optional(),
|
|
46666
|
+
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
46667
|
+
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
46668
|
+
/** Free-form operator instructions rendered above the fields. */
|
|
46669
|
+
note: string().optional()
|
|
46670
|
+
});
|
|
46671
|
+
var DeviceExportStatusSchema = object({
|
|
46672
|
+
linkState: LinkStateSchema,
|
|
46673
|
+
exposedDeviceCount: number$1(),
|
|
46674
|
+
error: string().optional(),
|
|
46675
|
+
/**
|
|
46676
|
+
* Optional pairing/account info the panel renders in a generic
|
|
46677
|
+
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
46678
|
+
* export target, never an `ecosystem` key here.
|
|
46679
|
+
*/
|
|
46680
|
+
setup: ExportSetupSchema.optional()
|
|
46681
|
+
});
|
|
46682
|
+
var DeviceKindSchema = string();
|
|
46683
|
+
/**
|
|
46684
|
+
* EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
|
|
46685
|
+
* device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
|
|
46686
|
+
* store (D865), validated by the exporter against its platform's naming rules, and never reaches
|
|
46687
|
+
* the exported id — a rename updates the SAME device on the platform, never a second one.
|
|
46688
|
+
* Blank or `null` = the device's own name. A name the platform would refuse is refused with
|
|
46689
|
+
* `ExportNameRefusedError` (`export-name-refused`), whose message says why.
|
|
46690
|
+
*/
|
|
46691
|
+
var ExposedDeviceSchema = object({
|
|
46692
|
+
deviceId: string(),
|
|
46693
|
+
exposedAs: string().optional(),
|
|
46694
|
+
/** The operator's name for this device on this instance; absent = the device's own name. */
|
|
46695
|
+
exposedName: string().optional(),
|
|
46696
|
+
capabilities: array(string()).optional()
|
|
46697
|
+
});
|
|
46698
|
+
var ExposeInputSchema = object({
|
|
46699
|
+
instanceId: InstanceIdSchema$1,
|
|
46700
|
+
deviceId: string(),
|
|
46701
|
+
capabilities: array(string()).optional(),
|
|
46702
|
+
/** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
|
|
46703
|
+
exposedName: string().nullable().optional()
|
|
46704
|
+
});
|
|
46705
|
+
var SetExposedNameInputSchema = object({
|
|
46706
|
+
instanceId: InstanceIdSchema$1,
|
|
46707
|
+
deviceId: string(),
|
|
46708
|
+
/** Blank or null = the device's own name. */
|
|
46709
|
+
name: string().nullable(),
|
|
46710
|
+
/**
|
|
46711
|
+
* Validate only: refuse exactly as a real call would, write nothing. A caller saving several
|
|
46712
|
+
* names at once checks every one first, so one refusal writes none (D1049).
|
|
46713
|
+
*/
|
|
46714
|
+
dryRun: boolean().optional()
|
|
46715
|
+
});
|
|
46716
|
+
var EXPORT_NAME_REFUSED = "export-name-refused";
|
|
46717
|
+
/** A name the instance's platform would refuse. The message starts with the code, then the reason. */
|
|
46718
|
+
var ExportNameRefusedError = class extends Error {
|
|
46719
|
+
code = EXPORT_NAME_REFUSED;
|
|
46720
|
+
instanceId;
|
|
46721
|
+
reason;
|
|
46722
|
+
constructor(instanceId, reason) {
|
|
46723
|
+
super(`${EXPORT_NAME_REFUSED}: ${reason}`);
|
|
46724
|
+
this.name = "ExportNameRefusedError";
|
|
46725
|
+
this.instanceId = instanceId;
|
|
46726
|
+
this.reason = reason;
|
|
46727
|
+
}
|
|
46728
|
+
};
|
|
46729
|
+
var UnexposeInputSchema = object({
|
|
46730
|
+
instanceId: InstanceIdSchema$1,
|
|
46731
|
+
deviceId: string()
|
|
46732
|
+
});
|
|
46733
|
+
/**
|
|
46734
|
+
* What an exporter may expose besides devices (D968). An action and a
|
|
46735
|
+
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
46736
|
+
* exporter's own selection, not the device registry.
|
|
46737
|
+
*/
|
|
46738
|
+
var ExportEntityKindSchema = _enum([
|
|
46739
|
+
"device",
|
|
46740
|
+
"action",
|
|
46741
|
+
"notifier"
|
|
46742
|
+
]);
|
|
46743
|
+
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
46744
|
+
object({
|
|
46745
|
+
kind: literal("device"),
|
|
46746
|
+
deviceId: string()
|
|
46747
|
+
}),
|
|
46748
|
+
object({
|
|
46749
|
+
kind: literal("action"),
|
|
46750
|
+
actionId: string().min(1)
|
|
46751
|
+
}),
|
|
46752
|
+
object({
|
|
46753
|
+
kind: literal("notifier"),
|
|
46754
|
+
targetId: string().min(1)
|
|
46755
|
+
})
|
|
46756
|
+
]);
|
|
46757
|
+
var ExposedEntitySchema = object({
|
|
46758
|
+
entity: ExportEntityRefSchema,
|
|
46759
|
+
exposedAs: string().optional()
|
|
46760
|
+
});
|
|
46761
|
+
var ExposeEntityInputSchema = object({
|
|
46762
|
+
instanceId: InstanceIdSchema$1,
|
|
46763
|
+
entity: ExportEntityRefSchema
|
|
46764
|
+
});
|
|
46765
|
+
var UnexposeEntityInputSchema = object({
|
|
46766
|
+
instanceId: InstanceIdSchema$1,
|
|
46767
|
+
entity: ExportEntityRefSchema
|
|
46768
|
+
});
|
|
46769
|
+
var deviceExportCapability = {
|
|
46770
|
+
name: "device-export",
|
|
46771
|
+
scope: "system",
|
|
46772
|
+
mode: "collection",
|
|
46773
|
+
providerKind: "device-export",
|
|
46774
|
+
status: {
|
|
46775
|
+
schema: DeviceExportStatusSchema,
|
|
46776
|
+
kind: "poll"
|
|
46777
|
+
},
|
|
46778
|
+
/**
|
|
46779
|
+
* Each export provider MAY contribute its own per-device "Export" panel
|
|
46780
|
+
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
46781
|
+
* framework methods are mounted on the cap router when present.
|
|
46782
|
+
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
46783
|
+
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
46784
|
+
* never hand-written — D14 — and an exporter is not one of those).
|
|
46785
|
+
*/
|
|
46786
|
+
exposesDeviceSettings: true,
|
|
46787
|
+
methods: {
|
|
46788
|
+
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
46789
|
+
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
46790
|
+
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
46791
|
+
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
46792
|
+
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
46793
|
+
kind: "mutation",
|
|
46794
|
+
auth: "admin"
|
|
46795
|
+
}),
|
|
46796
|
+
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
46797
|
+
kind: "mutation",
|
|
46798
|
+
auth: "admin"
|
|
46799
|
+
}),
|
|
46800
|
+
setExposedName: method(SetExposedNameInputSchema, _void(), {
|
|
46801
|
+
kind: "mutation",
|
|
46802
|
+
auth: "admin"
|
|
46803
|
+
}),
|
|
46804
|
+
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
46805
|
+
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
46806
|
+
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
46807
|
+
kind: "mutation",
|
|
46808
|
+
auth: "admin"
|
|
46809
|
+
}),
|
|
46810
|
+
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
46811
|
+
kind: "mutation",
|
|
46812
|
+
auth: "admin"
|
|
46813
|
+
})
|
|
46814
|
+
}
|
|
46815
|
+
};
|
|
46816
|
+
/**
|
|
46817
|
+
* The exposed name of a device on one export instance (`device-export`, D1049).
|
|
46818
|
+
*
|
|
46819
|
+
* Every exporter keeps its names the same way: in ITS per-device store (D865), under
|
|
46820
|
+
* {@link EXPOSED_NAMES_STORE_KEY}, one entry per instance id. The store is cleared centrally
|
|
46821
|
+
* when the device is deleted, so no removal hook is needed for it. Each exporter supplies the
|
|
46822
|
+
* validator of its own platform; the normalisation, the store shape and the refusal are here so
|
|
46823
|
+
* the four exporters cannot drift apart.
|
|
46824
|
+
*
|
|
46825
|
+
* The name is a label only: no exporter derives the exported id from it, so a rename updates
|
|
46826
|
+
* the same device on the platform.
|
|
46827
|
+
*/
|
|
46828
|
+
/** The per-device store key holding `{ [instanceId]: name }`. */
|
|
46829
|
+
var EXPOSED_NAMES_STORE_KEY = "exposedNames";
|
|
46830
|
+
var ExposedNamesSchema = record(string(), string());
|
|
46831
|
+
/** Trim and collapse whitespace, then the platform rule. Blank or null clears (`name: null`). */
|
|
46832
|
+
function checkExposedName(raw, validate) {
|
|
46833
|
+
if (raw === null || raw === void 0) return {
|
|
46834
|
+
ok: true,
|
|
46835
|
+
name: null
|
|
46836
|
+
};
|
|
46837
|
+
if (typeof raw !== "string") return {
|
|
46838
|
+
ok: false,
|
|
46839
|
+
reason: "The name must be text."
|
|
46840
|
+
};
|
|
46841
|
+
const name = raw.trim().replace(/\s+/g, " ");
|
|
46842
|
+
if (name.length === 0) return {
|
|
46843
|
+
ok: true,
|
|
46844
|
+
name: null
|
|
46845
|
+
};
|
|
46846
|
+
return validate(name);
|
|
46847
|
+
}
|
|
46848
|
+
/** Every saved name of a device, by instance id. A malformed blob reads as none. */
|
|
46849
|
+
function readExposedNames(store) {
|
|
46850
|
+
const parsed = ExposedNamesSchema.safeParse(store[EXPOSED_NAMES_STORE_KEY]);
|
|
46851
|
+
return parsed.success ? parsed.data : {};
|
|
46852
|
+
}
|
|
46853
|
+
/**
|
|
46854
|
+
* The saved name of one instance, or null: never saved, or a stored value the platform would
|
|
46855
|
+
* now refuse (the device's own name is used rather than pushing a name the platform rejects).
|
|
46856
|
+
*/
|
|
46857
|
+
function readExposedName(store, instanceId, validate) {
|
|
46858
|
+
const saved = readExposedNames(store)[instanceId];
|
|
46859
|
+
if (saved === void 0) return null;
|
|
46860
|
+
const check = checkExposedName(saved, validate);
|
|
46861
|
+
return check.ok ? check.name : null;
|
|
46862
|
+
}
|
|
46863
|
+
/** The store patch that sets (or, with null, clears) one instance's name and keeps the others. */
|
|
46864
|
+
function exposedNamePatch(store, instanceId, name) {
|
|
46865
|
+
const others = Object.fromEntries(Object.entries(readExposedNames(store)).filter(([id]) => id !== instanceId));
|
|
46866
|
+
return { [EXPOSED_NAMES_STORE_KEY]: name === null ? others : {
|
|
46867
|
+
...others,
|
|
46868
|
+
[instanceId]: name
|
|
46869
|
+
} };
|
|
46870
|
+
}
|
|
46871
|
+
/**
|
|
46872
|
+
* Validate and save one instance's name. A name the platform would refuse throws
|
|
46873
|
+
* {@link ExportNameRefusedError} BEFORE anything is written, so the old name stays.
|
|
46874
|
+
*/
|
|
46875
|
+
async function saveExposedName(input) {
|
|
46876
|
+
const check = checkExposedName(input.raw, input.validate);
|
|
46877
|
+
if (!check.ok) throw new ExportNameRefusedError(input.instanceId, check.reason);
|
|
46878
|
+
if (input.dryRun === true) return {
|
|
46879
|
+
changed: false,
|
|
46880
|
+
name: check.name
|
|
46881
|
+
};
|
|
46882
|
+
const store = await input.store.read(input.deviceId);
|
|
46883
|
+
if ((readExposedNames(store)[input.instanceId] ?? null) === check.name) return {
|
|
46884
|
+
changed: false,
|
|
46885
|
+
name: check.name
|
|
46886
|
+
};
|
|
46887
|
+
await input.store.write(input.deviceId, exposedNamePatch(store, input.instanceId, check.name));
|
|
46888
|
+
return {
|
|
46889
|
+
changed: true,
|
|
46890
|
+
name: check.name
|
|
46891
|
+
};
|
|
46892
|
+
}
|
|
46893
|
+
/** The exporter's per-device store as an {@link ExposedNameStore}; throws when settings are absent. */
|
|
46894
|
+
function exposedNameStoreOf(settings, owner) {
|
|
46895
|
+
const access = () => {
|
|
46896
|
+
if (settings === void 0) throw new Error(`${owner}: settings are not available`);
|
|
46897
|
+
return settings;
|
|
46898
|
+
};
|
|
46899
|
+
return {
|
|
46900
|
+
read: (deviceId) => access().readDeviceStore(deviceId),
|
|
46901
|
+
write: (deviceId, patch) => access().writeDeviceStore(deviceId, patch)
|
|
46902
|
+
};
|
|
46903
|
+
}
|
|
46904
|
+
/**
|
|
46905
|
+
* Remove every name saved for `instanceId` (the instance was deleted), so a later instance that
|
|
46906
|
+
* reuses the id does not inherit them. Returns the device ids that lost a name. A store that
|
|
46907
|
+
* cannot be read throws; nothing is written for the devices not reached.
|
|
46908
|
+
*/
|
|
46909
|
+
async function pruneExposedNames(settings, instanceId) {
|
|
46910
|
+
const ids = await settings.listDeviceStoreIds();
|
|
46911
|
+
if (ids.length === 0) return [];
|
|
46912
|
+
const pruned = [];
|
|
46913
|
+
for (const [deviceId, store] of await settings.readDeviceStoreBatch(ids)) {
|
|
46914
|
+
if (readExposedNames(store)[instanceId] === void 0) continue;
|
|
46915
|
+
await settings.writeDeviceStore(deviceId, exposedNamePatch(store, instanceId, null));
|
|
46916
|
+
pruned.push(deviceId);
|
|
46917
|
+
}
|
|
46918
|
+
return pruned;
|
|
46919
|
+
}
|
|
46213
46920
|
_enum([
|
|
46214
46921
|
"automation",
|
|
46215
46922
|
"action",
|
|
@@ -46408,7 +47115,9 @@ var AddonHttpRouteSchema = object({
|
|
|
46408
47115
|
]).optional(),
|
|
46409
47116
|
description: string().optional(),
|
|
46410
47117
|
/** The hub limits this route per client address before the handler runs. */
|
|
46411
|
-
rateLimit: _enum(["auth"]).optional()
|
|
47118
|
+
rateLimit: _enum(["auth"]).optional(),
|
|
47119
|
+
/** Served once per integration instance; the handler reads `instanceId`. */
|
|
47120
|
+
perInstance: boolean().optional()
|
|
46412
47121
|
});
|
|
46413
47122
|
/**
|
|
46414
47123
|
* Cross-process route invocation envelope. The hub captures the
|
|
@@ -46425,6 +47134,8 @@ var InvokeRequestSchema = object({
|
|
|
46425
47134
|
query: record(string(), string()),
|
|
46426
47135
|
body: unknown(),
|
|
46427
47136
|
headers: record(string(), string()),
|
|
47137
|
+
/** The instance the hub resolved for a `perInstance` route. */
|
|
47138
|
+
instanceId: string().optional(),
|
|
46428
47139
|
user: object({
|
|
46429
47140
|
id: string(),
|
|
46430
47141
|
username: string(),
|
|
@@ -50473,11 +51184,13 @@ var IrCodecError = class extends Error {
|
|
|
50473
51184
|
this.code = code;
|
|
50474
51185
|
}
|
|
50475
51186
|
};
|
|
51187
|
+
/** Maximum number of mark/space entries one pulse train may carry. */
|
|
51188
|
+
var IR_TIMINGS_MAX = 1024;
|
|
50476
51189
|
/**
|
|
50477
51190
|
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
50478
51191
|
* alternating, no zeros, 2..1024 entries.
|
|
50479
51192
|
*/
|
|
50480
|
-
var IrTimingsSchema = array(number$1().int()).min(2).max(
|
|
51193
|
+
var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
|
|
50481
51194
|
timings.forEach((value, index) => {
|
|
50482
51195
|
const expectMark = index % 2 === 0;
|
|
50483
51196
|
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
@@ -50524,15 +51237,186 @@ function decodePronto(code) {
|
|
|
50524
51237
|
carrierHz: Math.round(1e6 / unitUs)
|
|
50525
51238
|
};
|
|
50526
51239
|
}
|
|
50527
|
-
/**
|
|
50528
|
-
|
|
50529
|
-
|
|
50530
|
-
|
|
50531
|
-
|
|
50532
|
-
|
|
50533
|
-
|
|
50534
|
-
|
|
50535
|
-
|
|
51240
|
+
/**
|
|
51241
|
+
* FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
|
|
51242
|
+
* literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
|
|
51243
|
+
* is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
|
|
51244
|
+
* between the low 5 bits and the next byte.
|
|
51245
|
+
*/
|
|
51246
|
+
var MAX_DISTANCE = 8192;
|
|
51247
|
+
var MAX_LITERAL_RUN = 32;
|
|
51248
|
+
var MIN_MATCH = 3;
|
|
51249
|
+
var MAX_MATCH = 264;
|
|
51250
|
+
/**
|
|
51251
|
+
* Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
|
|
51252
|
+
* can expand ~130x, so the decoder checks this bound before every write.
|
|
51253
|
+
*/
|
|
51254
|
+
var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
|
|
51255
|
+
function fastlzDecompress(input) {
|
|
51256
|
+
const out = [];
|
|
51257
|
+
let ip = 0;
|
|
51258
|
+
const room = (count) => {
|
|
51259
|
+
if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
|
|
51260
|
+
};
|
|
51261
|
+
const next = () => {
|
|
51262
|
+
const byte = input[ip++];
|
|
51263
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
|
|
51264
|
+
return byte;
|
|
51265
|
+
};
|
|
51266
|
+
while (ip < input.length) {
|
|
51267
|
+
const ctrl = next();
|
|
51268
|
+
if (ctrl < 32) {
|
|
51269
|
+
room(ctrl + 1);
|
|
51270
|
+
for (let i = 0; i <= ctrl; i++) out.push(next());
|
|
51271
|
+
continue;
|
|
51272
|
+
}
|
|
51273
|
+
let len = (ctrl >> 5) - 1;
|
|
51274
|
+
if (len === 6) len += next();
|
|
51275
|
+
const distance = ((ctrl & 31) << 8) + next() + 1;
|
|
51276
|
+
const start = out.length - distance;
|
|
51277
|
+
if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
|
|
51278
|
+
room(len + 3);
|
|
51279
|
+
for (let i = 0; i < len + 3; i++) {
|
|
51280
|
+
const byte = out[start + i];
|
|
51281
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
|
|
51282
|
+
out.push(byte);
|
|
51283
|
+
}
|
|
51284
|
+
}
|
|
51285
|
+
return Uint8Array.from(out);
|
|
51286
|
+
}
|
|
51287
|
+
function fastlzCompress(input) {
|
|
51288
|
+
const out = [];
|
|
51289
|
+
const lastSeen = /* @__PURE__ */ new Map();
|
|
51290
|
+
let literalStart = 0;
|
|
51291
|
+
const flushLiterals = (end) => {
|
|
51292
|
+
for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
|
|
51293
|
+
const to = Math.min(from + MAX_LITERAL_RUN, end);
|
|
51294
|
+
out.push(to - from - 1);
|
|
51295
|
+
for (let i = from; i < to; i++) out.push(input[i] ?? 0);
|
|
51296
|
+
}
|
|
51297
|
+
};
|
|
51298
|
+
let pos = 0;
|
|
51299
|
+
while (pos < input.length) {
|
|
51300
|
+
let matchLen = 0;
|
|
51301
|
+
let matchDistance = 0;
|
|
51302
|
+
if (pos + MIN_MATCH <= input.length) {
|
|
51303
|
+
const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
|
|
51304
|
+
const candidate = lastSeen.get(key);
|
|
51305
|
+
lastSeen.set(key, pos);
|
|
51306
|
+
if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
|
|
51307
|
+
let len = 0;
|
|
51308
|
+
while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
|
|
51309
|
+
if (len >= MIN_MATCH) {
|
|
51310
|
+
matchLen = len;
|
|
51311
|
+
matchDistance = pos - candidate - 1;
|
|
51312
|
+
}
|
|
51313
|
+
}
|
|
51314
|
+
}
|
|
51315
|
+
if (matchLen === 0) {
|
|
51316
|
+
pos++;
|
|
51317
|
+
continue;
|
|
51318
|
+
}
|
|
51319
|
+
flushLiterals(pos);
|
|
51320
|
+
const enc = matchLen - 2;
|
|
51321
|
+
if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
|
|
51322
|
+
else out.push(224 | matchDistance >> 8, enc - 7);
|
|
51323
|
+
out.push(matchDistance & 255);
|
|
51324
|
+
pos += matchLen;
|
|
51325
|
+
literalStart = pos;
|
|
51326
|
+
}
|
|
51327
|
+
flushLiterals(input.length);
|
|
51328
|
+
return Uint8Array.from(out);
|
|
51329
|
+
}
|
|
51330
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
51331
|
+
var MAX_DURATION_US = 65535;
|
|
51332
|
+
function toBase64(bytes) {
|
|
51333
|
+
let out = "";
|
|
51334
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
51335
|
+
const a = bytes[i] ?? 0;
|
|
51336
|
+
const b = bytes[i + 1] ?? 0;
|
|
51337
|
+
const c = bytes[i + 2] ?? 0;
|
|
51338
|
+
const word = a << 16 | b << 8 | c;
|
|
51339
|
+
out += ALPHABET[word >> 18 & 63];
|
|
51340
|
+
out += ALPHABET[word >> 12 & 63];
|
|
51341
|
+
out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
|
|
51342
|
+
out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
|
|
51343
|
+
}
|
|
51344
|
+
return out;
|
|
51345
|
+
}
|
|
51346
|
+
function fromBase64(text) {
|
|
51347
|
+
const clean = text.trim().replace(/=+$/, "");
|
|
51348
|
+
if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51349
|
+
const out = [];
|
|
51350
|
+
let bits = 0;
|
|
51351
|
+
let acc = 0;
|
|
51352
|
+
for (const ch of clean) {
|
|
51353
|
+
const value = ALPHABET.indexOf(ch);
|
|
51354
|
+
if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51355
|
+
acc = acc << 6 | value;
|
|
51356
|
+
bits += 6;
|
|
51357
|
+
if (bits >= 8) {
|
|
51358
|
+
bits -= 8;
|
|
51359
|
+
out.push(acc >> bits & 255);
|
|
51360
|
+
}
|
|
51361
|
+
}
|
|
51362
|
+
return Uint8Array.from(out);
|
|
51363
|
+
}
|
|
51364
|
+
/** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
|
|
51365
|
+
function encodeTuya(timings) {
|
|
51366
|
+
const bytes = new Uint8Array(timings.length * 2);
|
|
51367
|
+
timings.forEach((value, index) => {
|
|
51368
|
+
const duration = Math.abs(value);
|
|
51369
|
+
if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
|
|
51370
|
+
bytes[index * 2] = duration & 255;
|
|
51371
|
+
bytes[index * 2 + 1] = duration >> 8;
|
|
51372
|
+
});
|
|
51373
|
+
return toBase64(fastlzCompress(bytes));
|
|
51374
|
+
}
|
|
51375
|
+
/** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
|
|
51376
|
+
function decodeTuya(code) {
|
|
51377
|
+
const bytes = fastlzDecompress(fromBase64(code));
|
|
51378
|
+
if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
|
|
51379
|
+
const timings = [];
|
|
51380
|
+
for (let i = 0; i < bytes.length; i += 2) {
|
|
51381
|
+
const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
|
|
51382
|
+
timings.push(i / 2 % 2 === 0 ? duration : -duration);
|
|
51383
|
+
}
|
|
51384
|
+
const checked = IrTimingsSchema.safeParse(timings);
|
|
51385
|
+
if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
|
|
51386
|
+
return checked.data;
|
|
51387
|
+
}
|
|
51388
|
+
/** Device-native IR code formats a transmitter can replay verbatim. */
|
|
51389
|
+
var IrNativeFormatSchema = _enum(["tuya"]);
|
|
51390
|
+
/**
|
|
51391
|
+
* Longest native code accepted: base64 of the worst-case compressed stream
|
|
51392
|
+
* (every decoded byte as a literal, plus one control byte per 32), with margin.
|
|
51393
|
+
*/
|
|
51394
|
+
var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
|
|
51395
|
+
var IrNativeCodeSchema = object({
|
|
51396
|
+
format: IrNativeFormatSchema,
|
|
51397
|
+
code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
|
|
51398
|
+
});
|
|
51399
|
+
var IR_NATIVE_CODECS = { tuya: {
|
|
51400
|
+
encode: encodeTuya,
|
|
51401
|
+
decode: decodeTuya
|
|
51402
|
+
} };
|
|
51403
|
+
/** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
|
|
51404
|
+
var IrPayloadSchema = discriminatedUnion("kind", [
|
|
51405
|
+
object({
|
|
51406
|
+
kind: literal("raw"),
|
|
51407
|
+
timings: array(number$1().int()),
|
|
51408
|
+
settings: TransmitSettingsSchema.optional()
|
|
51409
|
+
}),
|
|
51410
|
+
object({
|
|
51411
|
+
kind: literal("pronto"),
|
|
51412
|
+
code: string()
|
|
51413
|
+
}),
|
|
51414
|
+
object({
|
|
51415
|
+
kind: literal("native"),
|
|
51416
|
+
format: IrNativeFormatSchema,
|
|
51417
|
+
code: string()
|
|
51418
|
+
})
|
|
51419
|
+
]);
|
|
50536
51420
|
/** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
|
|
50537
51421
|
function toTimings(payload) {
|
|
50538
51422
|
if (payload.kind === "pronto") {
|
|
@@ -50542,6 +51426,10 @@ function toTimings(payload) {
|
|
|
50542
51426
|
settings: { carrierHz: decoded.carrierHz }
|
|
50543
51427
|
};
|
|
50544
51428
|
}
|
|
51429
|
+
if (payload.kind === "native") return {
|
|
51430
|
+
timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
|
|
51431
|
+
settings: {}
|
|
51432
|
+
};
|
|
50545
51433
|
const checked = IrTimingsSchema.safeParse(payload.timings);
|
|
50546
51434
|
if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
|
|
50547
51435
|
return {
|
|
@@ -52682,193 +53570,6 @@ method(object({
|
|
|
52682
53570
|
kind: "mutation",
|
|
52683
53571
|
auth: "admin"
|
|
52684
53572
|
});
|
|
52685
|
-
/**
|
|
52686
|
-
* `device-export` — collection cap for addons that export camstack
|
|
52687
|
-
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
52688
|
-
* HomeKit/HAP, Alexa Smart Home, …).
|
|
52689
|
-
*
|
|
52690
|
-
* No `ecosystem` enum — the addon id identifies the export target.
|
|
52691
|
-
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
52692
|
-
* exposes only the COMMON surface: link state, supported device
|
|
52693
|
-
* kinds (so the UI can filter the device picker), and per-device
|
|
52694
|
-
* expose/unexpose.
|
|
52695
|
-
*
|
|
52696
|
-
* INSTANCES. One export addon can serve several independent targets (a
|
|
52697
|
-
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
52698
|
-
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
52699
|
-
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
52700
|
-
* default instance's); present = that instance; an id the provider does not
|
|
52701
|
-
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
52702
|
-
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
52703
|
-
* change always names the target it changes. A single-instance provider
|
|
52704
|
-
* accepts an absent id on a read or its own id, and refuses any other.
|
|
52705
|
-
*/
|
|
52706
|
-
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
52707
|
-
var InstanceIdSchema$1 = string().min(1);
|
|
52708
|
-
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
52709
|
-
/** One independent export target of an addon. */
|
|
52710
|
-
var ExportInstanceSchema = object({
|
|
52711
|
-
instanceId: InstanceIdSchema$1,
|
|
52712
|
-
name: string(),
|
|
52713
|
-
enabled: boolean(),
|
|
52714
|
-
kind: string().optional()
|
|
52715
|
-
});
|
|
52716
|
-
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
52717
|
-
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
52718
|
-
var ExportInstanceUnknownError = class extends Error {
|
|
52719
|
-
code = EXPORT_INSTANCE_UNKNOWN;
|
|
52720
|
-
instanceId;
|
|
52721
|
-
constructor(addon, instanceId) {
|
|
52722
|
-
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
52723
|
-
this.name = "ExportInstanceUnknownError";
|
|
52724
|
-
this.instanceId = instanceId;
|
|
52725
|
-
}
|
|
52726
|
-
};
|
|
52727
|
-
/**
|
|
52728
|
-
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
52729
|
-
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
52730
|
-
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
52731
|
-
*/
|
|
52732
|
-
function statusInstanceOf(input) {
|
|
52733
|
-
return "instanceId" in input ? input.instanceId : void 0;
|
|
52734
|
-
}
|
|
52735
|
-
var LinkStateSchema = _enum([
|
|
52736
|
-
"unlinked",
|
|
52737
|
-
"linked",
|
|
52738
|
-
"error"
|
|
52739
|
-
]);
|
|
52740
|
-
/**
|
|
52741
|
-
* A single label/value row surfaced in the export panel's "Setup"
|
|
52742
|
-
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
52743
|
-
* rows are masked by default with a reveal toggle (client ids,
|
|
52744
|
-
* secrets, …).
|
|
52745
|
-
*/
|
|
52746
|
-
var ExportSetupFieldSchema = object({
|
|
52747
|
-
label: string(),
|
|
52748
|
-
value: string(),
|
|
52749
|
-
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
52750
|
-
secret: boolean().optional()
|
|
52751
|
-
});
|
|
52752
|
-
/**
|
|
52753
|
-
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
52754
|
-
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
52755
|
-
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
52756
|
-
* the provider supplies and skips the section entirely when `setup`
|
|
52757
|
-
* is unset.
|
|
52758
|
-
*/
|
|
52759
|
-
var ExportSetupSchema = object({
|
|
52760
|
-
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
52761
|
-
qr: string().optional(),
|
|
52762
|
-
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
52763
|
-
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
52764
|
-
/** Free-form operator instructions rendered above the fields. */
|
|
52765
|
-
note: string().optional()
|
|
52766
|
-
});
|
|
52767
|
-
var DeviceExportStatusSchema = object({
|
|
52768
|
-
linkState: LinkStateSchema,
|
|
52769
|
-
exposedDeviceCount: number$1(),
|
|
52770
|
-
error: string().optional(),
|
|
52771
|
-
/**
|
|
52772
|
-
* Optional pairing/account info the panel renders in a generic
|
|
52773
|
-
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
52774
|
-
* export target, never an `ecosystem` key here.
|
|
52775
|
-
*/
|
|
52776
|
-
setup: ExportSetupSchema.optional()
|
|
52777
|
-
});
|
|
52778
|
-
var DeviceKindSchema = string();
|
|
52779
|
-
var ExposedDeviceSchema = object({
|
|
52780
|
-
deviceId: string(),
|
|
52781
|
-
exposedAs: string().optional(),
|
|
52782
|
-
capabilities: array(string()).optional()
|
|
52783
|
-
});
|
|
52784
|
-
var ExposeInputSchema = object({
|
|
52785
|
-
instanceId: InstanceIdSchema$1,
|
|
52786
|
-
deviceId: string(),
|
|
52787
|
-
capabilities: array(string()).optional()
|
|
52788
|
-
});
|
|
52789
|
-
var UnexposeInputSchema = object({
|
|
52790
|
-
instanceId: InstanceIdSchema$1,
|
|
52791
|
-
deviceId: string()
|
|
52792
|
-
});
|
|
52793
|
-
/**
|
|
52794
|
-
* What an exporter may expose besides devices (D968). An action and a
|
|
52795
|
-
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
52796
|
-
* exporter's own selection, not the device registry.
|
|
52797
|
-
*/
|
|
52798
|
-
var ExportEntityKindSchema = _enum([
|
|
52799
|
-
"device",
|
|
52800
|
-
"action",
|
|
52801
|
-
"notifier"
|
|
52802
|
-
]);
|
|
52803
|
-
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
52804
|
-
object({
|
|
52805
|
-
kind: literal("device"),
|
|
52806
|
-
deviceId: string()
|
|
52807
|
-
}),
|
|
52808
|
-
object({
|
|
52809
|
-
kind: literal("action"),
|
|
52810
|
-
actionId: string().min(1)
|
|
52811
|
-
}),
|
|
52812
|
-
object({
|
|
52813
|
-
kind: literal("notifier"),
|
|
52814
|
-
targetId: string().min(1)
|
|
52815
|
-
})
|
|
52816
|
-
]);
|
|
52817
|
-
var ExposedEntitySchema = object({
|
|
52818
|
-
entity: ExportEntityRefSchema,
|
|
52819
|
-
exposedAs: string().optional()
|
|
52820
|
-
});
|
|
52821
|
-
var ExposeEntityInputSchema = object({
|
|
52822
|
-
instanceId: InstanceIdSchema$1,
|
|
52823
|
-
entity: ExportEntityRefSchema
|
|
52824
|
-
});
|
|
52825
|
-
var UnexposeEntityInputSchema = object({
|
|
52826
|
-
instanceId: InstanceIdSchema$1,
|
|
52827
|
-
entity: ExportEntityRefSchema
|
|
52828
|
-
});
|
|
52829
|
-
var deviceExportCapability = {
|
|
52830
|
-
name: "device-export",
|
|
52831
|
-
scope: "system",
|
|
52832
|
-
mode: "collection",
|
|
52833
|
-
providerKind: "device-export",
|
|
52834
|
-
status: {
|
|
52835
|
-
schema: DeviceExportStatusSchema,
|
|
52836
|
-
kind: "poll"
|
|
52837
|
-
},
|
|
52838
|
-
/**
|
|
52839
|
-
* Each export provider MAY contribute its own per-device "Export" panel
|
|
52840
|
-
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
52841
|
-
* framework methods are mounted on the cap router when present.
|
|
52842
|
-
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
52843
|
-
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
52844
|
-
* never hand-written — D14 — and an exporter is not one of those).
|
|
52845
|
-
*/
|
|
52846
|
-
exposesDeviceSettings: true,
|
|
52847
|
-
methods: {
|
|
52848
|
-
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
52849
|
-
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
52850
|
-
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
52851
|
-
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
52852
|
-
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
52853
|
-
kind: "mutation",
|
|
52854
|
-
auth: "admin"
|
|
52855
|
-
}),
|
|
52856
|
-
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
52857
|
-
kind: "mutation",
|
|
52858
|
-
auth: "admin"
|
|
52859
|
-
}),
|
|
52860
|
-
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
52861
|
-
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
52862
|
-
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
52863
|
-
kind: "mutation",
|
|
52864
|
-
auth: "admin"
|
|
52865
|
-
}),
|
|
52866
|
-
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
52867
|
-
kind: "mutation",
|
|
52868
|
-
auth: "admin"
|
|
52869
|
-
})
|
|
52870
|
-
}
|
|
52871
|
-
};
|
|
52872
53573
|
var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
52873
53574
|
var DeviceTemplateSchema = string().min(1).max(4096);
|
|
52874
53575
|
/** One value a caller hands the renderer for `thisDevice`. */
|
|
@@ -55719,29 +56420,6 @@ var EnumSensorStatusSchema = object({
|
|
|
55719
56420
|
lastFetchedAt: number$1()
|
|
55720
56421
|
});
|
|
55721
56422
|
DeviceType.Sensor;
|
|
55722
|
-
/**
|
|
55723
|
-
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
55724
|
-
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
55725
|
-
* (NO normalization). Two shapes:
|
|
55726
|
-
* - structured source (HA `event.*` entity) → `eventTypes` is the fixed
|
|
55727
|
-
* declared vocabulary (e.g. ['press_short','press_long',...]).
|
|
55728
|
-
* - generic/legacy source (HA bus events, e.g. zha_event) → `eventTypes`
|
|
55729
|
-
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
55730
|
-
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
55731
|
-
*/
|
|
55732
|
-
var EventFireSchema = object({
|
|
55733
|
-
deviceId: number$1(),
|
|
55734
|
-
eventType: string(),
|
|
55735
|
-
data: record(string(), unknown()).nullable(),
|
|
55736
|
-
timestamp: number$1().meta(readingMeta("none")),
|
|
55737
|
-
seq: number$1().meta(readingMeta("count"))
|
|
55738
|
-
});
|
|
55739
|
-
var EventEmitterStatusSchema = object({
|
|
55740
|
-
eventTypes: array(string()),
|
|
55741
|
-
lastEvent: EventFireSchema.nullable(),
|
|
55742
|
-
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
55743
|
-
});
|
|
55744
|
-
DeviceType.EventEmitter;
|
|
55745
56423
|
var IdentitySchema = object({
|
|
55746
56424
|
id: string(),
|
|
55747
56425
|
name: string(),
|
|
@@ -57040,6 +57718,128 @@ var StateLookSchema = object({
|
|
|
57040
57718
|
background: _enum(HERO_BACKGROUNDS),
|
|
57041
57719
|
animation: HeroAnimationSchema
|
|
57042
57720
|
});
|
|
57721
|
+
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
57722
|
+
var HeroTextSchema = object({
|
|
57723
|
+
en: string(),
|
|
57724
|
+
it: string()
|
|
57725
|
+
});
|
|
57726
|
+
/**
|
|
57727
|
+
* The ONE measurement a simple sensor shows (card wave, phase 1).
|
|
57728
|
+
*
|
|
57729
|
+
* A sensor that measures a single quantity (a temperature, a humidity, a power,
|
|
57730
|
+
* a contact, a text state) is drawn as that reading, once, big, inside a scene
|
|
57731
|
+
* whose motion says what the number means: heat rising when hot, flakes when
|
|
57732
|
+
* cold, a wire flowing at the speed of the power, a ring while a window is
|
|
57733
|
+
* open. Everything the card draws is decided here; a client only paints it.
|
|
57734
|
+
*/
|
|
57735
|
+
var HERO_MEASUREMENT_QUANTITIES = [
|
|
57736
|
+
"temperature",
|
|
57737
|
+
"humidity",
|
|
57738
|
+
"power",
|
|
57739
|
+
"contact",
|
|
57740
|
+
"text"
|
|
57741
|
+
];
|
|
57742
|
+
/** How a temperature reads to a person; drives the heat or the cold scene. */
|
|
57743
|
+
var HERO_MEASUREMENT_BANDS = [
|
|
57744
|
+
"hot",
|
|
57745
|
+
"mild",
|
|
57746
|
+
"cold"
|
|
57747
|
+
];
|
|
57748
|
+
/** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
|
|
57749
|
+
var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
|
|
57750
|
+
var HeroMeasurementReadingSchema = object({
|
|
57751
|
+
value: number$1(),
|
|
57752
|
+
quantity: ReadingQuantitySchema
|
|
57753
|
+
});
|
|
57754
|
+
var HeroMeasurementSchema = object({
|
|
57755
|
+
quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
|
|
57756
|
+
reading: HeroMeasurementReadingSchema.nullable(),
|
|
57757
|
+
icon: IconKeySchema.nullable(),
|
|
57758
|
+
value: HeroTextSchema,
|
|
57759
|
+
unit: string().nullable(),
|
|
57760
|
+
band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
|
|
57761
|
+
level: number$1().min(0).max(1).nullable(),
|
|
57762
|
+
word: HeroTextSchema,
|
|
57763
|
+
tone: _enum(HERO_TONES),
|
|
57764
|
+
since: number$1().nullable(),
|
|
57765
|
+
sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
|
|
57766
|
+
historyKey: string().nullable()
|
|
57767
|
+
});
|
|
57768
|
+
var same$2 = (text) => t(text, text);
|
|
57769
|
+
var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
|
|
57770
|
+
var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
|
|
57771
|
+
function temperatureBand(celsius) {
|
|
57772
|
+
if (celsius < 12) return "cold";
|
|
57773
|
+
if (celsius > 28) return "hot";
|
|
57774
|
+
return "mild";
|
|
57775
|
+
}
|
|
57776
|
+
var BAND_WORD = {
|
|
57777
|
+
hot: t("Hot", "Caldo"),
|
|
57778
|
+
mild: t("Normal", "Normale"),
|
|
57779
|
+
cold: t("Cold", "Freddo")
|
|
57780
|
+
};
|
|
57781
|
+
var BAND_TONE = {
|
|
57782
|
+
hot: "warning",
|
|
57783
|
+
mild: "muted",
|
|
57784
|
+
cold: "info"
|
|
57785
|
+
};
|
|
57786
|
+
function temperatureMeasurement(celsius, since) {
|
|
57787
|
+
const band = temperatureBand(celsius);
|
|
57788
|
+
return {
|
|
57789
|
+
quantity: "temperature",
|
|
57790
|
+
reading: {
|
|
57791
|
+
value: celsius,
|
|
57792
|
+
quantity: "temperature"
|
|
57793
|
+
},
|
|
57794
|
+
icon: "thermometer",
|
|
57795
|
+
value: same$2(trimmed(celsius, 1)),
|
|
57796
|
+
unit: "°C",
|
|
57797
|
+
band,
|
|
57798
|
+
level: null,
|
|
57799
|
+
word: BAND_WORD[band],
|
|
57800
|
+
tone: BAND_TONE[band],
|
|
57801
|
+
since,
|
|
57802
|
+
sinceKind: "updated",
|
|
57803
|
+
historyKey: "cap:temperature-sensor.temperature"
|
|
57804
|
+
};
|
|
57805
|
+
}
|
|
57806
|
+
function humidityMeasurement(percent, since) {
|
|
57807
|
+
const dry = percent < 30;
|
|
57808
|
+
const humid = percent > 70;
|
|
57809
|
+
return {
|
|
57810
|
+
quantity: "humidity",
|
|
57811
|
+
reading: {
|
|
57812
|
+
value: percent,
|
|
57813
|
+
quantity: "humidity"
|
|
57814
|
+
},
|
|
57815
|
+
icon: "droplets",
|
|
57816
|
+
value: same$2(String(Math.round(percent))),
|
|
57817
|
+
unit: "%",
|
|
57818
|
+
band: null,
|
|
57819
|
+
level: clamp01$1(percent / 100),
|
|
57820
|
+
word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
|
|
57821
|
+
tone: dry || humid ? "warning" : "info",
|
|
57822
|
+
since,
|
|
57823
|
+
sinceKind: "updated",
|
|
57824
|
+
historyKey: "cap:humidity-sensor.humidity"
|
|
57825
|
+
};
|
|
57826
|
+
}
|
|
57827
|
+
function textMeasurement(text, since) {
|
|
57828
|
+
return {
|
|
57829
|
+
quantity: "text",
|
|
57830
|
+
reading: null,
|
|
57831
|
+
icon: null,
|
|
57832
|
+
value: same$2(text),
|
|
57833
|
+
unit: null,
|
|
57834
|
+
band: null,
|
|
57835
|
+
level: null,
|
|
57836
|
+
word: t("Changed", "Cambiato"),
|
|
57837
|
+
tone: "muted",
|
|
57838
|
+
since,
|
|
57839
|
+
sinceKind: "updated",
|
|
57840
|
+
historyKey: null
|
|
57841
|
+
};
|
|
57842
|
+
}
|
|
57043
57843
|
/** The scene as the model carries it. `null` = the device did not say (never a guess). */
|
|
57044
57844
|
var HeroSceneSchema = object({
|
|
57045
57845
|
id: _enum([
|
|
@@ -57091,11 +57891,6 @@ var HeroSceneSchema = object({
|
|
|
57091
57891
|
});
|
|
57092
57892
|
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;
|
|
57093
57893
|
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;
|
|
57094
|
-
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
57095
|
-
var HeroTextSchema = object({
|
|
57096
|
-
en: string(),
|
|
57097
|
-
it: string()
|
|
57098
|
-
});
|
|
57099
57894
|
var HeroRowIdSchema = _enum([
|
|
57100
57895
|
"progress",
|
|
57101
57896
|
"run-for",
|
|
@@ -57201,6 +57996,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
|
|
|
57201
57996
|
optionLabels: record(string(), HeroTextSchema).optional(),
|
|
57202
57997
|
call: HeroCallSchema,
|
|
57203
57998
|
valueArg: string()
|
|
57999
|
+
}),
|
|
58000
|
+
object({
|
|
58001
|
+
kind: literal("number"),
|
|
58002
|
+
id: string(),
|
|
58003
|
+
label: HeroTextSchema,
|
|
58004
|
+
value: number$1().nullable(),
|
|
58005
|
+
/** `null` = any number; the device rounds what it does not accept. */
|
|
58006
|
+
step: number$1().nullable(),
|
|
58007
|
+
unit: string(),
|
|
58008
|
+
call: HeroCallSchema,
|
|
58009
|
+
valueArg: string()
|
|
58010
|
+
}),
|
|
58011
|
+
object({
|
|
58012
|
+
kind: literal("text"),
|
|
58013
|
+
id: string(),
|
|
58014
|
+
label: HeroTextSchema,
|
|
58015
|
+
value: string().nullable(),
|
|
58016
|
+
call: HeroCallSchema,
|
|
58017
|
+
valueArg: string()
|
|
57204
58018
|
})
|
|
57205
58019
|
]);
|
|
57206
58020
|
/** Declared by its interface: a `z.infer` of one more icon union pushes the cap's inferred type past what the compiler can print. */
|
|
@@ -57402,6 +58216,11 @@ var HeroModelSchema = object({
|
|
|
57402
58216
|
timedRun: HeroTimedRunSlotSchema.nullable(),
|
|
57403
58217
|
powerSupply: HeroPowerSupplySlotSchema.nullable(),
|
|
57404
58218
|
rows: array(HeroRowSchema),
|
|
58219
|
+
/**
|
|
58220
|
+
* The ONE measurement of a simple sensor, drawn once inside the scene in place of
|
|
58221
|
+
* the caption, tiles and value chips. Absent = the card draws as before.
|
|
58222
|
+
*/
|
|
58223
|
+
measurement: HeroMeasurementSchema.optional(),
|
|
57405
58224
|
/** Ids of parts that actuate the device, hidden from a session that may not act on it. */
|
|
57406
58225
|
gated: array(string()),
|
|
57407
58226
|
provenance: array(HeroProvenanceSchema)
|
|
@@ -57473,8 +58292,23 @@ var HeroRowModelSchema = object({
|
|
|
57473
58292
|
* the call. Absent or empty = `primary` alone.
|
|
57474
58293
|
*/
|
|
57475
58294
|
extras: array(HeroControlSchema).max(2).optional(),
|
|
57476
|
-
trailing: HeroFactSchema.nullable()
|
|
58295
|
+
trailing: HeroFactSchema.nullable(),
|
|
58296
|
+
/**
|
|
58297
|
+
* The simple sensor's one reading (the hero's `measurement`): the row draws its value
|
|
58298
|
+
* at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
|
|
58299
|
+
* older server or a device that is not a simple sensor: draw `trailing`.
|
|
58300
|
+
*/
|
|
58301
|
+
measurement: HeroMeasurementSchema.optional()
|
|
57477
58302
|
});
|
|
58303
|
+
new Set([
|
|
58304
|
+
"temperature",
|
|
58305
|
+
"humidity",
|
|
58306
|
+
"pressure",
|
|
58307
|
+
"illuminance",
|
|
58308
|
+
"reading",
|
|
58309
|
+
"air-quality",
|
|
58310
|
+
"valve"
|
|
58311
|
+
]);
|
|
57478
58312
|
DeviceType.Climate;
|
|
57479
58313
|
DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
|
|
57480
58314
|
/**
|
|
@@ -57791,6 +58625,12 @@ var IntegrationLiteSchema = object({
|
|
|
57791
58625
|
var AvailableIntegrationTypeSchema = object({
|
|
57792
58626
|
addonId: string(),
|
|
57793
58627
|
name: string(),
|
|
58628
|
+
/**
|
|
58629
|
+
* Product name a new integration is prefilled from (`<label> - Home`).
|
|
58630
|
+
* Absent: the client uses `name`. Set when the catalog title is not the
|
|
58631
|
+
* product (Bosch SHC, MQTT).
|
|
58632
|
+
*/
|
|
58633
|
+
providerLabel: string().optional(),
|
|
57794
58634
|
description: string(),
|
|
57795
58635
|
iconUrl: string().nullable(),
|
|
57796
58636
|
color: string(),
|
|
@@ -58302,13 +59142,32 @@ var IrSendResultSchema = object({
|
|
|
58302
59142
|
var IrTransmitterInfoSchema = object({
|
|
58303
59143
|
media: array(IrMediumSchema),
|
|
58304
59144
|
settable: array(TransmitSettingKeySchema),
|
|
58305
|
-
maxTimings: number$1().int().positive()
|
|
59145
|
+
maxTimings: number$1().int().positive(),
|
|
59146
|
+
/** The transmitter can learn a code (`learn`). */
|
|
59147
|
+
learn: boolean().default(false),
|
|
59148
|
+
/** Native code formats the transmitter replays verbatim (`send.native`). */
|
|
59149
|
+
formats: array(IrNativeFormatSchema).default([])
|
|
59150
|
+
});
|
|
59151
|
+
var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
|
|
59152
|
+
var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
|
|
59153
|
+
var IrLearnResultSchema = object({
|
|
59154
|
+
/** The code in the device's own format, when it reports one. */
|
|
59155
|
+
native: IrNativeCodeSchema.nullable(),
|
|
59156
|
+
timings: IrTimingsSchema,
|
|
59157
|
+
carrierHz: number$1().int().positive().nullable()
|
|
58306
59158
|
});
|
|
58307
59159
|
DeviceType.Generic, method(object({
|
|
58308
59160
|
deviceId: number$1().int().nonnegative(),
|
|
58309
|
-
timings: IrTimingsSchema,
|
|
59161
|
+
timings: IrTimingsSchema.optional(),
|
|
59162
|
+
native: IrNativeCodeSchema.optional(),
|
|
58310
59163
|
settings: TransmitSettingsSchema.optional()
|
|
58311
|
-
}), IrSendResultSchema, {
|
|
59164
|
+
}).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
|
|
59165
|
+
kind: "mutation",
|
|
59166
|
+
auth: "protected"
|
|
59167
|
+
}), method(object({
|
|
59168
|
+
deviceId: number$1().int().nonnegative(),
|
|
59169
|
+
timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
|
|
59170
|
+
}), IrLearnResultSchema, {
|
|
58312
59171
|
kind: "mutation",
|
|
58313
59172
|
auth: "protected"
|
|
58314
59173
|
}), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
|
|
@@ -67531,6 +68390,7 @@ var NcSystemEventKindSchema = _enum([
|
|
|
67531
68390
|
"recording-degraded",
|
|
67532
68391
|
"device-attention-required",
|
|
67533
68392
|
"device-attention-resolved",
|
|
68393
|
+
"device-command",
|
|
67534
68394
|
"storage-location-low",
|
|
67535
68395
|
"storage-location-critical",
|
|
67536
68396
|
"storage-location-ok",
|
|
@@ -67593,11 +68453,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
|
|
|
67593
68453
|
"alarm-sensor-bypass",
|
|
67594
68454
|
"alarm-disarmed"
|
|
67595
68455
|
];
|
|
67596
|
-
/**
|
|
67597
|
-
* One coherent system-event condition. `kinds` is the required opt-in safety
|
|
67598
|
-
* gate; the remaining lists are optional narrowing filters relevant to the
|
|
67599
|
-
* selected kinds.
|
|
67600
|
-
*/
|
|
67601
68456
|
var NcSystemEventConditionSchema = object({
|
|
67602
68457
|
kinds: array(NcSystemEventKindSchema).min(1),
|
|
67603
68458
|
deviceIds: array(number$1().int()).min(1).optional(),
|
|
@@ -67629,6 +68484,28 @@ var NcSystemEventConditionSchema = object({
|
|
|
67629
68484
|
nodeIds: array(string().min(1)).min(1).optional(),
|
|
67630
68485
|
packageNames: array(string().min(1)).min(1).optional(),
|
|
67631
68486
|
/**
|
|
68487
|
+
* `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
|
|
68488
|
+
* this rule speaks about - the same dictionary the automation action blocks
|
|
68489
|
+
* pick from. The hub refuses an id the action index does not know.
|
|
68490
|
+
*/
|
|
68491
|
+
commandActions: array(string().min(1)).min(1).optional(),
|
|
68492
|
+
/** `device-command` only: how the command settled. A device's own change is not a command. */
|
|
68493
|
+
commandOutcomes: array(_enum([
|
|
68494
|
+
"confirmed",
|
|
68495
|
+
"already",
|
|
68496
|
+
"unconfirmed",
|
|
68497
|
+
"failed"
|
|
68498
|
+
])).min(1).optional(),
|
|
68499
|
+
/** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
|
|
68500
|
+
commandActorKinds: array(_enum([
|
|
68501
|
+
"user",
|
|
68502
|
+
"addon",
|
|
68503
|
+
"action",
|
|
68504
|
+
"scheduler",
|
|
68505
|
+
"composition",
|
|
68506
|
+
"node"
|
|
68507
|
+
])).min(1).optional(),
|
|
68508
|
+
/**
|
|
67632
68509
|
* At or below this remaining-life %, a consumable is LOW for THIS rule
|
|
67633
68510
|
* (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
|
|
67634
68511
|
* {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
|
|
@@ -68609,6 +69486,13 @@ var NcRuleInputSchema = object({
|
|
|
68609
69486
|
*/
|
|
68610
69487
|
groupingSec: number$1().int().min(5).max(60).optional(),
|
|
68611
69488
|
/**
|
|
69489
|
+
* Hold deliveries of this rule to one target and, when two or more arrive
|
|
69490
|
+
* before the window ends, send them as one summary. Absent = the kind's
|
|
69491
|
+
* default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
|
|
69492
|
+
* other kind. `0` sends each delivery as it does today.
|
|
69493
|
+
*/
|
|
69494
|
+
groupWithinSec: number$1().int().min(0).max(300).optional(),
|
|
69495
|
+
/**
|
|
68612
69496
|
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
68613
69497
|
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
68614
69498
|
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
@@ -69045,7 +69929,12 @@ var NcHistoryEntrySchema = object({
|
|
|
69045
69929
|
* Assistant export) must render as "no image right now", never as a
|
|
69046
69930
|
* broken link.
|
|
69047
69931
|
*/
|
|
69048
|
-
artifactIds: array(string().min(1)).optional()
|
|
69932
|
+
artifactIds: array(string().min(1)).optional(),
|
|
69933
|
+
/**
|
|
69934
|
+
* When this row was folded into a group-window summary, the outbox id of
|
|
69935
|
+
* that one notification. Absent on a row that was sent as itself.
|
|
69936
|
+
*/
|
|
69937
|
+
groupedInto: string().min(1).optional()
|
|
69049
69938
|
});
|
|
69050
69939
|
/**
|
|
69051
69940
|
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
@@ -69932,7 +70821,18 @@ var OauthIntegrationDescriptorSchema = object({
|
|
|
69932
70821
|
* The value is baked into the authorization code at `/authorize` and travels
|
|
69933
70822
|
* on the tokens, so editing this field changes FUTURE links only.
|
|
69934
70823
|
*/
|
|
69935
|
-
refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional()
|
|
70824
|
+
refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional(),
|
|
70825
|
+
/**
|
|
70826
|
+
* The integration instances an account can be linked to (planning#415),
|
|
70827
|
+
* beside the default one. `/api/oauth2/authorize?instance=<id>` is accepted
|
|
70828
|
+
* only for an id listed here; with no `instance=` the link is made to the
|
|
70829
|
+
* default instance, which is never listed and always accepted — it is the
|
|
70830
|
+
* address third parties already hold. Omit for a single-instance integration.
|
|
70831
|
+
*/
|
|
70832
|
+
instances: array(object({
|
|
70833
|
+
id: string(),
|
|
70834
|
+
displayName: string()
|
|
70835
|
+
})).optional()
|
|
69936
70836
|
});
|
|
69937
70837
|
method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
|
|
69938
70838
|
/**
|
|
@@ -74674,10 +75574,15 @@ var RecordingSignalStatusSchema = object({
|
|
|
74674
75574
|
});
|
|
74675
75575
|
RecordingSignalStatusSchema.extend({ lastFetchedAt: number$1() });
|
|
74676
75576
|
DeviceType.Camera, method(object({ deviceId: number$1() }), RecordingSignalStatusSchema);
|
|
74677
|
-
var RemoteBindingSchema = object({ action:
|
|
74678
|
-
|
|
74679
|
-
|
|
74680
|
-
|
|
75577
|
+
var RemoteBindingSchema = object({ action: object({
|
|
75578
|
+
kind: literal("cap"),
|
|
75579
|
+
deviceId: number$1().int().nonnegative(),
|
|
75580
|
+
cap: string().min(1),
|
|
75581
|
+
method: string().min(1),
|
|
75582
|
+
args: record(string(), unknown()).optional(),
|
|
75583
|
+
/** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
|
|
75584
|
+
argUnits: record(string(), string().min(1)).optional()
|
|
75585
|
+
}) });
|
|
74681
75586
|
var RemoteCustomButtonSchema = object({
|
|
74682
75587
|
/** The slug after `custom:` in the role. */
|
|
74683
75588
|
key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
|
|
@@ -76254,6 +77159,13 @@ var SsoBridgeClaimsSchema = object({
|
|
|
76254
77159
|
/** OAuth authorization-code binding — set only on `oauth-code` tokens. */
|
|
76255
77160
|
redirectUri: string().optional(),
|
|
76256
77161
|
integrationId: string().optional(),
|
|
77162
|
+
/**
|
|
77163
|
+
* The integration INSTANCE an OAuth link was made for (planning#415). Set on
|
|
77164
|
+
* `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
|
|
77165
|
+
* with `instance=`; absent on a link to the default instance. A cloud relay
|
|
77166
|
+
* reads it off the access token to route; the hub answers from the session.
|
|
77167
|
+
*/
|
|
77168
|
+
instanceId: string().optional(),
|
|
76257
77169
|
/** JWT ID — unique per issued code; consumed-set enforces single-use. */
|
|
76258
77170
|
jti: string().optional(),
|
|
76259
77171
|
/** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
|
|
@@ -78335,6 +79247,8 @@ var OauthSessionSummarySchema = object({
|
|
|
78335
79247
|
userId: string(),
|
|
78336
79248
|
username: string(),
|
|
78337
79249
|
integrationId: string(),
|
|
79250
|
+
/** The instance the link was made for; `null` = the default instance. */
|
|
79251
|
+
instanceId: string().nullable().optional(),
|
|
78338
79252
|
scopes: array(TokenScopeSchema),
|
|
78339
79253
|
createdAt: number$1(),
|
|
78340
79254
|
lastUsedAt: number$1(),
|
|
@@ -78434,6 +79348,9 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
|
|
|
78434
79348
|
access: "view"
|
|
78435
79349
|
}), method(object({
|
|
78436
79350
|
integrationId: string(),
|
|
79351
|
+
/** The integration instance the link is for. Omit for the default
|
|
79352
|
+
* instance — never pass the addon id to mean it. */
|
|
79353
|
+
instanceId: string().optional(),
|
|
78437
79354
|
userId: string(),
|
|
78438
79355
|
username: string(),
|
|
78439
79356
|
scopes: array(TokenScopeSchema),
|
|
@@ -78472,7 +79389,13 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
|
|
|
78472
79389
|
}), method(object({ token: string() }), object({
|
|
78473
79390
|
userId: string(),
|
|
78474
79391
|
username: string(),
|
|
78475
|
-
scopes: array(TokenScopeSchema)
|
|
79392
|
+
scopes: array(TokenScopeSchema),
|
|
79393
|
+
/** The instance the link was made for, read from the SESSION.
|
|
79394
|
+
* Absent = the default instance. `oauthLinkServesInstance` is the
|
|
79395
|
+
* helper a per-instance route calls to compare it with the instance
|
|
79396
|
+
* of its path; no route declares `perInstance` yet (the Alexa
|
|
79397
|
+
* per-instance route, T3, is the first consumer). */
|
|
79398
|
+
instanceId: string().optional()
|
|
78476
79399
|
}).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
|
|
78477
79400
|
userId: string(),
|
|
78478
79401
|
issuer: string()
|
|
@@ -80086,6 +81009,13 @@ function contribution(cap, schema, build) {
|
|
|
80086
81009
|
}
|
|
80087
81010
|
};
|
|
80088
81011
|
}
|
|
81012
|
+
/** The fragment, carrying the cap's single measurement when it has one. */
|
|
81013
|
+
function measured(fragment, measurement) {
|
|
81014
|
+
return measurement === void 0 ? fragment : {
|
|
81015
|
+
...fragment,
|
|
81016
|
+
measurement
|
|
81017
|
+
};
|
|
81018
|
+
}
|
|
80089
81019
|
function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
|
|
80090
81020
|
return {
|
|
80091
81021
|
id,
|
|
@@ -81360,10 +82290,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
|
|
|
81360
82290
|
};
|
|
81361
82291
|
});
|
|
81362
82292
|
var CONTROL_LABEL = t("Value", "Valore");
|
|
81363
|
-
/**
|
|
82293
|
+
/**
|
|
82294
|
+
* A number with known bounds is a slider, one without a number field, a choice a picker,
|
|
82295
|
+
* free text a text field; a date stays read-only.
|
|
82296
|
+
*/
|
|
81364
82297
|
function controlRows(slice) {
|
|
81365
82298
|
if (slice.kind === "numeric" && typeof slice.value === "number") {
|
|
81366
|
-
if (slice.min === void 0 || slice.max === void 0) return [
|
|
82299
|
+
if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
|
|
82300
|
+
kind: "number",
|
|
82301
|
+
id: "control.value",
|
|
82302
|
+
label: CONTROL_LABEL,
|
|
82303
|
+
value: slice.value,
|
|
82304
|
+
step: slice.step ?? null,
|
|
82305
|
+
unit: "",
|
|
82306
|
+
call: {
|
|
82307
|
+
cap: "control",
|
|
82308
|
+
method: "setValue",
|
|
82309
|
+
args: { control: { kind: "numeric" } }
|
|
82310
|
+
},
|
|
82311
|
+
valueArg: "control.value"
|
|
82312
|
+
}])];
|
|
81367
82313
|
return [row$1("control", "sliders-horizontal", null, [{
|
|
81368
82314
|
kind: "slider",
|
|
81369
82315
|
id: "control.value",
|
|
@@ -81394,6 +82340,18 @@ function controlRows(slice) {
|
|
|
81394
82340
|
},
|
|
81395
82341
|
valueArg: "control.value"
|
|
81396
82342
|
}])];
|
|
82343
|
+
if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
|
|
82344
|
+
kind: "text",
|
|
82345
|
+
id: "control.value",
|
|
82346
|
+
label: CONTROL_LABEL,
|
|
82347
|
+
value: typeof slice.value === "string" ? slice.value : null,
|
|
82348
|
+
call: {
|
|
82349
|
+
cap: "control",
|
|
82350
|
+
method: "setValue",
|
|
82351
|
+
args: { control: { kind: "text" } }
|
|
82352
|
+
},
|
|
82353
|
+
valueArg: "control.value"
|
|
82354
|
+
}])];
|
|
81397
82355
|
return [];
|
|
81398
82356
|
}
|
|
81399
82357
|
var SENSORS_FAMILY_CONTRIBUTIONS = {
|
|
@@ -81749,15 +82707,15 @@ function sensorFragment(value, id, icon, en, it, text) {
|
|
|
81749
82707
|
tiles: { right: [tile$1(en, it, text)] }
|
|
81750
82708
|
};
|
|
81751
82709
|
}
|
|
81752
|
-
var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
|
|
81753
|
-
var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`));
|
|
82710
|
+
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)));
|
|
82711
|
+
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)));
|
|
81754
82712
|
var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
|
|
81755
82713
|
var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
|
|
81756
82714
|
var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
|
|
81757
82715
|
var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
|
|
81758
82716
|
if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
|
|
81759
82717
|
if (slice.timestamp === true) return { reading: reading("sensor", "on") };
|
|
81760
|
-
return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
|
|
82718
|
+
return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
|
|
81761
82719
|
});
|
|
81762
82720
|
/** Index bands: the headline of an air-quality sensor is a word, not a number. */
|
|
81763
82721
|
function airQualityWord(aqi) {
|
|
@@ -84653,6 +85611,13 @@ Object.freeze({
|
|
|
84653
85611
|
access: "view",
|
|
84654
85612
|
role: "admin"
|
|
84655
85613
|
},
|
|
85614
|
+
"deviceExport.setExposedName": {
|
|
85615
|
+
capName: "device-export",
|
|
85616
|
+
capScope: "system",
|
|
85617
|
+
addonId: null,
|
|
85618
|
+
access: "create",
|
|
85619
|
+
role: "admin"
|
|
85620
|
+
},
|
|
84656
85621
|
"deviceExport.unexposeDevice": {
|
|
84657
85622
|
capName: "device-export",
|
|
84658
85623
|
capScope: "system",
|
|
@@ -86592,6 +87557,13 @@ Object.freeze({
|
|
|
86592
87557
|
access: "view",
|
|
86593
87558
|
role: "viewer"
|
|
86594
87559
|
},
|
|
87560
|
+
"irTransmitter.learn": {
|
|
87561
|
+
capName: "ir-transmitter",
|
|
87562
|
+
capScope: "device",
|
|
87563
|
+
addonId: null,
|
|
87564
|
+
access: "create",
|
|
87565
|
+
role: "viewer"
|
|
87566
|
+
},
|
|
86595
87567
|
"irTransmitter.send": {
|
|
86596
87568
|
capName: "ir-transmitter",
|
|
86597
87569
|
capScope: "device",
|
|
@@ -93110,48 +94082,6 @@ Object.freeze({
|
|
|
93110
94082
|
role: "admin"
|
|
93111
94083
|
}
|
|
93112
94084
|
});
|
|
93113
|
-
/**
|
|
93114
|
-
* "Do" actions an operator can pick for a device — presentation-free.
|
|
93115
|
-
*
|
|
93116
|
-
* The wire shape stays `{ cap, method, args }`. Since D920 this module no
|
|
93117
|
-
* longer HOLDS a catalogue: {@link DEVICE_DO_ACTIONS} is a projection of the
|
|
93118
|
-
* cap vocabulary (`cap-vocabulary/`), the one cap-keyed map of every action
|
|
93119
|
-
* and trigger — so a picker built on this module and one built on
|
|
93120
|
-
* `actionsForDevice` (the vocabulary resolver) can never disagree about what
|
|
93121
|
-
* a device can do. Ids, baked args and the matching of saved steps are the
|
|
93122
|
-
* vocabulary's; labels here are its English labels.
|
|
93123
|
-
*
|
|
93124
|
-
* Shared by the admin NC Sequences / rule Do editor and Automations; the
|
|
93125
|
-
* viewer can reuse the same catalogue once its step editor catches up.
|
|
93126
|
-
*/
|
|
93127
|
-
function openArgKind(offer) {
|
|
93128
|
-
if (offer.kind === "number") return "number";
|
|
93129
|
-
if (offer.kind === "dynamic" && offer.valueKind === "number") return "number";
|
|
93130
|
-
if (offer.kind === "enum" && offer.values.every((v) => typeof v.value === "number")) return "number";
|
|
93131
|
-
return "string";
|
|
93132
|
-
}
|
|
93133
|
-
function projectOpenArg(arg) {
|
|
93134
|
-
return {
|
|
93135
|
-
key: arg.key,
|
|
93136
|
-
label: arg.label.en,
|
|
93137
|
-
kind: openArgKind(arg.offer),
|
|
93138
|
-
offer: arg.offer,
|
|
93139
|
-
...arg.optional === true ? { optional: true } : {}
|
|
93140
|
-
};
|
|
93141
|
-
}
|
|
93142
|
-
function projectAction(cap, action) {
|
|
93143
|
-
const open = action.openArgs ?? [];
|
|
93144
|
-
return {
|
|
93145
|
-
id: action.id,
|
|
93146
|
-
label: action.label.en,
|
|
93147
|
-
cap,
|
|
93148
|
-
method: action.method,
|
|
93149
|
-
args: action.args ?? {},
|
|
93150
|
-
...open.length > 0 ? { openArgs: open.map(projectOpenArg) } : {}
|
|
93151
|
-
};
|
|
93152
|
-
}
|
|
93153
|
-
Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
|
|
93154
|
-
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;
|
|
93155
94085
|
DeviceFeature.BatteryOperated;
|
|
93156
94086
|
function bound(cap, methods = [], authority = "reported") {
|
|
93157
94087
|
return {
|
|
@@ -94468,6 +95398,11 @@ Object.freeze({
|
|
|
94468
95398
|
form: "single",
|
|
94469
95399
|
optional: false
|
|
94470
95400
|
}],
|
|
95401
|
+
"irTransmitter.learn": [{
|
|
95402
|
+
name: "deviceId",
|
|
95403
|
+
form: "single",
|
|
95404
|
+
optional: false
|
|
95405
|
+
}],
|
|
94471
95406
|
"irTransmitter.send": [{
|
|
94472
95407
|
name: "deviceId",
|
|
94473
95408
|
form: "single",
|
|
@@ -96407,7 +97342,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
|
|
|
96407
97342
|
"deviceTypes",
|
|
96408
97343
|
"nodeIds",
|
|
96409
97344
|
"packageNames",
|
|
96410
|
-
"consumableLowPercent"
|
|
97345
|
+
"consumableLowPercent",
|
|
97346
|
+
"commandActions",
|
|
97347
|
+
"commandOutcomes",
|
|
97348
|
+
"commandActorKinds"
|
|
96411
97349
|
];
|
|
96412
97350
|
new Map(Object.entries({
|
|
96413
97351
|
"device-online": "device-events",
|
|
@@ -96430,6 +97368,7 @@ new Map(Object.entries({
|
|
|
96430
97368
|
"recording-degraded": "device-events",
|
|
96431
97369
|
"device-attention-required": "device-events",
|
|
96432
97370
|
"device-attention-resolved": "device-events",
|
|
97371
|
+
"device-command": "device-events",
|
|
96433
97372
|
"node-online": "system",
|
|
96434
97373
|
"node-offline": "system",
|
|
96435
97374
|
"node-restarting": "system",
|
|
@@ -96530,6 +97469,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
|
|
|
96530
97469
|
label: "Needs attention",
|
|
96531
97470
|
kinds: ["device-attention-required", "device-attention-resolved"]
|
|
96532
97471
|
},
|
|
97472
|
+
{
|
|
97473
|
+
id: "device-command",
|
|
97474
|
+
family: "device-events",
|
|
97475
|
+
label: "Commands given to devices",
|
|
97476
|
+
kinds: ["device-command"]
|
|
97477
|
+
},
|
|
96533
97478
|
{
|
|
96534
97479
|
id: "nodes",
|
|
96535
97480
|
family: "system",
|
|
@@ -96607,6 +97552,15 @@ function systemEventKindsOfFamily(family) {
|
|
|
96607
97552
|
return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
|
|
96608
97553
|
}
|
|
96609
97554
|
NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
|
|
97555
|
+
new Set([
|
|
97556
|
+
"alarm.trigger",
|
|
97557
|
+
"alarm.disarm",
|
|
97558
|
+
"alarm.arm.home",
|
|
97559
|
+
"alarm.arm.away",
|
|
97560
|
+
"alarm.arm.night",
|
|
97561
|
+
"alarm.arm.vacation",
|
|
97562
|
+
"alarm.arm.custom_bypass"
|
|
97563
|
+
]);
|
|
96610
97564
|
/**
|
|
96611
97565
|
* WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
|
|
96612
97566
|
* persists (D640 "a sensor rule fires on the raise, the clear, or both").
|
|
@@ -96802,6 +97756,7 @@ var DEVICE_EVENTS = [
|
|
|
96802
97756
|
"recording-healthy",
|
|
96803
97757
|
"recording-degraded",
|
|
96804
97758
|
...DEVICE_ATTENTION,
|
|
97759
|
+
"device-command",
|
|
96805
97760
|
...ALARM
|
|
96806
97761
|
];
|
|
96807
97762
|
/** Every kind a summary may speak about — the two summarisable families. */
|
|
@@ -96955,6 +97910,9 @@ var STATE_SUMMARY_VARS = [
|
|
|
96955
97910
|
[...RULE_BODY_ONLY],
|
|
96956
97911
|
[...RULE_TEXT],
|
|
96957
97912
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
97913
|
+
[...RULE_TEXT],
|
|
97914
|
+
[...RULE_TEXT],
|
|
97915
|
+
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
96958
97916
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96959
97917
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96960
97918
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
@@ -145082,6 +146040,160 @@ function carryForward(base, existing, keys) {
|
|
|
145082
146040
|
}
|
|
145083
146041
|
return out;
|
|
145084
146042
|
}
|
|
146043
|
+
/**
|
|
146044
|
+
* hap-nodejs' `checkName` regex, verbatim.
|
|
146045
|
+
*
|
|
146046
|
+
* Duplicated rather than imported because it is `@private Private API` in that
|
|
146047
|
+
* package and not exported. Duplicating a private regex is a liability, so the
|
|
146048
|
+
* guard against drift is behavioural, not textual: `service-naming.spec.ts`
|
|
146049
|
+
* builds real services and asserts hap-nodejs emits ZERO characteristic
|
|
146050
|
+
* warnings — if this expression ever diverges from theirs, that test fails.
|
|
146051
|
+
*/
|
|
146052
|
+
var HAP_NAME_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N}\p{Zs}’'&!._:;()/,-]*[\p{L}\p{N}]$/u;
|
|
146053
|
+
/** Characters HAP tolerates INSIDE a name. Anything else becomes a space. */
|
|
146054
|
+
var HAP_NAME_INNER = /[^\p{L}\p{N}\p{Zs}’'&!._:;()/,-]/gu;
|
|
146055
|
+
/** Would hap-nodejs accept this as a `Name` characteristic value? */
|
|
146056
|
+
function isHapServiceName(value) {
|
|
146057
|
+
return HAP_NAME_PATTERN.test(value);
|
|
146058
|
+
}
|
|
146059
|
+
/**
|
|
146060
|
+
* Build one HAP-valid service name from device-derived parts.
|
|
146061
|
+
*
|
|
146062
|
+
* Empty and absent parts are dropped rather than joined, so a missing role
|
|
146063
|
+
* never produces a double space. `fallback` is used ONLY when nothing
|
|
146064
|
+
* device-derived survives sanitisation — it is the last resort, not the
|
|
146065
|
+
* default, because a name that says nothing about the device is the defect
|
|
146066
|
+
* this module exists to end.
|
|
146067
|
+
*/
|
|
146068
|
+
function hapServiceName(parts, fallback) {
|
|
146069
|
+
const trimmed = trimToHapName(parts.map((part) => typeof part === "string" ? part : "").map((part) => part.replace(HAP_NAME_INNER, " ")).join(" ").replace(/\s+/gu, " ").trim());
|
|
146070
|
+
if (trimmed !== null) return trimmed;
|
|
146071
|
+
return trimToHapName(fallback.replace(HAP_NAME_INNER, " ").replace(/\s+/gu, " ").trim()) ?? "";
|
|
146072
|
+
}
|
|
146073
|
+
/**
|
|
146074
|
+
* The privacy-mask switch.
|
|
146075
|
+
*
|
|
146076
|
+
* Just "Privacy". The camera name is NOT prefixed: this service lives inside
|
|
146077
|
+
* the camera's own accessory, iOS already renders it under the camera, and a
|
|
146078
|
+
* round that prefixed it gave the operator "Camera front door Privacy"
|
|
146079
|
+
* sitting inside a tile titled "Camera front door".
|
|
146080
|
+
*
|
|
146081
|
+
* The prefix was added for a real reason — two cameras publishing a switch
|
|
146082
|
+
* called "Privacy" — but that was a symptom of the label being the ONLY thing
|
|
146083
|
+
* shown, which stopped being true once `ConfiguredName` made the service
|
|
146084
|
+
* render in its accessory's context. Uniqueness is required WITHIN one
|
|
146085
|
+
* accessory, not across the bridge, and one camera has one privacy switch.
|
|
146086
|
+
*/
|
|
146087
|
+
function privacyServiceName() {
|
|
146088
|
+
return hapServiceName([PRIVACY_SUFFIX], PRIVACY_SUFFIX);
|
|
146089
|
+
}
|
|
146090
|
+
/**
|
|
146091
|
+
* Deliberately not localised, and deliberately not a translation table.
|
|
146092
|
+
*
|
|
146093
|
+
* The device half of the name is the operator's own text and arrives in the
|
|
146094
|
+
* operator's language. This half names a camstack capability (`privacy-mask`)
|
|
146095
|
+
* and there is no locale in an addon's context to resolve it against; the word
|
|
146096
|
+
* is also identical in the operator's language. A translation layer for one
|
|
146097
|
+
* word would be the kind of leftover that reads as verification.
|
|
146098
|
+
*/
|
|
146099
|
+
var PRIVACY_SUFFIX = "Privacy";
|
|
146100
|
+
/**
|
|
146101
|
+
* An accessory child (siren, floodlight, spotlight) rendered as a service on
|
|
146102
|
+
* the parent camera.
|
|
146103
|
+
*
|
|
146104
|
+
* The child's OWN stored name wins. It is the string the operator typed, in
|
|
146105
|
+
* the operator's language, and an early rule threw it away: `role` was
|
|
146106
|
+
* consulted first and title-cased, so every siren on the fleet published as
|
|
146107
|
+
* the English word "Siren" no matter what the operator had called it.
|
|
146108
|
+
*
|
|
146109
|
+
* Providers name children both ways — "Sirena" and "Camera kitchen
|
|
146110
|
+
* Sirena". The parent half is now REMOVED rather than added, because the
|
|
146111
|
+
* service is published inside the parent camera's own accessory and iOS
|
|
146112
|
+
* already shows it there. The result must be one form, not two.
|
|
146113
|
+
*/
|
|
146114
|
+
function childServiceName(parentName, child) {
|
|
146115
|
+
const own = withoutParent(child.name.trim(), parentName);
|
|
146116
|
+
if (own.length > 0) return hapServiceName([own], own);
|
|
146117
|
+
return hapServiceName([typeof child.role === "string" ? titleCase(child.role) : ""], CHILD_FALLBACK);
|
|
146118
|
+
}
|
|
146119
|
+
/**
|
|
146120
|
+
* Last resort for a child that carries neither a name nor a role. Better than
|
|
146121
|
+
* the parent's name, which would publish a service indistinguishable from the
|
|
146122
|
+
* accessory holding it — the exact defect this module keeps being asked to fix.
|
|
146123
|
+
*
|
|
146124
|
+
* English, like the role slugs it stands in for ("Floodlight", "Siren"): the
|
|
146125
|
+
* only strings this module invents are English, and inventing one Italian word
|
|
146126
|
+
* would be a localisation layer that localises nothing.
|
|
146127
|
+
*/
|
|
146128
|
+
var CHILD_FALLBACK = "Accessory";
|
|
146129
|
+
/**
|
|
146130
|
+
* A PTZ action switch: the bare action, "Preset front door" / "Pan Left" /
|
|
146131
|
+
* "Autotrack".
|
|
146132
|
+
*
|
|
146133
|
+
* The labels themselves stay in `ptz-labels.ts` — they name a HomeKit control,
|
|
146134
|
+
* not a device. This function exists only to put the operator-typed half of a
|
|
146135
|
+
* preset name through the same sanitisation everything else gets; it no longer
|
|
146136
|
+
* qualifies the label with the camera, because all eight PTZ services live on
|
|
146137
|
+
* that camera's accessory and are unique among themselves.
|
|
146138
|
+
*/
|
|
146139
|
+
function ptzServiceName(actionLabel) {
|
|
146140
|
+
return hapServiceName([actionLabel], actionLabel);
|
|
146141
|
+
}
|
|
146142
|
+
/**
|
|
146143
|
+
* Drop `parentName` from the front of `name`.
|
|
146144
|
+
*
|
|
146145
|
+
* A PREFIX only. "Camera kitchen Sirena" → "Sirena"; "Sirena" is already
|
|
146146
|
+
* bare and untouched. A parent name appearing anywhere else in the child's
|
|
146147
|
+
* name is left alone — cutting from the middle of a string the operator typed
|
|
146148
|
+
* would mangle it, and this function must never make a label WORSE.
|
|
146149
|
+
*
|
|
146150
|
+
* Returns `name` unchanged when stripping would leave nothing: a child the
|
|
146151
|
+
* operator called exactly what the camera is called still needs a label.
|
|
146152
|
+
*/
|
|
146153
|
+
function withoutParent(name, parentName) {
|
|
146154
|
+
const needle = parentName.trim();
|
|
146155
|
+
if (needle.length === 0) return name;
|
|
146156
|
+
if (!name.toLowerCase().startsWith(needle.toLowerCase())) return name;
|
|
146157
|
+
const rest = name.slice(needle.length).trim();
|
|
146158
|
+
return rest.length > 0 ? rest : name;
|
|
146159
|
+
}
|
|
146160
|
+
/**
|
|
146161
|
+
* Truncate to the HAP ceiling and shave any leading/trailing character the
|
|
146162
|
+
* pattern forbids. Returns `null` when nothing usable is left — the caller
|
|
146163
|
+
* decides what to do with that, because "fall back" and "drop the part" are
|
|
146164
|
+
* different answers.
|
|
146165
|
+
*/
|
|
146166
|
+
function trimToHapName(value) {
|
|
146167
|
+
let out = value.length > 64 ? value.slice(0, 64) : value;
|
|
146168
|
+
while (out.length > 0 && !isAlphanumeric(out[out.length - 1])) out = out.slice(0, -1);
|
|
146169
|
+
while (out.length > 0 && !isAlphanumeric(out[0])) out = out.slice(1);
|
|
146170
|
+
return isHapServiceName(out) ? out : null;
|
|
146171
|
+
}
|
|
146172
|
+
function isAlphanumeric(ch) {
|
|
146173
|
+
return ch !== void 0 && /[\p{L}\p{N}]/u.test(ch);
|
|
146174
|
+
}
|
|
146175
|
+
function titleCase(raw) {
|
|
146176
|
+
return raw.split(/[-_\s]+/u).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
146177
|
+
}
|
|
146178
|
+
//#endregion
|
|
146179
|
+
//#region src/exposed-name.ts
|
|
146180
|
+
/** Apple's rule: at most 64 characters, begins and ends with a letter or digit, HAP punctuation only. */
|
|
146181
|
+
/** HomeKit's rule, as the derived "Name on <bridge>" field states it (D1049). */
|
|
146182
|
+
var HAP_NAME_RULE = `HomeKit takes up to 64 characters, starting and ending with a letter or digit; inside, only letters, digits, spaces and ' & ! . _ : ; ( ) / , -.`;
|
|
146183
|
+
var hapNameValidator = (name) => {
|
|
146184
|
+
if (name.length > 64) return {
|
|
146185
|
+
ok: false,
|
|
146186
|
+
reason: `The HomeKit name is ${name.length} characters; HomeKit allows at most 64.`
|
|
146187
|
+
};
|
|
146188
|
+
if (!isHapServiceName(name)) return {
|
|
146189
|
+
ok: false,
|
|
146190
|
+
reason: "The HomeKit name must begin and end with a letter or digit and may contain only letters, digits, spaces and ' & ! . _ : ; ( ) / , -"
|
|
146191
|
+
};
|
|
146192
|
+
return {
|
|
146193
|
+
ok: true,
|
|
146194
|
+
name
|
|
146195
|
+
};
|
|
146196
|
+
};
|
|
145085
146197
|
//#endregion
|
|
145086
146198
|
//#region src/hap-export-records.ts
|
|
145087
146199
|
/**
|
|
@@ -147602,141 +148714,6 @@ function reader(schema, toUpdates) {
|
|
|
147602
148714
|
function applyUpdates(service, updates) {
|
|
147603
148715
|
for (const update of updates) service.updateCharacteristic(update.characteristic, update.value);
|
|
147604
148716
|
}
|
|
147605
|
-
/**
|
|
147606
|
-
* hap-nodejs' `checkName` regex, verbatim.
|
|
147607
|
-
*
|
|
147608
|
-
* Duplicated rather than imported because it is `@private Private API` in that
|
|
147609
|
-
* package and not exported. Duplicating a private regex is a liability, so the
|
|
147610
|
-
* guard against drift is behavioural, not textual: `service-naming.spec.ts`
|
|
147611
|
-
* builds real services and asserts hap-nodejs emits ZERO characteristic
|
|
147612
|
-
* warnings — if this expression ever diverges from theirs, that test fails.
|
|
147613
|
-
*/
|
|
147614
|
-
var HAP_NAME_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N}\p{Zs}’'&!._:;()/,-]*[\p{L}\p{N}]$/u;
|
|
147615
|
-
/** Characters HAP tolerates INSIDE a name. Anything else becomes a space. */
|
|
147616
|
-
var HAP_NAME_INNER = /[^\p{L}\p{N}\p{Zs}’'&!._:;()/,-]/gu;
|
|
147617
|
-
/** Would hap-nodejs accept this as a `Name` characteristic value? */
|
|
147618
|
-
function isHapServiceName(value) {
|
|
147619
|
-
return HAP_NAME_PATTERN.test(value);
|
|
147620
|
-
}
|
|
147621
|
-
/**
|
|
147622
|
-
* Build one HAP-valid service name from device-derived parts.
|
|
147623
|
-
*
|
|
147624
|
-
* Empty and absent parts are dropped rather than joined, so a missing role
|
|
147625
|
-
* never produces a double space. `fallback` is used ONLY when nothing
|
|
147626
|
-
* device-derived survives sanitisation — it is the last resort, not the
|
|
147627
|
-
* default, because a name that says nothing about the device is the defect
|
|
147628
|
-
* this module exists to end.
|
|
147629
|
-
*/
|
|
147630
|
-
function hapServiceName(parts, fallback) {
|
|
147631
|
-
const trimmed = trimToHapName(parts.map((part) => typeof part === "string" ? part : "").map((part) => part.replace(HAP_NAME_INNER, " ")).join(" ").replace(/\s+/gu, " ").trim());
|
|
147632
|
-
if (trimmed !== null) return trimmed;
|
|
147633
|
-
return trimToHapName(fallback.replace(HAP_NAME_INNER, " ").replace(/\s+/gu, " ").trim()) ?? "";
|
|
147634
|
-
}
|
|
147635
|
-
/**
|
|
147636
|
-
* The privacy-mask switch.
|
|
147637
|
-
*
|
|
147638
|
-
* Just "Privacy". The camera name is NOT prefixed: this service lives inside
|
|
147639
|
-
* the camera's own accessory, iOS already renders it under the camera, and a
|
|
147640
|
-
* round that prefixed it gave the operator "Camera front door Privacy"
|
|
147641
|
-
* sitting inside a tile titled "Camera front door".
|
|
147642
|
-
*
|
|
147643
|
-
* The prefix was added for a real reason — two cameras publishing a switch
|
|
147644
|
-
* called "Privacy" — but that was a symptom of the label being the ONLY thing
|
|
147645
|
-
* shown, which stopped being true once `ConfiguredName` made the service
|
|
147646
|
-
* render in its accessory's context. Uniqueness is required WITHIN one
|
|
147647
|
-
* accessory, not across the bridge, and one camera has one privacy switch.
|
|
147648
|
-
*/
|
|
147649
|
-
function privacyServiceName() {
|
|
147650
|
-
return hapServiceName([PRIVACY_SUFFIX], PRIVACY_SUFFIX);
|
|
147651
|
-
}
|
|
147652
|
-
/**
|
|
147653
|
-
* Deliberately not localised, and deliberately not a translation table.
|
|
147654
|
-
*
|
|
147655
|
-
* The device half of the name is the operator's own text and arrives in the
|
|
147656
|
-
* operator's language. This half names a camstack capability (`privacy-mask`)
|
|
147657
|
-
* and there is no locale in an addon's context to resolve it against; the word
|
|
147658
|
-
* is also identical in the operator's language. A translation layer for one
|
|
147659
|
-
* word would be the kind of leftover that reads as verification.
|
|
147660
|
-
*/
|
|
147661
|
-
var PRIVACY_SUFFIX = "Privacy";
|
|
147662
|
-
/**
|
|
147663
|
-
* An accessory child (siren, floodlight, spotlight) rendered as a service on
|
|
147664
|
-
* the parent camera.
|
|
147665
|
-
*
|
|
147666
|
-
* The child's OWN stored name wins. It is the string the operator typed, in
|
|
147667
|
-
* the operator's language, and an early rule threw it away: `role` was
|
|
147668
|
-
* consulted first and title-cased, so every siren on the fleet published as
|
|
147669
|
-
* the English word "Siren" no matter what the operator had called it.
|
|
147670
|
-
*
|
|
147671
|
-
* Providers name children both ways — "Sirena" and "Camera kitchen
|
|
147672
|
-
* Sirena". The parent half is now REMOVED rather than added, because the
|
|
147673
|
-
* service is published inside the parent camera's own accessory and iOS
|
|
147674
|
-
* already shows it there. The result must be one form, not two.
|
|
147675
|
-
*/
|
|
147676
|
-
function childServiceName(parentName, child) {
|
|
147677
|
-
const own = withoutParent(child.name.trim(), parentName);
|
|
147678
|
-
if (own.length > 0) return hapServiceName([own], own);
|
|
147679
|
-
return hapServiceName([typeof child.role === "string" ? titleCase(child.role) : ""], CHILD_FALLBACK);
|
|
147680
|
-
}
|
|
147681
|
-
/**
|
|
147682
|
-
* Last resort for a child that carries neither a name nor a role. Better than
|
|
147683
|
-
* the parent's name, which would publish a service indistinguishable from the
|
|
147684
|
-
* accessory holding it — the exact defect this module keeps being asked to fix.
|
|
147685
|
-
*
|
|
147686
|
-
* English, like the role slugs it stands in for ("Floodlight", "Siren"): the
|
|
147687
|
-
* only strings this module invents are English, and inventing one Italian word
|
|
147688
|
-
* would be a localisation layer that localises nothing.
|
|
147689
|
-
*/
|
|
147690
|
-
var CHILD_FALLBACK = "Accessory";
|
|
147691
|
-
/**
|
|
147692
|
-
* A PTZ action switch: the bare action, "Preset front door" / "Pan Left" /
|
|
147693
|
-
* "Autotrack".
|
|
147694
|
-
*
|
|
147695
|
-
* The labels themselves stay in `ptz-labels.ts` — they name a HomeKit control,
|
|
147696
|
-
* not a device. This function exists only to put the operator-typed half of a
|
|
147697
|
-
* preset name through the same sanitisation everything else gets; it no longer
|
|
147698
|
-
* qualifies the label with the camera, because all eight PTZ services live on
|
|
147699
|
-
* that camera's accessory and are unique among themselves.
|
|
147700
|
-
*/
|
|
147701
|
-
function ptzServiceName(actionLabel) {
|
|
147702
|
-
return hapServiceName([actionLabel], actionLabel);
|
|
147703
|
-
}
|
|
147704
|
-
/**
|
|
147705
|
-
* Drop `parentName` from the front of `name`.
|
|
147706
|
-
*
|
|
147707
|
-
* A PREFIX only. "Camera kitchen Sirena" → "Sirena"; "Sirena" is already
|
|
147708
|
-
* bare and untouched. A parent name appearing anywhere else in the child's
|
|
147709
|
-
* name is left alone — cutting from the middle of a string the operator typed
|
|
147710
|
-
* would mangle it, and this function must never make a label WORSE.
|
|
147711
|
-
*
|
|
147712
|
-
* Returns `name` unchanged when stripping would leave nothing: a child the
|
|
147713
|
-
* operator called exactly what the camera is called still needs a label.
|
|
147714
|
-
*/
|
|
147715
|
-
function withoutParent(name, parentName) {
|
|
147716
|
-
const needle = parentName.trim();
|
|
147717
|
-
if (needle.length === 0) return name;
|
|
147718
|
-
if (!name.toLowerCase().startsWith(needle.toLowerCase())) return name;
|
|
147719
|
-
const rest = name.slice(needle.length).trim();
|
|
147720
|
-
return rest.length > 0 ? rest : name;
|
|
147721
|
-
}
|
|
147722
|
-
/**
|
|
147723
|
-
* Truncate to the HAP ceiling and shave any leading/trailing character the
|
|
147724
|
-
* pattern forbids. Returns `null` when nothing usable is left — the caller
|
|
147725
|
-
* decides what to do with that, because "fall back" and "drop the part" are
|
|
147726
|
-
* different answers.
|
|
147727
|
-
*/
|
|
147728
|
-
function trimToHapName(value) {
|
|
147729
|
-
let out = value.length > 64 ? value.slice(0, 64) : value;
|
|
147730
|
-
while (out.length > 0 && !isAlphanumeric(out[out.length - 1])) out = out.slice(0, -1);
|
|
147731
|
-
while (out.length > 0 && !isAlphanumeric(out[0])) out = out.slice(1);
|
|
147732
|
-
return isHapServiceName(out) ? out : null;
|
|
147733
|
-
}
|
|
147734
|
-
function isAlphanumeric(ch) {
|
|
147735
|
-
return ch !== void 0 && /[\p{L}\p{N}]/u.test(ch);
|
|
147736
|
-
}
|
|
147737
|
-
function titleCase(raw) {
|
|
147738
|
-
return raw.split(/[-_\s]+/u).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
147739
|
-
}
|
|
147740
148717
|
//#endregion
|
|
147741
148718
|
//#region src/mappers/builders/service-label.ts
|
|
147742
148719
|
/**
|
|
@@ -165201,8 +166178,19 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165201
166178
|
for (const uuid of uuids) clearPairingFiles(uuid, this.ctx.logger);
|
|
165202
166179
|
await this.exposureHandle().delete(id);
|
|
165203
166180
|
if (id === "export-hap") await this.exportSyncState.set({});
|
|
166181
|
+
await this.pruneBridgeNames(id);
|
|
165204
166182
|
this.ctx.logger.info("export-hap: bridge removed", { meta: { instanceId: id } });
|
|
165205
166183
|
}
|
|
166184
|
+
/** A removed bridge's device names go too, so a bridge that reuses the id inherits none (D1049). */
|
|
166185
|
+
async pruneBridgeNames(id) {
|
|
166186
|
+
const settings = this.ctx.settings;
|
|
166187
|
+
if (settings === void 0) return;
|
|
166188
|
+
const pruned = await pruneExposedNames(settings, id);
|
|
166189
|
+
if (pruned.length > 0) this.ctx.logger.info("export-hap: removed bridge names deleted", { meta: {
|
|
166190
|
+
instanceId: id,
|
|
166191
|
+
devices: pruned.length
|
|
166192
|
+
} });
|
|
166193
|
+
}
|
|
165206
166194
|
/**
|
|
165207
166195
|
* "Regenerate" (operator decision): a new setup code, every pairing of this bridge cleared and
|
|
165208
166196
|
* the bridge republished. Every controller has to pair again; the instance and its exposed
|
|
@@ -165298,21 +166286,33 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165298
166286
|
instanceId: row.id,
|
|
165299
166287
|
name: row.body.name,
|
|
165300
166288
|
enabled: row.enabled,
|
|
165301
|
-
kind: "hap-bridge"
|
|
166289
|
+
kind: "hap-bridge",
|
|
166290
|
+
nameRule: HAP_NAME_RULE
|
|
165302
166291
|
})),
|
|
165303
166292
|
listSupportedDeviceKinds: async ({ instanceId }) => {
|
|
165304
166293
|
this.bridgesOf(instanceId);
|
|
165305
166294
|
return [...HAP_EXPORTABLE_DEVICE_TYPES];
|
|
165306
166295
|
},
|
|
165307
|
-
listExposedDevices: async ({ instanceId }) =>
|
|
165308
|
-
const
|
|
165309
|
-
|
|
165310
|
-
deviceId
|
|
165311
|
-
|
|
165312
|
-
|
|
165313
|
-
|
|
165314
|
-
|
|
165315
|
-
|
|
166296
|
+
listExposedDevices: async ({ instanceId }) => {
|
|
166297
|
+
const out = [];
|
|
166298
|
+
for (const inst of this.bridgesOf(instanceId)) for (const [deviceId, m] of inst.exposed.entries()) {
|
|
166299
|
+
const entry = inst.exposure.devices.find((e) => e.deviceId === deviceId);
|
|
166300
|
+
const exposedName = await this.exposedNameOf(inst.id, deviceId);
|
|
166301
|
+
out.push({
|
|
166302
|
+
deviceId,
|
|
166303
|
+
exposedAs: m.accessory.displayName,
|
|
166304
|
+
...exposedName !== null ? { exposedName } : {},
|
|
166305
|
+
...entry?.capabilities ? { capabilities: [...entry.capabilities] } : {}
|
|
166306
|
+
});
|
|
166307
|
+
}
|
|
166308
|
+
return out;
|
|
166309
|
+
},
|
|
166310
|
+
exposeDevice: async ({ instanceId, deviceId, capabilities, exposedName }) => {
|
|
166311
|
+
const inst = this.requireBridge(instanceId);
|
|
166312
|
+
if (exposedName !== void 0) await this.saveExposedName(inst, deviceId, exposedName);
|
|
166313
|
+
return this.exposeDevice(inst, deviceId, capabilities);
|
|
166314
|
+
},
|
|
166315
|
+
setExposedName: async ({ instanceId, deviceId, name, dryRun }) => this.setExposedName(this.requireBridge(instanceId), deviceId, name, dryRun === true),
|
|
165316
166316
|
unexposeDevice: async ({ instanceId, deviceId }) => this.unexposeDevice(this.requireBridge(instanceId), deviceId),
|
|
165317
166317
|
listSupportedEntityKinds: async () => ["device", "action"],
|
|
165318
166318
|
listExposedEntities: async ({ instanceId }) => {
|
|
@@ -165455,7 +166455,7 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165455
166455
|
const summary = await this.fetchDeviceSummary(numericId);
|
|
165456
166456
|
const mapperKind = pickMapperKind(summary?.type);
|
|
165457
166457
|
if (!mapperKind) throw new Error(`export-hap: device ${numericId} has type '${summary?.type ?? "unknown"}', which HomeKit export does not support`);
|
|
165458
|
-
const displayName = summary?.name ?? `Device ${deviceId}`;
|
|
166458
|
+
const displayName = await this.exposedNameOf(inst.id, deviceId) ?? summary?.name ?? `Device ${deviceId}`;
|
|
165459
166459
|
const previous = inst.exposure.devices.find((e) => e.deviceId === deviceId);
|
|
165460
166460
|
const rebuilt = {
|
|
165461
166461
|
deviceId,
|
|
@@ -165487,6 +166487,54 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165487
166487
|
childCount: attached.childAccessoryUuids.length
|
|
165488
166488
|
} });
|
|
165489
166489
|
}
|
|
166490
|
+
nameStore() {
|
|
166491
|
+
return exposedNameStoreOf(this.ctx.settings, "export-hap");
|
|
166492
|
+
}
|
|
166493
|
+
async exposedNameOf(instanceId, deviceId) {
|
|
166494
|
+
const numericId = Number.parseInt(deviceId, 10);
|
|
166495
|
+
if (!Number.isFinite(numericId)) return null;
|
|
166496
|
+
try {
|
|
166497
|
+
return readExposedName(await this.nameStore().read(numericId), instanceId, hapNameValidator);
|
|
166498
|
+
} catch (err) {
|
|
166499
|
+
this.ctx.logger.warn("export-hap: HomeKit name unreadable", {
|
|
166500
|
+
tags: { deviceId: numericId },
|
|
166501
|
+
meta: {
|
|
166502
|
+
instanceId,
|
|
166503
|
+
error: err instanceof Error ? err.message : String(err)
|
|
166504
|
+
}
|
|
166505
|
+
});
|
|
166506
|
+
return null;
|
|
166507
|
+
}
|
|
166508
|
+
}
|
|
166509
|
+
/** Validate and store the HomeKit name; a refusal throws before anything is written. */
|
|
166510
|
+
async saveExposedName(inst, deviceIdStr, raw, dryRun = false) {
|
|
166511
|
+
const deviceId = Number.parseInt(deviceIdStr, 10);
|
|
166512
|
+
if (!Number.isFinite(deviceId)) throw new Error(`export-hap: invalid device id '${deviceIdStr}'`);
|
|
166513
|
+
const saved = await saveExposedName({
|
|
166514
|
+
store: this.nameStore(),
|
|
166515
|
+
deviceId,
|
|
166516
|
+
instanceId: inst.id,
|
|
166517
|
+
raw,
|
|
166518
|
+
validate: hapNameValidator,
|
|
166519
|
+
...dryRun ? { dryRun: true } : {}
|
|
166520
|
+
});
|
|
166521
|
+
if (saved.changed) this.ctx.logger.info("export-hap: HomeKit name saved", {
|
|
166522
|
+
tags: { deviceId },
|
|
166523
|
+
meta: {
|
|
166524
|
+
instanceId: inst.id,
|
|
166525
|
+
name: saved.name
|
|
166526
|
+
}
|
|
166527
|
+
});
|
|
166528
|
+
return saved.changed;
|
|
166529
|
+
}
|
|
166530
|
+
/**
|
|
166531
|
+
* Rename on HomeKit (D1049). An exposed device is re-exposed in place — the same accessory
|
|
166532
|
+
* UUID, the pairing untouched (no unexpose, which would wipe it) — so Home shows the new name
|
|
166533
|
+
* on the same tile. A dry run only validates.
|
|
166534
|
+
*/
|
|
166535
|
+
async setExposedName(inst, deviceIdStr, raw, dryRun = false) {
|
|
166536
|
+
if (await this.saveExposedName(inst, deviceIdStr, raw, dryRun) && inst.exposed.has(deviceIdStr)) await this.exposeDevice(inst, deviceIdStr);
|
|
166537
|
+
}
|
|
165490
166538
|
async unexposeDevice(inst, deviceId, options = {}) {
|
|
165491
166539
|
const numericId = Number.parseInt(deviceId, 10);
|
|
165492
166540
|
const log = this.ctx.logger.withTags({ deviceId: numericId });
|