@camstack/addon-export-hap 1.2.199 → 1.2.201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/hap-export.addon.js +1747 -576
- package/dist/hap-export.addon.mjs +1747 -576
- 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
|
|
@@ -852,7 +861,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
852
861
|
return EventCategory;
|
|
853
862
|
}({});
|
|
854
863
|
//#endregion
|
|
855
|
-
//#region ../types/dist/composed-stable-id-
|
|
864
|
+
//#region ../types/dist/composed-stable-id-iddnCQ51.mjs
|
|
856
865
|
/**
|
|
857
866
|
import { errMsg } from '@camstack/types'
|
|
858
867
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -1194,6 +1203,11 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1194
1203
|
* with the switch's on/off only. Speed or oscillation appear only when the
|
|
1195
1204
|
* device also has a fan cap (D1033). */
|
|
1196
1205
|
DeviceRole["SwitchFan"] = "switch-fan";
|
|
1206
|
+
/** A relay driving an on/off-only lamp: drawn as a light (bulb and glow, no
|
|
1207
|
+
* slider), presented to the exports as a light with power only. Not a
|
|
1208
|
+
* `light` type: the provider owns the type, and a light implies brightness
|
|
1209
|
+
* or colour this relay lacks. */
|
|
1210
|
+
DeviceRole["SwitchLight"] = "switch-light";
|
|
1197
1211
|
/** Air conditioner / split unit: cooling, fan speed, louvres. */
|
|
1198
1212
|
DeviceRole["ClimateAc"] = "climate-ac";
|
|
1199
1213
|
/** Room thermostat: a setpoint and a room temperature. The default. */
|
|
@@ -6094,7 +6108,7 @@ var ZodIssueCode = {
|
|
|
6094
6108
|
var ZodFirstPartyTypeKind;
|
|
6095
6109
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6096
6110
|
//#endregion
|
|
6097
|
-
//#region ../types/dist/sleep-
|
|
6111
|
+
//#region ../types/dist/sleep-BvVGLl30.mjs
|
|
6098
6112
|
/**
|
|
6099
6113
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6100
6114
|
* window to float samples (D455).
|
|
@@ -6777,6 +6791,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6777
6791
|
else skipped.push(id);
|
|
6778
6792
|
};
|
|
6779
6793
|
const selected = options.only === void 0 ? null : new Set(options.only);
|
|
6794
|
+
const deferred = /* @__PURE__ */ new Set();
|
|
6795
|
+
const deferredBy = (reason) => {
|
|
6796
|
+
if (selected === null || reason === null) return null;
|
|
6797
|
+
const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
|
|
6798
|
+
if (dep === void 0 || !byId.has(dep)) return null;
|
|
6799
|
+
return !selected.has(dep) || deferred.has(dep) ? dep : null;
|
|
6800
|
+
};
|
|
6780
6801
|
for (const step of declaration.steps) {
|
|
6781
6802
|
if (selected !== null && !selected.has(step.id)) continue;
|
|
6782
6803
|
const bound = byId.get(step.id);
|
|
@@ -6788,6 +6809,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6788
6809
|
try {
|
|
6789
6810
|
const gate = await host.startMigration({ id: step.id });
|
|
6790
6811
|
if (!gate.proceed) {
|
|
6812
|
+
const waitsFor = deferredBy(gate.reason);
|
|
6813
|
+
if (waitsFor !== null) {
|
|
6814
|
+
log.info("migration deferred: its predecessor runs in another phase of this owner", {
|
|
6815
|
+
tags,
|
|
6816
|
+
meta: {
|
|
6817
|
+
waitsFor,
|
|
6818
|
+
reason: gate.reason
|
|
6819
|
+
}
|
|
6820
|
+
});
|
|
6821
|
+
deferred.add(step.id);
|
|
6822
|
+
skipped.push(step.id);
|
|
6823
|
+
continue;
|
|
6824
|
+
}
|
|
6791
6825
|
log.warn("migration not run", {
|
|
6792
6826
|
tags,
|
|
6793
6827
|
meta: {
|
|
@@ -10237,6 +10271,13 @@ var DeviceTransitionSchema = object({
|
|
|
10237
10271
|
actor: TransitionActorSchema,
|
|
10238
10272
|
command: TransitionCommandSchema.optional()
|
|
10239
10273
|
});
|
|
10274
|
+
object({
|
|
10275
|
+
deviceId: number$1().int(),
|
|
10276
|
+
action: string(),
|
|
10277
|
+
outcome: TransitionOutcomeSchema,
|
|
10278
|
+
actor: TransitionActorSchema,
|
|
10279
|
+
at: number$1()
|
|
10280
|
+
});
|
|
10240
10281
|
var READING_QUANTITIES = [
|
|
10241
10282
|
"temperature",
|
|
10242
10283
|
"pressure",
|
|
@@ -10780,6 +10821,13 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
10780
10821
|
},
|
|
10781
10822
|
state: { on: { icon: "lightbulb" } }
|
|
10782
10823
|
},
|
|
10824
|
+
[DeviceRole.SwitchLight]: {
|
|
10825
|
+
actions: {
|
|
10826
|
+
"switch.on": { icon: "lightbulb" },
|
|
10827
|
+
"switch.off": { icon: "lightbulb-off" }
|
|
10828
|
+
},
|
|
10829
|
+
state: { on: { icon: "lightbulb" } }
|
|
10830
|
+
},
|
|
10783
10831
|
[DeviceRole.Chime]: { actions: {
|
|
10784
10832
|
"switch.on": {
|
|
10785
10833
|
label: t("Enable chime", "Attiva il campanello"),
|
|
@@ -12260,7 +12308,10 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
12260
12308
|
"ir-transmitter": {
|
|
12261
12309
|
scope: "device",
|
|
12262
12310
|
noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
|
|
12263
|
-
notOperatorFacing: {
|
|
12311
|
+
notOperatorFacing: {
|
|
12312
|
+
send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
|
|
12313
|
+
learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
|
|
12314
|
+
}
|
|
12264
12315
|
},
|
|
12265
12316
|
control: {
|
|
12266
12317
|
scope: "device",
|
|
@@ -15181,6 +15232,32 @@ var CAP_VOCABULARY_BY_NAME = {
|
|
|
15181
15232
|
...SYSTEM_CAP_VOCABULARY
|
|
15182
15233
|
};
|
|
15183
15234
|
/**
|
|
15235
|
+
* Vocabulary actions by id (D983). An action step names a vocabulary action
|
|
15236
|
+
* (`cover.open`), never a raw cap method; this is the one lookup that turns the
|
|
15237
|
+
* id into its cap, method and effect — and a persisted legacy `cap` + `method`
|
|
15238
|
+
* pair back into the action id when exactly one action matches.
|
|
15239
|
+
*/
|
|
15240
|
+
function buildIndex() {
|
|
15241
|
+
const byId = /* @__PURE__ */ new Map();
|
|
15242
|
+
for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
|
|
15243
|
+
if (entry.scope !== "device") continue;
|
|
15244
|
+
for (const action of entry.actions ?? []) byId.set(action.id, {
|
|
15245
|
+
cap,
|
|
15246
|
+
action
|
|
15247
|
+
});
|
|
15248
|
+
}
|
|
15249
|
+
return byId;
|
|
15250
|
+
}
|
|
15251
|
+
var index;
|
|
15252
|
+
function actionIndex() {
|
|
15253
|
+
index ??= buildIndex();
|
|
15254
|
+
return index;
|
|
15255
|
+
}
|
|
15256
|
+
/** The vocabulary action with this id, or `undefined`. */
|
|
15257
|
+
function findVocabAction(actionId) {
|
|
15258
|
+
return actionIndex().get(actionId);
|
|
15259
|
+
}
|
|
15260
|
+
/**
|
|
15184
15261
|
* `addon-pages-source` — collection cap exposing per-provider raw page
|
|
15185
15262
|
* declarations. Every addon that contributes a UI page registers a
|
|
15186
15263
|
* provider here. The hub-side singleton aggregator (`addon-pages` cap,
|
|
@@ -16263,6 +16340,10 @@ Object.freeze({
|
|
|
16263
16340
|
"path": "lastEvent.eventType",
|
|
16264
16341
|
"valueType": "string"
|
|
16265
16342
|
},
|
|
16343
|
+
{
|
|
16344
|
+
"path": "lastEvent.sourceId",
|
|
16345
|
+
"valueType": "string"
|
|
16346
|
+
},
|
|
16266
16347
|
{
|
|
16267
16348
|
"path": "lastEvent.timestamp",
|
|
16268
16349
|
"valueType": "number"
|
|
@@ -17526,7 +17607,7 @@ Object.freeze({
|
|
|
17526
17607
|
}
|
|
17527
17608
|
});
|
|
17528
17609
|
//#endregion
|
|
17529
|
-
//#region ../types/dist/implemented-methods-
|
|
17610
|
+
//#region ../types/dist/implemented-methods-CSTk6zYK.mjs
|
|
17530
17611
|
var AUDIO_ENCODER_BY_CODEC = {
|
|
17531
17612
|
opus: "libopus",
|
|
17532
17613
|
aac: "aac",
|
|
@@ -18176,6 +18257,60 @@ function portable(target) {
|
|
|
18176
18257
|
}
|
|
18177
18258
|
portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac64"), `${BASE}${FFMPEG_RELEASE}`;
|
|
18178
18259
|
/**
|
|
18260
|
+
* A device's KIND is its type plus its role (D1033): the type is the set of
|
|
18261
|
+
* controls it has, the role says which thing it is among the devices that
|
|
18262
|
+
* share those controls. A plug-in heater is a `switch` with role
|
|
18263
|
+
* `switch-heater`; an air conditioner and a radiator valve are both `climate`,
|
|
18264
|
+
* told apart by their `climate-*` role.
|
|
18265
|
+
*/
|
|
18266
|
+
/**
|
|
18267
|
+
* Type values a persisted row may still carry after the type was retired, and
|
|
18268
|
+
* the type each one is read as. The row is rewritten by the next registration
|
|
18269
|
+
* of the device (its provider stamps the live type), so this is a read alias,
|
|
18270
|
+
* not a migration.
|
|
18271
|
+
*
|
|
18272
|
+
* `heater` is deliberately absent: the only heaters were composed devices the
|
|
18273
|
+
* operator deletes. Such a row stays an unknown type, which every reader
|
|
18274
|
+
* treats as a generic device.
|
|
18275
|
+
*/
|
|
18276
|
+
var RETIRED_DEVICE_TYPES = { thermostat: DeviceType.Climate };
|
|
18277
|
+
/** The live type a stored `type` value stands for (itself unless retired). */
|
|
18278
|
+
function canonicalStoredDeviceType(stored) {
|
|
18279
|
+
return RETIRED_DEVICE_TYPES[stored] ?? stored;
|
|
18280
|
+
}
|
|
18281
|
+
preprocess((value) => typeof value === "string" ? canonicalStoredDeviceType(value) : value, _enum(DeviceType));
|
|
18282
|
+
DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
|
|
18283
|
+
/**
|
|
18284
|
+
* A relay driving an on/off-only lamp (a `switch` with role `switch-light`):
|
|
18285
|
+
* drawn and exported as a light, with the switch's power only. The one place
|
|
18286
|
+
* that reads the role for it — a consumer asks this, never the role string.
|
|
18287
|
+
*/
|
|
18288
|
+
function isSwitchLight(type, role) {
|
|
18289
|
+
return type === DeviceType.Switch && role === DeviceRole.SwitchLight;
|
|
18290
|
+
}
|
|
18291
|
+
/**
|
|
18292
|
+
* A smart plug (a `switch` with role `outlet`, D875): exported as a plug /
|
|
18293
|
+
* outlet. Exports ask this, never the role string.
|
|
18294
|
+
*/
|
|
18295
|
+
function isOutlet(type, role) {
|
|
18296
|
+
return type === DeviceType.Switch && role === DeviceRole.Outlet;
|
|
18297
|
+
}
|
|
18298
|
+
/**
|
|
18299
|
+
* A plain fan behind a switch (a `switch` with role `switch-fan`): exported as
|
|
18300
|
+
* a fan with the switch's on/off only — no speed it does not have.
|
|
18301
|
+
*/
|
|
18302
|
+
function isSwitchFan(type, role) {
|
|
18303
|
+
return type === DeviceType.Switch && role === DeviceRole.SwitchFan;
|
|
18304
|
+
}
|
|
18305
|
+
/**
|
|
18306
|
+
* A plug-in heater behind a switch (a `switch` with role `switch-heater`): it
|
|
18307
|
+
* has power only, no setpoint and no room temperature, so an export never
|
|
18308
|
+
* presents it as a thermostat.
|
|
18309
|
+
*/
|
|
18310
|
+
function isSwitchHeater(type, role) {
|
|
18311
|
+
return type === DeviceType.Switch && role === DeviceRole.SwitchHeater;
|
|
18312
|
+
}
|
|
18313
|
+
/**
|
|
18179
18314
|
* THE table "which boolean of this device type counts as HIGH", and the
|
|
18180
18315
|
* pure evaluator of its EDGE.
|
|
18181
18316
|
*
|
|
@@ -24103,7 +24238,7 @@ var DeviceTokenScopeSchema = object({
|
|
|
24103
24238
|
function migrateLegacyTokenScope(raw) {
|
|
24104
24239
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
24105
24240
|
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
24106
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
24241
|
+
if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
|
|
24107
24242
|
const targets = Reflect.get(raw, "targets");
|
|
24108
24243
|
if (!Array.isArray(targets)) return raw;
|
|
24109
24244
|
return {
|
|
@@ -24115,6 +24250,27 @@ function migrateLegacyTokenScope(raw) {
|
|
|
24115
24250
|
access: Reflect.get(raw, "access")
|
|
24116
24251
|
};
|
|
24117
24252
|
}
|
|
24253
|
+
/**
|
|
24254
|
+
* A stored `types` selector may name a type D1033 retired (`thermostat`). The
|
|
24255
|
+
* grant is read back through this same preprocess, so the retired name is
|
|
24256
|
+
* rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
|
|
24257
|
+
* stays a strict enum on the wire.
|
|
24258
|
+
*/
|
|
24259
|
+
function canonicalSelectorTypes(raw) {
|
|
24260
|
+
const selector = Reflect.get(raw, "selector");
|
|
24261
|
+
if (selector === null || typeof selector !== "object") return raw;
|
|
24262
|
+
if (Reflect.get(selector, "kind") !== "types") return raw;
|
|
24263
|
+
const types = Reflect.get(selector, "types");
|
|
24264
|
+
if (!Array.isArray(types)) return raw;
|
|
24265
|
+
const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
|
|
24266
|
+
return {
|
|
24267
|
+
...raw,
|
|
24268
|
+
selector: {
|
|
24269
|
+
...selector,
|
|
24270
|
+
types: canonical
|
|
24271
|
+
}
|
|
24272
|
+
};
|
|
24273
|
+
}
|
|
24118
24274
|
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
24119
24275
|
object({
|
|
24120
24276
|
type: literal("category"),
|
|
@@ -44671,6 +44827,41 @@ function macroOnly(macro) {
|
|
|
44671
44827
|
};
|
|
44672
44828
|
}
|
|
44673
44829
|
}
|
|
44830
|
+
var EventVocabularyKindSchema = _enum([
|
|
44831
|
+
"press",
|
|
44832
|
+
"long-press",
|
|
44833
|
+
"long-press-start",
|
|
44834
|
+
"release",
|
|
44835
|
+
"repeat",
|
|
44836
|
+
"double-press",
|
|
44837
|
+
"other"
|
|
44838
|
+
]);
|
|
44839
|
+
/** The part of the device an event comes from: a button, a channel. */
|
|
44840
|
+
var EventVocabularySourceSchema = object({
|
|
44841
|
+
id: string().min(1),
|
|
44842
|
+
label: string().min(1)
|
|
44843
|
+
});
|
|
44844
|
+
/** One scalar field of an event's `data`, by dotted path. */
|
|
44845
|
+
var EventVocabularyFieldSchema = object({
|
|
44846
|
+
path: string().min(1),
|
|
44847
|
+
kind: _enum([
|
|
44848
|
+
"string",
|
|
44849
|
+
"number",
|
|
44850
|
+
"boolean",
|
|
44851
|
+
"enum"
|
|
44852
|
+
]),
|
|
44853
|
+
enumValues: array(string()).optional(),
|
|
44854
|
+
label: string().min(1).optional()
|
|
44855
|
+
});
|
|
44856
|
+
var EventVocabularyEntrySchema = object({
|
|
44857
|
+
/** The native token, verbatim. */
|
|
44858
|
+
id: string().min(1),
|
|
44859
|
+
source: EventVocabularySourceSchema.optional(),
|
|
44860
|
+
label: string().min(1),
|
|
44861
|
+
description: string().optional(),
|
|
44862
|
+
kind: EventVocabularyKindSchema.optional(),
|
|
44863
|
+
payload: array(EventVocabularyFieldSchema).optional()
|
|
44864
|
+
});
|
|
44674
44865
|
Math.PI / 180;
|
|
44675
44866
|
/**
|
|
44676
44867
|
* WHEN something happens, as data (D983) — the one time vocabulary of the
|
|
@@ -44878,6 +45069,33 @@ var ScheduleLeafSchema = object({
|
|
|
44878
45069
|
/** @deprecated legacy cron — new schedules use `at`. */
|
|
44879
45070
|
cron: string().min(1).max(120).optional()
|
|
44880
45071
|
}).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" });
|
|
45072
|
+
/**
|
|
45073
|
+
* One payload predicate of a `device-fired` row: the value at `path` inside
|
|
45074
|
+
* the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
|
|
45075
|
+
*/
|
|
45076
|
+
var DeviceFiredMatchSchema = object({
|
|
45077
|
+
path: string().min(1).max(120),
|
|
45078
|
+
equals: union([
|
|
45079
|
+
string(),
|
|
45080
|
+
number$1(),
|
|
45081
|
+
boolean()
|
|
45082
|
+
])
|
|
45083
|
+
});
|
|
45084
|
+
/**
|
|
45085
|
+
* "fires": one device of the `event-emitter` capability reported an event
|
|
45086
|
+
* (D1045). Every list is an OR, the lists together an AND; an absent list does
|
|
45087
|
+
* not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
|
|
45088
|
+
* the device (a button), `kinds` the shared press kinds of its vocabulary.
|
|
45089
|
+
*/
|
|
45090
|
+
var DeviceFiredLeafSchema = object({
|
|
45091
|
+
kind: literal("device-fired"),
|
|
45092
|
+
...eventLeafId,
|
|
45093
|
+
deviceId: number$1().int().nonnegative(),
|
|
45094
|
+
eventIds: array(string().min(1)).min(1).max(64).optional(),
|
|
45095
|
+
sourceIds: array(string().min(1)).min(1).max(64).optional(),
|
|
45096
|
+
kinds: array(EventVocabularyKindSchema).min(1).optional(),
|
|
45097
|
+
match: array(DeviceFiredMatchSchema).min(1).max(8).optional()
|
|
45098
|
+
});
|
|
44881
45099
|
var ManualLeafSchema = object({
|
|
44882
45100
|
kind: literal("manual"),
|
|
44883
45101
|
...eventLeafId
|
|
@@ -45019,6 +45237,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
45019
45237
|
}),
|
|
45020
45238
|
DeviceBecomesLeafSchema,
|
|
45021
45239
|
DeviceEventLeafSchema,
|
|
45240
|
+
DeviceFiredLeafSchema,
|
|
45022
45241
|
ScheduleLeafSchema,
|
|
45023
45242
|
ManualLeafSchema,
|
|
45024
45243
|
IntervalLeafSchema,
|
|
@@ -45033,6 +45252,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
45033
45252
|
var EVENT_KINDS = new Set([
|
|
45034
45253
|
"device-becomes",
|
|
45035
45254
|
"device-event",
|
|
45255
|
+
"device-fired",
|
|
45036
45256
|
"schedule",
|
|
45037
45257
|
"manual",
|
|
45038
45258
|
"interval",
|
|
@@ -45113,6 +45333,7 @@ function hasEmptyContainer(node) {
|
|
|
45113
45333
|
var LEAF_WORDS = {
|
|
45114
45334
|
"device-becomes": "a device value that becomes",
|
|
45115
45335
|
"device-event": "a device event",
|
|
45336
|
+
"device-fired": "a device firing an event",
|
|
45116
45337
|
schedule: "a schedule",
|
|
45117
45338
|
manual: "a manual run",
|
|
45118
45339
|
interval: "an interval",
|
|
@@ -45362,59 +45583,47 @@ function convertLegacyWhen(half) {
|
|
|
45362
45583
|
* (instants) and state leaves (durations). It replaces the flat trigger list
|
|
45363
45584
|
* plus the separate condition tree; the firing rule is in that file and in
|
|
45364
45585
|
* ADR "one tree".
|
|
45365
|
-
* - **Actions** — the `wait` and `
|
|
45586
|
+
* - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
|
|
45366
45587
|
* fragment of §3.2.2. See {@link AutomationActionSchema}.
|
|
45367
45588
|
*
|
|
45368
45589
|
* A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
|
|
45369
45590
|
* {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
|
|
45370
45591
|
*/
|
|
45371
45592
|
/**
|
|
45372
|
-
* One action step: `wait`, or a `
|
|
45593
|
+
* One action step: `wait`, or a device `command`.
|
|
45373
45594
|
*
|
|
45374
|
-
* A
|
|
45375
|
-
* `{ $var }` resolved from the run's
|
|
45376
|
-
*
|
|
45377
|
-
*
|
|
45378
|
-
*
|
|
45379
|
-
*
|
|
45595
|
+
* A command step names a VOCABULARY action (`cover.open`) and who it acts on
|
|
45596
|
+
* (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
|
|
45597
|
+
* variables). It never names a cap method: the step runner turns the action
|
|
45598
|
+
* id into its cap + method through the vocabulary index when the step runs
|
|
45599
|
+
* (`vocabCall`), the one place that mapping happens. The step runner
|
|
45600
|
+
* (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
|
|
45601
|
+
* variable substitution, once, for every caller — automations, Actions, and
|
|
45602
|
+
* the notification centre, which runs only Actions (planning#473).
|
|
45380
45603
|
*/
|
|
45604
|
+
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
45605
|
+
var WAIT_MAX_SECONDS = 3600;
|
|
45606
|
+
var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
|
|
45381
45607
|
var AutomationWaitStepSchema = object({
|
|
45382
45608
|
kind: literal("wait"),
|
|
45383
|
-
seconds: number$1().min(0).max(
|
|
45609
|
+
seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
45384
45610
|
});
|
|
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
45611
|
/**
|
|
45392
|
-
* The fields of a
|
|
45393
|
-
*
|
|
45394
|
-
* device); a step is {@link AutomationCapStepSchema}.
|
|
45612
|
+
* The fields of a command step, before the vocabulary check. A step is
|
|
45613
|
+
* {@link AutomationCommandStepSchema}.
|
|
45395
45614
|
*/
|
|
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(),
|
|
45615
|
+
var AutomationCommandStepBaseSchema = object({
|
|
45616
|
+
kind: literal("command"),
|
|
45617
|
+
/** WHO the step acts on. */
|
|
45618
|
+
target: ActionTargetSchema,
|
|
45619
|
+
/** The vocabulary action this step performs (`cover.open`). */
|
|
45620
|
+
actionId: string().min(1),
|
|
45407
45621
|
/**
|
|
45408
|
-
*
|
|
45409
|
-
*
|
|
45410
|
-
*
|
|
45622
|
+
* The values of the action's OPEN args (`position`, `presetId`); the args
|
|
45623
|
+
* the vocabulary bakes into the action are added when the step runs. Values
|
|
45624
|
+
* may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
45625
|
+
* SUBSTITUTE and do not evaluate (§3.2.3).
|
|
45411
45626
|
*/
|
|
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
45627
|
args: record(string(), unknown()).optional(),
|
|
45419
45628
|
/**
|
|
45420
45629
|
* The unit the person picked per arg (display only). `args` always hold the
|
|
@@ -45423,18 +45632,20 @@ var AutomationCapStepBaseSchema = object({
|
|
|
45423
45632
|
*/
|
|
45424
45633
|
argUnits: record(string(), string().min(1)).optional()
|
|
45425
45634
|
});
|
|
45635
|
+
/** The vocabulary check every command step passes: the action exists. */
|
|
45636
|
+
function refineKnownAction(step, ctx) {
|
|
45637
|
+
if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
|
|
45638
|
+
code: "custom",
|
|
45639
|
+
message: `"${step.actionId}" is not a vocabulary action id`,
|
|
45640
|
+
path: ["actionId"]
|
|
45641
|
+
});
|
|
45642
|
+
}
|
|
45426
45643
|
/**
|
|
45427
|
-
* The steps an internal Action may contain:
|
|
45644
|
+
* The steps an internal Action may contain: command and wait, and nothing that can
|
|
45428
45645
|
* call back into an Action — so an Action can never reach itself (no cycles).
|
|
45429
45646
|
* This is the LEAF shape: no condition of its own.
|
|
45430
45647
|
*/
|
|
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
|
-
})]);
|
|
45648
|
+
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
|
|
45438
45649
|
/**
|
|
45439
45650
|
* The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
|
|
45440
45651
|
* on the state mirror when the step is reached; `else` runs when it is false.
|
|
@@ -45450,39 +45661,209 @@ var elseNeedsIf = {
|
|
|
45450
45661
|
path: ["else"]
|
|
45451
45662
|
};
|
|
45452
45663
|
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
45664
|
/**
|
|
45461
45665
|
* A step of a STANDALONE list (an action, a scheduler point, a preset): the
|
|
45462
45666
|
* same two step kinds an automation runs, minus a guard that reads the
|
|
45463
45667
|
* automation's trigger, which such a list does not have.
|
|
45464
45668
|
*/
|
|
45465
|
-
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema,
|
|
45669
|
+
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
45670
|
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
45467
45671
|
code: "custom",
|
|
45468
45672
|
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
45469
45673
|
path: ["if"]
|
|
45470
45674
|
});
|
|
45471
45675
|
});
|
|
45676
|
+
/**
|
|
45677
|
+
* Flow control of an AUTOMATION's list (#500). A standalone list (an action, a
|
|
45678
|
+
* scheduler point, a preset) stays `wait` and `cap`: it has no run of its own
|
|
45679
|
+
* to end and no variable bag to write.
|
|
45680
|
+
*/
|
|
45681
|
+
var continueOnErrorShape = {
|
|
45682
|
+
/** A failure of this step is traced `failed-continued` and the next step runs. */
|
|
45683
|
+
continueOnError: literal(true).optional() };
|
|
45684
|
+
/** An automation's command step: the shared guarded command step, plus `continueOnError`. */
|
|
45685
|
+
var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
|
|
45686
|
+
...stepGuardShape,
|
|
45687
|
+
...continueOnErrorShape
|
|
45688
|
+
}).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45689
|
+
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
45690
|
+
var AutomationStopStepSchema = object({
|
|
45691
|
+
kind: literal("stop"),
|
|
45692
|
+
reason: string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
|
|
45693
|
+
/** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
|
|
45694
|
+
outcome: _enum(["ok", "failed"]),
|
|
45695
|
+
/** Stop only when this reads true; false or unknown does not stop. */
|
|
45696
|
+
if: AutomationWhenSchema.optional()
|
|
45697
|
+
});
|
|
45698
|
+
var SET_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,39}$/;
|
|
45699
|
+
/** Names the run itself writes and reads (`leaf` is what `triggered-by` judges): a step may not overwrite them. */
|
|
45700
|
+
var RESERVED_RUN_VARS = [
|
|
45701
|
+
"kind",
|
|
45702
|
+
"leaf",
|
|
45703
|
+
"at"
|
|
45704
|
+
];
|
|
45705
|
+
/**
|
|
45706
|
+
* Write variables into the run's bag, for the steps after it. SUBSTITUTION
|
|
45707
|
+
* only, never evaluation: a text value may carry `{{vars.x}}` slots.
|
|
45708
|
+
*/
|
|
45709
|
+
var AutomationSetStepSchema = object({
|
|
45710
|
+
kind: literal("set"),
|
|
45711
|
+
vars: record(string(), union([
|
|
45712
|
+
string().max(500),
|
|
45713
|
+
number$1(),
|
|
45714
|
+
boolean()
|
|
45715
|
+
])).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` }),
|
|
45716
|
+
/** Set only when this reads true; false or unknown leaves the bag as it is. */
|
|
45717
|
+
if: AutomationWhenSchema.optional()
|
|
45718
|
+
});
|
|
45719
|
+
var AutomationRunActionStepSchema = object({
|
|
45720
|
+
kind: literal("action"),
|
|
45721
|
+
/** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
|
|
45722
|
+
actionId: string().min(1),
|
|
45723
|
+
/** Values for the action's declared variables; the others take their default. */
|
|
45724
|
+
variables: record(string(), union([
|
|
45725
|
+
string(),
|
|
45726
|
+
number$1(),
|
|
45727
|
+
boolean()
|
|
45728
|
+
])).optional(),
|
|
45729
|
+
...continueOnErrorShape
|
|
45730
|
+
});
|
|
45731
|
+
/**
|
|
45732
|
+
* A step INSIDE a branch of a `choose`: a flow step with no condition of its
|
|
45733
|
+
* own (the branch is the condition) and no block inside it. Strict, so an `if`
|
|
45734
|
+
* written on such a step is refused rather than dropped.
|
|
45735
|
+
*/
|
|
45736
|
+
/** The longest a `wait-until` may wait: six hours. */
|
|
45737
|
+
var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
|
|
45738
|
+
/**
|
|
45739
|
+
* Pause the run until a condition is true (#500). The timeout is mandatory: a
|
|
45740
|
+
* run never waits without an end. `onTimeout` says what a wait that ran out
|
|
45741
|
+
* does: `continue` goes on to the next step, `stop` ends the run as a failure.
|
|
45742
|
+
* A condition that cannot be read is not "true": the wait goes on (D49).
|
|
45743
|
+
*/
|
|
45744
|
+
var AutomationWaitUntilStepSchema = object({
|
|
45745
|
+
kind: literal("wait-until"),
|
|
45746
|
+
when: AutomationWhenSchema,
|
|
45747
|
+
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)`),
|
|
45748
|
+
onTimeout: _enum(["continue", "stop"])
|
|
45749
|
+
}).strict();
|
|
45750
|
+
/** The step kinds that hold steps of their own, or pause on a condition: they nest two levels at most. */
|
|
45751
|
+
var BLOCK_STEP_KINDS = [
|
|
45752
|
+
"choose",
|
|
45753
|
+
"repeat",
|
|
45754
|
+
"parallel",
|
|
45755
|
+
"wait-until"
|
|
45756
|
+
];
|
|
45757
|
+
var NEST_TOO_DEEP = `steps nest two levels at most: a step inside a nested choose or repeat can be a plain step only`;
|
|
45758
|
+
function kindOf(input) {
|
|
45759
|
+
return typeof input === "object" && input !== null ? Reflect.get(input, "kind") : void 0;
|
|
45760
|
+
}
|
|
45761
|
+
/** Where the nesting ends, a block step is refused in words rather than as an unknown kind. */
|
|
45762
|
+
function nestTooDeep(issue) {
|
|
45763
|
+
const kind = kindOf(issue.input);
|
|
45764
|
+
return typeof kind === "string" && BLOCK_STEP_KINDS.includes(kind) ? NEST_TOO_DEEP : void 0;
|
|
45765
|
+
}
|
|
45766
|
+
var plainStepSchemas = [
|
|
45767
|
+
AutomationWaitStepSchema.strict(),
|
|
45768
|
+
AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
|
|
45769
|
+
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
45770
|
+
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
45771
|
+
AutomationRunActionStepSchema.strict()
|
|
45772
|
+
];
|
|
45773
|
+
/**
|
|
45774
|
+
* A plain step: a flow step with no condition of its own and no step inside
|
|
45775
|
+
* it. The second (last) level of nesting holds these only.
|
|
45776
|
+
*/
|
|
45777
|
+
var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
|
|
45778
|
+
/** A step that can run beside others: it writes no variable and does not end the run. */
|
|
45779
|
+
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");
|
|
45780
|
+
/**
|
|
45781
|
+
* Several steps at once (#500): all are started together and all are awaited.
|
|
45782
|
+
* A failure fails the run once the others finished, as in a sequence; a member
|
|
45783
|
+
* marked "continue if this fails" does not.
|
|
45784
|
+
*/
|
|
45785
|
+
var AutomationParallelStepSchema = object({
|
|
45786
|
+
kind: literal("parallel"),
|
|
45787
|
+
steps: array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
|
|
45788
|
+
}).strict();
|
|
45789
|
+
var REPEAT_NEEDS_MAX = "a repeat on a condition needs a maximum number of iterations";
|
|
45790
|
+
/** A loop on a condition: the bound is mandatory, so a run never loops without an end. */
|
|
45791
|
+
var repeatConditionShape = {
|
|
45792
|
+
when: AutomationWhenSchema,
|
|
45793
|
+
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`),
|
|
45794
|
+
/** A pause between two iterations, never after the last. */
|
|
45795
|
+
waitS: number$1().int().min(1).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG).optional()
|
|
45796
|
+
};
|
|
45797
|
+
/** What decides how many times a `repeat` runs. */
|
|
45798
|
+
var AutomationRepeatLoopSchema = discriminatedUnion("by", [
|
|
45799
|
+
object({
|
|
45800
|
+
by: literal("count"),
|
|
45801
|
+
count: number$1().int().min(1).max(20, `a repeat runs at most 20 times`)
|
|
45802
|
+
}).strict(),
|
|
45803
|
+
object({
|
|
45804
|
+
by: literal("while"),
|
|
45805
|
+
...repeatConditionShape
|
|
45806
|
+
}).strict(),
|
|
45807
|
+
object({
|
|
45808
|
+
by: literal("until"),
|
|
45809
|
+
...repeatConditionShape
|
|
45810
|
+
}).strict(),
|
|
45811
|
+
object({
|
|
45812
|
+
by: literal("forEach"),
|
|
45813
|
+
target: object({
|
|
45814
|
+
kind: literal("devices"),
|
|
45815
|
+
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`)
|
|
45816
|
+
}).strict()
|
|
45817
|
+
}).strict()
|
|
45818
|
+
]);
|
|
45819
|
+
/**
|
|
45820
|
+
* The same steps several times (#500). Every form is bounded at save, so a
|
|
45821
|
+
* run cannot loop without an end. A failure or a `stop` in the steps ends the
|
|
45822
|
+
* loop and the run, as in a sequence.
|
|
45823
|
+
*/
|
|
45824
|
+
function repeatSchemaOf(step) {
|
|
45825
|
+
return object({
|
|
45826
|
+
kind: literal("repeat"),
|
|
45827
|
+
loop: AutomationRepeatLoopSchema,
|
|
45828
|
+
steps: array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
|
|
45829
|
+
}).strict();
|
|
45830
|
+
}
|
|
45831
|
+
/**
|
|
45832
|
+
* One step, several ways (#500): the branches are read in order and the FIRST
|
|
45833
|
+
* whose condition is true runs; `else` runs when every branch is false. A
|
|
45834
|
+
* branch that cannot be read ends the choice: nothing runs, not the branches
|
|
45835
|
+
* after it and not the else (D49). The #472 `if` / `else` of a wait or cap
|
|
45836
|
+
* step is the one-branch case and stays as it is stored.
|
|
45837
|
+
*/
|
|
45838
|
+
function chooseSchemaOf(step) {
|
|
45839
|
+
const steps = array(step).max(10);
|
|
45840
|
+
return object({
|
|
45841
|
+
kind: literal("choose"),
|
|
45842
|
+
branches: array(object({
|
|
45843
|
+
if: AutomationWhenSchema,
|
|
45844
|
+
steps: steps.min(1, "a branch needs at least one step")
|
|
45845
|
+
})).min(1, "a choose needs at least one branch").max(6, `a choose takes at most 6 branches`),
|
|
45846
|
+
else: steps.optional()
|
|
45847
|
+
});
|
|
45848
|
+
}
|
|
45849
|
+
var AutomationBodyStepSchema = discriminatedUnion("kind", [
|
|
45850
|
+
...plainStepSchemas,
|
|
45851
|
+
AutomationWaitUntilStepSchema,
|
|
45852
|
+
AutomationParallelStepSchema,
|
|
45853
|
+
chooseSchemaOf(AutomationBranchStepSchema),
|
|
45854
|
+
repeatSchemaOf(AutomationBranchStepSchema)
|
|
45855
|
+
]);
|
|
45856
|
+
var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
|
|
45472
45857
|
var AutomationActionSchema = discriminatedUnion("kind", [
|
|
45473
45858
|
GuardedWaitStepSchema,
|
|
45474
|
-
|
|
45475
|
-
|
|
45476
|
-
|
|
45477
|
-
|
|
45478
|
-
|
|
45479
|
-
|
|
45480
|
-
|
|
45481
|
-
|
|
45482
|
-
number$1(),
|
|
45483
|
-
boolean()
|
|
45484
|
-
])).optional()
|
|
45485
|
-
}),
|
|
45859
|
+
AutomationGuardedCommandStepSchema,
|
|
45860
|
+
AutomationStopStepSchema,
|
|
45861
|
+
AutomationSetStepSchema,
|
|
45862
|
+
chooseSchemaOf(AutomationBodyStepSchema),
|
|
45863
|
+
AutomationWaitUntilStepSchema,
|
|
45864
|
+
AutomationParallelStepSchema,
|
|
45865
|
+
AutomationRepeatStepSchema,
|
|
45866
|
+
AutomationRunActionStepSchema,
|
|
45486
45867
|
object({
|
|
45487
45868
|
kind: literal("code"),
|
|
45488
45869
|
/** Compiled into the automation's OWN block by esbuild — not a third
|
|
@@ -45545,44 +45926,7 @@ function convertLegacyRecipe(legacy) {
|
|
|
45545
45926
|
...rest
|
|
45546
45927
|
};
|
|
45547
45928
|
}
|
|
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
45929
|
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
45930
|
/**
|
|
45587
45931
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
45588
45932
|
*
|
|
@@ -45634,12 +45978,16 @@ var HoldOverrideSchema = discriminatedUnion("mode", [object({ mode: literal("res
|
|
|
45634
45978
|
})]);
|
|
45635
45979
|
/** A missed edge up to this late still runs. */
|
|
45636
45980
|
var DEFAULT_MAX_LATE_MS = 10 * 6e4;
|
|
45981
|
+
var SchedulerStepSchema = ActionStepSchema.refine((step) => step.kind !== "wait" || step.seconds <= 300, {
|
|
45982
|
+
message: `a scheduler point waits at most five minutes (300 s); put a longer wait in an action`,
|
|
45983
|
+
path: ["seconds"]
|
|
45984
|
+
});
|
|
45637
45985
|
var SchedulerPointSchema = object({
|
|
45638
45986
|
id: string().min(1).max(64),
|
|
45639
45987
|
at: SchedulerTimeSpecSchema,
|
|
45640
45988
|
mode: SchedulerPointModeSchema,
|
|
45641
45989
|
/** The actions of an `edge` or `hold`; a `release` has none. */
|
|
45642
|
-
steps: array(
|
|
45990
|
+
steps: array(SchedulerStepSchema).max(20).default([]),
|
|
45643
45991
|
/** Checked when the point runs (an edge) or is applied (a hold). */
|
|
45644
45992
|
conditions: SchedulerStateTreeSchema.optional(),
|
|
45645
45993
|
/** Hold only; absent means `respect`. */
|
|
@@ -45837,6 +46185,7 @@ var AutomationConditionTraceNodeSchema = object({
|
|
|
45837
46185
|
"triggered-by",
|
|
45838
46186
|
"device-becomes",
|
|
45839
46187
|
"device-event",
|
|
46188
|
+
"device-fired",
|
|
45840
46189
|
"schedule",
|
|
45841
46190
|
"interval",
|
|
45842
46191
|
"manual",
|
|
@@ -45907,18 +46256,46 @@ var StepTraceBaseSchema = object({
|
|
|
45907
46256
|
]).optional(),
|
|
45908
46257
|
/** Why the condition read what it read, in the evaluator's own words. */
|
|
45909
46258
|
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. */
|
|
46259
|
+
/** `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
46260
|
outcome: _enum([
|
|
45912
46261
|
"ok",
|
|
45913
46262
|
"error",
|
|
45914
46263
|
"not-run",
|
|
45915
46264
|
"empty",
|
|
45916
|
-
"skipped"
|
|
46265
|
+
"skipped",
|
|
46266
|
+
"failed-continued",
|
|
46267
|
+
"timed-out"
|
|
45917
46268
|
]),
|
|
45918
46269
|
message: string().optional()
|
|
45919
46270
|
});
|
|
46271
|
+
/** What a block step adds to its row: which list ran, what each branch read, how many rounds. */
|
|
46272
|
+
var blockTraceShape = {
|
|
46273
|
+
/** A `choose` step (#500): the list that ran, `branches.<n>` or `else`. Absent when none did. */
|
|
46274
|
+
branch: string().optional(),
|
|
46275
|
+
/** A `choose` step: what each branch read, in order, up to the one that decided. */
|
|
46276
|
+
branchChecks: array(object({
|
|
46277
|
+
condition: _enum([
|
|
46278
|
+
"true",
|
|
46279
|
+
"false",
|
|
46280
|
+
"unknown"
|
|
46281
|
+
]),
|
|
46282
|
+
conditionReason: string().optional()
|
|
46283
|
+
})).optional(),
|
|
46284
|
+
/** A `repeat` step (#500): how many times its steps ran. */
|
|
46285
|
+
iterations: number$1().int().optional()
|
|
46286
|
+
};
|
|
46287
|
+
/** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
|
|
46288
|
+
var NestedStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46289
|
+
...blockTraceShape,
|
|
46290
|
+
steps: array(StepTraceBaseSchema).optional()
|
|
46291
|
+
});
|
|
45920
46292
|
/** 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({
|
|
46293
|
+
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46294
|
+
else: array(StepTraceBaseSchema).optional(),
|
|
46295
|
+
...blockTraceShape,
|
|
46296
|
+
/** A `choose` step: the steps of the list that ran. A `parallel`: its members. A `repeat`: the LAST iteration. */
|
|
46297
|
+
steps: array(NestedStepTraceSchema).optional()
|
|
46298
|
+
});
|
|
45922
46299
|
var AutomationRunTraceSchema = object({
|
|
45923
46300
|
runId: string().min(1),
|
|
45924
46301
|
startedAt: number$1(),
|
|
@@ -45948,6 +46325,86 @@ var AutomationStateDocSchema = object({
|
|
|
45948
46325
|
lastRunStartedAt: number$1().nullable(),
|
|
45949
46326
|
traces: array(AutomationRunTraceSchema)
|
|
45950
46327
|
});
|
|
46328
|
+
var DETECTION_DESCRIPTIONS = {
|
|
46329
|
+
deviceId: "the camera that saw it",
|
|
46330
|
+
className: "what it saw",
|
|
46331
|
+
trackId: "the track",
|
|
46332
|
+
score: "how sure the detector was",
|
|
46333
|
+
label: "the label it matched (a name, a plate), empty when none"
|
|
46334
|
+
};
|
|
46335
|
+
var STATIONARY_DESCRIPTIONS = {
|
|
46336
|
+
deviceId: "the camera that saw it",
|
|
46337
|
+
className: "what it saw",
|
|
46338
|
+
zones: "the zones it is in",
|
|
46339
|
+
phase: "appeared or departed",
|
|
46340
|
+
entryId: "the stopped object"
|
|
46341
|
+
};
|
|
46342
|
+
var BECOMES_DESCRIPTIONS = {
|
|
46343
|
+
deviceId: "the device that changed",
|
|
46344
|
+
from: "the value before the change, empty when it is not known",
|
|
46345
|
+
to: "the value it changed to"
|
|
46346
|
+
};
|
|
46347
|
+
/**
|
|
46348
|
+
* A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
|
|
46349
|
+
* those names depend on the device, so they are not in this list.
|
|
46350
|
+
*/
|
|
46351
|
+
var FIRED_DESCRIPTIONS = {
|
|
46352
|
+
deviceId: "the device that fired",
|
|
46353
|
+
eventType: "the event, as the device names it",
|
|
46354
|
+
sourceId: "the part of the device that fired (a button), empty when it names none",
|
|
46355
|
+
eventKind: "the kind of press (press, long-press …), empty when the device declares none"
|
|
46356
|
+
};
|
|
46357
|
+
function describe$1(descriptions) {
|
|
46358
|
+
return Object.entries(descriptions).map(([name, description]) => ({
|
|
46359
|
+
name,
|
|
46360
|
+
description
|
|
46361
|
+
}));
|
|
46362
|
+
}
|
|
46363
|
+
describe$1(DETECTION_DESCRIPTIONS);
|
|
46364
|
+
describe$1(STATIONARY_DESCRIPTIONS);
|
|
46365
|
+
describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
46366
|
+
...v,
|
|
46367
|
+
hintKey: "firedDeviceId"
|
|
46368
|
+
} : v);
|
|
46369
|
+
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
46370
|
+
...v,
|
|
46371
|
+
hintKey: "becomesDeviceId"
|
|
46372
|
+
} : v);
|
|
46373
|
+
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
46374
|
+
/**
|
|
46375
|
+
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
46376
|
+
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
46377
|
+
* (NO normalization). Two shapes:
|
|
46378
|
+
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
46379
|
+
* declared set (e.g. press_short, press_long, …).
|
|
46380
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
46381
|
+
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
46382
|
+
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
46383
|
+
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
46384
|
+
* A fire names the part of the device it came from in `sourceId` when the
|
|
46385
|
+
* vocabulary declares sources (a remote's buttons).
|
|
46386
|
+
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
46387
|
+
*/
|
|
46388
|
+
var EventFireSchema = object({
|
|
46389
|
+
deviceId: number$1(),
|
|
46390
|
+
eventType: string(),
|
|
46391
|
+
sourceId: string().optional(),
|
|
46392
|
+
data: record(string(), unknown()).nullable(),
|
|
46393
|
+
timestamp: number$1().meta(readingMeta("none")),
|
|
46394
|
+
seq: number$1().meta(readingMeta("count"))
|
|
46395
|
+
});
|
|
46396
|
+
var EventEmitterStatusSchema = object({
|
|
46397
|
+
eventTypes: array(string()),
|
|
46398
|
+
/**
|
|
46399
|
+
* Required of a provider by the type. A status written before the field
|
|
46400
|
+
* existed still parses, as an empty vocabulary: read it through
|
|
46401
|
+
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
46402
|
+
*/
|
|
46403
|
+
vocabulary: array(EventVocabularyEntrySchema).default([]),
|
|
46404
|
+
lastEvent: EventFireSchema.nullable(),
|
|
46405
|
+
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
46406
|
+
});
|
|
46407
|
+
DeviceType.EventEmitter;
|
|
45951
46408
|
/**
|
|
45952
46409
|
* Actions — named, runnable things an operator (or an automation) can start,
|
|
45953
46410
|
* declared as LIST ENTRIES, never as devices.
|
|
@@ -46210,6 +46667,343 @@ function pruneDeletedEntities(selection, live, log, exporter) {
|
|
|
46210
46667
|
dropped
|
|
46211
46668
|
};
|
|
46212
46669
|
}
|
|
46670
|
+
/**
|
|
46671
|
+
* `device-export` — collection cap for addons that export camstack
|
|
46672
|
+
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
46673
|
+
* HomeKit/HAP, Alexa Smart Home, …).
|
|
46674
|
+
*
|
|
46675
|
+
* No `ecosystem` enum — the addon id identifies the export target.
|
|
46676
|
+
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
46677
|
+
* exposes only the COMMON surface: link state, supported device
|
|
46678
|
+
* kinds (so the UI can filter the device picker), and per-device
|
|
46679
|
+
* expose/unexpose.
|
|
46680
|
+
*
|
|
46681
|
+
* INSTANCES. One export addon can serve several independent targets (a
|
|
46682
|
+
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
46683
|
+
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
46684
|
+
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
46685
|
+
* default instance's); present = that instance; an id the provider does not
|
|
46686
|
+
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
46687
|
+
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
46688
|
+
* change always names the target it changes. A single-instance provider
|
|
46689
|
+
* accepts an absent id on a read or its own id, and refuses any other.
|
|
46690
|
+
*/
|
|
46691
|
+
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
46692
|
+
var InstanceIdSchema$1 = string().min(1);
|
|
46693
|
+
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
46694
|
+
/** One independent export target of an addon. */
|
|
46695
|
+
var ExportInstanceSchema = object({
|
|
46696
|
+
instanceId: InstanceIdSchema$1,
|
|
46697
|
+
name: string(),
|
|
46698
|
+
enabled: boolean(),
|
|
46699
|
+
kind: string().optional(),
|
|
46700
|
+
/**
|
|
46701
|
+
* What this instance's platform accepts as a device name, in one operator-facing sentence
|
|
46702
|
+
* (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
|
|
46703
|
+
* about the rule.
|
|
46704
|
+
*/
|
|
46705
|
+
nameRule: string().optional()
|
|
46706
|
+
});
|
|
46707
|
+
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
46708
|
+
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
46709
|
+
var ExportInstanceUnknownError = class extends Error {
|
|
46710
|
+
code = EXPORT_INSTANCE_UNKNOWN;
|
|
46711
|
+
instanceId;
|
|
46712
|
+
constructor(addon, instanceId) {
|
|
46713
|
+
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
46714
|
+
this.name = "ExportInstanceUnknownError";
|
|
46715
|
+
this.instanceId = instanceId;
|
|
46716
|
+
}
|
|
46717
|
+
};
|
|
46718
|
+
/**
|
|
46719
|
+
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
46720
|
+
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
46721
|
+
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
46722
|
+
*/
|
|
46723
|
+
function statusInstanceOf(input) {
|
|
46724
|
+
return "instanceId" in input ? input.instanceId : void 0;
|
|
46725
|
+
}
|
|
46726
|
+
var LinkStateSchema = _enum([
|
|
46727
|
+
"unlinked",
|
|
46728
|
+
"linked",
|
|
46729
|
+
"error"
|
|
46730
|
+
]);
|
|
46731
|
+
/**
|
|
46732
|
+
* A single label/value row surfaced in the export panel's "Setup"
|
|
46733
|
+
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
46734
|
+
* rows are masked by default with a reveal toggle (client ids,
|
|
46735
|
+
* secrets, …).
|
|
46736
|
+
*/
|
|
46737
|
+
var ExportSetupFieldSchema = object({
|
|
46738
|
+
label: string(),
|
|
46739
|
+
value: string(),
|
|
46740
|
+
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
46741
|
+
secret: boolean().optional()
|
|
46742
|
+
});
|
|
46743
|
+
/**
|
|
46744
|
+
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
46745
|
+
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
46746
|
+
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
46747
|
+
* the provider supplies and skips the section entirely when `setup`
|
|
46748
|
+
* is unset.
|
|
46749
|
+
*/
|
|
46750
|
+
var ExportSetupSchema = object({
|
|
46751
|
+
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
46752
|
+
qr: string().optional(),
|
|
46753
|
+
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
46754
|
+
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
46755
|
+
/** Free-form operator instructions rendered above the fields. */
|
|
46756
|
+
note: string().optional()
|
|
46757
|
+
});
|
|
46758
|
+
var DeviceExportStatusSchema = object({
|
|
46759
|
+
linkState: LinkStateSchema,
|
|
46760
|
+
exposedDeviceCount: number$1(),
|
|
46761
|
+
error: string().optional(),
|
|
46762
|
+
/**
|
|
46763
|
+
* Optional pairing/account info the panel renders in a generic
|
|
46764
|
+
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
46765
|
+
* export target, never an `ecosystem` key here.
|
|
46766
|
+
*/
|
|
46767
|
+
setup: ExportSetupSchema.optional()
|
|
46768
|
+
});
|
|
46769
|
+
var DeviceKindSchema = string();
|
|
46770
|
+
/**
|
|
46771
|
+
* EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
|
|
46772
|
+
* device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
|
|
46773
|
+
* store (D865), validated by the exporter against its platform's naming rules, and never reaches
|
|
46774
|
+
* the exported id — a rename updates the SAME device on the platform, never a second one.
|
|
46775
|
+
* Blank or `null` = the device's own name. A name the platform would refuse is refused with
|
|
46776
|
+
* `ExportNameRefusedError` (`export-name-refused`), whose message says why.
|
|
46777
|
+
*/
|
|
46778
|
+
var ExposedDeviceSchema = object({
|
|
46779
|
+
deviceId: string(),
|
|
46780
|
+
exposedAs: string().optional(),
|
|
46781
|
+
/** The operator's name for this device on this instance; absent = the device's own name. */
|
|
46782
|
+
exposedName: string().optional(),
|
|
46783
|
+
capabilities: array(string()).optional()
|
|
46784
|
+
});
|
|
46785
|
+
var ExposeInputSchema = object({
|
|
46786
|
+
instanceId: InstanceIdSchema$1,
|
|
46787
|
+
deviceId: string(),
|
|
46788
|
+
capabilities: array(string()).optional(),
|
|
46789
|
+
/** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
|
|
46790
|
+
exposedName: string().nullable().optional()
|
|
46791
|
+
});
|
|
46792
|
+
var SetExposedNameInputSchema = object({
|
|
46793
|
+
instanceId: InstanceIdSchema$1,
|
|
46794
|
+
deviceId: string(),
|
|
46795
|
+
/** Blank or null = the device's own name. */
|
|
46796
|
+
name: string().nullable(),
|
|
46797
|
+
/**
|
|
46798
|
+
* Validate only: refuse exactly as a real call would, write nothing. A caller saving several
|
|
46799
|
+
* names at once checks every one first, so one refusal writes none (D1049).
|
|
46800
|
+
*/
|
|
46801
|
+
dryRun: boolean().optional()
|
|
46802
|
+
});
|
|
46803
|
+
var EXPORT_NAME_REFUSED = "export-name-refused";
|
|
46804
|
+
/** A name the instance's platform would refuse. The message starts with the code, then the reason. */
|
|
46805
|
+
var ExportNameRefusedError = class extends Error {
|
|
46806
|
+
code = EXPORT_NAME_REFUSED;
|
|
46807
|
+
instanceId;
|
|
46808
|
+
reason;
|
|
46809
|
+
constructor(instanceId, reason) {
|
|
46810
|
+
super(`${EXPORT_NAME_REFUSED}: ${reason}`);
|
|
46811
|
+
this.name = "ExportNameRefusedError";
|
|
46812
|
+
this.instanceId = instanceId;
|
|
46813
|
+
this.reason = reason;
|
|
46814
|
+
}
|
|
46815
|
+
};
|
|
46816
|
+
var UnexposeInputSchema = object({
|
|
46817
|
+
instanceId: InstanceIdSchema$1,
|
|
46818
|
+
deviceId: string()
|
|
46819
|
+
});
|
|
46820
|
+
/**
|
|
46821
|
+
* What an exporter may expose besides devices (D968). An action and a
|
|
46822
|
+
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
46823
|
+
* exporter's own selection, not the device registry.
|
|
46824
|
+
*/
|
|
46825
|
+
var ExportEntityKindSchema = _enum([
|
|
46826
|
+
"device",
|
|
46827
|
+
"action",
|
|
46828
|
+
"notifier"
|
|
46829
|
+
]);
|
|
46830
|
+
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
46831
|
+
object({
|
|
46832
|
+
kind: literal("device"),
|
|
46833
|
+
deviceId: string()
|
|
46834
|
+
}),
|
|
46835
|
+
object({
|
|
46836
|
+
kind: literal("action"),
|
|
46837
|
+
actionId: string().min(1)
|
|
46838
|
+
}),
|
|
46839
|
+
object({
|
|
46840
|
+
kind: literal("notifier"),
|
|
46841
|
+
targetId: string().min(1)
|
|
46842
|
+
})
|
|
46843
|
+
]);
|
|
46844
|
+
var ExposedEntitySchema = object({
|
|
46845
|
+
entity: ExportEntityRefSchema,
|
|
46846
|
+
exposedAs: string().optional()
|
|
46847
|
+
});
|
|
46848
|
+
var ExposeEntityInputSchema = object({
|
|
46849
|
+
instanceId: InstanceIdSchema$1,
|
|
46850
|
+
entity: ExportEntityRefSchema
|
|
46851
|
+
});
|
|
46852
|
+
var UnexposeEntityInputSchema = object({
|
|
46853
|
+
instanceId: InstanceIdSchema$1,
|
|
46854
|
+
entity: ExportEntityRefSchema
|
|
46855
|
+
});
|
|
46856
|
+
var deviceExportCapability = {
|
|
46857
|
+
name: "device-export",
|
|
46858
|
+
scope: "system",
|
|
46859
|
+
mode: "collection",
|
|
46860
|
+
providerKind: "device-export",
|
|
46861
|
+
status: {
|
|
46862
|
+
schema: DeviceExportStatusSchema,
|
|
46863
|
+
kind: "poll"
|
|
46864
|
+
},
|
|
46865
|
+
/**
|
|
46866
|
+
* Each export provider MAY contribute its own per-device "Export" panel
|
|
46867
|
+
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
46868
|
+
* framework methods are mounted on the cap router when present.
|
|
46869
|
+
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
46870
|
+
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
46871
|
+
* never hand-written — D14 — and an exporter is not one of those).
|
|
46872
|
+
*/
|
|
46873
|
+
exposesDeviceSettings: true,
|
|
46874
|
+
methods: {
|
|
46875
|
+
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
46876
|
+
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
46877
|
+
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
46878
|
+
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
46879
|
+
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
46880
|
+
kind: "mutation",
|
|
46881
|
+
auth: "admin"
|
|
46882
|
+
}),
|
|
46883
|
+
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
46884
|
+
kind: "mutation",
|
|
46885
|
+
auth: "admin"
|
|
46886
|
+
}),
|
|
46887
|
+
setExposedName: method(SetExposedNameInputSchema, _void(), {
|
|
46888
|
+
kind: "mutation",
|
|
46889
|
+
auth: "admin"
|
|
46890
|
+
}),
|
|
46891
|
+
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
46892
|
+
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
46893
|
+
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
46894
|
+
kind: "mutation",
|
|
46895
|
+
auth: "admin"
|
|
46896
|
+
}),
|
|
46897
|
+
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
46898
|
+
kind: "mutation",
|
|
46899
|
+
auth: "admin"
|
|
46900
|
+
})
|
|
46901
|
+
}
|
|
46902
|
+
};
|
|
46903
|
+
/**
|
|
46904
|
+
* The exposed name of a device on one export instance (`device-export`, D1049).
|
|
46905
|
+
*
|
|
46906
|
+
* Every exporter keeps its names the same way: in ITS per-device store (D865), under
|
|
46907
|
+
* {@link EXPOSED_NAMES_STORE_KEY}, one entry per instance id. The store is cleared centrally
|
|
46908
|
+
* when the device is deleted, so no removal hook is needed for it. Each exporter supplies the
|
|
46909
|
+
* validator of its own platform; the normalisation, the store shape and the refusal are here so
|
|
46910
|
+
* the four exporters cannot drift apart.
|
|
46911
|
+
*
|
|
46912
|
+
* The name is a label only: no exporter derives the exported id from it, so a rename updates
|
|
46913
|
+
* the same device on the platform.
|
|
46914
|
+
*/
|
|
46915
|
+
/** The per-device store key holding `{ [instanceId]: name }`. */
|
|
46916
|
+
var EXPOSED_NAMES_STORE_KEY = "exposedNames";
|
|
46917
|
+
var ExposedNamesSchema = record(string(), string());
|
|
46918
|
+
/** Trim and collapse whitespace, then the platform rule. Blank or null clears (`name: null`). */
|
|
46919
|
+
function checkExposedName(raw, validate) {
|
|
46920
|
+
if (raw === null || raw === void 0) return {
|
|
46921
|
+
ok: true,
|
|
46922
|
+
name: null
|
|
46923
|
+
};
|
|
46924
|
+
if (typeof raw !== "string") return {
|
|
46925
|
+
ok: false,
|
|
46926
|
+
reason: "The name must be text."
|
|
46927
|
+
};
|
|
46928
|
+
const name = raw.trim().replace(/\s+/g, " ");
|
|
46929
|
+
if (name.length === 0) return {
|
|
46930
|
+
ok: true,
|
|
46931
|
+
name: null
|
|
46932
|
+
};
|
|
46933
|
+
return validate(name);
|
|
46934
|
+
}
|
|
46935
|
+
/** Every saved name of a device, by instance id. A malformed blob reads as none. */
|
|
46936
|
+
function readExposedNames(store) {
|
|
46937
|
+
const parsed = ExposedNamesSchema.safeParse(store[EXPOSED_NAMES_STORE_KEY]);
|
|
46938
|
+
return parsed.success ? parsed.data : {};
|
|
46939
|
+
}
|
|
46940
|
+
/**
|
|
46941
|
+
* The saved name of one instance, or null: never saved, or a stored value the platform would
|
|
46942
|
+
* now refuse (the device's own name is used rather than pushing a name the platform rejects).
|
|
46943
|
+
*/
|
|
46944
|
+
function readExposedName(store, instanceId, validate) {
|
|
46945
|
+
const saved = readExposedNames(store)[instanceId];
|
|
46946
|
+
if (saved === void 0) return null;
|
|
46947
|
+
const check = checkExposedName(saved, validate);
|
|
46948
|
+
return check.ok ? check.name : null;
|
|
46949
|
+
}
|
|
46950
|
+
/** The store patch that sets (or, with null, clears) one instance's name and keeps the others. */
|
|
46951
|
+
function exposedNamePatch(store, instanceId, name) {
|
|
46952
|
+
const others = Object.fromEntries(Object.entries(readExposedNames(store)).filter(([id]) => id !== instanceId));
|
|
46953
|
+
return { [EXPOSED_NAMES_STORE_KEY]: name === null ? others : {
|
|
46954
|
+
...others,
|
|
46955
|
+
[instanceId]: name
|
|
46956
|
+
} };
|
|
46957
|
+
}
|
|
46958
|
+
/**
|
|
46959
|
+
* Validate and save one instance's name. A name the platform would refuse throws
|
|
46960
|
+
* {@link ExportNameRefusedError} BEFORE anything is written, so the old name stays.
|
|
46961
|
+
*/
|
|
46962
|
+
async function saveExposedName(input) {
|
|
46963
|
+
const check = checkExposedName(input.raw, input.validate);
|
|
46964
|
+
if (!check.ok) throw new ExportNameRefusedError(input.instanceId, check.reason);
|
|
46965
|
+
if (input.dryRun === true) return {
|
|
46966
|
+
changed: false,
|
|
46967
|
+
name: check.name
|
|
46968
|
+
};
|
|
46969
|
+
const store = await input.store.read(input.deviceId);
|
|
46970
|
+
if ((readExposedNames(store)[input.instanceId] ?? null) === check.name) return {
|
|
46971
|
+
changed: false,
|
|
46972
|
+
name: check.name
|
|
46973
|
+
};
|
|
46974
|
+
await input.store.write(input.deviceId, exposedNamePatch(store, input.instanceId, check.name));
|
|
46975
|
+
return {
|
|
46976
|
+
changed: true,
|
|
46977
|
+
name: check.name
|
|
46978
|
+
};
|
|
46979
|
+
}
|
|
46980
|
+
/** The exporter's per-device store as an {@link ExposedNameStore}; throws when settings are absent. */
|
|
46981
|
+
function exposedNameStoreOf(settings, owner) {
|
|
46982
|
+
const access = () => {
|
|
46983
|
+
if (settings === void 0) throw new Error(`${owner}: settings are not available`);
|
|
46984
|
+
return settings;
|
|
46985
|
+
};
|
|
46986
|
+
return {
|
|
46987
|
+
read: (deviceId) => access().readDeviceStore(deviceId),
|
|
46988
|
+
write: (deviceId, patch) => access().writeDeviceStore(deviceId, patch)
|
|
46989
|
+
};
|
|
46990
|
+
}
|
|
46991
|
+
/**
|
|
46992
|
+
* Remove every name saved for `instanceId` (the instance was deleted), so a later instance that
|
|
46993
|
+
* reuses the id does not inherit them. Returns the device ids that lost a name. A store that
|
|
46994
|
+
* cannot be read throws; nothing is written for the devices not reached.
|
|
46995
|
+
*/
|
|
46996
|
+
async function pruneExposedNames(settings, instanceId) {
|
|
46997
|
+
const ids = await settings.listDeviceStoreIds();
|
|
46998
|
+
if (ids.length === 0) return [];
|
|
46999
|
+
const pruned = [];
|
|
47000
|
+
for (const [deviceId, store] of await settings.readDeviceStoreBatch(ids)) {
|
|
47001
|
+
if (readExposedNames(store)[instanceId] === void 0) continue;
|
|
47002
|
+
await settings.writeDeviceStore(deviceId, exposedNamePatch(store, instanceId, null));
|
|
47003
|
+
pruned.push(deviceId);
|
|
47004
|
+
}
|
|
47005
|
+
return pruned;
|
|
47006
|
+
}
|
|
46213
47007
|
_enum([
|
|
46214
47008
|
"automation",
|
|
46215
47009
|
"action",
|
|
@@ -46408,7 +47202,9 @@ var AddonHttpRouteSchema = object({
|
|
|
46408
47202
|
]).optional(),
|
|
46409
47203
|
description: string().optional(),
|
|
46410
47204
|
/** The hub limits this route per client address before the handler runs. */
|
|
46411
|
-
rateLimit: _enum(["auth"]).optional()
|
|
47205
|
+
rateLimit: _enum(["auth"]).optional(),
|
|
47206
|
+
/** Served once per integration instance; the handler reads `instanceId`. */
|
|
47207
|
+
perInstance: boolean().optional()
|
|
46412
47208
|
});
|
|
46413
47209
|
/**
|
|
46414
47210
|
* Cross-process route invocation envelope. The hub captures the
|
|
@@ -46425,6 +47221,8 @@ var InvokeRequestSchema = object({
|
|
|
46425
47221
|
query: record(string(), string()),
|
|
46426
47222
|
body: unknown(),
|
|
46427
47223
|
headers: record(string(), string()),
|
|
47224
|
+
/** The instance the hub resolved for a `perInstance` route. */
|
|
47225
|
+
instanceId: string().optional(),
|
|
46428
47226
|
user: object({
|
|
46429
47227
|
id: string(),
|
|
46430
47228
|
username: string(),
|
|
@@ -50473,11 +51271,13 @@ var IrCodecError = class extends Error {
|
|
|
50473
51271
|
this.code = code;
|
|
50474
51272
|
}
|
|
50475
51273
|
};
|
|
51274
|
+
/** Maximum number of mark/space entries one pulse train may carry. */
|
|
51275
|
+
var IR_TIMINGS_MAX = 1024;
|
|
50476
51276
|
/**
|
|
50477
51277
|
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
50478
51278
|
* alternating, no zeros, 2..1024 entries.
|
|
50479
51279
|
*/
|
|
50480
|
-
var IrTimingsSchema = array(number$1().int()).min(2).max(
|
|
51280
|
+
var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
|
|
50481
51281
|
timings.forEach((value, index) => {
|
|
50482
51282
|
const expectMark = index % 2 === 0;
|
|
50483
51283
|
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
@@ -50524,15 +51324,186 @@ function decodePronto(code) {
|
|
|
50524
51324
|
carrierHz: Math.round(1e6 / unitUs)
|
|
50525
51325
|
};
|
|
50526
51326
|
}
|
|
50527
|
-
/**
|
|
50528
|
-
|
|
50529
|
-
|
|
50530
|
-
|
|
50531
|
-
|
|
50532
|
-
|
|
50533
|
-
|
|
50534
|
-
|
|
50535
|
-
|
|
51327
|
+
/**
|
|
51328
|
+
* FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
|
|
51329
|
+
* literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
|
|
51330
|
+
* is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
|
|
51331
|
+
* between the low 5 bits and the next byte.
|
|
51332
|
+
*/
|
|
51333
|
+
var MAX_DISTANCE = 8192;
|
|
51334
|
+
var MAX_LITERAL_RUN = 32;
|
|
51335
|
+
var MIN_MATCH = 3;
|
|
51336
|
+
var MAX_MATCH = 264;
|
|
51337
|
+
/**
|
|
51338
|
+
* Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
|
|
51339
|
+
* can expand ~130x, so the decoder checks this bound before every write.
|
|
51340
|
+
*/
|
|
51341
|
+
var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
|
|
51342
|
+
function fastlzDecompress(input) {
|
|
51343
|
+
const out = [];
|
|
51344
|
+
let ip = 0;
|
|
51345
|
+
const room = (count) => {
|
|
51346
|
+
if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
|
|
51347
|
+
};
|
|
51348
|
+
const next = () => {
|
|
51349
|
+
const byte = input[ip++];
|
|
51350
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
|
|
51351
|
+
return byte;
|
|
51352
|
+
};
|
|
51353
|
+
while (ip < input.length) {
|
|
51354
|
+
const ctrl = next();
|
|
51355
|
+
if (ctrl < 32) {
|
|
51356
|
+
room(ctrl + 1);
|
|
51357
|
+
for (let i = 0; i <= ctrl; i++) out.push(next());
|
|
51358
|
+
continue;
|
|
51359
|
+
}
|
|
51360
|
+
let len = (ctrl >> 5) - 1;
|
|
51361
|
+
if (len === 6) len += next();
|
|
51362
|
+
const distance = ((ctrl & 31) << 8) + next() + 1;
|
|
51363
|
+
const start = out.length - distance;
|
|
51364
|
+
if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
|
|
51365
|
+
room(len + 3);
|
|
51366
|
+
for (let i = 0; i < len + 3; i++) {
|
|
51367
|
+
const byte = out[start + i];
|
|
51368
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
|
|
51369
|
+
out.push(byte);
|
|
51370
|
+
}
|
|
51371
|
+
}
|
|
51372
|
+
return Uint8Array.from(out);
|
|
51373
|
+
}
|
|
51374
|
+
function fastlzCompress(input) {
|
|
51375
|
+
const out = [];
|
|
51376
|
+
const lastSeen = /* @__PURE__ */ new Map();
|
|
51377
|
+
let literalStart = 0;
|
|
51378
|
+
const flushLiterals = (end) => {
|
|
51379
|
+
for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
|
|
51380
|
+
const to = Math.min(from + MAX_LITERAL_RUN, end);
|
|
51381
|
+
out.push(to - from - 1);
|
|
51382
|
+
for (let i = from; i < to; i++) out.push(input[i] ?? 0);
|
|
51383
|
+
}
|
|
51384
|
+
};
|
|
51385
|
+
let pos = 0;
|
|
51386
|
+
while (pos < input.length) {
|
|
51387
|
+
let matchLen = 0;
|
|
51388
|
+
let matchDistance = 0;
|
|
51389
|
+
if (pos + MIN_MATCH <= input.length) {
|
|
51390
|
+
const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
|
|
51391
|
+
const candidate = lastSeen.get(key);
|
|
51392
|
+
lastSeen.set(key, pos);
|
|
51393
|
+
if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
|
|
51394
|
+
let len = 0;
|
|
51395
|
+
while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
|
|
51396
|
+
if (len >= MIN_MATCH) {
|
|
51397
|
+
matchLen = len;
|
|
51398
|
+
matchDistance = pos - candidate - 1;
|
|
51399
|
+
}
|
|
51400
|
+
}
|
|
51401
|
+
}
|
|
51402
|
+
if (matchLen === 0) {
|
|
51403
|
+
pos++;
|
|
51404
|
+
continue;
|
|
51405
|
+
}
|
|
51406
|
+
flushLiterals(pos);
|
|
51407
|
+
const enc = matchLen - 2;
|
|
51408
|
+
if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
|
|
51409
|
+
else out.push(224 | matchDistance >> 8, enc - 7);
|
|
51410
|
+
out.push(matchDistance & 255);
|
|
51411
|
+
pos += matchLen;
|
|
51412
|
+
literalStart = pos;
|
|
51413
|
+
}
|
|
51414
|
+
flushLiterals(input.length);
|
|
51415
|
+
return Uint8Array.from(out);
|
|
51416
|
+
}
|
|
51417
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
51418
|
+
var MAX_DURATION_US = 65535;
|
|
51419
|
+
function toBase64(bytes) {
|
|
51420
|
+
let out = "";
|
|
51421
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
51422
|
+
const a = bytes[i] ?? 0;
|
|
51423
|
+
const b = bytes[i + 1] ?? 0;
|
|
51424
|
+
const c = bytes[i + 2] ?? 0;
|
|
51425
|
+
const word = a << 16 | b << 8 | c;
|
|
51426
|
+
out += ALPHABET[word >> 18 & 63];
|
|
51427
|
+
out += ALPHABET[word >> 12 & 63];
|
|
51428
|
+
out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
|
|
51429
|
+
out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
|
|
51430
|
+
}
|
|
51431
|
+
return out;
|
|
51432
|
+
}
|
|
51433
|
+
function fromBase64(text) {
|
|
51434
|
+
const clean = text.trim().replace(/=+$/, "");
|
|
51435
|
+
if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51436
|
+
const out = [];
|
|
51437
|
+
let bits = 0;
|
|
51438
|
+
let acc = 0;
|
|
51439
|
+
for (const ch of clean) {
|
|
51440
|
+
const value = ALPHABET.indexOf(ch);
|
|
51441
|
+
if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51442
|
+
acc = acc << 6 | value;
|
|
51443
|
+
bits += 6;
|
|
51444
|
+
if (bits >= 8) {
|
|
51445
|
+
bits -= 8;
|
|
51446
|
+
out.push(acc >> bits & 255);
|
|
51447
|
+
}
|
|
51448
|
+
}
|
|
51449
|
+
return Uint8Array.from(out);
|
|
51450
|
+
}
|
|
51451
|
+
/** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
|
|
51452
|
+
function encodeTuya(timings) {
|
|
51453
|
+
const bytes = new Uint8Array(timings.length * 2);
|
|
51454
|
+
timings.forEach((value, index) => {
|
|
51455
|
+
const duration = Math.abs(value);
|
|
51456
|
+
if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
|
|
51457
|
+
bytes[index * 2] = duration & 255;
|
|
51458
|
+
bytes[index * 2 + 1] = duration >> 8;
|
|
51459
|
+
});
|
|
51460
|
+
return toBase64(fastlzCompress(bytes));
|
|
51461
|
+
}
|
|
51462
|
+
/** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
|
|
51463
|
+
function decodeTuya(code) {
|
|
51464
|
+
const bytes = fastlzDecompress(fromBase64(code));
|
|
51465
|
+
if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
|
|
51466
|
+
const timings = [];
|
|
51467
|
+
for (let i = 0; i < bytes.length; i += 2) {
|
|
51468
|
+
const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
|
|
51469
|
+
timings.push(i / 2 % 2 === 0 ? duration : -duration);
|
|
51470
|
+
}
|
|
51471
|
+
const checked = IrTimingsSchema.safeParse(timings);
|
|
51472
|
+
if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
|
|
51473
|
+
return checked.data;
|
|
51474
|
+
}
|
|
51475
|
+
/** Device-native IR code formats a transmitter can replay verbatim. */
|
|
51476
|
+
var IrNativeFormatSchema = _enum(["tuya"]);
|
|
51477
|
+
/**
|
|
51478
|
+
* Longest native code accepted: base64 of the worst-case compressed stream
|
|
51479
|
+
* (every decoded byte as a literal, plus one control byte per 32), with margin.
|
|
51480
|
+
*/
|
|
51481
|
+
var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
|
|
51482
|
+
var IrNativeCodeSchema = object({
|
|
51483
|
+
format: IrNativeFormatSchema,
|
|
51484
|
+
code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
|
|
51485
|
+
});
|
|
51486
|
+
var IR_NATIVE_CODECS = { tuya: {
|
|
51487
|
+
encode: encodeTuya,
|
|
51488
|
+
decode: decodeTuya
|
|
51489
|
+
} };
|
|
51490
|
+
/** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
|
|
51491
|
+
var IrPayloadSchema = discriminatedUnion("kind", [
|
|
51492
|
+
object({
|
|
51493
|
+
kind: literal("raw"),
|
|
51494
|
+
timings: array(number$1().int()),
|
|
51495
|
+
settings: TransmitSettingsSchema.optional()
|
|
51496
|
+
}),
|
|
51497
|
+
object({
|
|
51498
|
+
kind: literal("pronto"),
|
|
51499
|
+
code: string()
|
|
51500
|
+
}),
|
|
51501
|
+
object({
|
|
51502
|
+
kind: literal("native"),
|
|
51503
|
+
format: IrNativeFormatSchema,
|
|
51504
|
+
code: string()
|
|
51505
|
+
})
|
|
51506
|
+
]);
|
|
50536
51507
|
/** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
|
|
50537
51508
|
function toTimings(payload) {
|
|
50538
51509
|
if (payload.kind === "pronto") {
|
|
@@ -50542,6 +51513,10 @@ function toTimings(payload) {
|
|
|
50542
51513
|
settings: { carrierHz: decoded.carrierHz }
|
|
50543
51514
|
};
|
|
50544
51515
|
}
|
|
51516
|
+
if (payload.kind === "native") return {
|
|
51517
|
+
timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
|
|
51518
|
+
settings: {}
|
|
51519
|
+
};
|
|
50545
51520
|
const checked = IrTimingsSchema.safeParse(payload.timings);
|
|
50546
51521
|
if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
|
|
50547
51522
|
return {
|
|
@@ -51350,8 +52325,8 @@ function actuator(input) {
|
|
|
51350
52325
|
};
|
|
51351
52326
|
}
|
|
51352
52327
|
new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
|
|
51353
|
-
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
51354
52328
|
DeviceType.Camera;
|
|
52329
|
+
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
51355
52330
|
var PowerSourceRefusalReasonSchema = _enum([
|
|
51356
52331
|
"no-power-source",
|
|
51357
52332
|
"switch-missing",
|
|
@@ -52682,193 +53657,6 @@ method(object({
|
|
|
52682
53657
|
kind: "mutation",
|
|
52683
53658
|
auth: "admin"
|
|
52684
53659
|
});
|
|
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
53660
|
var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
52873
53661
|
var DeviceTemplateSchema = string().min(1).max(4096);
|
|
52874
53662
|
/** One value a caller hands the renderer for `thisDevice`. */
|
|
@@ -55719,29 +56507,6 @@ var EnumSensorStatusSchema = object({
|
|
|
55719
56507
|
lastFetchedAt: number$1()
|
|
55720
56508
|
});
|
|
55721
56509
|
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
56510
|
var IdentitySchema = object({
|
|
55746
56511
|
id: string(),
|
|
55747
56512
|
name: string(),
|
|
@@ -57040,6 +57805,128 @@ var StateLookSchema = object({
|
|
|
57040
57805
|
background: _enum(HERO_BACKGROUNDS),
|
|
57041
57806
|
animation: HeroAnimationSchema
|
|
57042
57807
|
});
|
|
57808
|
+
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
57809
|
+
var HeroTextSchema = object({
|
|
57810
|
+
en: string(),
|
|
57811
|
+
it: string()
|
|
57812
|
+
});
|
|
57813
|
+
/**
|
|
57814
|
+
* The ONE measurement a simple sensor shows (card wave, phase 1).
|
|
57815
|
+
*
|
|
57816
|
+
* A sensor that measures a single quantity (a temperature, a humidity, a power,
|
|
57817
|
+
* a contact, a text state) is drawn as that reading, once, big, inside a scene
|
|
57818
|
+
* whose motion says what the number means: heat rising when hot, flakes when
|
|
57819
|
+
* cold, a wire flowing at the speed of the power, a ring while a window is
|
|
57820
|
+
* open. Everything the card draws is decided here; a client only paints it.
|
|
57821
|
+
*/
|
|
57822
|
+
var HERO_MEASUREMENT_QUANTITIES = [
|
|
57823
|
+
"temperature",
|
|
57824
|
+
"humidity",
|
|
57825
|
+
"power",
|
|
57826
|
+
"contact",
|
|
57827
|
+
"text"
|
|
57828
|
+
];
|
|
57829
|
+
/** How a temperature reads to a person; drives the heat or the cold scene. */
|
|
57830
|
+
var HERO_MEASUREMENT_BANDS = [
|
|
57831
|
+
"hot",
|
|
57832
|
+
"mild",
|
|
57833
|
+
"cold"
|
|
57834
|
+
];
|
|
57835
|
+
/** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
|
|
57836
|
+
var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
|
|
57837
|
+
var HeroMeasurementReadingSchema = object({
|
|
57838
|
+
value: number$1(),
|
|
57839
|
+
quantity: ReadingQuantitySchema
|
|
57840
|
+
});
|
|
57841
|
+
var HeroMeasurementSchema = object({
|
|
57842
|
+
quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
|
|
57843
|
+
reading: HeroMeasurementReadingSchema.nullable(),
|
|
57844
|
+
icon: IconKeySchema.nullable(),
|
|
57845
|
+
value: HeroTextSchema,
|
|
57846
|
+
unit: string().nullable(),
|
|
57847
|
+
band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
|
|
57848
|
+
level: number$1().min(0).max(1).nullable(),
|
|
57849
|
+
word: HeroTextSchema,
|
|
57850
|
+
tone: _enum(HERO_TONES),
|
|
57851
|
+
since: number$1().nullable(),
|
|
57852
|
+
sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
|
|
57853
|
+
historyKey: string().nullable()
|
|
57854
|
+
});
|
|
57855
|
+
var same$2 = (text) => t(text, text);
|
|
57856
|
+
var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
|
|
57857
|
+
var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
|
|
57858
|
+
function temperatureBand(celsius) {
|
|
57859
|
+
if (celsius < 12) return "cold";
|
|
57860
|
+
if (celsius > 28) return "hot";
|
|
57861
|
+
return "mild";
|
|
57862
|
+
}
|
|
57863
|
+
var BAND_WORD = {
|
|
57864
|
+
hot: t("Hot", "Caldo"),
|
|
57865
|
+
mild: t("Normal", "Normale"),
|
|
57866
|
+
cold: t("Cold", "Freddo")
|
|
57867
|
+
};
|
|
57868
|
+
var BAND_TONE = {
|
|
57869
|
+
hot: "warning",
|
|
57870
|
+
mild: "muted",
|
|
57871
|
+
cold: "info"
|
|
57872
|
+
};
|
|
57873
|
+
function temperatureMeasurement(celsius, since) {
|
|
57874
|
+
const band = temperatureBand(celsius);
|
|
57875
|
+
return {
|
|
57876
|
+
quantity: "temperature",
|
|
57877
|
+
reading: {
|
|
57878
|
+
value: celsius,
|
|
57879
|
+
quantity: "temperature"
|
|
57880
|
+
},
|
|
57881
|
+
icon: "thermometer",
|
|
57882
|
+
value: same$2(trimmed(celsius, 1)),
|
|
57883
|
+
unit: "°C",
|
|
57884
|
+
band,
|
|
57885
|
+
level: null,
|
|
57886
|
+
word: BAND_WORD[band],
|
|
57887
|
+
tone: BAND_TONE[band],
|
|
57888
|
+
since,
|
|
57889
|
+
sinceKind: "updated",
|
|
57890
|
+
historyKey: "cap:temperature-sensor.temperature"
|
|
57891
|
+
};
|
|
57892
|
+
}
|
|
57893
|
+
function humidityMeasurement(percent, since) {
|
|
57894
|
+
const dry = percent < 30;
|
|
57895
|
+
const humid = percent > 70;
|
|
57896
|
+
return {
|
|
57897
|
+
quantity: "humidity",
|
|
57898
|
+
reading: {
|
|
57899
|
+
value: percent,
|
|
57900
|
+
quantity: "humidity"
|
|
57901
|
+
},
|
|
57902
|
+
icon: "droplets",
|
|
57903
|
+
value: same$2(String(Math.round(percent))),
|
|
57904
|
+
unit: "%",
|
|
57905
|
+
band: null,
|
|
57906
|
+
level: clamp01$1(percent / 100),
|
|
57907
|
+
word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
|
|
57908
|
+
tone: dry || humid ? "warning" : "info",
|
|
57909
|
+
since,
|
|
57910
|
+
sinceKind: "updated",
|
|
57911
|
+
historyKey: "cap:humidity-sensor.humidity"
|
|
57912
|
+
};
|
|
57913
|
+
}
|
|
57914
|
+
function textMeasurement(text, since) {
|
|
57915
|
+
return {
|
|
57916
|
+
quantity: "text",
|
|
57917
|
+
reading: null,
|
|
57918
|
+
icon: null,
|
|
57919
|
+
value: same$2(text),
|
|
57920
|
+
unit: null,
|
|
57921
|
+
band: null,
|
|
57922
|
+
level: null,
|
|
57923
|
+
word: t("Changed", "Cambiato"),
|
|
57924
|
+
tone: "muted",
|
|
57925
|
+
since,
|
|
57926
|
+
sinceKind: "updated",
|
|
57927
|
+
historyKey: null
|
|
57928
|
+
};
|
|
57929
|
+
}
|
|
57043
57930
|
/** The scene as the model carries it. `null` = the device did not say (never a guess). */
|
|
57044
57931
|
var HeroSceneSchema = object({
|
|
57045
57932
|
id: _enum([
|
|
@@ -57090,12 +57977,7 @@ var HeroSceneSchema = object({
|
|
|
57090
57977
|
level: number$1().min(0).max(1).nullable()
|
|
57091
57978
|
});
|
|
57092
57979
|
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
|
-
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
|
-
});
|
|
57980
|
+
DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
|
|
57099
57981
|
var HeroRowIdSchema = _enum([
|
|
57100
57982
|
"progress",
|
|
57101
57983
|
"run-for",
|
|
@@ -57201,6 +58083,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
|
|
|
57201
58083
|
optionLabels: record(string(), HeroTextSchema).optional(),
|
|
57202
58084
|
call: HeroCallSchema,
|
|
57203
58085
|
valueArg: string()
|
|
58086
|
+
}),
|
|
58087
|
+
object({
|
|
58088
|
+
kind: literal("number"),
|
|
58089
|
+
id: string(),
|
|
58090
|
+
label: HeroTextSchema,
|
|
58091
|
+
value: number$1().nullable(),
|
|
58092
|
+
/** `null` = any number; the device rounds what it does not accept. */
|
|
58093
|
+
step: number$1().nullable(),
|
|
58094
|
+
unit: string(),
|
|
58095
|
+
call: HeroCallSchema,
|
|
58096
|
+
valueArg: string()
|
|
58097
|
+
}),
|
|
58098
|
+
object({
|
|
58099
|
+
kind: literal("text"),
|
|
58100
|
+
id: string(),
|
|
58101
|
+
label: HeroTextSchema,
|
|
58102
|
+
value: string().nullable(),
|
|
58103
|
+
call: HeroCallSchema,
|
|
58104
|
+
valueArg: string()
|
|
57204
58105
|
})
|
|
57205
58106
|
]);
|
|
57206
58107
|
/** 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 +58303,11 @@ var HeroModelSchema = object({
|
|
|
57402
58303
|
timedRun: HeroTimedRunSlotSchema.nullable(),
|
|
57403
58304
|
powerSupply: HeroPowerSupplySlotSchema.nullable(),
|
|
57404
58305
|
rows: array(HeroRowSchema),
|
|
58306
|
+
/**
|
|
58307
|
+
* The ONE measurement of a simple sensor, drawn once inside the scene in place of
|
|
58308
|
+
* the caption, tiles and value chips. Absent = the card draws as before.
|
|
58309
|
+
*/
|
|
58310
|
+
measurement: HeroMeasurementSchema.optional(),
|
|
57405
58311
|
/** Ids of parts that actuate the device, hidden from a session that may not act on it. */
|
|
57406
58312
|
gated: array(string()),
|
|
57407
58313
|
provenance: array(HeroProvenanceSchema)
|
|
@@ -57473,8 +58379,23 @@ var HeroRowModelSchema = object({
|
|
|
57473
58379
|
* the call. Absent or empty = `primary` alone.
|
|
57474
58380
|
*/
|
|
57475
58381
|
extras: array(HeroControlSchema).max(2).optional(),
|
|
57476
|
-
trailing: HeroFactSchema.nullable()
|
|
58382
|
+
trailing: HeroFactSchema.nullable(),
|
|
58383
|
+
/**
|
|
58384
|
+
* The simple sensor's one reading (the hero's `measurement`): the row draws its value
|
|
58385
|
+
* at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
|
|
58386
|
+
* older server or a device that is not a simple sensor: draw `trailing`.
|
|
58387
|
+
*/
|
|
58388
|
+
measurement: HeroMeasurementSchema.optional()
|
|
57477
58389
|
});
|
|
58390
|
+
new Set([
|
|
58391
|
+
"temperature",
|
|
58392
|
+
"humidity",
|
|
58393
|
+
"pressure",
|
|
58394
|
+
"illuminance",
|
|
58395
|
+
"reading",
|
|
58396
|
+
"air-quality",
|
|
58397
|
+
"valve"
|
|
58398
|
+
]);
|
|
57478
58399
|
DeviceType.Climate;
|
|
57479
58400
|
DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
|
|
57480
58401
|
/**
|
|
@@ -57791,6 +58712,12 @@ var IntegrationLiteSchema = object({
|
|
|
57791
58712
|
var AvailableIntegrationTypeSchema = object({
|
|
57792
58713
|
addonId: string(),
|
|
57793
58714
|
name: string(),
|
|
58715
|
+
/**
|
|
58716
|
+
* Product name a new integration is prefilled from (`<label> - Home`).
|
|
58717
|
+
* Absent: the client uses `name`. Set when the catalog title is not the
|
|
58718
|
+
* product (Bosch SHC, MQTT).
|
|
58719
|
+
*/
|
|
58720
|
+
providerLabel: string().optional(),
|
|
57794
58721
|
description: string(),
|
|
57795
58722
|
iconUrl: string().nullable(),
|
|
57796
58723
|
color: string(),
|
|
@@ -58302,13 +59229,32 @@ var IrSendResultSchema = object({
|
|
|
58302
59229
|
var IrTransmitterInfoSchema = object({
|
|
58303
59230
|
media: array(IrMediumSchema),
|
|
58304
59231
|
settable: array(TransmitSettingKeySchema),
|
|
58305
|
-
maxTimings: number$1().int().positive()
|
|
59232
|
+
maxTimings: number$1().int().positive(),
|
|
59233
|
+
/** The transmitter can learn a code (`learn`). */
|
|
59234
|
+
learn: boolean().default(false),
|
|
59235
|
+
/** Native code formats the transmitter replays verbatim (`send.native`). */
|
|
59236
|
+
formats: array(IrNativeFormatSchema).default([])
|
|
59237
|
+
});
|
|
59238
|
+
var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
|
|
59239
|
+
var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
|
|
59240
|
+
var IrLearnResultSchema = object({
|
|
59241
|
+
/** The code in the device's own format, when it reports one. */
|
|
59242
|
+
native: IrNativeCodeSchema.nullable(),
|
|
59243
|
+
timings: IrTimingsSchema,
|
|
59244
|
+
carrierHz: number$1().int().positive().nullable()
|
|
58306
59245
|
});
|
|
58307
59246
|
DeviceType.Generic, method(object({
|
|
58308
59247
|
deviceId: number$1().int().nonnegative(),
|
|
58309
|
-
timings: IrTimingsSchema,
|
|
59248
|
+
timings: IrTimingsSchema.optional(),
|
|
59249
|
+
native: IrNativeCodeSchema.optional(),
|
|
58310
59250
|
settings: TransmitSettingsSchema.optional()
|
|
58311
|
-
}), IrSendResultSchema, {
|
|
59251
|
+
}).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
|
|
59252
|
+
kind: "mutation",
|
|
59253
|
+
auth: "protected"
|
|
59254
|
+
}), method(object({
|
|
59255
|
+
deviceId: number$1().int().nonnegative(),
|
|
59256
|
+
timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
|
|
59257
|
+
}), IrLearnResultSchema, {
|
|
58312
59258
|
kind: "mutation",
|
|
58313
59259
|
auth: "protected"
|
|
58314
59260
|
}), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
|
|
@@ -67531,6 +68477,7 @@ var NcSystemEventKindSchema = _enum([
|
|
|
67531
68477
|
"recording-degraded",
|
|
67532
68478
|
"device-attention-required",
|
|
67533
68479
|
"device-attention-resolved",
|
|
68480
|
+
"device-command",
|
|
67534
68481
|
"storage-location-low",
|
|
67535
68482
|
"storage-location-critical",
|
|
67536
68483
|
"storage-location-ok",
|
|
@@ -67593,11 +68540,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
|
|
|
67593
68540
|
"alarm-sensor-bypass",
|
|
67594
68541
|
"alarm-disarmed"
|
|
67595
68542
|
];
|
|
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
68543
|
var NcSystemEventConditionSchema = object({
|
|
67602
68544
|
kinds: array(NcSystemEventKindSchema).min(1),
|
|
67603
68545
|
deviceIds: array(number$1().int()).min(1).optional(),
|
|
@@ -67629,6 +68571,28 @@ var NcSystemEventConditionSchema = object({
|
|
|
67629
68571
|
nodeIds: array(string().min(1)).min(1).optional(),
|
|
67630
68572
|
packageNames: array(string().min(1)).min(1).optional(),
|
|
67631
68573
|
/**
|
|
68574
|
+
* `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
|
|
68575
|
+
* this rule speaks about - the same dictionary the automation action blocks
|
|
68576
|
+
* pick from. The hub refuses an id the action index does not know.
|
|
68577
|
+
*/
|
|
68578
|
+
commandActions: array(string().min(1)).min(1).optional(),
|
|
68579
|
+
/** `device-command` only: how the command settled. A device's own change is not a command. */
|
|
68580
|
+
commandOutcomes: array(_enum([
|
|
68581
|
+
"confirmed",
|
|
68582
|
+
"already",
|
|
68583
|
+
"unconfirmed",
|
|
68584
|
+
"failed"
|
|
68585
|
+
])).min(1).optional(),
|
|
68586
|
+
/** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
|
|
68587
|
+
commandActorKinds: array(_enum([
|
|
68588
|
+
"user",
|
|
68589
|
+
"addon",
|
|
68590
|
+
"action",
|
|
68591
|
+
"scheduler",
|
|
68592
|
+
"composition",
|
|
68593
|
+
"node"
|
|
68594
|
+
])).min(1).optional(),
|
|
68595
|
+
/**
|
|
67632
68596
|
* At or below this remaining-life %, a consumable is LOW for THIS rule
|
|
67633
68597
|
* (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
|
|
67634
68598
|
* {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
|
|
@@ -68609,6 +69573,13 @@ var NcRuleInputSchema = object({
|
|
|
68609
69573
|
*/
|
|
68610
69574
|
groupingSec: number$1().int().min(5).max(60).optional(),
|
|
68611
69575
|
/**
|
|
69576
|
+
* Hold deliveries of this rule to one target and, when two or more arrive
|
|
69577
|
+
* before the window ends, send them as one summary. Absent = the kind's
|
|
69578
|
+
* default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
|
|
69579
|
+
* other kind. `0` sends each delivery as it does today.
|
|
69580
|
+
*/
|
|
69581
|
+
groupWithinSec: number$1().int().min(0).max(300).optional(),
|
|
69582
|
+
/**
|
|
68612
69583
|
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
68613
69584
|
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
68614
69585
|
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
@@ -69045,7 +70016,12 @@ var NcHistoryEntrySchema = object({
|
|
|
69045
70016
|
* Assistant export) must render as "no image right now", never as a
|
|
69046
70017
|
* broken link.
|
|
69047
70018
|
*/
|
|
69048
|
-
artifactIds: array(string().min(1)).optional()
|
|
70019
|
+
artifactIds: array(string().min(1)).optional(),
|
|
70020
|
+
/**
|
|
70021
|
+
* When this row was folded into a group-window summary, the outbox id of
|
|
70022
|
+
* that one notification. Absent on a row that was sent as itself.
|
|
70023
|
+
*/
|
|
70024
|
+
groupedInto: string().min(1).optional()
|
|
69049
70025
|
});
|
|
69050
70026
|
/**
|
|
69051
70027
|
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
@@ -69932,7 +70908,18 @@ var OauthIntegrationDescriptorSchema = object({
|
|
|
69932
70908
|
* The value is baked into the authorization code at `/authorize` and travels
|
|
69933
70909
|
* on the tokens, so editing this field changes FUTURE links only.
|
|
69934
70910
|
*/
|
|
69935
|
-
refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional()
|
|
70911
|
+
refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional(),
|
|
70912
|
+
/**
|
|
70913
|
+
* The integration instances an account can be linked to (planning#415),
|
|
70914
|
+
* beside the default one. `/api/oauth2/authorize?instance=<id>` is accepted
|
|
70915
|
+
* only for an id listed here; with no `instance=` the link is made to the
|
|
70916
|
+
* default instance, which is never listed and always accepted — it is the
|
|
70917
|
+
* address third parties already hold. Omit for a single-instance integration.
|
|
70918
|
+
*/
|
|
70919
|
+
instances: array(object({
|
|
70920
|
+
id: string(),
|
|
70921
|
+
displayName: string()
|
|
70922
|
+
})).optional()
|
|
69936
70923
|
});
|
|
69937
70924
|
method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
|
|
69938
70925
|
/**
|
|
@@ -74674,10 +75661,15 @@ var RecordingSignalStatusSchema = object({
|
|
|
74674
75661
|
});
|
|
74675
75662
|
RecordingSignalStatusSchema.extend({ lastFetchedAt: number$1() });
|
|
74676
75663
|
DeviceType.Camera, method(object({ deviceId: number$1() }), RecordingSignalStatusSchema);
|
|
74677
|
-
var RemoteBindingSchema = object({ action:
|
|
74678
|
-
|
|
74679
|
-
|
|
74680
|
-
|
|
75664
|
+
var RemoteBindingSchema = object({ action: object({
|
|
75665
|
+
kind: literal("cap"),
|
|
75666
|
+
deviceId: number$1().int().nonnegative(),
|
|
75667
|
+
cap: string().min(1),
|
|
75668
|
+
method: string().min(1),
|
|
75669
|
+
args: record(string(), unknown()).optional(),
|
|
75670
|
+
/** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
|
|
75671
|
+
argUnits: record(string(), string().min(1)).optional()
|
|
75672
|
+
}) });
|
|
74681
75673
|
var RemoteCustomButtonSchema = object({
|
|
74682
75674
|
/** The slug after `custom:` in the role. */
|
|
74683
75675
|
key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
|
|
@@ -76254,6 +77246,13 @@ var SsoBridgeClaimsSchema = object({
|
|
|
76254
77246
|
/** OAuth authorization-code binding — set only on `oauth-code` tokens. */
|
|
76255
77247
|
redirectUri: string().optional(),
|
|
76256
77248
|
integrationId: string().optional(),
|
|
77249
|
+
/**
|
|
77250
|
+
* The integration INSTANCE an OAuth link was made for (planning#415). Set on
|
|
77251
|
+
* `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
|
|
77252
|
+
* with `instance=`; absent on a link to the default instance. A cloud relay
|
|
77253
|
+
* reads it off the access token to route; the hub answers from the session.
|
|
77254
|
+
*/
|
|
77255
|
+
instanceId: string().optional(),
|
|
76257
77256
|
/** JWT ID — unique per issued code; consumed-set enforces single-use. */
|
|
76258
77257
|
jti: string().optional(),
|
|
76259
77258
|
/** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
|
|
@@ -78335,6 +79334,8 @@ var OauthSessionSummarySchema = object({
|
|
|
78335
79334
|
userId: string(),
|
|
78336
79335
|
username: string(),
|
|
78337
79336
|
integrationId: string(),
|
|
79337
|
+
/** The instance the link was made for; `null` = the default instance. */
|
|
79338
|
+
instanceId: string().nullable().optional(),
|
|
78338
79339
|
scopes: array(TokenScopeSchema),
|
|
78339
79340
|
createdAt: number$1(),
|
|
78340
79341
|
lastUsedAt: number$1(),
|
|
@@ -78434,6 +79435,9 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
|
|
|
78434
79435
|
access: "view"
|
|
78435
79436
|
}), method(object({
|
|
78436
79437
|
integrationId: string(),
|
|
79438
|
+
/** The integration instance the link is for. Omit for the default
|
|
79439
|
+
* instance — never pass the addon id to mean it. */
|
|
79440
|
+
instanceId: string().optional(),
|
|
78437
79441
|
userId: string(),
|
|
78438
79442
|
username: string(),
|
|
78439
79443
|
scopes: array(TokenScopeSchema),
|
|
@@ -78472,7 +79476,13 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
|
|
|
78472
79476
|
}), method(object({ token: string() }), object({
|
|
78473
79477
|
userId: string(),
|
|
78474
79478
|
username: string(),
|
|
78475
|
-
scopes: array(TokenScopeSchema)
|
|
79479
|
+
scopes: array(TokenScopeSchema),
|
|
79480
|
+
/** The instance the link was made for, read from the SESSION.
|
|
79481
|
+
* Absent = the default instance. `oauthLinkServesInstance` is the
|
|
79482
|
+
* helper a per-instance route calls to compare it with the instance
|
|
79483
|
+
* of its path; no route declares `perInstance` yet (the Alexa
|
|
79484
|
+
* per-instance route, T3, is the first consumer). */
|
|
79485
|
+
instanceId: string().optional()
|
|
78476
79486
|
}).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
|
|
78477
79487
|
userId: string(),
|
|
78478
79488
|
issuer: string()
|
|
@@ -80072,8 +81082,6 @@ var AccessoryKind = {
|
|
|
80072
81082
|
};
|
|
80073
81083
|
AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
|
|
80074
81084
|
DeviceType.HeatPump;
|
|
80075
|
-
DeviceType.Climate;
|
|
80076
|
-
DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
|
|
80077
81085
|
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
80078
81086
|
new Set(Object.values(DeviceType));
|
|
80079
81087
|
/** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
|
|
@@ -80086,6 +81094,13 @@ function contribution(cap, schema, build) {
|
|
|
80086
81094
|
}
|
|
80087
81095
|
};
|
|
80088
81096
|
}
|
|
81097
|
+
/** The fragment, carrying the cap's single measurement when it has one. */
|
|
81098
|
+
function measured(fragment, measurement) {
|
|
81099
|
+
return measurement === void 0 ? fragment : {
|
|
81100
|
+
...fragment,
|
|
81101
|
+
measurement
|
|
81102
|
+
};
|
|
81103
|
+
}
|
|
80089
81104
|
function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
|
|
80090
81105
|
return {
|
|
80091
81106
|
id,
|
|
@@ -81360,10 +82375,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
|
|
|
81360
82375
|
};
|
|
81361
82376
|
});
|
|
81362
82377
|
var CONTROL_LABEL = t("Value", "Valore");
|
|
81363
|
-
/**
|
|
82378
|
+
/**
|
|
82379
|
+
* A number with known bounds is a slider, one without a number field, a choice a picker,
|
|
82380
|
+
* free text a text field; a date stays read-only.
|
|
82381
|
+
*/
|
|
81364
82382
|
function controlRows(slice) {
|
|
81365
82383
|
if (slice.kind === "numeric" && typeof slice.value === "number") {
|
|
81366
|
-
if (slice.min === void 0 || slice.max === void 0) return [
|
|
82384
|
+
if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
|
|
82385
|
+
kind: "number",
|
|
82386
|
+
id: "control.value",
|
|
82387
|
+
label: CONTROL_LABEL,
|
|
82388
|
+
value: slice.value,
|
|
82389
|
+
step: slice.step ?? null,
|
|
82390
|
+
unit: "",
|
|
82391
|
+
call: {
|
|
82392
|
+
cap: "control",
|
|
82393
|
+
method: "setValue",
|
|
82394
|
+
args: { control: { kind: "numeric" } }
|
|
82395
|
+
},
|
|
82396
|
+
valueArg: "control.value"
|
|
82397
|
+
}])];
|
|
81367
82398
|
return [row$1("control", "sliders-horizontal", null, [{
|
|
81368
82399
|
kind: "slider",
|
|
81369
82400
|
id: "control.value",
|
|
@@ -81394,6 +82425,18 @@ function controlRows(slice) {
|
|
|
81394
82425
|
},
|
|
81395
82426
|
valueArg: "control.value"
|
|
81396
82427
|
}])];
|
|
82428
|
+
if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
|
|
82429
|
+
kind: "text",
|
|
82430
|
+
id: "control.value",
|
|
82431
|
+
label: CONTROL_LABEL,
|
|
82432
|
+
value: typeof slice.value === "string" ? slice.value : null,
|
|
82433
|
+
call: {
|
|
82434
|
+
cap: "control",
|
|
82435
|
+
method: "setValue",
|
|
82436
|
+
args: { control: { kind: "text" } }
|
|
82437
|
+
},
|
|
82438
|
+
valueArg: "control.value"
|
|
82439
|
+
}])];
|
|
81397
82440
|
return [];
|
|
81398
82441
|
}
|
|
81399
82442
|
var SENSORS_FAMILY_CONTRIBUTIONS = {
|
|
@@ -81749,15 +82792,15 @@ function sensorFragment(value, id, icon, en, it, text) {
|
|
|
81749
82792
|
tiles: { right: [tile$1(en, it, text)] }
|
|
81750
82793
|
};
|
|
81751
82794
|
}
|
|
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)}%`));
|
|
82795
|
+
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)));
|
|
82796
|
+
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
82797
|
var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
|
|
81755
82798
|
var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
|
|
81756
82799
|
var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
|
|
81757
82800
|
var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
|
|
81758
82801
|
if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
|
|
81759
82802
|
if (slice.timestamp === true) return { reading: reading("sensor", "on") };
|
|
81760
|
-
return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
|
|
82803
|
+
return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
|
|
81761
82804
|
});
|
|
81762
82805
|
/** Index bands: the headline of an air-quality sensor is a word, not a number. */
|
|
81763
82806
|
function airQualityWord(aqi) {
|
|
@@ -82726,7 +83769,7 @@ lookOf({
|
|
|
82726
83769
|
});
|
|
82727
83770
|
DeviceType.Climate;
|
|
82728
83771
|
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;
|
|
82729
|
-
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;
|
|
83772
|
+
DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
|
|
82730
83773
|
Object.freeze({
|
|
82731
83774
|
"accessories.getStatus": {
|
|
82732
83775
|
capName: "accessories",
|
|
@@ -84653,6 +85696,13 @@ Object.freeze({
|
|
|
84653
85696
|
access: "view",
|
|
84654
85697
|
role: "admin"
|
|
84655
85698
|
},
|
|
85699
|
+
"deviceExport.setExposedName": {
|
|
85700
|
+
capName: "device-export",
|
|
85701
|
+
capScope: "system",
|
|
85702
|
+
addonId: null,
|
|
85703
|
+
access: "create",
|
|
85704
|
+
role: "admin"
|
|
85705
|
+
},
|
|
84656
85706
|
"deviceExport.unexposeDevice": {
|
|
84657
85707
|
capName: "device-export",
|
|
84658
85708
|
capScope: "system",
|
|
@@ -86592,6 +87642,13 @@ Object.freeze({
|
|
|
86592
87642
|
access: "view",
|
|
86593
87643
|
role: "viewer"
|
|
86594
87644
|
},
|
|
87645
|
+
"irTransmitter.learn": {
|
|
87646
|
+
capName: "ir-transmitter",
|
|
87647
|
+
capScope: "device",
|
|
87648
|
+
addonId: null,
|
|
87649
|
+
access: "create",
|
|
87650
|
+
role: "viewer"
|
|
87651
|
+
},
|
|
86595
87652
|
"irTransmitter.send": {
|
|
86596
87653
|
capName: "ir-transmitter",
|
|
86597
87654
|
capScope: "device",
|
|
@@ -93110,48 +94167,6 @@ Object.freeze({
|
|
|
93110
94167
|
role: "admin"
|
|
93111
94168
|
}
|
|
93112
94169
|
});
|
|
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
94170
|
DeviceFeature.BatteryOperated;
|
|
93156
94171
|
function bound(cap, methods = [], authority = "reported") {
|
|
93157
94172
|
return {
|
|
@@ -94468,6 +95483,11 @@ Object.freeze({
|
|
|
94468
95483
|
form: "single",
|
|
94469
95484
|
optional: false
|
|
94470
95485
|
}],
|
|
95486
|
+
"irTransmitter.learn": [{
|
|
95487
|
+
name: "deviceId",
|
|
95488
|
+
form: "single",
|
|
95489
|
+
optional: false
|
|
95490
|
+
}],
|
|
94471
95491
|
"irTransmitter.send": [{
|
|
94472
95492
|
name: "deviceId",
|
|
94473
95493
|
form: "single",
|
|
@@ -96407,7 +97427,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
|
|
|
96407
97427
|
"deviceTypes",
|
|
96408
97428
|
"nodeIds",
|
|
96409
97429
|
"packageNames",
|
|
96410
|
-
"consumableLowPercent"
|
|
97430
|
+
"consumableLowPercent",
|
|
97431
|
+
"commandActions",
|
|
97432
|
+
"commandOutcomes",
|
|
97433
|
+
"commandActorKinds"
|
|
96411
97434
|
];
|
|
96412
97435
|
new Map(Object.entries({
|
|
96413
97436
|
"device-online": "device-events",
|
|
@@ -96430,6 +97453,7 @@ new Map(Object.entries({
|
|
|
96430
97453
|
"recording-degraded": "device-events",
|
|
96431
97454
|
"device-attention-required": "device-events",
|
|
96432
97455
|
"device-attention-resolved": "device-events",
|
|
97456
|
+
"device-command": "device-events",
|
|
96433
97457
|
"node-online": "system",
|
|
96434
97458
|
"node-offline": "system",
|
|
96435
97459
|
"node-restarting": "system",
|
|
@@ -96530,6 +97554,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
|
|
|
96530
97554
|
label: "Needs attention",
|
|
96531
97555
|
kinds: ["device-attention-required", "device-attention-resolved"]
|
|
96532
97556
|
},
|
|
97557
|
+
{
|
|
97558
|
+
id: "device-command",
|
|
97559
|
+
family: "device-events",
|
|
97560
|
+
label: "Commands given to devices",
|
|
97561
|
+
kinds: ["device-command"]
|
|
97562
|
+
},
|
|
96533
97563
|
{
|
|
96534
97564
|
id: "nodes",
|
|
96535
97565
|
family: "system",
|
|
@@ -96607,6 +97637,15 @@ function systemEventKindsOfFamily(family) {
|
|
|
96607
97637
|
return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
|
|
96608
97638
|
}
|
|
96609
97639
|
NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
|
|
97640
|
+
new Set([
|
|
97641
|
+
"alarm.trigger",
|
|
97642
|
+
"alarm.disarm",
|
|
97643
|
+
"alarm.arm.home",
|
|
97644
|
+
"alarm.arm.away",
|
|
97645
|
+
"alarm.arm.night",
|
|
97646
|
+
"alarm.arm.vacation",
|
|
97647
|
+
"alarm.arm.custom_bypass"
|
|
97648
|
+
]);
|
|
96610
97649
|
/**
|
|
96611
97650
|
* WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
|
|
96612
97651
|
* persists (D640 "a sensor rule fires on the raise, the clear, or both").
|
|
@@ -96802,6 +97841,7 @@ var DEVICE_EVENTS = [
|
|
|
96802
97841
|
"recording-healthy",
|
|
96803
97842
|
"recording-degraded",
|
|
96804
97843
|
...DEVICE_ATTENTION,
|
|
97844
|
+
"device-command",
|
|
96805
97845
|
...ALARM
|
|
96806
97846
|
];
|
|
96807
97847
|
/** Every kind a summary may speak about — the two summarisable families. */
|
|
@@ -96955,6 +97995,9 @@ var STATE_SUMMARY_VARS = [
|
|
|
96955
97995
|
[...RULE_BODY_ONLY],
|
|
96956
97996
|
[...RULE_TEXT],
|
|
96957
97997
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
97998
|
+
[...RULE_TEXT],
|
|
97999
|
+
[...RULE_TEXT],
|
|
98000
|
+
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
96958
98001
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96959
98002
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96960
98003
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
@@ -145082,6 +146125,160 @@ function carryForward(base, existing, keys) {
|
|
|
145082
146125
|
}
|
|
145083
146126
|
return out;
|
|
145084
146127
|
}
|
|
146128
|
+
/**
|
|
146129
|
+
* hap-nodejs' `checkName` regex, verbatim.
|
|
146130
|
+
*
|
|
146131
|
+
* Duplicated rather than imported because it is `@private Private API` in that
|
|
146132
|
+
* package and not exported. Duplicating a private regex is a liability, so the
|
|
146133
|
+
* guard against drift is behavioural, not textual: `service-naming.spec.ts`
|
|
146134
|
+
* builds real services and asserts hap-nodejs emits ZERO characteristic
|
|
146135
|
+
* warnings — if this expression ever diverges from theirs, that test fails.
|
|
146136
|
+
*/
|
|
146137
|
+
var HAP_NAME_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N}\p{Zs}’'&!._:;()/,-]*[\p{L}\p{N}]$/u;
|
|
146138
|
+
/** Characters HAP tolerates INSIDE a name. Anything else becomes a space. */
|
|
146139
|
+
var HAP_NAME_INNER = /[^\p{L}\p{N}\p{Zs}’'&!._:;()/,-]/gu;
|
|
146140
|
+
/** Would hap-nodejs accept this as a `Name` characteristic value? */
|
|
146141
|
+
function isHapServiceName(value) {
|
|
146142
|
+
return HAP_NAME_PATTERN.test(value);
|
|
146143
|
+
}
|
|
146144
|
+
/**
|
|
146145
|
+
* Build one HAP-valid service name from device-derived parts.
|
|
146146
|
+
*
|
|
146147
|
+
* Empty and absent parts are dropped rather than joined, so a missing role
|
|
146148
|
+
* never produces a double space. `fallback` is used ONLY when nothing
|
|
146149
|
+
* device-derived survives sanitisation — it is the last resort, not the
|
|
146150
|
+
* default, because a name that says nothing about the device is the defect
|
|
146151
|
+
* this module exists to end.
|
|
146152
|
+
*/
|
|
146153
|
+
function hapServiceName(parts, fallback) {
|
|
146154
|
+
const trimmed = trimToHapName(parts.map((part) => typeof part === "string" ? part : "").map((part) => part.replace(HAP_NAME_INNER, " ")).join(" ").replace(/\s+/gu, " ").trim());
|
|
146155
|
+
if (trimmed !== null) return trimmed;
|
|
146156
|
+
return trimToHapName(fallback.replace(HAP_NAME_INNER, " ").replace(/\s+/gu, " ").trim()) ?? "";
|
|
146157
|
+
}
|
|
146158
|
+
/**
|
|
146159
|
+
* The privacy-mask switch.
|
|
146160
|
+
*
|
|
146161
|
+
* Just "Privacy". The camera name is NOT prefixed: this service lives inside
|
|
146162
|
+
* the camera's own accessory, iOS already renders it under the camera, and a
|
|
146163
|
+
* round that prefixed it gave the operator "Camera front door Privacy"
|
|
146164
|
+
* sitting inside a tile titled "Camera front door".
|
|
146165
|
+
*
|
|
146166
|
+
* The prefix was added for a real reason — two cameras publishing a switch
|
|
146167
|
+
* called "Privacy" — but that was a symptom of the label being the ONLY thing
|
|
146168
|
+
* shown, which stopped being true once `ConfiguredName` made the service
|
|
146169
|
+
* render in its accessory's context. Uniqueness is required WITHIN one
|
|
146170
|
+
* accessory, not across the bridge, and one camera has one privacy switch.
|
|
146171
|
+
*/
|
|
146172
|
+
function privacyServiceName() {
|
|
146173
|
+
return hapServiceName([PRIVACY_SUFFIX], PRIVACY_SUFFIX);
|
|
146174
|
+
}
|
|
146175
|
+
/**
|
|
146176
|
+
* Deliberately not localised, and deliberately not a translation table.
|
|
146177
|
+
*
|
|
146178
|
+
* The device half of the name is the operator's own text and arrives in the
|
|
146179
|
+
* operator's language. This half names a camstack capability (`privacy-mask`)
|
|
146180
|
+
* and there is no locale in an addon's context to resolve it against; the word
|
|
146181
|
+
* is also identical in the operator's language. A translation layer for one
|
|
146182
|
+
* word would be the kind of leftover that reads as verification.
|
|
146183
|
+
*/
|
|
146184
|
+
var PRIVACY_SUFFIX = "Privacy";
|
|
146185
|
+
/**
|
|
146186
|
+
* An accessory child (siren, floodlight, spotlight) rendered as a service on
|
|
146187
|
+
* the parent camera.
|
|
146188
|
+
*
|
|
146189
|
+
* The child's OWN stored name wins. It is the string the operator typed, in
|
|
146190
|
+
* the operator's language, and an early rule threw it away: `role` was
|
|
146191
|
+
* consulted first and title-cased, so every siren on the fleet published as
|
|
146192
|
+
* the English word "Siren" no matter what the operator had called it.
|
|
146193
|
+
*
|
|
146194
|
+
* Providers name children both ways — "Sirena" and "Camera kitchen
|
|
146195
|
+
* Sirena". The parent half is now REMOVED rather than added, because the
|
|
146196
|
+
* service is published inside the parent camera's own accessory and iOS
|
|
146197
|
+
* already shows it there. The result must be one form, not two.
|
|
146198
|
+
*/
|
|
146199
|
+
function childServiceName(parentName, child) {
|
|
146200
|
+
const own = withoutParent(child.name.trim(), parentName);
|
|
146201
|
+
if (own.length > 0) return hapServiceName([own], own);
|
|
146202
|
+
return hapServiceName([typeof child.role === "string" ? titleCase(child.role) : ""], CHILD_FALLBACK);
|
|
146203
|
+
}
|
|
146204
|
+
/**
|
|
146205
|
+
* Last resort for a child that carries neither a name nor a role. Better than
|
|
146206
|
+
* the parent's name, which would publish a service indistinguishable from the
|
|
146207
|
+
* accessory holding it — the exact defect this module keeps being asked to fix.
|
|
146208
|
+
*
|
|
146209
|
+
* English, like the role slugs it stands in for ("Floodlight", "Siren"): the
|
|
146210
|
+
* only strings this module invents are English, and inventing one Italian word
|
|
146211
|
+
* would be a localisation layer that localises nothing.
|
|
146212
|
+
*/
|
|
146213
|
+
var CHILD_FALLBACK = "Accessory";
|
|
146214
|
+
/**
|
|
146215
|
+
* A PTZ action switch: the bare action, "Preset front door" / "Pan Left" /
|
|
146216
|
+
* "Autotrack".
|
|
146217
|
+
*
|
|
146218
|
+
* The labels themselves stay in `ptz-labels.ts` — they name a HomeKit control,
|
|
146219
|
+
* not a device. This function exists only to put the operator-typed half of a
|
|
146220
|
+
* preset name through the same sanitisation everything else gets; it no longer
|
|
146221
|
+
* qualifies the label with the camera, because all eight PTZ services live on
|
|
146222
|
+
* that camera's accessory and are unique among themselves.
|
|
146223
|
+
*/
|
|
146224
|
+
function ptzServiceName(actionLabel) {
|
|
146225
|
+
return hapServiceName([actionLabel], actionLabel);
|
|
146226
|
+
}
|
|
146227
|
+
/**
|
|
146228
|
+
* Drop `parentName` from the front of `name`.
|
|
146229
|
+
*
|
|
146230
|
+
* A PREFIX only. "Camera kitchen Sirena" → "Sirena"; "Sirena" is already
|
|
146231
|
+
* bare and untouched. A parent name appearing anywhere else in the child's
|
|
146232
|
+
* name is left alone — cutting from the middle of a string the operator typed
|
|
146233
|
+
* would mangle it, and this function must never make a label WORSE.
|
|
146234
|
+
*
|
|
146235
|
+
* Returns `name` unchanged when stripping would leave nothing: a child the
|
|
146236
|
+
* operator called exactly what the camera is called still needs a label.
|
|
146237
|
+
*/
|
|
146238
|
+
function withoutParent(name, parentName) {
|
|
146239
|
+
const needle = parentName.trim();
|
|
146240
|
+
if (needle.length === 0) return name;
|
|
146241
|
+
if (!name.toLowerCase().startsWith(needle.toLowerCase())) return name;
|
|
146242
|
+
const rest = name.slice(needle.length).trim();
|
|
146243
|
+
return rest.length > 0 ? rest : name;
|
|
146244
|
+
}
|
|
146245
|
+
/**
|
|
146246
|
+
* Truncate to the HAP ceiling and shave any leading/trailing character the
|
|
146247
|
+
* pattern forbids. Returns `null` when nothing usable is left — the caller
|
|
146248
|
+
* decides what to do with that, because "fall back" and "drop the part" are
|
|
146249
|
+
* different answers.
|
|
146250
|
+
*/
|
|
146251
|
+
function trimToHapName(value) {
|
|
146252
|
+
let out = value.length > 64 ? value.slice(0, 64) : value;
|
|
146253
|
+
while (out.length > 0 && !isAlphanumeric(out[out.length - 1])) out = out.slice(0, -1);
|
|
146254
|
+
while (out.length > 0 && !isAlphanumeric(out[0])) out = out.slice(1);
|
|
146255
|
+
return isHapServiceName(out) ? out : null;
|
|
146256
|
+
}
|
|
146257
|
+
function isAlphanumeric(ch) {
|
|
146258
|
+
return ch !== void 0 && /[\p{L}\p{N}]/u.test(ch);
|
|
146259
|
+
}
|
|
146260
|
+
function titleCase(raw) {
|
|
146261
|
+
return raw.split(/[-_\s]+/u).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
146262
|
+
}
|
|
146263
|
+
//#endregion
|
|
146264
|
+
//#region src/exposed-name.ts
|
|
146265
|
+
/** Apple's rule: at most 64 characters, begins and ends with a letter or digit, HAP punctuation only. */
|
|
146266
|
+
/** HomeKit's rule, as the derived "Name on <bridge>" field states it (D1049). */
|
|
146267
|
+
var HAP_NAME_RULE = `HomeKit takes up to 64 characters, starting and ending with a letter or digit; inside, only letters, digits, spaces and ' & ! . _ : ; ( ) / , -.`;
|
|
146268
|
+
var hapNameValidator = (name) => {
|
|
146269
|
+
if (name.length > 64) return {
|
|
146270
|
+
ok: false,
|
|
146271
|
+
reason: `The HomeKit name is ${name.length} characters; HomeKit allows at most 64.`
|
|
146272
|
+
};
|
|
146273
|
+
if (!isHapServiceName(name)) return {
|
|
146274
|
+
ok: false,
|
|
146275
|
+
reason: "The HomeKit name must begin and end with a letter or digit and may contain only letters, digits, spaces and ' & ! . _ : ; ( ) / , -"
|
|
146276
|
+
};
|
|
146277
|
+
return {
|
|
146278
|
+
ok: true,
|
|
146279
|
+
name
|
|
146280
|
+
};
|
|
146281
|
+
};
|
|
145085
146282
|
//#endregion
|
|
145086
146283
|
//#region src/hap-export-records.ts
|
|
145087
146284
|
/**
|
|
@@ -147602,141 +148799,6 @@ function reader(schema, toUpdates) {
|
|
|
147602
148799
|
function applyUpdates(service, updates) {
|
|
147603
148800
|
for (const update of updates) service.updateCharacteristic(update.characteristic, update.value);
|
|
147604
148801
|
}
|
|
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
148802
|
//#endregion
|
|
147741
148803
|
//#region src/mappers/builders/service-label.ts
|
|
147742
148804
|
/**
|
|
@@ -147915,7 +148977,8 @@ function errMsg$14(err) {
|
|
|
147915
148977
|
* hands this builder the PARENT accessory + the CHILD's proxy + a
|
|
147916
148978
|
* unique subtype so each service round-trips deterministically through
|
|
147917
148979
|
* HAP serialisation. The builder:
|
|
147918
|
-
* - Maps `switch` cap → `Service.Switch
|
|
148980
|
+
* - Maps `switch` cap → `Service.Switch`, or the service the device's switch
|
|
148981
|
+
* sub-role names (`onOffServiceKind`).
|
|
147919
148982
|
* - Maps `switch` + `brightness` cap → `Service.Lightbulb` with
|
|
147920
148983
|
* Brightness characteristic (lighting devices only — see below).
|
|
147921
148984
|
* - Hydrates initial state from `getStatus({})`.
|
|
@@ -147937,7 +149000,21 @@ function errMsg$14(err) {
|
|
|
147937
149000
|
* Child devices without `switch` / `brightness` cap (status sensors,
|
|
147938
149001
|
* IR LED, etc.) return a no-op handle.
|
|
147939
149002
|
*/
|
|
147940
|
-
|
|
149003
|
+
function onOffServiceKind(deviceType, role, hasBrightness) {
|
|
149004
|
+
const isLightingDevice = deviceType === DeviceType.Light || deviceType === DeviceType.Generic;
|
|
149005
|
+
if (hasBrightness && isLightingDevice) return "dimmable-lightbulb";
|
|
149006
|
+
if (isSwitchLight(deviceType, role)) return "lightbulb";
|
|
149007
|
+
if (isOutlet(deviceType, role)) return "outlet";
|
|
149008
|
+
if (isSwitchFan(deviceType, role)) return "fan";
|
|
149009
|
+
return "switch";
|
|
149010
|
+
}
|
|
149011
|
+
function addOnOffService(accessory, kind, displayName, subtype) {
|
|
149012
|
+
if (kind === "dimmable-lightbulb" || kind === "lightbulb") return accessory.addService(import_dist.Service.Lightbulb, displayName, subtype);
|
|
149013
|
+
if (kind === "outlet") return accessory.addService(import_dist.Service.Outlet, displayName, subtype);
|
|
149014
|
+
if (kind === "fan") return accessory.addService(import_dist.Service.Fan, displayName, subtype);
|
|
149015
|
+
return accessory.addService(import_dist.Service.Switch, displayName, subtype);
|
|
149016
|
+
}
|
|
149017
|
+
async function buildChildSwitch(bctx, subtype, deviceType, role = null) {
|
|
147941
149018
|
const { ctx, accessory, proxy, numericDeviceId, displayName } = bctx;
|
|
147942
149019
|
const log = ctx.logger.withTags({ deviceId: numericDeviceId });
|
|
147943
149020
|
const hasSwitch = !!proxy.switch;
|
|
@@ -147946,17 +149023,21 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
147946
149023
|
log.debug("export-hap: child has no switch/brightness cap — skipping");
|
|
147947
149024
|
return { async dispose() {} };
|
|
147948
149025
|
}
|
|
147949
|
-
const
|
|
147950
|
-
const
|
|
147951
|
-
const service =
|
|
149026
|
+
const kind = onOffServiceKind(deviceType, role, hasBrightness);
|
|
149027
|
+
const dimmable = kind === "dimmable-lightbulb";
|
|
149028
|
+
const service = addOnOffService(accessory, kind, displayName, subtype);
|
|
147952
149029
|
applyServiceLabel(service, displayName);
|
|
149030
|
+
const setOn = (on) => {
|
|
149031
|
+
service.updateCharacteristic(import_dist.Characteristic.On, on);
|
|
149032
|
+
if (kind === "outlet") service.updateCharacteristic(import_dist.Characteristic.OutletInUse, on);
|
|
149033
|
+
};
|
|
147953
149034
|
try {
|
|
147954
149035
|
const switchStatus = await proxy.switch?.getStatus({});
|
|
147955
|
-
if (switchStatus && typeof switchStatus.on === "boolean")
|
|
149036
|
+
if (switchStatus && typeof switchStatus.on === "boolean") setOn(switchStatus.on);
|
|
147956
149037
|
} catch (err) {
|
|
147957
149038
|
log.debug("export-hap: child switch.getStatus failed (non-fatal)", { meta: { error: errMsg$13(err) } });
|
|
147958
149039
|
}
|
|
147959
|
-
if (
|
|
149040
|
+
if (dimmable) try {
|
|
147960
149041
|
const status = await proxy.brightness?.getStatus({});
|
|
147961
149042
|
if (status && typeof status.level === "number") service.updateCharacteristic(import_dist.Characteristic.Brightness, status.level);
|
|
147962
149043
|
} catch (err) {
|
|
@@ -147973,7 +149054,7 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
147973
149054
|
} });
|
|
147974
149055
|
}
|
|
147975
149056
|
});
|
|
147976
|
-
if (
|
|
149057
|
+
if (dimmable) service.getCharacteristic(import_dist.Characteristic.Brightness).onSet(async (value) => {
|
|
147977
149058
|
const percentage = typeof value === "number" ? value : Number(value);
|
|
147978
149059
|
if (!Number.isFinite(percentage)) return;
|
|
147979
149060
|
try {
|
|
@@ -147988,11 +149069,11 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
147988
149069
|
const unsubscribes = [];
|
|
147989
149070
|
if (proxy.state.switch) {
|
|
147990
149071
|
const unsubSwitch = proxy.state.switch.subscribe((value) => {
|
|
147991
|
-
if (value && typeof value.on === "boolean")
|
|
149072
|
+
if (value && typeof value.on === "boolean") setOn(value.on);
|
|
147992
149073
|
});
|
|
147993
149074
|
unsubscribes.push(unsubSwitch);
|
|
147994
149075
|
}
|
|
147995
|
-
if (
|
|
149076
|
+
if (dimmable && proxy.state.brightness) {
|
|
147996
149077
|
const unsubBrightness = proxy.state.brightness.subscribe((value) => {
|
|
147997
149078
|
if (value && typeof value.level === "number") service.updateCharacteristic(import_dist.Characteristic.Brightness, value.level);
|
|
147998
149079
|
});
|
|
@@ -148600,10 +149681,10 @@ var HAP_CAP_SERVICES = [
|
|
|
148600
149681
|
{
|
|
148601
149682
|
caps: ["switch", "brightness"],
|
|
148602
149683
|
label: "Power",
|
|
148603
|
-
build: ({ bctx, name, deviceType }) => buildChildSwitch({
|
|
149684
|
+
build: ({ bctx, name, deviceType, role }) => buildChildSwitch({
|
|
148604
149685
|
...bctx,
|
|
148605
149686
|
displayName: name
|
|
148606
|
-
}, "switch", deviceType)
|
|
149687
|
+
}, "switch", deviceType, role)
|
|
148607
149688
|
},
|
|
148608
149689
|
{
|
|
148609
149690
|
caps: ["lock-control"],
|
|
@@ -148661,7 +149742,17 @@ var ACCESSORY_CATEGORY_BY_TYPE = {
|
|
|
148661
149742
|
[DeviceType.Presence]: import_dist.Categories.SENSOR,
|
|
148662
149743
|
[DeviceType.AlarmPanel]: import_dist.Categories.SECURITY_SYSTEM
|
|
148663
149744
|
};
|
|
148664
|
-
|
|
149745
|
+
/**
|
|
149746
|
+
* The category, by type and then by the switch's sub-role (read only through
|
|
149747
|
+
* the `@camstack/types` accessors). A heater keeps a Switch service (see
|
|
149748
|
+
* `onOffServiceKind`) and takes HomeKit's heater category, which is an icon
|
|
149749
|
+
* and promises no characteristic. A helper boolean stays a SWITCH.
|
|
149750
|
+
*/
|
|
149751
|
+
function accessoryCategoryFor(deviceType, role) {
|
|
149752
|
+
if (isSwitchLight(deviceType, role)) return import_dist.Categories.LIGHTBULB;
|
|
149753
|
+
if (isOutlet(deviceType, role)) return import_dist.Categories.OUTLET;
|
|
149754
|
+
if (isSwitchFan(deviceType, role)) return import_dist.Categories.FAN;
|
|
149755
|
+
if (isSwitchHeater(deviceType, role)) return import_dist.Categories.AIR_HEATER;
|
|
148665
149756
|
return ACCESSORY_CATEGORY_BY_TYPE[deviceType] ?? import_dist.Categories.OTHER;
|
|
148666
149757
|
}
|
|
148667
149758
|
//#endregion
|
|
@@ -163648,7 +164739,7 @@ async function buildChildServicesFor(input) {
|
|
|
163648
164739
|
options
|
|
163649
164740
|
};
|
|
163650
164741
|
const subtype = `child-${child.id}`;
|
|
163651
|
-
handles.push(await buildChildSwitch(childCtx, subtype, asDeviceType(child.type)));
|
|
164742
|
+
handles.push(await buildChildSwitch(childCtx, subtype, asDeviceType(child.type), child.role ?? null));
|
|
163652
164743
|
}
|
|
163653
164744
|
return { async dispose() {
|
|
163654
164745
|
for (const h of handles) try {
|
|
@@ -164626,9 +165717,9 @@ async function buildGenericAccessory(input) {
|
|
|
164626
165717
|
const capNames = new Set(proxy.binding?.entries.map((e) => e.capName) ?? []);
|
|
164627
165718
|
const rows = rowsForCaps(capNames);
|
|
164628
165719
|
if (rows.length === 0) throw new Error(`export-hap: device ${numericId} carries no capability HomeKit can export (bound: ${[...capNames].toSorted().join(", ") || "none"})`);
|
|
164629
|
-
const deviceType = await
|
|
165720
|
+
const { type: deviceType, role } = await resolveDeviceKind(proxy);
|
|
164630
165721
|
const accessory = new import_dist.Accessory(displayName, accessoryUuidFor("generic", numericId, options.instanceId));
|
|
164631
|
-
accessory.category = accessoryCategoryFor(deviceType);
|
|
165722
|
+
accessory.category = accessoryCategoryFor(deviceType, role);
|
|
164632
165723
|
await populateAccessoryInfo(accessory, proxy, displayName, "Accessory");
|
|
164633
165724
|
const bctx = {
|
|
164634
165725
|
ctx,
|
|
@@ -164644,11 +165735,13 @@ async function buildGenericAccessory(input) {
|
|
|
164644
165735
|
handles.push(await row.build({
|
|
164645
165736
|
bctx,
|
|
164646
165737
|
name,
|
|
164647
|
-
deviceType
|
|
165738
|
+
deviceType,
|
|
165739
|
+
role
|
|
164648
165740
|
}));
|
|
164649
165741
|
}
|
|
164650
165742
|
log.info("export-hap: built generic accessory", { meta: {
|
|
164651
165743
|
deviceType,
|
|
165744
|
+
role,
|
|
164652
165745
|
services: rows.map((row) => row.caps[0]).join(",")
|
|
164653
165746
|
} });
|
|
164654
165747
|
return {
|
|
@@ -164664,20 +165757,27 @@ async function buildGenericAccessory(input) {
|
|
|
164664
165757
|
};
|
|
164665
165758
|
}
|
|
164666
165759
|
/**
|
|
164667
|
-
* The device's own type, or `Generic
|
|
165760
|
+
* The device's own type, or `Generic`, and its role (null when unread).
|
|
164668
165761
|
*
|
|
164669
165762
|
* Used ONLY where one capability has two HomeKit shapes — a siren's
|
|
164670
|
-
* `brightness` is alarm volume, not luminosity
|
|
165763
|
+
* `brightness` is alarm volume, not luminosity; a `switch-light` relay is a
|
|
165764
|
+
* Lightbulb, not a Switch — and for the accessory's icon.
|
|
164671
165765
|
* `Generic` is the safe reading: it is the shape `child-switch.ts` already
|
|
164672
165766
|
* treats as "a lamp if it dims, a switch otherwise".
|
|
164673
165767
|
*/
|
|
164674
|
-
async function
|
|
165768
|
+
async function resolveDeviceKind(proxy) {
|
|
164675
165769
|
try {
|
|
164676
165770
|
const device = await proxy.deviceManager?.getDevice({});
|
|
164677
165771
|
const raw = typeof device?.type === "string" ? device.type.toLowerCase() : "";
|
|
164678
|
-
return
|
|
165772
|
+
return {
|
|
165773
|
+
type: Object.values(DeviceType).find((value) => value === raw) ?? DeviceType.Generic,
|
|
165774
|
+
role: typeof device?.role === "string" ? device.role : null
|
|
165775
|
+
};
|
|
164679
165776
|
} catch {
|
|
164680
|
-
return
|
|
165777
|
+
return {
|
|
165778
|
+
type: DeviceType.Generic,
|
|
165779
|
+
role: null
|
|
165780
|
+
};
|
|
164681
165781
|
}
|
|
164682
165782
|
}
|
|
164683
165783
|
function errMsg$1(err) {
|
|
@@ -165201,8 +166301,19 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165201
166301
|
for (const uuid of uuids) clearPairingFiles(uuid, this.ctx.logger);
|
|
165202
166302
|
await this.exposureHandle().delete(id);
|
|
165203
166303
|
if (id === "export-hap") await this.exportSyncState.set({});
|
|
166304
|
+
await this.pruneBridgeNames(id);
|
|
165204
166305
|
this.ctx.logger.info("export-hap: bridge removed", { meta: { instanceId: id } });
|
|
165205
166306
|
}
|
|
166307
|
+
/** A removed bridge's device names go too, so a bridge that reuses the id inherits none (D1049). */
|
|
166308
|
+
async pruneBridgeNames(id) {
|
|
166309
|
+
const settings = this.ctx.settings;
|
|
166310
|
+
if (settings === void 0) return;
|
|
166311
|
+
const pruned = await pruneExposedNames(settings, id);
|
|
166312
|
+
if (pruned.length > 0) this.ctx.logger.info("export-hap: removed bridge names deleted", { meta: {
|
|
166313
|
+
instanceId: id,
|
|
166314
|
+
devices: pruned.length
|
|
166315
|
+
} });
|
|
166316
|
+
}
|
|
165206
166317
|
/**
|
|
165207
166318
|
* "Regenerate" (operator decision): a new setup code, every pairing of this bridge cleared and
|
|
165208
166319
|
* the bridge republished. Every controller has to pair again; the instance and its exposed
|
|
@@ -165298,21 +166409,33 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165298
166409
|
instanceId: row.id,
|
|
165299
166410
|
name: row.body.name,
|
|
165300
166411
|
enabled: row.enabled,
|
|
165301
|
-
kind: "hap-bridge"
|
|
166412
|
+
kind: "hap-bridge",
|
|
166413
|
+
nameRule: HAP_NAME_RULE
|
|
165302
166414
|
})),
|
|
165303
166415
|
listSupportedDeviceKinds: async ({ instanceId }) => {
|
|
165304
166416
|
this.bridgesOf(instanceId);
|
|
165305
166417
|
return [...HAP_EXPORTABLE_DEVICE_TYPES];
|
|
165306
166418
|
},
|
|
165307
|
-
listExposedDevices: async ({ instanceId }) =>
|
|
165308
|
-
const
|
|
165309
|
-
|
|
165310
|
-
deviceId
|
|
165311
|
-
|
|
165312
|
-
|
|
165313
|
-
|
|
165314
|
-
|
|
165315
|
-
|
|
166419
|
+
listExposedDevices: async ({ instanceId }) => {
|
|
166420
|
+
const out = [];
|
|
166421
|
+
for (const inst of this.bridgesOf(instanceId)) for (const [deviceId, m] of inst.exposed.entries()) {
|
|
166422
|
+
const entry = inst.exposure.devices.find((e) => e.deviceId === deviceId);
|
|
166423
|
+
const exposedName = await this.exposedNameOf(inst.id, deviceId);
|
|
166424
|
+
out.push({
|
|
166425
|
+
deviceId,
|
|
166426
|
+
exposedAs: m.accessory.displayName,
|
|
166427
|
+
...exposedName !== null ? { exposedName } : {},
|
|
166428
|
+
...entry?.capabilities ? { capabilities: [...entry.capabilities] } : {}
|
|
166429
|
+
});
|
|
166430
|
+
}
|
|
166431
|
+
return out;
|
|
166432
|
+
},
|
|
166433
|
+
exposeDevice: async ({ instanceId, deviceId, capabilities, exposedName }) => {
|
|
166434
|
+
const inst = this.requireBridge(instanceId);
|
|
166435
|
+
if (exposedName !== void 0) await this.saveExposedName(inst, deviceId, exposedName);
|
|
166436
|
+
return this.exposeDevice(inst, deviceId, capabilities);
|
|
166437
|
+
},
|
|
166438
|
+
setExposedName: async ({ instanceId, deviceId, name, dryRun }) => this.setExposedName(this.requireBridge(instanceId), deviceId, name, dryRun === true),
|
|
165316
166439
|
unexposeDevice: async ({ instanceId, deviceId }) => this.unexposeDevice(this.requireBridge(instanceId), deviceId),
|
|
165317
166440
|
listSupportedEntityKinds: async () => ["device", "action"],
|
|
165318
166441
|
listExposedEntities: async ({ instanceId }) => {
|
|
@@ -165455,7 +166578,7 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165455
166578
|
const summary = await this.fetchDeviceSummary(numericId);
|
|
165456
166579
|
const mapperKind = pickMapperKind(summary?.type);
|
|
165457
166580
|
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}`;
|
|
166581
|
+
const displayName = await this.exposedNameOf(inst.id, deviceId) ?? summary?.name ?? `Device ${deviceId}`;
|
|
165459
166582
|
const previous = inst.exposure.devices.find((e) => e.deviceId === deviceId);
|
|
165460
166583
|
const rebuilt = {
|
|
165461
166584
|
deviceId,
|
|
@@ -165487,6 +166610,54 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165487
166610
|
childCount: attached.childAccessoryUuids.length
|
|
165488
166611
|
} });
|
|
165489
166612
|
}
|
|
166613
|
+
nameStore() {
|
|
166614
|
+
return exposedNameStoreOf(this.ctx.settings, "export-hap");
|
|
166615
|
+
}
|
|
166616
|
+
async exposedNameOf(instanceId, deviceId) {
|
|
166617
|
+
const numericId = Number.parseInt(deviceId, 10);
|
|
166618
|
+
if (!Number.isFinite(numericId)) return null;
|
|
166619
|
+
try {
|
|
166620
|
+
return readExposedName(await this.nameStore().read(numericId), instanceId, hapNameValidator);
|
|
166621
|
+
} catch (err) {
|
|
166622
|
+
this.ctx.logger.warn("export-hap: HomeKit name unreadable", {
|
|
166623
|
+
tags: { deviceId: numericId },
|
|
166624
|
+
meta: {
|
|
166625
|
+
instanceId,
|
|
166626
|
+
error: err instanceof Error ? err.message : String(err)
|
|
166627
|
+
}
|
|
166628
|
+
});
|
|
166629
|
+
return null;
|
|
166630
|
+
}
|
|
166631
|
+
}
|
|
166632
|
+
/** Validate and store the HomeKit name; a refusal throws before anything is written. */
|
|
166633
|
+
async saveExposedName(inst, deviceIdStr, raw, dryRun = false) {
|
|
166634
|
+
const deviceId = Number.parseInt(deviceIdStr, 10);
|
|
166635
|
+
if (!Number.isFinite(deviceId)) throw new Error(`export-hap: invalid device id '${deviceIdStr}'`);
|
|
166636
|
+
const saved = await saveExposedName({
|
|
166637
|
+
store: this.nameStore(),
|
|
166638
|
+
deviceId,
|
|
166639
|
+
instanceId: inst.id,
|
|
166640
|
+
raw,
|
|
166641
|
+
validate: hapNameValidator,
|
|
166642
|
+
...dryRun ? { dryRun: true } : {}
|
|
166643
|
+
});
|
|
166644
|
+
if (saved.changed) this.ctx.logger.info("export-hap: HomeKit name saved", {
|
|
166645
|
+
tags: { deviceId },
|
|
166646
|
+
meta: {
|
|
166647
|
+
instanceId: inst.id,
|
|
166648
|
+
name: saved.name
|
|
166649
|
+
}
|
|
166650
|
+
});
|
|
166651
|
+
return saved.changed;
|
|
166652
|
+
}
|
|
166653
|
+
/**
|
|
166654
|
+
* Rename on HomeKit (D1049). An exposed device is re-exposed in place — the same accessory
|
|
166655
|
+
* UUID, the pairing untouched (no unexpose, which would wipe it) — so Home shows the new name
|
|
166656
|
+
* on the same tile. A dry run only validates.
|
|
166657
|
+
*/
|
|
166658
|
+
async setExposedName(inst, deviceIdStr, raw, dryRun = false) {
|
|
166659
|
+
if (await this.saveExposedName(inst, deviceIdStr, raw, dryRun) && inst.exposed.has(deviceIdStr)) await this.exposeDevice(inst, deviceIdStr);
|
|
166660
|
+
}
|
|
165490
166661
|
async unexposeDevice(inst, deviceId, options = {}) {
|
|
165491
166662
|
const numericId = Number.parseInt(deviceId, 10);
|
|
165492
166663
|
const log = this.ctx.logger.withTags({ deviceId: numericId });
|