@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
|
@@ -39,7 +39,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
39
39
|
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
40
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
41
41
|
//#endregion
|
|
42
|
-
//#region ../types/dist/event-category-
|
|
42
|
+
//#region ../types/dist/event-category-Dv-Gcv1f.mjs
|
|
43
43
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
44
44
|
EventCategory["SystemBoot"] = "system.boot";
|
|
45
45
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -480,6 +480,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
480
480
|
*/
|
|
481
481
|
EventCategory["DeviceStateChanged"] = "device.state-changed";
|
|
482
482
|
/**
|
|
483
|
+
* A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
|
|
484
|
+
* transition audit (D1022): confirmed, already in place, unconfirmed or
|
|
485
|
+
* failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
|
|
486
|
+
* (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
|
|
487
|
+
* the Notification Center `device-command` kind. Telemetry (D8): losing one
|
|
488
|
+
* costs a notification, never state; the audit row is the record.
|
|
489
|
+
*/
|
|
490
|
+
EventCategory["DeviceCommandSettled"] = "device.command-settled";
|
|
491
|
+
/**
|
|
483
492
|
* The NATIVE shadow of a cap a composition has claimed fields of moved
|
|
484
493
|
* (D663). Payload: `{ deviceId, capName, native }` — what the provider
|
|
485
494
|
* wrote, BEFORE the owned fields are overlaid. Owner-only (D224): it is for
|
|
@@ -842,7 +851,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
842
851
|
return EventCategory;
|
|
843
852
|
}({});
|
|
844
853
|
//#endregion
|
|
845
|
-
//#region ../types/dist/composed-stable-id-
|
|
854
|
+
//#region ../types/dist/composed-stable-id-iddnCQ51.mjs
|
|
846
855
|
/**
|
|
847
856
|
import { errMsg } from '@camstack/types'
|
|
848
857
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -1184,6 +1193,11 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1184
1193
|
* with the switch's on/off only. Speed or oscillation appear only when the
|
|
1185
1194
|
* device also has a fan cap (D1033). */
|
|
1186
1195
|
DeviceRole["SwitchFan"] = "switch-fan";
|
|
1196
|
+
/** A relay driving an on/off-only lamp: drawn as a light (bulb and glow, no
|
|
1197
|
+
* slider), presented to the exports as a light with power only. Not a
|
|
1198
|
+
* `light` type: the provider owns the type, and a light implies brightness
|
|
1199
|
+
* or colour this relay lacks. */
|
|
1200
|
+
DeviceRole["SwitchLight"] = "switch-light";
|
|
1187
1201
|
/** Air conditioner / split unit: cooling, fan speed, louvres. */
|
|
1188
1202
|
DeviceRole["ClimateAc"] = "climate-ac";
|
|
1189
1203
|
/** Room thermostat: a setpoint and a room temperature. The default. */
|
|
@@ -6084,7 +6098,7 @@ var ZodIssueCode = {
|
|
|
6084
6098
|
var ZodFirstPartyTypeKind;
|
|
6085
6099
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6086
6100
|
//#endregion
|
|
6087
|
-
//#region ../types/dist/sleep-
|
|
6101
|
+
//#region ../types/dist/sleep-BvVGLl30.mjs
|
|
6088
6102
|
/**
|
|
6089
6103
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6090
6104
|
* window to float samples (D455).
|
|
@@ -6767,6 +6781,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6767
6781
|
else skipped.push(id);
|
|
6768
6782
|
};
|
|
6769
6783
|
const selected = options.only === void 0 ? null : new Set(options.only);
|
|
6784
|
+
const deferred = /* @__PURE__ */ new Set();
|
|
6785
|
+
const deferredBy = (reason) => {
|
|
6786
|
+
if (selected === null || reason === null) return null;
|
|
6787
|
+
const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
|
|
6788
|
+
if (dep === void 0 || !byId.has(dep)) return null;
|
|
6789
|
+
return !selected.has(dep) || deferred.has(dep) ? dep : null;
|
|
6790
|
+
};
|
|
6770
6791
|
for (const step of declaration.steps) {
|
|
6771
6792
|
if (selected !== null && !selected.has(step.id)) continue;
|
|
6772
6793
|
const bound = byId.get(step.id);
|
|
@@ -6778,6 +6799,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6778
6799
|
try {
|
|
6779
6800
|
const gate = await host.startMigration({ id: step.id });
|
|
6780
6801
|
if (!gate.proceed) {
|
|
6802
|
+
const waitsFor = deferredBy(gate.reason);
|
|
6803
|
+
if (waitsFor !== null) {
|
|
6804
|
+
log.info("migration deferred: its predecessor runs in another phase of this owner", {
|
|
6805
|
+
tags,
|
|
6806
|
+
meta: {
|
|
6807
|
+
waitsFor,
|
|
6808
|
+
reason: gate.reason
|
|
6809
|
+
}
|
|
6810
|
+
});
|
|
6811
|
+
deferred.add(step.id);
|
|
6812
|
+
skipped.push(step.id);
|
|
6813
|
+
continue;
|
|
6814
|
+
}
|
|
6781
6815
|
log.warn("migration not run", {
|
|
6782
6816
|
tags,
|
|
6783
6817
|
meta: {
|
|
@@ -10227,6 +10261,13 @@ var DeviceTransitionSchema = object({
|
|
|
10227
10261
|
actor: TransitionActorSchema,
|
|
10228
10262
|
command: TransitionCommandSchema.optional()
|
|
10229
10263
|
});
|
|
10264
|
+
object({
|
|
10265
|
+
deviceId: number$1().int(),
|
|
10266
|
+
action: string(),
|
|
10267
|
+
outcome: TransitionOutcomeSchema,
|
|
10268
|
+
actor: TransitionActorSchema,
|
|
10269
|
+
at: number$1()
|
|
10270
|
+
});
|
|
10230
10271
|
var READING_QUANTITIES = [
|
|
10231
10272
|
"temperature",
|
|
10232
10273
|
"pressure",
|
|
@@ -10770,6 +10811,13 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
10770
10811
|
},
|
|
10771
10812
|
state: { on: { icon: "lightbulb" } }
|
|
10772
10813
|
},
|
|
10814
|
+
[DeviceRole.SwitchLight]: {
|
|
10815
|
+
actions: {
|
|
10816
|
+
"switch.on": { icon: "lightbulb" },
|
|
10817
|
+
"switch.off": { icon: "lightbulb-off" }
|
|
10818
|
+
},
|
|
10819
|
+
state: { on: { icon: "lightbulb" } }
|
|
10820
|
+
},
|
|
10773
10821
|
[DeviceRole.Chime]: { actions: {
|
|
10774
10822
|
"switch.on": {
|
|
10775
10823
|
label: t("Enable chime", "Attiva il campanello"),
|
|
@@ -12250,7 +12298,10 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
12250
12298
|
"ir-transmitter": {
|
|
12251
12299
|
scope: "device",
|
|
12252
12300
|
noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
|
|
12253
|
-
notOperatorFacing: {
|
|
12301
|
+
notOperatorFacing: {
|
|
12302
|
+
send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
|
|
12303
|
+
learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
|
|
12304
|
+
}
|
|
12254
12305
|
},
|
|
12255
12306
|
control: {
|
|
12256
12307
|
scope: "device",
|
|
@@ -15171,6 +15222,32 @@ var CAP_VOCABULARY_BY_NAME = {
|
|
|
15171
15222
|
...SYSTEM_CAP_VOCABULARY
|
|
15172
15223
|
};
|
|
15173
15224
|
/**
|
|
15225
|
+
* Vocabulary actions by id (D983). An action step names a vocabulary action
|
|
15226
|
+
* (`cover.open`), never a raw cap method; this is the one lookup that turns the
|
|
15227
|
+
* id into its cap, method and effect — and a persisted legacy `cap` + `method`
|
|
15228
|
+
* pair back into the action id when exactly one action matches.
|
|
15229
|
+
*/
|
|
15230
|
+
function buildIndex() {
|
|
15231
|
+
const byId = /* @__PURE__ */ new Map();
|
|
15232
|
+
for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
|
|
15233
|
+
if (entry.scope !== "device") continue;
|
|
15234
|
+
for (const action of entry.actions ?? []) byId.set(action.id, {
|
|
15235
|
+
cap,
|
|
15236
|
+
action
|
|
15237
|
+
});
|
|
15238
|
+
}
|
|
15239
|
+
return byId;
|
|
15240
|
+
}
|
|
15241
|
+
var index;
|
|
15242
|
+
function actionIndex() {
|
|
15243
|
+
index ??= buildIndex();
|
|
15244
|
+
return index;
|
|
15245
|
+
}
|
|
15246
|
+
/** The vocabulary action with this id, or `undefined`. */
|
|
15247
|
+
function findVocabAction(actionId) {
|
|
15248
|
+
return actionIndex().get(actionId);
|
|
15249
|
+
}
|
|
15250
|
+
/**
|
|
15174
15251
|
* `addon-pages-source` — collection cap exposing per-provider raw page
|
|
15175
15252
|
* declarations. Every addon that contributes a UI page registers a
|
|
15176
15253
|
* provider here. The hub-side singleton aggregator (`addon-pages` cap,
|
|
@@ -16253,6 +16330,10 @@ Object.freeze({
|
|
|
16253
16330
|
"path": "lastEvent.eventType",
|
|
16254
16331
|
"valueType": "string"
|
|
16255
16332
|
},
|
|
16333
|
+
{
|
|
16334
|
+
"path": "lastEvent.sourceId",
|
|
16335
|
+
"valueType": "string"
|
|
16336
|
+
},
|
|
16256
16337
|
{
|
|
16257
16338
|
"path": "lastEvent.timestamp",
|
|
16258
16339
|
"valueType": "number"
|
|
@@ -17516,7 +17597,7 @@ Object.freeze({
|
|
|
17516
17597
|
}
|
|
17517
17598
|
});
|
|
17518
17599
|
//#endregion
|
|
17519
|
-
//#region ../types/dist/implemented-methods-
|
|
17600
|
+
//#region ../types/dist/implemented-methods-CSTk6zYK.mjs
|
|
17520
17601
|
var AUDIO_ENCODER_BY_CODEC = {
|
|
17521
17602
|
opus: "libopus",
|
|
17522
17603
|
aac: "aac",
|
|
@@ -18166,6 +18247,60 @@ function portable(target) {
|
|
|
18166
18247
|
}
|
|
18167
18248
|
portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac64"), `${BASE}${FFMPEG_RELEASE}`;
|
|
18168
18249
|
/**
|
|
18250
|
+
* A device's KIND is its type plus its role (D1033): the type is the set of
|
|
18251
|
+
* controls it has, the role says which thing it is among the devices that
|
|
18252
|
+
* share those controls. A plug-in heater is a `switch` with role
|
|
18253
|
+
* `switch-heater`; an air conditioner and a radiator valve are both `climate`,
|
|
18254
|
+
* told apart by their `climate-*` role.
|
|
18255
|
+
*/
|
|
18256
|
+
/**
|
|
18257
|
+
* Type values a persisted row may still carry after the type was retired, and
|
|
18258
|
+
* the type each one is read as. The row is rewritten by the next registration
|
|
18259
|
+
* of the device (its provider stamps the live type), so this is a read alias,
|
|
18260
|
+
* not a migration.
|
|
18261
|
+
*
|
|
18262
|
+
* `heater` is deliberately absent: the only heaters were composed devices the
|
|
18263
|
+
* operator deletes. Such a row stays an unknown type, which every reader
|
|
18264
|
+
* treats as a generic device.
|
|
18265
|
+
*/
|
|
18266
|
+
var RETIRED_DEVICE_TYPES = { thermostat: DeviceType.Climate };
|
|
18267
|
+
/** The live type a stored `type` value stands for (itself unless retired). */
|
|
18268
|
+
function canonicalStoredDeviceType(stored) {
|
|
18269
|
+
return RETIRED_DEVICE_TYPES[stored] ?? stored;
|
|
18270
|
+
}
|
|
18271
|
+
preprocess((value) => typeof value === "string" ? canonicalStoredDeviceType(value) : value, _enum(DeviceType));
|
|
18272
|
+
DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
|
|
18273
|
+
/**
|
|
18274
|
+
* A relay driving an on/off-only lamp (a `switch` with role `switch-light`):
|
|
18275
|
+
* drawn and exported as a light, with the switch's power only. The one place
|
|
18276
|
+
* that reads the role for it — a consumer asks this, never the role string.
|
|
18277
|
+
*/
|
|
18278
|
+
function isSwitchLight(type, role) {
|
|
18279
|
+
return type === DeviceType.Switch && role === DeviceRole.SwitchLight;
|
|
18280
|
+
}
|
|
18281
|
+
/**
|
|
18282
|
+
* A smart plug (a `switch` with role `outlet`, D875): exported as a plug /
|
|
18283
|
+
* outlet. Exports ask this, never the role string.
|
|
18284
|
+
*/
|
|
18285
|
+
function isOutlet(type, role) {
|
|
18286
|
+
return type === DeviceType.Switch && role === DeviceRole.Outlet;
|
|
18287
|
+
}
|
|
18288
|
+
/**
|
|
18289
|
+
* A plain fan behind a switch (a `switch` with role `switch-fan`): exported as
|
|
18290
|
+
* a fan with the switch's on/off only — no speed it does not have.
|
|
18291
|
+
*/
|
|
18292
|
+
function isSwitchFan(type, role) {
|
|
18293
|
+
return type === DeviceType.Switch && role === DeviceRole.SwitchFan;
|
|
18294
|
+
}
|
|
18295
|
+
/**
|
|
18296
|
+
* A plug-in heater behind a switch (a `switch` with role `switch-heater`): it
|
|
18297
|
+
* has power only, no setpoint and no room temperature, so an export never
|
|
18298
|
+
* presents it as a thermostat.
|
|
18299
|
+
*/
|
|
18300
|
+
function isSwitchHeater(type, role) {
|
|
18301
|
+
return type === DeviceType.Switch && role === DeviceRole.SwitchHeater;
|
|
18302
|
+
}
|
|
18303
|
+
/**
|
|
18169
18304
|
* THE table "which boolean of this device type counts as HIGH", and the
|
|
18170
18305
|
* pure evaluator of its EDGE.
|
|
18171
18306
|
*
|
|
@@ -24093,7 +24228,7 @@ var DeviceTokenScopeSchema = object({
|
|
|
24093
24228
|
function migrateLegacyTokenScope(raw) {
|
|
24094
24229
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
24095
24230
|
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
24096
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
24231
|
+
if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
|
|
24097
24232
|
const targets = Reflect.get(raw, "targets");
|
|
24098
24233
|
if (!Array.isArray(targets)) return raw;
|
|
24099
24234
|
return {
|
|
@@ -24105,6 +24240,27 @@ function migrateLegacyTokenScope(raw) {
|
|
|
24105
24240
|
access: Reflect.get(raw, "access")
|
|
24106
24241
|
};
|
|
24107
24242
|
}
|
|
24243
|
+
/**
|
|
24244
|
+
* A stored `types` selector may name a type D1033 retired (`thermostat`). The
|
|
24245
|
+
* grant is read back through this same preprocess, so the retired name is
|
|
24246
|
+
* rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
|
|
24247
|
+
* stays a strict enum on the wire.
|
|
24248
|
+
*/
|
|
24249
|
+
function canonicalSelectorTypes(raw) {
|
|
24250
|
+
const selector = Reflect.get(raw, "selector");
|
|
24251
|
+
if (selector === null || typeof selector !== "object") return raw;
|
|
24252
|
+
if (Reflect.get(selector, "kind") !== "types") return raw;
|
|
24253
|
+
const types = Reflect.get(selector, "types");
|
|
24254
|
+
if (!Array.isArray(types)) return raw;
|
|
24255
|
+
const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
|
|
24256
|
+
return {
|
|
24257
|
+
...raw,
|
|
24258
|
+
selector: {
|
|
24259
|
+
...selector,
|
|
24260
|
+
types: canonical
|
|
24261
|
+
}
|
|
24262
|
+
};
|
|
24263
|
+
}
|
|
24108
24264
|
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
24109
24265
|
object({
|
|
24110
24266
|
type: literal("category"),
|
|
@@ -44661,6 +44817,41 @@ function macroOnly(macro) {
|
|
|
44661
44817
|
};
|
|
44662
44818
|
}
|
|
44663
44819
|
}
|
|
44820
|
+
var EventVocabularyKindSchema = _enum([
|
|
44821
|
+
"press",
|
|
44822
|
+
"long-press",
|
|
44823
|
+
"long-press-start",
|
|
44824
|
+
"release",
|
|
44825
|
+
"repeat",
|
|
44826
|
+
"double-press",
|
|
44827
|
+
"other"
|
|
44828
|
+
]);
|
|
44829
|
+
/** The part of the device an event comes from: a button, a channel. */
|
|
44830
|
+
var EventVocabularySourceSchema = object({
|
|
44831
|
+
id: string().min(1),
|
|
44832
|
+
label: string().min(1)
|
|
44833
|
+
});
|
|
44834
|
+
/** One scalar field of an event's `data`, by dotted path. */
|
|
44835
|
+
var EventVocabularyFieldSchema = object({
|
|
44836
|
+
path: string().min(1),
|
|
44837
|
+
kind: _enum([
|
|
44838
|
+
"string",
|
|
44839
|
+
"number",
|
|
44840
|
+
"boolean",
|
|
44841
|
+
"enum"
|
|
44842
|
+
]),
|
|
44843
|
+
enumValues: array(string()).optional(),
|
|
44844
|
+
label: string().min(1).optional()
|
|
44845
|
+
});
|
|
44846
|
+
var EventVocabularyEntrySchema = object({
|
|
44847
|
+
/** The native token, verbatim. */
|
|
44848
|
+
id: string().min(1),
|
|
44849
|
+
source: EventVocabularySourceSchema.optional(),
|
|
44850
|
+
label: string().min(1),
|
|
44851
|
+
description: string().optional(),
|
|
44852
|
+
kind: EventVocabularyKindSchema.optional(),
|
|
44853
|
+
payload: array(EventVocabularyFieldSchema).optional()
|
|
44854
|
+
});
|
|
44664
44855
|
Math.PI / 180;
|
|
44665
44856
|
/**
|
|
44666
44857
|
* WHEN something happens, as data (D983) — the one time vocabulary of the
|
|
@@ -44868,6 +45059,33 @@ var ScheduleLeafSchema = object({
|
|
|
44868
45059
|
/** @deprecated legacy cron — new schedules use `at`. */
|
|
44869
45060
|
cron: string().min(1).max(120).optional()
|
|
44870
45061
|
}).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" });
|
|
45062
|
+
/**
|
|
45063
|
+
* One payload predicate of a `device-fired` row: the value at `path` inside
|
|
45064
|
+
* the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
|
|
45065
|
+
*/
|
|
45066
|
+
var DeviceFiredMatchSchema = object({
|
|
45067
|
+
path: string().min(1).max(120),
|
|
45068
|
+
equals: union([
|
|
45069
|
+
string(),
|
|
45070
|
+
number$1(),
|
|
45071
|
+
boolean()
|
|
45072
|
+
])
|
|
45073
|
+
});
|
|
45074
|
+
/**
|
|
45075
|
+
* "fires": one device of the `event-emitter` capability reported an event
|
|
45076
|
+
* (D1045). Every list is an OR, the lists together an AND; an absent list does
|
|
45077
|
+
* not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
|
|
45078
|
+
* the device (a button), `kinds` the shared press kinds of its vocabulary.
|
|
45079
|
+
*/
|
|
45080
|
+
var DeviceFiredLeafSchema = object({
|
|
45081
|
+
kind: literal("device-fired"),
|
|
45082
|
+
...eventLeafId,
|
|
45083
|
+
deviceId: number$1().int().nonnegative(),
|
|
45084
|
+
eventIds: array(string().min(1)).min(1).max(64).optional(),
|
|
45085
|
+
sourceIds: array(string().min(1)).min(1).max(64).optional(),
|
|
45086
|
+
kinds: array(EventVocabularyKindSchema).min(1).optional(),
|
|
45087
|
+
match: array(DeviceFiredMatchSchema).min(1).max(8).optional()
|
|
45088
|
+
});
|
|
44871
45089
|
var ManualLeafSchema = object({
|
|
44872
45090
|
kind: literal("manual"),
|
|
44873
45091
|
...eventLeafId
|
|
@@ -45009,6 +45227,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
45009
45227
|
}),
|
|
45010
45228
|
DeviceBecomesLeafSchema,
|
|
45011
45229
|
DeviceEventLeafSchema,
|
|
45230
|
+
DeviceFiredLeafSchema,
|
|
45012
45231
|
ScheduleLeafSchema,
|
|
45013
45232
|
ManualLeafSchema,
|
|
45014
45233
|
IntervalLeafSchema,
|
|
@@ -45023,6 +45242,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
45023
45242
|
var EVENT_KINDS = new Set([
|
|
45024
45243
|
"device-becomes",
|
|
45025
45244
|
"device-event",
|
|
45245
|
+
"device-fired",
|
|
45026
45246
|
"schedule",
|
|
45027
45247
|
"manual",
|
|
45028
45248
|
"interval",
|
|
@@ -45103,6 +45323,7 @@ function hasEmptyContainer(node) {
|
|
|
45103
45323
|
var LEAF_WORDS = {
|
|
45104
45324
|
"device-becomes": "a device value that becomes",
|
|
45105
45325
|
"device-event": "a device event",
|
|
45326
|
+
"device-fired": "a device firing an event",
|
|
45106
45327
|
schedule: "a schedule",
|
|
45107
45328
|
manual: "a manual run",
|
|
45108
45329
|
interval: "an interval",
|
|
@@ -45352,59 +45573,47 @@ function convertLegacyWhen(half) {
|
|
|
45352
45573
|
* (instants) and state leaves (durations). It replaces the flat trigger list
|
|
45353
45574
|
* plus the separate condition tree; the firing rule is in that file and in
|
|
45354
45575
|
* ADR "one tree".
|
|
45355
|
-
* - **Actions** — the `wait` and `
|
|
45576
|
+
* - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
|
|
45356
45577
|
* fragment of §3.2.2. See {@link AutomationActionSchema}.
|
|
45357
45578
|
*
|
|
45358
45579
|
* A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
|
|
45359
45580
|
* {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
|
|
45360
45581
|
*/
|
|
45361
45582
|
/**
|
|
45362
|
-
* One action step: `wait`, or a `
|
|
45583
|
+
* One action step: `wait`, or a device `command`.
|
|
45363
45584
|
*
|
|
45364
|
-
* A
|
|
45365
|
-
* `{ $var }` resolved from the run's
|
|
45366
|
-
*
|
|
45367
|
-
*
|
|
45368
|
-
*
|
|
45369
|
-
*
|
|
45585
|
+
* A command step names a VOCABULARY action (`cover.open`) and who it acts on
|
|
45586
|
+
* (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
|
|
45587
|
+
* variables). It never names a cap method: the step runner turns the action
|
|
45588
|
+
* id into its cap + method through the vocabulary index when the step runs
|
|
45589
|
+
* (`vocabCall`), the one place that mapping happens. The step runner
|
|
45590
|
+
* (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
|
|
45591
|
+
* variable substitution, once, for every caller — automations, Actions, and
|
|
45592
|
+
* the notification centre, which runs only Actions (planning#473).
|
|
45370
45593
|
*/
|
|
45594
|
+
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
45595
|
+
var WAIT_MAX_SECONDS = 3600;
|
|
45596
|
+
var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
|
|
45371
45597
|
var AutomationWaitStepSchema = object({
|
|
45372
45598
|
kind: literal("wait"),
|
|
45373
|
-
seconds: number$1().min(0).max(
|
|
45599
|
+
seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
45374
45600
|
});
|
|
45375
|
-
/** The legacy `deviceId` of a cap step: still READ, never written (D983). */
|
|
45376
|
-
var LegacyStepDeviceSchema = union([
|
|
45377
|
-
number$1().int(),
|
|
45378
|
-
array(number$1().int()).min(1),
|
|
45379
|
-
object({ $var: string().min(1) })
|
|
45380
|
-
]);
|
|
45381
45601
|
/**
|
|
45382
|
-
* The fields of a
|
|
45383
|
-
*
|
|
45384
|
-
* device); a step is {@link AutomationCapStepSchema}.
|
|
45602
|
+
* The fields of a command step, before the vocabulary check. A step is
|
|
45603
|
+
* {@link AutomationCommandStepSchema}.
|
|
45385
45604
|
*/
|
|
45386
|
-
var
|
|
45387
|
-
kind: literal("
|
|
45388
|
-
/**
|
|
45389
|
-
|
|
45390
|
-
|
|
45391
|
-
|
|
45392
|
-
* cap + method match exactly one vocabulary action.
|
|
45393
|
-
*/
|
|
45394
|
-
actionId: string().min(1).optional(),
|
|
45395
|
-
/** WHO the step acts on. The only shape that is written. */
|
|
45396
|
-
target: ActionTargetSchema.optional(),
|
|
45605
|
+
var AutomationCommandStepBaseSchema = object({
|
|
45606
|
+
kind: literal("command"),
|
|
45607
|
+
/** WHO the step acts on. */
|
|
45608
|
+
target: ActionTargetSchema,
|
|
45609
|
+
/** The vocabulary action this step performs (`cover.open`). */
|
|
45610
|
+
actionId: string().min(1),
|
|
45397
45611
|
/**
|
|
45398
|
-
*
|
|
45399
|
-
*
|
|
45400
|
-
*
|
|
45612
|
+
* The values of the action's OPEN args (`position`, `presetId`); the args
|
|
45613
|
+
* the vocabulary bakes into the action are added when the step runs. Values
|
|
45614
|
+
* may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
45615
|
+
* SUBSTITUTE and do not evaluate (§3.2.3).
|
|
45401
45616
|
*/
|
|
45402
|
-
deviceId: LegacyStepDeviceSchema.optional(),
|
|
45403
|
-
cap: string().min(1),
|
|
45404
|
-
method: string().min(1),
|
|
45405
|
-
/** Values may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
45406
|
-
* SUBSTITUTE and do not evaluate (§3.2.3). Anything beyond substitution is
|
|
45407
|
-
* the expression leaf. */
|
|
45408
45617
|
args: record(string(), unknown()).optional(),
|
|
45409
45618
|
/**
|
|
45410
45619
|
* The unit the person picked per arg (display only). `args` always hold the
|
|
@@ -45413,18 +45622,20 @@ var AutomationCapStepBaseSchema = object({
|
|
|
45413
45622
|
*/
|
|
45414
45623
|
argUnits: record(string(), string().min(1)).optional()
|
|
45415
45624
|
});
|
|
45625
|
+
/** The vocabulary check every command step passes: the action exists. */
|
|
45626
|
+
function refineKnownAction(step, ctx) {
|
|
45627
|
+
if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
|
|
45628
|
+
code: "custom",
|
|
45629
|
+
message: `"${step.actionId}" is not a vocabulary action id`,
|
|
45630
|
+
path: ["actionId"]
|
|
45631
|
+
});
|
|
45632
|
+
}
|
|
45416
45633
|
/**
|
|
45417
|
-
* The steps an internal Action may contain:
|
|
45634
|
+
* The steps an internal Action may contain: command and wait, and nothing that can
|
|
45418
45635
|
* call back into an Action — so an Action can never reach itself (no cycles).
|
|
45419
45636
|
* This is the LEAF shape: no condition of its own.
|
|
45420
45637
|
*/
|
|
45421
|
-
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema,
|
|
45422
|
-
message: "a cap step needs a target",
|
|
45423
|
-
path: ["target"]
|
|
45424
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
45425
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
45426
|
-
path: ["actionId"]
|
|
45427
|
-
})]);
|
|
45638
|
+
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
|
|
45428
45639
|
/**
|
|
45429
45640
|
* The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
|
|
45430
45641
|
* on the state mirror when the step is reached; `else` runs when it is false.
|
|
@@ -45440,39 +45651,209 @@ var elseNeedsIf = {
|
|
|
45440
45651
|
path: ["else"]
|
|
45441
45652
|
};
|
|
45442
45653
|
var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45443
|
-
var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
|
|
45444
|
-
message: "a cap step needs a target",
|
|
45445
|
-
path: ["target"]
|
|
45446
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
45447
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
45448
|
-
path: ["actionId"]
|
|
45449
|
-
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45450
45654
|
/**
|
|
45451
45655
|
* A step of a STANDALONE list (an action, a scheduler point, a preset): the
|
|
45452
45656
|
* same two step kinds an automation runs, minus a guard that reads the
|
|
45453
45657
|
* automation's trigger, which such a list does not have.
|
|
45454
45658
|
*/
|
|
45455
|
-
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema,
|
|
45659
|
+
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCommandStepBaseSchema.extend(stepGuardShape).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
|
|
45456
45660
|
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
45457
45661
|
code: "custom",
|
|
45458
45662
|
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
45459
45663
|
path: ["if"]
|
|
45460
45664
|
});
|
|
45461
45665
|
});
|
|
45666
|
+
/**
|
|
45667
|
+
* Flow control of an AUTOMATION's list (#500). A standalone list (an action, a
|
|
45668
|
+
* scheduler point, a preset) stays `wait` and `cap`: it has no run of its own
|
|
45669
|
+
* to end and no variable bag to write.
|
|
45670
|
+
*/
|
|
45671
|
+
var continueOnErrorShape = {
|
|
45672
|
+
/** A failure of this step is traced `failed-continued` and the next step runs. */
|
|
45673
|
+
continueOnError: literal(true).optional() };
|
|
45674
|
+
/** An automation's command step: the shared guarded command step, plus `continueOnError`. */
|
|
45675
|
+
var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
|
|
45676
|
+
...stepGuardShape,
|
|
45677
|
+
...continueOnErrorShape
|
|
45678
|
+
}).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45679
|
+
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
45680
|
+
var AutomationStopStepSchema = object({
|
|
45681
|
+
kind: literal("stop"),
|
|
45682
|
+
reason: string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
|
|
45683
|
+
/** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
|
|
45684
|
+
outcome: _enum(["ok", "failed"]),
|
|
45685
|
+
/** Stop only when this reads true; false or unknown does not stop. */
|
|
45686
|
+
if: AutomationWhenSchema.optional()
|
|
45687
|
+
});
|
|
45688
|
+
var SET_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,39}$/;
|
|
45689
|
+
/** Names the run itself writes and reads (`leaf` is what `triggered-by` judges): a step may not overwrite them. */
|
|
45690
|
+
var RESERVED_RUN_VARS = [
|
|
45691
|
+
"kind",
|
|
45692
|
+
"leaf",
|
|
45693
|
+
"at"
|
|
45694
|
+
];
|
|
45695
|
+
/**
|
|
45696
|
+
* Write variables into the run's bag, for the steps after it. SUBSTITUTION
|
|
45697
|
+
* only, never evaluation: a text value may carry `{{vars.x}}` slots.
|
|
45698
|
+
*/
|
|
45699
|
+
var AutomationSetStepSchema = object({
|
|
45700
|
+
kind: literal("set"),
|
|
45701
|
+
vars: record(string(), union([
|
|
45702
|
+
string().max(500),
|
|
45703
|
+
number$1(),
|
|
45704
|
+
boolean()
|
|
45705
|
+
])).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` }),
|
|
45706
|
+
/** Set only when this reads true; false or unknown leaves the bag as it is. */
|
|
45707
|
+
if: AutomationWhenSchema.optional()
|
|
45708
|
+
});
|
|
45709
|
+
var AutomationRunActionStepSchema = object({
|
|
45710
|
+
kind: literal("action"),
|
|
45711
|
+
/** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
|
|
45712
|
+
actionId: string().min(1),
|
|
45713
|
+
/** Values for the action's declared variables; the others take their default. */
|
|
45714
|
+
variables: record(string(), union([
|
|
45715
|
+
string(),
|
|
45716
|
+
number$1(),
|
|
45717
|
+
boolean()
|
|
45718
|
+
])).optional(),
|
|
45719
|
+
...continueOnErrorShape
|
|
45720
|
+
});
|
|
45721
|
+
/**
|
|
45722
|
+
* A step INSIDE a branch of a `choose`: a flow step with no condition of its
|
|
45723
|
+
* own (the branch is the condition) and no block inside it. Strict, so an `if`
|
|
45724
|
+
* written on such a step is refused rather than dropped.
|
|
45725
|
+
*/
|
|
45726
|
+
/** The longest a `wait-until` may wait: six hours. */
|
|
45727
|
+
var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
|
|
45728
|
+
/**
|
|
45729
|
+
* Pause the run until a condition is true (#500). The timeout is mandatory: a
|
|
45730
|
+
* run never waits without an end. `onTimeout` says what a wait that ran out
|
|
45731
|
+
* does: `continue` goes on to the next step, `stop` ends the run as a failure.
|
|
45732
|
+
* A condition that cannot be read is not "true": the wait goes on (D49).
|
|
45733
|
+
*/
|
|
45734
|
+
var AutomationWaitUntilStepSchema = object({
|
|
45735
|
+
kind: literal("wait-until"),
|
|
45736
|
+
when: AutomationWhenSchema,
|
|
45737
|
+
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)`),
|
|
45738
|
+
onTimeout: _enum(["continue", "stop"])
|
|
45739
|
+
}).strict();
|
|
45740
|
+
/** The step kinds that hold steps of their own, or pause on a condition: they nest two levels at most. */
|
|
45741
|
+
var BLOCK_STEP_KINDS = [
|
|
45742
|
+
"choose",
|
|
45743
|
+
"repeat",
|
|
45744
|
+
"parallel",
|
|
45745
|
+
"wait-until"
|
|
45746
|
+
];
|
|
45747
|
+
var NEST_TOO_DEEP = `steps nest two levels at most: a step inside a nested choose or repeat can be a plain step only`;
|
|
45748
|
+
function kindOf(input) {
|
|
45749
|
+
return typeof input === "object" && input !== null ? Reflect.get(input, "kind") : void 0;
|
|
45750
|
+
}
|
|
45751
|
+
/** Where the nesting ends, a block step is refused in words rather than as an unknown kind. */
|
|
45752
|
+
function nestTooDeep(issue) {
|
|
45753
|
+
const kind = kindOf(issue.input);
|
|
45754
|
+
return typeof kind === "string" && BLOCK_STEP_KINDS.includes(kind) ? NEST_TOO_DEEP : void 0;
|
|
45755
|
+
}
|
|
45756
|
+
var plainStepSchemas = [
|
|
45757
|
+
AutomationWaitStepSchema.strict(),
|
|
45758
|
+
AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
|
|
45759
|
+
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
45760
|
+
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
45761
|
+
AutomationRunActionStepSchema.strict()
|
|
45762
|
+
];
|
|
45763
|
+
/**
|
|
45764
|
+
* A plain step: a flow step with no condition of its own and no step inside
|
|
45765
|
+
* it. The second (last) level of nesting holds these only.
|
|
45766
|
+
*/
|
|
45767
|
+
var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
|
|
45768
|
+
/** A step that can run beside others: it writes no variable and does not end the run. */
|
|
45769
|
+
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");
|
|
45770
|
+
/**
|
|
45771
|
+
* Several steps at once (#500): all are started together and all are awaited.
|
|
45772
|
+
* A failure fails the run once the others finished, as in a sequence; a member
|
|
45773
|
+
* marked "continue if this fails" does not.
|
|
45774
|
+
*/
|
|
45775
|
+
var AutomationParallelStepSchema = object({
|
|
45776
|
+
kind: literal("parallel"),
|
|
45777
|
+
steps: array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
|
|
45778
|
+
}).strict();
|
|
45779
|
+
var REPEAT_NEEDS_MAX = "a repeat on a condition needs a maximum number of iterations";
|
|
45780
|
+
/** A loop on a condition: the bound is mandatory, so a run never loops without an end. */
|
|
45781
|
+
var repeatConditionShape = {
|
|
45782
|
+
when: AutomationWhenSchema,
|
|
45783
|
+
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`),
|
|
45784
|
+
/** A pause between two iterations, never after the last. */
|
|
45785
|
+
waitS: number$1().int().min(1).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG).optional()
|
|
45786
|
+
};
|
|
45787
|
+
/** What decides how many times a `repeat` runs. */
|
|
45788
|
+
var AutomationRepeatLoopSchema = discriminatedUnion("by", [
|
|
45789
|
+
object({
|
|
45790
|
+
by: literal("count"),
|
|
45791
|
+
count: number$1().int().min(1).max(20, `a repeat runs at most 20 times`)
|
|
45792
|
+
}).strict(),
|
|
45793
|
+
object({
|
|
45794
|
+
by: literal("while"),
|
|
45795
|
+
...repeatConditionShape
|
|
45796
|
+
}).strict(),
|
|
45797
|
+
object({
|
|
45798
|
+
by: literal("until"),
|
|
45799
|
+
...repeatConditionShape
|
|
45800
|
+
}).strict(),
|
|
45801
|
+
object({
|
|
45802
|
+
by: literal("forEach"),
|
|
45803
|
+
target: object({
|
|
45804
|
+
kind: literal("devices"),
|
|
45805
|
+
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`)
|
|
45806
|
+
}).strict()
|
|
45807
|
+
}).strict()
|
|
45808
|
+
]);
|
|
45809
|
+
/**
|
|
45810
|
+
* The same steps several times (#500). Every form is bounded at save, so a
|
|
45811
|
+
* run cannot loop without an end. A failure or a `stop` in the steps ends the
|
|
45812
|
+
* loop and the run, as in a sequence.
|
|
45813
|
+
*/
|
|
45814
|
+
function repeatSchemaOf(step) {
|
|
45815
|
+
return object({
|
|
45816
|
+
kind: literal("repeat"),
|
|
45817
|
+
loop: AutomationRepeatLoopSchema,
|
|
45818
|
+
steps: array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
|
|
45819
|
+
}).strict();
|
|
45820
|
+
}
|
|
45821
|
+
/**
|
|
45822
|
+
* One step, several ways (#500): the branches are read in order and the FIRST
|
|
45823
|
+
* whose condition is true runs; `else` runs when every branch is false. A
|
|
45824
|
+
* branch that cannot be read ends the choice: nothing runs, not the branches
|
|
45825
|
+
* after it and not the else (D49). The #472 `if` / `else` of a wait or cap
|
|
45826
|
+
* step is the one-branch case and stays as it is stored.
|
|
45827
|
+
*/
|
|
45828
|
+
function chooseSchemaOf(step) {
|
|
45829
|
+
const steps = array(step).max(10);
|
|
45830
|
+
return object({
|
|
45831
|
+
kind: literal("choose"),
|
|
45832
|
+
branches: array(object({
|
|
45833
|
+
if: AutomationWhenSchema,
|
|
45834
|
+
steps: steps.min(1, "a branch needs at least one step")
|
|
45835
|
+
})).min(1, "a choose needs at least one branch").max(6, `a choose takes at most 6 branches`),
|
|
45836
|
+
else: steps.optional()
|
|
45837
|
+
});
|
|
45838
|
+
}
|
|
45839
|
+
var AutomationBodyStepSchema = discriminatedUnion("kind", [
|
|
45840
|
+
...plainStepSchemas,
|
|
45841
|
+
AutomationWaitUntilStepSchema,
|
|
45842
|
+
AutomationParallelStepSchema,
|
|
45843
|
+
chooseSchemaOf(AutomationBranchStepSchema),
|
|
45844
|
+
repeatSchemaOf(AutomationBranchStepSchema)
|
|
45845
|
+
]);
|
|
45846
|
+
var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
|
|
45462
45847
|
var AutomationActionSchema = discriminatedUnion("kind", [
|
|
45463
45848
|
GuardedWaitStepSchema,
|
|
45464
|
-
|
|
45465
|
-
|
|
45466
|
-
|
|
45467
|
-
|
|
45468
|
-
|
|
45469
|
-
|
|
45470
|
-
|
|
45471
|
-
|
|
45472
|
-
number$1(),
|
|
45473
|
-
boolean()
|
|
45474
|
-
])).optional()
|
|
45475
|
-
}),
|
|
45849
|
+
AutomationGuardedCommandStepSchema,
|
|
45850
|
+
AutomationStopStepSchema,
|
|
45851
|
+
AutomationSetStepSchema,
|
|
45852
|
+
chooseSchemaOf(AutomationBodyStepSchema),
|
|
45853
|
+
AutomationWaitUntilStepSchema,
|
|
45854
|
+
AutomationParallelStepSchema,
|
|
45855
|
+
AutomationRepeatStepSchema,
|
|
45856
|
+
AutomationRunActionStepSchema,
|
|
45476
45857
|
object({
|
|
45477
45858
|
kind: literal("code"),
|
|
45478
45859
|
/** Compiled into the automation's OWN block by esbuild — not a third
|
|
@@ -45535,44 +45916,7 @@ function convertLegacyRecipe(legacy) {
|
|
|
45535
45916
|
...rest
|
|
45536
45917
|
};
|
|
45537
45918
|
}
|
|
45538
|
-
/**
|
|
45539
|
-
* Where recipes are PARSED (the core-blocks cap, the MCP tool, the literal a
|
|
45540
|
-
* saved block carries): the new shape as it is, or the old shape converted to
|
|
45541
|
-
* it. The output type is always the new one.
|
|
45542
|
-
*/
|
|
45543
45919
|
var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
|
|
45544
|
-
var DETECTION_DESCRIPTIONS = {
|
|
45545
|
-
deviceId: "the camera that saw it",
|
|
45546
|
-
className: "what it saw",
|
|
45547
|
-
trackId: "the track",
|
|
45548
|
-
score: "how sure the detector was",
|
|
45549
|
-
label: "the label it matched (a name, a plate), empty when none"
|
|
45550
|
-
};
|
|
45551
|
-
var STATIONARY_DESCRIPTIONS = {
|
|
45552
|
-
deviceId: "the camera that saw it",
|
|
45553
|
-
className: "what it saw",
|
|
45554
|
-
zones: "the zones it is in",
|
|
45555
|
-
phase: "appeared or departed",
|
|
45556
|
-
entryId: "the stopped object"
|
|
45557
|
-
};
|
|
45558
|
-
var BECOMES_DESCRIPTIONS = {
|
|
45559
|
-
deviceId: "the device that changed",
|
|
45560
|
-
from: "the value before the change, empty when it is not known",
|
|
45561
|
-
to: "the value it changed to"
|
|
45562
|
-
};
|
|
45563
|
-
function describe$1(descriptions) {
|
|
45564
|
-
return Object.entries(descriptions).map(([name, description]) => ({
|
|
45565
|
-
name,
|
|
45566
|
-
description
|
|
45567
|
-
}));
|
|
45568
|
-
}
|
|
45569
|
-
describe$1(DETECTION_DESCRIPTIONS);
|
|
45570
|
-
describe$1(STATIONARY_DESCRIPTIONS);
|
|
45571
|
-
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45572
|
-
...v,
|
|
45573
|
-
hintKey: "becomesDeviceId"
|
|
45574
|
-
} : v);
|
|
45575
|
-
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
45576
45920
|
/**
|
|
45577
45921
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
45578
45922
|
*
|
|
@@ -45624,12 +45968,16 @@ var HoldOverrideSchema = discriminatedUnion("mode", [object({ mode: literal("res
|
|
|
45624
45968
|
})]);
|
|
45625
45969
|
/** A missed edge up to this late still runs. */
|
|
45626
45970
|
var DEFAULT_MAX_LATE_MS = 10 * 6e4;
|
|
45971
|
+
var SchedulerStepSchema = ActionStepSchema.refine((step) => step.kind !== "wait" || step.seconds <= 300, {
|
|
45972
|
+
message: `a scheduler point waits at most five minutes (300 s); put a longer wait in an action`,
|
|
45973
|
+
path: ["seconds"]
|
|
45974
|
+
});
|
|
45627
45975
|
var SchedulerPointSchema = object({
|
|
45628
45976
|
id: string().min(1).max(64),
|
|
45629
45977
|
at: SchedulerTimeSpecSchema,
|
|
45630
45978
|
mode: SchedulerPointModeSchema,
|
|
45631
45979
|
/** The actions of an `edge` or `hold`; a `release` has none. */
|
|
45632
|
-
steps: array(
|
|
45980
|
+
steps: array(SchedulerStepSchema).max(20).default([]),
|
|
45633
45981
|
/** Checked when the point runs (an edge) or is applied (a hold). */
|
|
45634
45982
|
conditions: SchedulerStateTreeSchema.optional(),
|
|
45635
45983
|
/** Hold only; absent means `respect`. */
|
|
@@ -45827,6 +46175,7 @@ var AutomationConditionTraceNodeSchema = object({
|
|
|
45827
46175
|
"triggered-by",
|
|
45828
46176
|
"device-becomes",
|
|
45829
46177
|
"device-event",
|
|
46178
|
+
"device-fired",
|
|
45830
46179
|
"schedule",
|
|
45831
46180
|
"interval",
|
|
45832
46181
|
"manual",
|
|
@@ -45897,18 +46246,46 @@ var StepTraceBaseSchema = object({
|
|
|
45897
46246
|
]).optional(),
|
|
45898
46247
|
/** Why the condition read what it read, in the evaluator's own words. */
|
|
45899
46248
|
conditionReason: string().optional(),
|
|
45900
|
-
/** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. */
|
|
46249
|
+
/** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. `failed-continued`: it failed and was marked to be passed over (#500). */
|
|
45901
46250
|
outcome: _enum([
|
|
45902
46251
|
"ok",
|
|
45903
46252
|
"error",
|
|
45904
46253
|
"not-run",
|
|
45905
46254
|
"empty",
|
|
45906
|
-
"skipped"
|
|
46255
|
+
"skipped",
|
|
46256
|
+
"failed-continued",
|
|
46257
|
+
"timed-out"
|
|
45907
46258
|
]),
|
|
45908
46259
|
message: string().optional()
|
|
45909
46260
|
});
|
|
46261
|
+
/** What a block step adds to its row: which list ran, what each branch read, how many rounds. */
|
|
46262
|
+
var blockTraceShape = {
|
|
46263
|
+
/** A `choose` step (#500): the list that ran, `branches.<n>` or `else`. Absent when none did. */
|
|
46264
|
+
branch: string().optional(),
|
|
46265
|
+
/** A `choose` step: what each branch read, in order, up to the one that decided. */
|
|
46266
|
+
branchChecks: array(object({
|
|
46267
|
+
condition: _enum([
|
|
46268
|
+
"true",
|
|
46269
|
+
"false",
|
|
46270
|
+
"unknown"
|
|
46271
|
+
]),
|
|
46272
|
+
conditionReason: string().optional()
|
|
46273
|
+
})).optional(),
|
|
46274
|
+
/** A `repeat` step (#500): how many times its steps ran. */
|
|
46275
|
+
iterations: number$1().int().optional()
|
|
46276
|
+
};
|
|
46277
|
+
/** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
|
|
46278
|
+
var NestedStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46279
|
+
...blockTraceShape,
|
|
46280
|
+
steps: array(StepTraceBaseSchema).optional()
|
|
46281
|
+
});
|
|
45910
46282
|
/** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
|
|
45911
|
-
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46283
|
+
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
46284
|
+
else: array(StepTraceBaseSchema).optional(),
|
|
46285
|
+
...blockTraceShape,
|
|
46286
|
+
/** A `choose` step: the steps of the list that ran. A `parallel`: its members. A `repeat`: the LAST iteration. */
|
|
46287
|
+
steps: array(NestedStepTraceSchema).optional()
|
|
46288
|
+
});
|
|
45912
46289
|
var AutomationRunTraceSchema = object({
|
|
45913
46290
|
runId: string().min(1),
|
|
45914
46291
|
startedAt: number$1(),
|
|
@@ -45938,6 +46315,86 @@ var AutomationStateDocSchema = object({
|
|
|
45938
46315
|
lastRunStartedAt: number$1().nullable(),
|
|
45939
46316
|
traces: array(AutomationRunTraceSchema)
|
|
45940
46317
|
});
|
|
46318
|
+
var DETECTION_DESCRIPTIONS = {
|
|
46319
|
+
deviceId: "the camera that saw it",
|
|
46320
|
+
className: "what it saw",
|
|
46321
|
+
trackId: "the track",
|
|
46322
|
+
score: "how sure the detector was",
|
|
46323
|
+
label: "the label it matched (a name, a plate), empty when none"
|
|
46324
|
+
};
|
|
46325
|
+
var STATIONARY_DESCRIPTIONS = {
|
|
46326
|
+
deviceId: "the camera that saw it",
|
|
46327
|
+
className: "what it saw",
|
|
46328
|
+
zones: "the zones it is in",
|
|
46329
|
+
phase: "appeared or departed",
|
|
46330
|
+
entryId: "the stopped object"
|
|
46331
|
+
};
|
|
46332
|
+
var BECOMES_DESCRIPTIONS = {
|
|
46333
|
+
deviceId: "the device that changed",
|
|
46334
|
+
from: "the value before the change, empty when it is not known",
|
|
46335
|
+
to: "the value it changed to"
|
|
46336
|
+
};
|
|
46337
|
+
/**
|
|
46338
|
+
* A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
|
|
46339
|
+
* those names depend on the device, so they are not in this list.
|
|
46340
|
+
*/
|
|
46341
|
+
var FIRED_DESCRIPTIONS = {
|
|
46342
|
+
deviceId: "the device that fired",
|
|
46343
|
+
eventType: "the event, as the device names it",
|
|
46344
|
+
sourceId: "the part of the device that fired (a button), empty when it names none",
|
|
46345
|
+
eventKind: "the kind of press (press, long-press …), empty when the device declares none"
|
|
46346
|
+
};
|
|
46347
|
+
function describe$1(descriptions) {
|
|
46348
|
+
return Object.entries(descriptions).map(([name, description]) => ({
|
|
46349
|
+
name,
|
|
46350
|
+
description
|
|
46351
|
+
}));
|
|
46352
|
+
}
|
|
46353
|
+
describe$1(DETECTION_DESCRIPTIONS);
|
|
46354
|
+
describe$1(STATIONARY_DESCRIPTIONS);
|
|
46355
|
+
describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
46356
|
+
...v,
|
|
46357
|
+
hintKey: "firedDeviceId"
|
|
46358
|
+
} : v);
|
|
46359
|
+
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
46360
|
+
...v,
|
|
46361
|
+
hintKey: "becomesDeviceId"
|
|
46362
|
+
} : v);
|
|
46363
|
+
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
46364
|
+
/**
|
|
46365
|
+
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
46366
|
+
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
46367
|
+
* (NO normalization). Two shapes:
|
|
46368
|
+
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
46369
|
+
* declared set (e.g. press_short, press_long, …).
|
|
46370
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
46371
|
+
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
46372
|
+
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
46373
|
+
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
46374
|
+
* A fire names the part of the device it came from in `sourceId` when the
|
|
46375
|
+
* vocabulary declares sources (a remote's buttons).
|
|
46376
|
+
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
46377
|
+
*/
|
|
46378
|
+
var EventFireSchema = object({
|
|
46379
|
+
deviceId: number$1(),
|
|
46380
|
+
eventType: string(),
|
|
46381
|
+
sourceId: string().optional(),
|
|
46382
|
+
data: record(string(), unknown()).nullable(),
|
|
46383
|
+
timestamp: number$1().meta(readingMeta("none")),
|
|
46384
|
+
seq: number$1().meta(readingMeta("count"))
|
|
46385
|
+
});
|
|
46386
|
+
var EventEmitterStatusSchema = object({
|
|
46387
|
+
eventTypes: array(string()),
|
|
46388
|
+
/**
|
|
46389
|
+
* Required of a provider by the type. A status written before the field
|
|
46390
|
+
* existed still parses, as an empty vocabulary: read it through
|
|
46391
|
+
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
46392
|
+
*/
|
|
46393
|
+
vocabulary: array(EventVocabularyEntrySchema).default([]),
|
|
46394
|
+
lastEvent: EventFireSchema.nullable(),
|
|
46395
|
+
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
46396
|
+
});
|
|
46397
|
+
DeviceType.EventEmitter;
|
|
45941
46398
|
/**
|
|
45942
46399
|
* Actions — named, runnable things an operator (or an automation) can start,
|
|
45943
46400
|
* declared as LIST ENTRIES, never as devices.
|
|
@@ -46200,6 +46657,343 @@ function pruneDeletedEntities(selection, live, log, exporter) {
|
|
|
46200
46657
|
dropped
|
|
46201
46658
|
};
|
|
46202
46659
|
}
|
|
46660
|
+
/**
|
|
46661
|
+
* `device-export` — collection cap for addons that export camstack
|
|
46662
|
+
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
46663
|
+
* HomeKit/HAP, Alexa Smart Home, …).
|
|
46664
|
+
*
|
|
46665
|
+
* No `ecosystem` enum — the addon id identifies the export target.
|
|
46666
|
+
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
46667
|
+
* exposes only the COMMON surface: link state, supported device
|
|
46668
|
+
* kinds (so the UI can filter the device picker), and per-device
|
|
46669
|
+
* expose/unexpose.
|
|
46670
|
+
*
|
|
46671
|
+
* INSTANCES. One export addon can serve several independent targets (a
|
|
46672
|
+
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
46673
|
+
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
46674
|
+
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
46675
|
+
* default instance's); present = that instance; an id the provider does not
|
|
46676
|
+
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
46677
|
+
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
46678
|
+
* change always names the target it changes. A single-instance provider
|
|
46679
|
+
* accepts an absent id on a read or its own id, and refuses any other.
|
|
46680
|
+
*/
|
|
46681
|
+
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
46682
|
+
var InstanceIdSchema$1 = string().min(1);
|
|
46683
|
+
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
46684
|
+
/** One independent export target of an addon. */
|
|
46685
|
+
var ExportInstanceSchema = object({
|
|
46686
|
+
instanceId: InstanceIdSchema$1,
|
|
46687
|
+
name: string(),
|
|
46688
|
+
enabled: boolean(),
|
|
46689
|
+
kind: string().optional(),
|
|
46690
|
+
/**
|
|
46691
|
+
* What this instance's platform accepts as a device name, in one operator-facing sentence
|
|
46692
|
+
* (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
|
|
46693
|
+
* about the rule.
|
|
46694
|
+
*/
|
|
46695
|
+
nameRule: string().optional()
|
|
46696
|
+
});
|
|
46697
|
+
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
46698
|
+
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
46699
|
+
var ExportInstanceUnknownError = class extends Error {
|
|
46700
|
+
code = EXPORT_INSTANCE_UNKNOWN;
|
|
46701
|
+
instanceId;
|
|
46702
|
+
constructor(addon, instanceId) {
|
|
46703
|
+
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
46704
|
+
this.name = "ExportInstanceUnknownError";
|
|
46705
|
+
this.instanceId = instanceId;
|
|
46706
|
+
}
|
|
46707
|
+
};
|
|
46708
|
+
/**
|
|
46709
|
+
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
46710
|
+
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
46711
|
+
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
46712
|
+
*/
|
|
46713
|
+
function statusInstanceOf(input) {
|
|
46714
|
+
return "instanceId" in input ? input.instanceId : void 0;
|
|
46715
|
+
}
|
|
46716
|
+
var LinkStateSchema = _enum([
|
|
46717
|
+
"unlinked",
|
|
46718
|
+
"linked",
|
|
46719
|
+
"error"
|
|
46720
|
+
]);
|
|
46721
|
+
/**
|
|
46722
|
+
* A single label/value row surfaced in the export panel's "Setup"
|
|
46723
|
+
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
46724
|
+
* rows are masked by default with a reveal toggle (client ids,
|
|
46725
|
+
* secrets, …).
|
|
46726
|
+
*/
|
|
46727
|
+
var ExportSetupFieldSchema = object({
|
|
46728
|
+
label: string(),
|
|
46729
|
+
value: string(),
|
|
46730
|
+
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
46731
|
+
secret: boolean().optional()
|
|
46732
|
+
});
|
|
46733
|
+
/**
|
|
46734
|
+
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
46735
|
+
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
46736
|
+
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
46737
|
+
* the provider supplies and skips the section entirely when `setup`
|
|
46738
|
+
* is unset.
|
|
46739
|
+
*/
|
|
46740
|
+
var ExportSetupSchema = object({
|
|
46741
|
+
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
46742
|
+
qr: string().optional(),
|
|
46743
|
+
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
46744
|
+
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
46745
|
+
/** Free-form operator instructions rendered above the fields. */
|
|
46746
|
+
note: string().optional()
|
|
46747
|
+
});
|
|
46748
|
+
var DeviceExportStatusSchema = object({
|
|
46749
|
+
linkState: LinkStateSchema,
|
|
46750
|
+
exposedDeviceCount: number$1(),
|
|
46751
|
+
error: string().optional(),
|
|
46752
|
+
/**
|
|
46753
|
+
* Optional pairing/account info the panel renders in a generic
|
|
46754
|
+
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
46755
|
+
* export target, never an `ecosystem` key here.
|
|
46756
|
+
*/
|
|
46757
|
+
setup: ExportSetupSchema.optional()
|
|
46758
|
+
});
|
|
46759
|
+
var DeviceKindSchema = string();
|
|
46760
|
+
/**
|
|
46761
|
+
* EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
|
|
46762
|
+
* device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
|
|
46763
|
+
* store (D865), validated by the exporter against its platform's naming rules, and never reaches
|
|
46764
|
+
* the exported id — a rename updates the SAME device on the platform, never a second one.
|
|
46765
|
+
* Blank or `null` = the device's own name. A name the platform would refuse is refused with
|
|
46766
|
+
* `ExportNameRefusedError` (`export-name-refused`), whose message says why.
|
|
46767
|
+
*/
|
|
46768
|
+
var ExposedDeviceSchema = object({
|
|
46769
|
+
deviceId: string(),
|
|
46770
|
+
exposedAs: string().optional(),
|
|
46771
|
+
/** The operator's name for this device on this instance; absent = the device's own name. */
|
|
46772
|
+
exposedName: string().optional(),
|
|
46773
|
+
capabilities: array(string()).optional()
|
|
46774
|
+
});
|
|
46775
|
+
var ExposeInputSchema = object({
|
|
46776
|
+
instanceId: InstanceIdSchema$1,
|
|
46777
|
+
deviceId: string(),
|
|
46778
|
+
capabilities: array(string()).optional(),
|
|
46779
|
+
/** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
|
|
46780
|
+
exposedName: string().nullable().optional()
|
|
46781
|
+
});
|
|
46782
|
+
var SetExposedNameInputSchema = object({
|
|
46783
|
+
instanceId: InstanceIdSchema$1,
|
|
46784
|
+
deviceId: string(),
|
|
46785
|
+
/** Blank or null = the device's own name. */
|
|
46786
|
+
name: string().nullable(),
|
|
46787
|
+
/**
|
|
46788
|
+
* Validate only: refuse exactly as a real call would, write nothing. A caller saving several
|
|
46789
|
+
* names at once checks every one first, so one refusal writes none (D1049).
|
|
46790
|
+
*/
|
|
46791
|
+
dryRun: boolean().optional()
|
|
46792
|
+
});
|
|
46793
|
+
var EXPORT_NAME_REFUSED = "export-name-refused";
|
|
46794
|
+
/** A name the instance's platform would refuse. The message starts with the code, then the reason. */
|
|
46795
|
+
var ExportNameRefusedError = class extends Error {
|
|
46796
|
+
code = EXPORT_NAME_REFUSED;
|
|
46797
|
+
instanceId;
|
|
46798
|
+
reason;
|
|
46799
|
+
constructor(instanceId, reason) {
|
|
46800
|
+
super(`${EXPORT_NAME_REFUSED}: ${reason}`);
|
|
46801
|
+
this.name = "ExportNameRefusedError";
|
|
46802
|
+
this.instanceId = instanceId;
|
|
46803
|
+
this.reason = reason;
|
|
46804
|
+
}
|
|
46805
|
+
};
|
|
46806
|
+
var UnexposeInputSchema = object({
|
|
46807
|
+
instanceId: InstanceIdSchema$1,
|
|
46808
|
+
deviceId: string()
|
|
46809
|
+
});
|
|
46810
|
+
/**
|
|
46811
|
+
* What an exporter may expose besides devices (D968). An action and a
|
|
46812
|
+
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
46813
|
+
* exporter's own selection, not the device registry.
|
|
46814
|
+
*/
|
|
46815
|
+
var ExportEntityKindSchema = _enum([
|
|
46816
|
+
"device",
|
|
46817
|
+
"action",
|
|
46818
|
+
"notifier"
|
|
46819
|
+
]);
|
|
46820
|
+
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
46821
|
+
object({
|
|
46822
|
+
kind: literal("device"),
|
|
46823
|
+
deviceId: string()
|
|
46824
|
+
}),
|
|
46825
|
+
object({
|
|
46826
|
+
kind: literal("action"),
|
|
46827
|
+
actionId: string().min(1)
|
|
46828
|
+
}),
|
|
46829
|
+
object({
|
|
46830
|
+
kind: literal("notifier"),
|
|
46831
|
+
targetId: string().min(1)
|
|
46832
|
+
})
|
|
46833
|
+
]);
|
|
46834
|
+
var ExposedEntitySchema = object({
|
|
46835
|
+
entity: ExportEntityRefSchema,
|
|
46836
|
+
exposedAs: string().optional()
|
|
46837
|
+
});
|
|
46838
|
+
var ExposeEntityInputSchema = object({
|
|
46839
|
+
instanceId: InstanceIdSchema$1,
|
|
46840
|
+
entity: ExportEntityRefSchema
|
|
46841
|
+
});
|
|
46842
|
+
var UnexposeEntityInputSchema = object({
|
|
46843
|
+
instanceId: InstanceIdSchema$1,
|
|
46844
|
+
entity: ExportEntityRefSchema
|
|
46845
|
+
});
|
|
46846
|
+
var deviceExportCapability = {
|
|
46847
|
+
name: "device-export",
|
|
46848
|
+
scope: "system",
|
|
46849
|
+
mode: "collection",
|
|
46850
|
+
providerKind: "device-export",
|
|
46851
|
+
status: {
|
|
46852
|
+
schema: DeviceExportStatusSchema,
|
|
46853
|
+
kind: "poll"
|
|
46854
|
+
},
|
|
46855
|
+
/**
|
|
46856
|
+
* Each export provider MAY contribute its own per-device "Export" panel
|
|
46857
|
+
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
46858
|
+
* framework methods are mounted on the cap router when present.
|
|
46859
|
+
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
46860
|
+
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
46861
|
+
* never hand-written — D14 — and an exporter is not one of those).
|
|
46862
|
+
*/
|
|
46863
|
+
exposesDeviceSettings: true,
|
|
46864
|
+
methods: {
|
|
46865
|
+
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
46866
|
+
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
46867
|
+
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
46868
|
+
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
46869
|
+
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
46870
|
+
kind: "mutation",
|
|
46871
|
+
auth: "admin"
|
|
46872
|
+
}),
|
|
46873
|
+
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
46874
|
+
kind: "mutation",
|
|
46875
|
+
auth: "admin"
|
|
46876
|
+
}),
|
|
46877
|
+
setExposedName: method(SetExposedNameInputSchema, _void(), {
|
|
46878
|
+
kind: "mutation",
|
|
46879
|
+
auth: "admin"
|
|
46880
|
+
}),
|
|
46881
|
+
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
46882
|
+
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
46883
|
+
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
46884
|
+
kind: "mutation",
|
|
46885
|
+
auth: "admin"
|
|
46886
|
+
}),
|
|
46887
|
+
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
46888
|
+
kind: "mutation",
|
|
46889
|
+
auth: "admin"
|
|
46890
|
+
})
|
|
46891
|
+
}
|
|
46892
|
+
};
|
|
46893
|
+
/**
|
|
46894
|
+
* The exposed name of a device on one export instance (`device-export`, D1049).
|
|
46895
|
+
*
|
|
46896
|
+
* Every exporter keeps its names the same way: in ITS per-device store (D865), under
|
|
46897
|
+
* {@link EXPOSED_NAMES_STORE_KEY}, one entry per instance id. The store is cleared centrally
|
|
46898
|
+
* when the device is deleted, so no removal hook is needed for it. Each exporter supplies the
|
|
46899
|
+
* validator of its own platform; the normalisation, the store shape and the refusal are here so
|
|
46900
|
+
* the four exporters cannot drift apart.
|
|
46901
|
+
*
|
|
46902
|
+
* The name is a label only: no exporter derives the exported id from it, so a rename updates
|
|
46903
|
+
* the same device on the platform.
|
|
46904
|
+
*/
|
|
46905
|
+
/** The per-device store key holding `{ [instanceId]: name }`. */
|
|
46906
|
+
var EXPOSED_NAMES_STORE_KEY = "exposedNames";
|
|
46907
|
+
var ExposedNamesSchema = record(string(), string());
|
|
46908
|
+
/** Trim and collapse whitespace, then the platform rule. Blank or null clears (`name: null`). */
|
|
46909
|
+
function checkExposedName(raw, validate) {
|
|
46910
|
+
if (raw === null || raw === void 0) return {
|
|
46911
|
+
ok: true,
|
|
46912
|
+
name: null
|
|
46913
|
+
};
|
|
46914
|
+
if (typeof raw !== "string") return {
|
|
46915
|
+
ok: false,
|
|
46916
|
+
reason: "The name must be text."
|
|
46917
|
+
};
|
|
46918
|
+
const name = raw.trim().replace(/\s+/g, " ");
|
|
46919
|
+
if (name.length === 0) return {
|
|
46920
|
+
ok: true,
|
|
46921
|
+
name: null
|
|
46922
|
+
};
|
|
46923
|
+
return validate(name);
|
|
46924
|
+
}
|
|
46925
|
+
/** Every saved name of a device, by instance id. A malformed blob reads as none. */
|
|
46926
|
+
function readExposedNames(store) {
|
|
46927
|
+
const parsed = ExposedNamesSchema.safeParse(store[EXPOSED_NAMES_STORE_KEY]);
|
|
46928
|
+
return parsed.success ? parsed.data : {};
|
|
46929
|
+
}
|
|
46930
|
+
/**
|
|
46931
|
+
* The saved name of one instance, or null: never saved, or a stored value the platform would
|
|
46932
|
+
* now refuse (the device's own name is used rather than pushing a name the platform rejects).
|
|
46933
|
+
*/
|
|
46934
|
+
function readExposedName(store, instanceId, validate) {
|
|
46935
|
+
const saved = readExposedNames(store)[instanceId];
|
|
46936
|
+
if (saved === void 0) return null;
|
|
46937
|
+
const check = checkExposedName(saved, validate);
|
|
46938
|
+
return check.ok ? check.name : null;
|
|
46939
|
+
}
|
|
46940
|
+
/** The store patch that sets (or, with null, clears) one instance's name and keeps the others. */
|
|
46941
|
+
function exposedNamePatch(store, instanceId, name) {
|
|
46942
|
+
const others = Object.fromEntries(Object.entries(readExposedNames(store)).filter(([id]) => id !== instanceId));
|
|
46943
|
+
return { [EXPOSED_NAMES_STORE_KEY]: name === null ? others : {
|
|
46944
|
+
...others,
|
|
46945
|
+
[instanceId]: name
|
|
46946
|
+
} };
|
|
46947
|
+
}
|
|
46948
|
+
/**
|
|
46949
|
+
* Validate and save one instance's name. A name the platform would refuse throws
|
|
46950
|
+
* {@link ExportNameRefusedError} BEFORE anything is written, so the old name stays.
|
|
46951
|
+
*/
|
|
46952
|
+
async function saveExposedName(input) {
|
|
46953
|
+
const check = checkExposedName(input.raw, input.validate);
|
|
46954
|
+
if (!check.ok) throw new ExportNameRefusedError(input.instanceId, check.reason);
|
|
46955
|
+
if (input.dryRun === true) return {
|
|
46956
|
+
changed: false,
|
|
46957
|
+
name: check.name
|
|
46958
|
+
};
|
|
46959
|
+
const store = await input.store.read(input.deviceId);
|
|
46960
|
+
if ((readExposedNames(store)[input.instanceId] ?? null) === check.name) return {
|
|
46961
|
+
changed: false,
|
|
46962
|
+
name: check.name
|
|
46963
|
+
};
|
|
46964
|
+
await input.store.write(input.deviceId, exposedNamePatch(store, input.instanceId, check.name));
|
|
46965
|
+
return {
|
|
46966
|
+
changed: true,
|
|
46967
|
+
name: check.name
|
|
46968
|
+
};
|
|
46969
|
+
}
|
|
46970
|
+
/** The exporter's per-device store as an {@link ExposedNameStore}; throws when settings are absent. */
|
|
46971
|
+
function exposedNameStoreOf(settings, owner) {
|
|
46972
|
+
const access = () => {
|
|
46973
|
+
if (settings === void 0) throw new Error(`${owner}: settings are not available`);
|
|
46974
|
+
return settings;
|
|
46975
|
+
};
|
|
46976
|
+
return {
|
|
46977
|
+
read: (deviceId) => access().readDeviceStore(deviceId),
|
|
46978
|
+
write: (deviceId, patch) => access().writeDeviceStore(deviceId, patch)
|
|
46979
|
+
};
|
|
46980
|
+
}
|
|
46981
|
+
/**
|
|
46982
|
+
* Remove every name saved for `instanceId` (the instance was deleted), so a later instance that
|
|
46983
|
+
* reuses the id does not inherit them. Returns the device ids that lost a name. A store that
|
|
46984
|
+
* cannot be read throws; nothing is written for the devices not reached.
|
|
46985
|
+
*/
|
|
46986
|
+
async function pruneExposedNames(settings, instanceId) {
|
|
46987
|
+
const ids = await settings.listDeviceStoreIds();
|
|
46988
|
+
if (ids.length === 0) return [];
|
|
46989
|
+
const pruned = [];
|
|
46990
|
+
for (const [deviceId, store] of await settings.readDeviceStoreBatch(ids)) {
|
|
46991
|
+
if (readExposedNames(store)[instanceId] === void 0) continue;
|
|
46992
|
+
await settings.writeDeviceStore(deviceId, exposedNamePatch(store, instanceId, null));
|
|
46993
|
+
pruned.push(deviceId);
|
|
46994
|
+
}
|
|
46995
|
+
return pruned;
|
|
46996
|
+
}
|
|
46203
46997
|
_enum([
|
|
46204
46998
|
"automation",
|
|
46205
46999
|
"action",
|
|
@@ -46398,7 +47192,9 @@ var AddonHttpRouteSchema = object({
|
|
|
46398
47192
|
]).optional(),
|
|
46399
47193
|
description: string().optional(),
|
|
46400
47194
|
/** The hub limits this route per client address before the handler runs. */
|
|
46401
|
-
rateLimit: _enum(["auth"]).optional()
|
|
47195
|
+
rateLimit: _enum(["auth"]).optional(),
|
|
47196
|
+
/** Served once per integration instance; the handler reads `instanceId`. */
|
|
47197
|
+
perInstance: boolean().optional()
|
|
46402
47198
|
});
|
|
46403
47199
|
/**
|
|
46404
47200
|
* Cross-process route invocation envelope. The hub captures the
|
|
@@ -46415,6 +47211,8 @@ var InvokeRequestSchema = object({
|
|
|
46415
47211
|
query: record(string(), string()),
|
|
46416
47212
|
body: unknown(),
|
|
46417
47213
|
headers: record(string(), string()),
|
|
47214
|
+
/** The instance the hub resolved for a `perInstance` route. */
|
|
47215
|
+
instanceId: string().optional(),
|
|
46418
47216
|
user: object({
|
|
46419
47217
|
id: string(),
|
|
46420
47218
|
username: string(),
|
|
@@ -50463,11 +51261,13 @@ var IrCodecError = class extends Error {
|
|
|
50463
51261
|
this.code = code;
|
|
50464
51262
|
}
|
|
50465
51263
|
};
|
|
51264
|
+
/** Maximum number of mark/space entries one pulse train may carry. */
|
|
51265
|
+
var IR_TIMINGS_MAX = 1024;
|
|
50466
51266
|
/**
|
|
50467
51267
|
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
50468
51268
|
* alternating, no zeros, 2..1024 entries.
|
|
50469
51269
|
*/
|
|
50470
|
-
var IrTimingsSchema = array(number$1().int()).min(2).max(
|
|
51270
|
+
var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
|
|
50471
51271
|
timings.forEach((value, index) => {
|
|
50472
51272
|
const expectMark = index % 2 === 0;
|
|
50473
51273
|
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
@@ -50514,15 +51314,186 @@ function decodePronto(code) {
|
|
|
50514
51314
|
carrierHz: Math.round(1e6 / unitUs)
|
|
50515
51315
|
};
|
|
50516
51316
|
}
|
|
50517
|
-
/**
|
|
50518
|
-
|
|
50519
|
-
|
|
50520
|
-
|
|
50521
|
-
|
|
50522
|
-
|
|
50523
|
-
|
|
50524
|
-
|
|
50525
|
-
|
|
51317
|
+
/**
|
|
51318
|
+
* FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
|
|
51319
|
+
* literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
|
|
51320
|
+
* is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
|
|
51321
|
+
* between the low 5 bits and the next byte.
|
|
51322
|
+
*/
|
|
51323
|
+
var MAX_DISTANCE = 8192;
|
|
51324
|
+
var MAX_LITERAL_RUN = 32;
|
|
51325
|
+
var MIN_MATCH = 3;
|
|
51326
|
+
var MAX_MATCH = 264;
|
|
51327
|
+
/**
|
|
51328
|
+
* Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
|
|
51329
|
+
* can expand ~130x, so the decoder checks this bound before every write.
|
|
51330
|
+
*/
|
|
51331
|
+
var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
|
|
51332
|
+
function fastlzDecompress(input) {
|
|
51333
|
+
const out = [];
|
|
51334
|
+
let ip = 0;
|
|
51335
|
+
const room = (count) => {
|
|
51336
|
+
if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
|
|
51337
|
+
};
|
|
51338
|
+
const next = () => {
|
|
51339
|
+
const byte = input[ip++];
|
|
51340
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
|
|
51341
|
+
return byte;
|
|
51342
|
+
};
|
|
51343
|
+
while (ip < input.length) {
|
|
51344
|
+
const ctrl = next();
|
|
51345
|
+
if (ctrl < 32) {
|
|
51346
|
+
room(ctrl + 1);
|
|
51347
|
+
for (let i = 0; i <= ctrl; i++) out.push(next());
|
|
51348
|
+
continue;
|
|
51349
|
+
}
|
|
51350
|
+
let len = (ctrl >> 5) - 1;
|
|
51351
|
+
if (len === 6) len += next();
|
|
51352
|
+
const distance = ((ctrl & 31) << 8) + next() + 1;
|
|
51353
|
+
const start = out.length - distance;
|
|
51354
|
+
if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
|
|
51355
|
+
room(len + 3);
|
|
51356
|
+
for (let i = 0; i < len + 3; i++) {
|
|
51357
|
+
const byte = out[start + i];
|
|
51358
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
|
|
51359
|
+
out.push(byte);
|
|
51360
|
+
}
|
|
51361
|
+
}
|
|
51362
|
+
return Uint8Array.from(out);
|
|
51363
|
+
}
|
|
51364
|
+
function fastlzCompress(input) {
|
|
51365
|
+
const out = [];
|
|
51366
|
+
const lastSeen = /* @__PURE__ */ new Map();
|
|
51367
|
+
let literalStart = 0;
|
|
51368
|
+
const flushLiterals = (end) => {
|
|
51369
|
+
for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
|
|
51370
|
+
const to = Math.min(from + MAX_LITERAL_RUN, end);
|
|
51371
|
+
out.push(to - from - 1);
|
|
51372
|
+
for (let i = from; i < to; i++) out.push(input[i] ?? 0);
|
|
51373
|
+
}
|
|
51374
|
+
};
|
|
51375
|
+
let pos = 0;
|
|
51376
|
+
while (pos < input.length) {
|
|
51377
|
+
let matchLen = 0;
|
|
51378
|
+
let matchDistance = 0;
|
|
51379
|
+
if (pos + MIN_MATCH <= input.length) {
|
|
51380
|
+
const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
|
|
51381
|
+
const candidate = lastSeen.get(key);
|
|
51382
|
+
lastSeen.set(key, pos);
|
|
51383
|
+
if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
|
|
51384
|
+
let len = 0;
|
|
51385
|
+
while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
|
|
51386
|
+
if (len >= MIN_MATCH) {
|
|
51387
|
+
matchLen = len;
|
|
51388
|
+
matchDistance = pos - candidate - 1;
|
|
51389
|
+
}
|
|
51390
|
+
}
|
|
51391
|
+
}
|
|
51392
|
+
if (matchLen === 0) {
|
|
51393
|
+
pos++;
|
|
51394
|
+
continue;
|
|
51395
|
+
}
|
|
51396
|
+
flushLiterals(pos);
|
|
51397
|
+
const enc = matchLen - 2;
|
|
51398
|
+
if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
|
|
51399
|
+
else out.push(224 | matchDistance >> 8, enc - 7);
|
|
51400
|
+
out.push(matchDistance & 255);
|
|
51401
|
+
pos += matchLen;
|
|
51402
|
+
literalStart = pos;
|
|
51403
|
+
}
|
|
51404
|
+
flushLiterals(input.length);
|
|
51405
|
+
return Uint8Array.from(out);
|
|
51406
|
+
}
|
|
51407
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
51408
|
+
var MAX_DURATION_US = 65535;
|
|
51409
|
+
function toBase64(bytes) {
|
|
51410
|
+
let out = "";
|
|
51411
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
51412
|
+
const a = bytes[i] ?? 0;
|
|
51413
|
+
const b = bytes[i + 1] ?? 0;
|
|
51414
|
+
const c = bytes[i + 2] ?? 0;
|
|
51415
|
+
const word = a << 16 | b << 8 | c;
|
|
51416
|
+
out += ALPHABET[word >> 18 & 63];
|
|
51417
|
+
out += ALPHABET[word >> 12 & 63];
|
|
51418
|
+
out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
|
|
51419
|
+
out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
|
|
51420
|
+
}
|
|
51421
|
+
return out;
|
|
51422
|
+
}
|
|
51423
|
+
function fromBase64(text) {
|
|
51424
|
+
const clean = text.trim().replace(/=+$/, "");
|
|
51425
|
+
if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51426
|
+
const out = [];
|
|
51427
|
+
let bits = 0;
|
|
51428
|
+
let acc = 0;
|
|
51429
|
+
for (const ch of clean) {
|
|
51430
|
+
const value = ALPHABET.indexOf(ch);
|
|
51431
|
+
if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51432
|
+
acc = acc << 6 | value;
|
|
51433
|
+
bits += 6;
|
|
51434
|
+
if (bits >= 8) {
|
|
51435
|
+
bits -= 8;
|
|
51436
|
+
out.push(acc >> bits & 255);
|
|
51437
|
+
}
|
|
51438
|
+
}
|
|
51439
|
+
return Uint8Array.from(out);
|
|
51440
|
+
}
|
|
51441
|
+
/** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
|
|
51442
|
+
function encodeTuya(timings) {
|
|
51443
|
+
const bytes = new Uint8Array(timings.length * 2);
|
|
51444
|
+
timings.forEach((value, index) => {
|
|
51445
|
+
const duration = Math.abs(value);
|
|
51446
|
+
if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
|
|
51447
|
+
bytes[index * 2] = duration & 255;
|
|
51448
|
+
bytes[index * 2 + 1] = duration >> 8;
|
|
51449
|
+
});
|
|
51450
|
+
return toBase64(fastlzCompress(bytes));
|
|
51451
|
+
}
|
|
51452
|
+
/** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
|
|
51453
|
+
function decodeTuya(code) {
|
|
51454
|
+
const bytes = fastlzDecompress(fromBase64(code));
|
|
51455
|
+
if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
|
|
51456
|
+
const timings = [];
|
|
51457
|
+
for (let i = 0; i < bytes.length; i += 2) {
|
|
51458
|
+
const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
|
|
51459
|
+
timings.push(i / 2 % 2 === 0 ? duration : -duration);
|
|
51460
|
+
}
|
|
51461
|
+
const checked = IrTimingsSchema.safeParse(timings);
|
|
51462
|
+
if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
|
|
51463
|
+
return checked.data;
|
|
51464
|
+
}
|
|
51465
|
+
/** Device-native IR code formats a transmitter can replay verbatim. */
|
|
51466
|
+
var IrNativeFormatSchema = _enum(["tuya"]);
|
|
51467
|
+
/**
|
|
51468
|
+
* Longest native code accepted: base64 of the worst-case compressed stream
|
|
51469
|
+
* (every decoded byte as a literal, plus one control byte per 32), with margin.
|
|
51470
|
+
*/
|
|
51471
|
+
var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
|
|
51472
|
+
var IrNativeCodeSchema = object({
|
|
51473
|
+
format: IrNativeFormatSchema,
|
|
51474
|
+
code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
|
|
51475
|
+
});
|
|
51476
|
+
var IR_NATIVE_CODECS = { tuya: {
|
|
51477
|
+
encode: encodeTuya,
|
|
51478
|
+
decode: decodeTuya
|
|
51479
|
+
} };
|
|
51480
|
+
/** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
|
|
51481
|
+
var IrPayloadSchema = discriminatedUnion("kind", [
|
|
51482
|
+
object({
|
|
51483
|
+
kind: literal("raw"),
|
|
51484
|
+
timings: array(number$1().int()),
|
|
51485
|
+
settings: TransmitSettingsSchema.optional()
|
|
51486
|
+
}),
|
|
51487
|
+
object({
|
|
51488
|
+
kind: literal("pronto"),
|
|
51489
|
+
code: string()
|
|
51490
|
+
}),
|
|
51491
|
+
object({
|
|
51492
|
+
kind: literal("native"),
|
|
51493
|
+
format: IrNativeFormatSchema,
|
|
51494
|
+
code: string()
|
|
51495
|
+
})
|
|
51496
|
+
]);
|
|
50526
51497
|
/** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
|
|
50527
51498
|
function toTimings(payload) {
|
|
50528
51499
|
if (payload.kind === "pronto") {
|
|
@@ -50532,6 +51503,10 @@ function toTimings(payload) {
|
|
|
50532
51503
|
settings: { carrierHz: decoded.carrierHz }
|
|
50533
51504
|
};
|
|
50534
51505
|
}
|
|
51506
|
+
if (payload.kind === "native") return {
|
|
51507
|
+
timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
|
|
51508
|
+
settings: {}
|
|
51509
|
+
};
|
|
50535
51510
|
const checked = IrTimingsSchema.safeParse(payload.timings);
|
|
50536
51511
|
if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
|
|
50537
51512
|
return {
|
|
@@ -51340,8 +52315,8 @@ function actuator(input) {
|
|
|
51340
52315
|
};
|
|
51341
52316
|
}
|
|
51342
52317
|
new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
|
|
51343
|
-
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
51344
52318
|
DeviceType.Camera;
|
|
52319
|
+
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
51345
52320
|
var PowerSourceRefusalReasonSchema = _enum([
|
|
51346
52321
|
"no-power-source",
|
|
51347
52322
|
"switch-missing",
|
|
@@ -52672,193 +53647,6 @@ method(object({
|
|
|
52672
53647
|
kind: "mutation",
|
|
52673
53648
|
auth: "admin"
|
|
52674
53649
|
});
|
|
52675
|
-
/**
|
|
52676
|
-
* `device-export` — collection cap for addons that export camstack
|
|
52677
|
-
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
52678
|
-
* HomeKit/HAP, Alexa Smart Home, …).
|
|
52679
|
-
*
|
|
52680
|
-
* No `ecosystem` enum — the addon id identifies the export target.
|
|
52681
|
-
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
52682
|
-
* exposes only the COMMON surface: link state, supported device
|
|
52683
|
-
* kinds (so the UI can filter the device picker), and per-device
|
|
52684
|
-
* expose/unexpose.
|
|
52685
|
-
*
|
|
52686
|
-
* INSTANCES. One export addon can serve several independent targets (a
|
|
52687
|
-
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
52688
|
-
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
52689
|
-
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
52690
|
-
* default instance's); present = that instance; an id the provider does not
|
|
52691
|
-
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
52692
|
-
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
52693
|
-
* change always names the target it changes. A single-instance provider
|
|
52694
|
-
* accepts an absent id on a read or its own id, and refuses any other.
|
|
52695
|
-
*/
|
|
52696
|
-
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
52697
|
-
var InstanceIdSchema$1 = string().min(1);
|
|
52698
|
-
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
52699
|
-
/** One independent export target of an addon. */
|
|
52700
|
-
var ExportInstanceSchema = object({
|
|
52701
|
-
instanceId: InstanceIdSchema$1,
|
|
52702
|
-
name: string(),
|
|
52703
|
-
enabled: boolean(),
|
|
52704
|
-
kind: string().optional()
|
|
52705
|
-
});
|
|
52706
|
-
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
52707
|
-
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
52708
|
-
var ExportInstanceUnknownError = class extends Error {
|
|
52709
|
-
code = EXPORT_INSTANCE_UNKNOWN;
|
|
52710
|
-
instanceId;
|
|
52711
|
-
constructor(addon, instanceId) {
|
|
52712
|
-
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
52713
|
-
this.name = "ExportInstanceUnknownError";
|
|
52714
|
-
this.instanceId = instanceId;
|
|
52715
|
-
}
|
|
52716
|
-
};
|
|
52717
|
-
/**
|
|
52718
|
-
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
52719
|
-
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
52720
|
-
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
52721
|
-
*/
|
|
52722
|
-
function statusInstanceOf(input) {
|
|
52723
|
-
return "instanceId" in input ? input.instanceId : void 0;
|
|
52724
|
-
}
|
|
52725
|
-
var LinkStateSchema = _enum([
|
|
52726
|
-
"unlinked",
|
|
52727
|
-
"linked",
|
|
52728
|
-
"error"
|
|
52729
|
-
]);
|
|
52730
|
-
/**
|
|
52731
|
-
* A single label/value row surfaced in the export panel's "Setup"
|
|
52732
|
-
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
52733
|
-
* rows are masked by default with a reveal toggle (client ids,
|
|
52734
|
-
* secrets, …).
|
|
52735
|
-
*/
|
|
52736
|
-
var ExportSetupFieldSchema = object({
|
|
52737
|
-
label: string(),
|
|
52738
|
-
value: string(),
|
|
52739
|
-
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
52740
|
-
secret: boolean().optional()
|
|
52741
|
-
});
|
|
52742
|
-
/**
|
|
52743
|
-
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
52744
|
-
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
52745
|
-
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
52746
|
-
* the provider supplies and skips the section entirely when `setup`
|
|
52747
|
-
* is unset.
|
|
52748
|
-
*/
|
|
52749
|
-
var ExportSetupSchema = object({
|
|
52750
|
-
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
52751
|
-
qr: string().optional(),
|
|
52752
|
-
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
52753
|
-
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
52754
|
-
/** Free-form operator instructions rendered above the fields. */
|
|
52755
|
-
note: string().optional()
|
|
52756
|
-
});
|
|
52757
|
-
var DeviceExportStatusSchema = object({
|
|
52758
|
-
linkState: LinkStateSchema,
|
|
52759
|
-
exposedDeviceCount: number$1(),
|
|
52760
|
-
error: string().optional(),
|
|
52761
|
-
/**
|
|
52762
|
-
* Optional pairing/account info the panel renders in a generic
|
|
52763
|
-
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
52764
|
-
* export target, never an `ecosystem` key here.
|
|
52765
|
-
*/
|
|
52766
|
-
setup: ExportSetupSchema.optional()
|
|
52767
|
-
});
|
|
52768
|
-
var DeviceKindSchema = string();
|
|
52769
|
-
var ExposedDeviceSchema = object({
|
|
52770
|
-
deviceId: string(),
|
|
52771
|
-
exposedAs: string().optional(),
|
|
52772
|
-
capabilities: array(string()).optional()
|
|
52773
|
-
});
|
|
52774
|
-
var ExposeInputSchema = object({
|
|
52775
|
-
instanceId: InstanceIdSchema$1,
|
|
52776
|
-
deviceId: string(),
|
|
52777
|
-
capabilities: array(string()).optional()
|
|
52778
|
-
});
|
|
52779
|
-
var UnexposeInputSchema = object({
|
|
52780
|
-
instanceId: InstanceIdSchema$1,
|
|
52781
|
-
deviceId: string()
|
|
52782
|
-
});
|
|
52783
|
-
/**
|
|
52784
|
-
* What an exporter may expose besides devices (D968). An action and a
|
|
52785
|
-
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
52786
|
-
* exporter's own selection, not the device registry.
|
|
52787
|
-
*/
|
|
52788
|
-
var ExportEntityKindSchema = _enum([
|
|
52789
|
-
"device",
|
|
52790
|
-
"action",
|
|
52791
|
-
"notifier"
|
|
52792
|
-
]);
|
|
52793
|
-
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
52794
|
-
object({
|
|
52795
|
-
kind: literal("device"),
|
|
52796
|
-
deviceId: string()
|
|
52797
|
-
}),
|
|
52798
|
-
object({
|
|
52799
|
-
kind: literal("action"),
|
|
52800
|
-
actionId: string().min(1)
|
|
52801
|
-
}),
|
|
52802
|
-
object({
|
|
52803
|
-
kind: literal("notifier"),
|
|
52804
|
-
targetId: string().min(1)
|
|
52805
|
-
})
|
|
52806
|
-
]);
|
|
52807
|
-
var ExposedEntitySchema = object({
|
|
52808
|
-
entity: ExportEntityRefSchema,
|
|
52809
|
-
exposedAs: string().optional()
|
|
52810
|
-
});
|
|
52811
|
-
var ExposeEntityInputSchema = object({
|
|
52812
|
-
instanceId: InstanceIdSchema$1,
|
|
52813
|
-
entity: ExportEntityRefSchema
|
|
52814
|
-
});
|
|
52815
|
-
var UnexposeEntityInputSchema = object({
|
|
52816
|
-
instanceId: InstanceIdSchema$1,
|
|
52817
|
-
entity: ExportEntityRefSchema
|
|
52818
|
-
});
|
|
52819
|
-
var deviceExportCapability = {
|
|
52820
|
-
name: "device-export",
|
|
52821
|
-
scope: "system",
|
|
52822
|
-
mode: "collection",
|
|
52823
|
-
providerKind: "device-export",
|
|
52824
|
-
status: {
|
|
52825
|
-
schema: DeviceExportStatusSchema,
|
|
52826
|
-
kind: "poll"
|
|
52827
|
-
},
|
|
52828
|
-
/**
|
|
52829
|
-
* Each export provider MAY contribute its own per-device "Export" panel
|
|
52830
|
-
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
52831
|
-
* framework methods are mounted on the cap router when present.
|
|
52832
|
-
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
52833
|
-
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
52834
|
-
* never hand-written — D14 — and an exporter is not one of those).
|
|
52835
|
-
*/
|
|
52836
|
-
exposesDeviceSettings: true,
|
|
52837
|
-
methods: {
|
|
52838
|
-
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
52839
|
-
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
52840
|
-
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
52841
|
-
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
52842
|
-
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
52843
|
-
kind: "mutation",
|
|
52844
|
-
auth: "admin"
|
|
52845
|
-
}),
|
|
52846
|
-
unexposeDevice: method(UnexposeInputSchema, _void(), {
|
|
52847
|
-
kind: "mutation",
|
|
52848
|
-
auth: "admin"
|
|
52849
|
-
}),
|
|
52850
|
-
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
52851
|
-
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
52852
|
-
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
52853
|
-
kind: "mutation",
|
|
52854
|
-
auth: "admin"
|
|
52855
|
-
}),
|
|
52856
|
-
unexposeEntity: optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
52857
|
-
kind: "mutation",
|
|
52858
|
-
auth: "admin"
|
|
52859
|
-
})
|
|
52860
|
-
}
|
|
52861
|
-
};
|
|
52862
53650
|
var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
52863
53651
|
var DeviceTemplateSchema = string().min(1).max(4096);
|
|
52864
53652
|
/** One value a caller hands the renderer for `thisDevice`. */
|
|
@@ -55709,29 +56497,6 @@ var EnumSensorStatusSchema = object({
|
|
|
55709
56497
|
lastFetchedAt: number$1()
|
|
55710
56498
|
});
|
|
55711
56499
|
DeviceType.Sensor;
|
|
55712
|
-
/**
|
|
55713
|
-
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
55714
|
-
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
55715
|
-
* (NO normalization). Two shapes:
|
|
55716
|
-
* - structured source (HA `event.*` entity) → `eventTypes` is the fixed
|
|
55717
|
-
* declared vocabulary (e.g. ['press_short','press_long',...]).
|
|
55718
|
-
* - generic/legacy source (HA bus events, e.g. zha_event) → `eventTypes`
|
|
55719
|
-
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
55720
|
-
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
55721
|
-
*/
|
|
55722
|
-
var EventFireSchema = object({
|
|
55723
|
-
deviceId: number$1(),
|
|
55724
|
-
eventType: string(),
|
|
55725
|
-
data: record(string(), unknown()).nullable(),
|
|
55726
|
-
timestamp: number$1().meta(readingMeta("none")),
|
|
55727
|
-
seq: number$1().meta(readingMeta("count"))
|
|
55728
|
-
});
|
|
55729
|
-
var EventEmitterStatusSchema = object({
|
|
55730
|
-
eventTypes: array(string()),
|
|
55731
|
-
lastEvent: EventFireSchema.nullable(),
|
|
55732
|
-
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
55733
|
-
});
|
|
55734
|
-
DeviceType.EventEmitter;
|
|
55735
56500
|
var IdentitySchema = object({
|
|
55736
56501
|
id: string(),
|
|
55737
56502
|
name: string(),
|
|
@@ -57030,6 +57795,128 @@ var StateLookSchema = object({
|
|
|
57030
57795
|
background: _enum(HERO_BACKGROUNDS),
|
|
57031
57796
|
animation: HeroAnimationSchema
|
|
57032
57797
|
});
|
|
57798
|
+
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
57799
|
+
var HeroTextSchema = object({
|
|
57800
|
+
en: string(),
|
|
57801
|
+
it: string()
|
|
57802
|
+
});
|
|
57803
|
+
/**
|
|
57804
|
+
* The ONE measurement a simple sensor shows (card wave, phase 1).
|
|
57805
|
+
*
|
|
57806
|
+
* A sensor that measures a single quantity (a temperature, a humidity, a power,
|
|
57807
|
+
* a contact, a text state) is drawn as that reading, once, big, inside a scene
|
|
57808
|
+
* whose motion says what the number means: heat rising when hot, flakes when
|
|
57809
|
+
* cold, a wire flowing at the speed of the power, a ring while a window is
|
|
57810
|
+
* open. Everything the card draws is decided here; a client only paints it.
|
|
57811
|
+
*/
|
|
57812
|
+
var HERO_MEASUREMENT_QUANTITIES = [
|
|
57813
|
+
"temperature",
|
|
57814
|
+
"humidity",
|
|
57815
|
+
"power",
|
|
57816
|
+
"contact",
|
|
57817
|
+
"text"
|
|
57818
|
+
];
|
|
57819
|
+
/** How a temperature reads to a person; drives the heat or the cold scene. */
|
|
57820
|
+
var HERO_MEASUREMENT_BANDS = [
|
|
57821
|
+
"hot",
|
|
57822
|
+
"mild",
|
|
57823
|
+
"cold"
|
|
57824
|
+
];
|
|
57825
|
+
/** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
|
|
57826
|
+
var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
|
|
57827
|
+
var HeroMeasurementReadingSchema = object({
|
|
57828
|
+
value: number$1(),
|
|
57829
|
+
quantity: ReadingQuantitySchema
|
|
57830
|
+
});
|
|
57831
|
+
var HeroMeasurementSchema = object({
|
|
57832
|
+
quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
|
|
57833
|
+
reading: HeroMeasurementReadingSchema.nullable(),
|
|
57834
|
+
icon: IconKeySchema.nullable(),
|
|
57835
|
+
value: HeroTextSchema,
|
|
57836
|
+
unit: string().nullable(),
|
|
57837
|
+
band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
|
|
57838
|
+
level: number$1().min(0).max(1).nullable(),
|
|
57839
|
+
word: HeroTextSchema,
|
|
57840
|
+
tone: _enum(HERO_TONES),
|
|
57841
|
+
since: number$1().nullable(),
|
|
57842
|
+
sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
|
|
57843
|
+
historyKey: string().nullable()
|
|
57844
|
+
});
|
|
57845
|
+
var same$2 = (text) => t(text, text);
|
|
57846
|
+
var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
|
|
57847
|
+
var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
|
|
57848
|
+
function temperatureBand(celsius) {
|
|
57849
|
+
if (celsius < 12) return "cold";
|
|
57850
|
+
if (celsius > 28) return "hot";
|
|
57851
|
+
return "mild";
|
|
57852
|
+
}
|
|
57853
|
+
var BAND_WORD = {
|
|
57854
|
+
hot: t("Hot", "Caldo"),
|
|
57855
|
+
mild: t("Normal", "Normale"),
|
|
57856
|
+
cold: t("Cold", "Freddo")
|
|
57857
|
+
};
|
|
57858
|
+
var BAND_TONE = {
|
|
57859
|
+
hot: "warning",
|
|
57860
|
+
mild: "muted",
|
|
57861
|
+
cold: "info"
|
|
57862
|
+
};
|
|
57863
|
+
function temperatureMeasurement(celsius, since) {
|
|
57864
|
+
const band = temperatureBand(celsius);
|
|
57865
|
+
return {
|
|
57866
|
+
quantity: "temperature",
|
|
57867
|
+
reading: {
|
|
57868
|
+
value: celsius,
|
|
57869
|
+
quantity: "temperature"
|
|
57870
|
+
},
|
|
57871
|
+
icon: "thermometer",
|
|
57872
|
+
value: same$2(trimmed(celsius, 1)),
|
|
57873
|
+
unit: "°C",
|
|
57874
|
+
band,
|
|
57875
|
+
level: null,
|
|
57876
|
+
word: BAND_WORD[band],
|
|
57877
|
+
tone: BAND_TONE[band],
|
|
57878
|
+
since,
|
|
57879
|
+
sinceKind: "updated",
|
|
57880
|
+
historyKey: "cap:temperature-sensor.temperature"
|
|
57881
|
+
};
|
|
57882
|
+
}
|
|
57883
|
+
function humidityMeasurement(percent, since) {
|
|
57884
|
+
const dry = percent < 30;
|
|
57885
|
+
const humid = percent > 70;
|
|
57886
|
+
return {
|
|
57887
|
+
quantity: "humidity",
|
|
57888
|
+
reading: {
|
|
57889
|
+
value: percent,
|
|
57890
|
+
quantity: "humidity"
|
|
57891
|
+
},
|
|
57892
|
+
icon: "droplets",
|
|
57893
|
+
value: same$2(String(Math.round(percent))),
|
|
57894
|
+
unit: "%",
|
|
57895
|
+
band: null,
|
|
57896
|
+
level: clamp01$1(percent / 100),
|
|
57897
|
+
word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
|
|
57898
|
+
tone: dry || humid ? "warning" : "info",
|
|
57899
|
+
since,
|
|
57900
|
+
sinceKind: "updated",
|
|
57901
|
+
historyKey: "cap:humidity-sensor.humidity"
|
|
57902
|
+
};
|
|
57903
|
+
}
|
|
57904
|
+
function textMeasurement(text, since) {
|
|
57905
|
+
return {
|
|
57906
|
+
quantity: "text",
|
|
57907
|
+
reading: null,
|
|
57908
|
+
icon: null,
|
|
57909
|
+
value: same$2(text),
|
|
57910
|
+
unit: null,
|
|
57911
|
+
band: null,
|
|
57912
|
+
level: null,
|
|
57913
|
+
word: t("Changed", "Cambiato"),
|
|
57914
|
+
tone: "muted",
|
|
57915
|
+
since,
|
|
57916
|
+
sinceKind: "updated",
|
|
57917
|
+
historyKey: null
|
|
57918
|
+
};
|
|
57919
|
+
}
|
|
57033
57920
|
/** The scene as the model carries it. `null` = the device did not say (never a guess). */
|
|
57034
57921
|
var HeroSceneSchema = object({
|
|
57035
57922
|
id: _enum([
|
|
@@ -57080,12 +57967,7 @@ var HeroSceneSchema = object({
|
|
|
57080
57967
|
level: number$1().min(0).max(1).nullable()
|
|
57081
57968
|
});
|
|
57082
57969
|
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
57083
|
-
DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
|
|
57084
|
-
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
57085
|
-
var HeroTextSchema = object({
|
|
57086
|
-
en: string(),
|
|
57087
|
-
it: string()
|
|
57088
|
-
});
|
|
57970
|
+
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;
|
|
57089
57971
|
var HeroRowIdSchema = _enum([
|
|
57090
57972
|
"progress",
|
|
57091
57973
|
"run-for",
|
|
@@ -57191,6 +58073,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
|
|
|
57191
58073
|
optionLabels: record(string(), HeroTextSchema).optional(),
|
|
57192
58074
|
call: HeroCallSchema,
|
|
57193
58075
|
valueArg: string()
|
|
58076
|
+
}),
|
|
58077
|
+
object({
|
|
58078
|
+
kind: literal("number"),
|
|
58079
|
+
id: string(),
|
|
58080
|
+
label: HeroTextSchema,
|
|
58081
|
+
value: number$1().nullable(),
|
|
58082
|
+
/** `null` = any number; the device rounds what it does not accept. */
|
|
58083
|
+
step: number$1().nullable(),
|
|
58084
|
+
unit: string(),
|
|
58085
|
+
call: HeroCallSchema,
|
|
58086
|
+
valueArg: string()
|
|
58087
|
+
}),
|
|
58088
|
+
object({
|
|
58089
|
+
kind: literal("text"),
|
|
58090
|
+
id: string(),
|
|
58091
|
+
label: HeroTextSchema,
|
|
58092
|
+
value: string().nullable(),
|
|
58093
|
+
call: HeroCallSchema,
|
|
58094
|
+
valueArg: string()
|
|
57194
58095
|
})
|
|
57195
58096
|
]);
|
|
57196
58097
|
/** Declared by its interface: a `z.infer` of one more icon union pushes the cap's inferred type past what the compiler can print. */
|
|
@@ -57392,6 +58293,11 @@ var HeroModelSchema = object({
|
|
|
57392
58293
|
timedRun: HeroTimedRunSlotSchema.nullable(),
|
|
57393
58294
|
powerSupply: HeroPowerSupplySlotSchema.nullable(),
|
|
57394
58295
|
rows: array(HeroRowSchema),
|
|
58296
|
+
/**
|
|
58297
|
+
* The ONE measurement of a simple sensor, drawn once inside the scene in place of
|
|
58298
|
+
* the caption, tiles and value chips. Absent = the card draws as before.
|
|
58299
|
+
*/
|
|
58300
|
+
measurement: HeroMeasurementSchema.optional(),
|
|
57395
58301
|
/** Ids of parts that actuate the device, hidden from a session that may not act on it. */
|
|
57396
58302
|
gated: array(string()),
|
|
57397
58303
|
provenance: array(HeroProvenanceSchema)
|
|
@@ -57463,8 +58369,23 @@ var HeroRowModelSchema = object({
|
|
|
57463
58369
|
* the call. Absent or empty = `primary` alone.
|
|
57464
58370
|
*/
|
|
57465
58371
|
extras: array(HeroControlSchema).max(2).optional(),
|
|
57466
|
-
trailing: HeroFactSchema.nullable()
|
|
58372
|
+
trailing: HeroFactSchema.nullable(),
|
|
58373
|
+
/**
|
|
58374
|
+
* The simple sensor's one reading (the hero's `measurement`): the row draws its value
|
|
58375
|
+
* at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
|
|
58376
|
+
* older server or a device that is not a simple sensor: draw `trailing`.
|
|
58377
|
+
*/
|
|
58378
|
+
measurement: HeroMeasurementSchema.optional()
|
|
57467
58379
|
});
|
|
58380
|
+
new Set([
|
|
58381
|
+
"temperature",
|
|
58382
|
+
"humidity",
|
|
58383
|
+
"pressure",
|
|
58384
|
+
"illuminance",
|
|
58385
|
+
"reading",
|
|
58386
|
+
"air-quality",
|
|
58387
|
+
"valve"
|
|
58388
|
+
]);
|
|
57468
58389
|
DeviceType.Climate;
|
|
57469
58390
|
DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
|
|
57470
58391
|
/**
|
|
@@ -57781,6 +58702,12 @@ var IntegrationLiteSchema = object({
|
|
|
57781
58702
|
var AvailableIntegrationTypeSchema = object({
|
|
57782
58703
|
addonId: string(),
|
|
57783
58704
|
name: string(),
|
|
58705
|
+
/**
|
|
58706
|
+
* Product name a new integration is prefilled from (`<label> - Home`).
|
|
58707
|
+
* Absent: the client uses `name`. Set when the catalog title is not the
|
|
58708
|
+
* product (Bosch SHC, MQTT).
|
|
58709
|
+
*/
|
|
58710
|
+
providerLabel: string().optional(),
|
|
57784
58711
|
description: string(),
|
|
57785
58712
|
iconUrl: string().nullable(),
|
|
57786
58713
|
color: string(),
|
|
@@ -58292,13 +59219,32 @@ var IrSendResultSchema = object({
|
|
|
58292
59219
|
var IrTransmitterInfoSchema = object({
|
|
58293
59220
|
media: array(IrMediumSchema),
|
|
58294
59221
|
settable: array(TransmitSettingKeySchema),
|
|
58295
|
-
maxTimings: number$1().int().positive()
|
|
59222
|
+
maxTimings: number$1().int().positive(),
|
|
59223
|
+
/** The transmitter can learn a code (`learn`). */
|
|
59224
|
+
learn: boolean().default(false),
|
|
59225
|
+
/** Native code formats the transmitter replays verbatim (`send.native`). */
|
|
59226
|
+
formats: array(IrNativeFormatSchema).default([])
|
|
59227
|
+
});
|
|
59228
|
+
var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
|
|
59229
|
+
var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
|
|
59230
|
+
var IrLearnResultSchema = object({
|
|
59231
|
+
/** The code in the device's own format, when it reports one. */
|
|
59232
|
+
native: IrNativeCodeSchema.nullable(),
|
|
59233
|
+
timings: IrTimingsSchema,
|
|
59234
|
+
carrierHz: number$1().int().positive().nullable()
|
|
58296
59235
|
});
|
|
58297
59236
|
DeviceType.Generic, method(object({
|
|
58298
59237
|
deviceId: number$1().int().nonnegative(),
|
|
58299
|
-
timings: IrTimingsSchema,
|
|
59238
|
+
timings: IrTimingsSchema.optional(),
|
|
59239
|
+
native: IrNativeCodeSchema.optional(),
|
|
58300
59240
|
settings: TransmitSettingsSchema.optional()
|
|
58301
|
-
}), IrSendResultSchema, {
|
|
59241
|
+
}).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
|
|
59242
|
+
kind: "mutation",
|
|
59243
|
+
auth: "protected"
|
|
59244
|
+
}), method(object({
|
|
59245
|
+
deviceId: number$1().int().nonnegative(),
|
|
59246
|
+
timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
|
|
59247
|
+
}), IrLearnResultSchema, {
|
|
58302
59248
|
kind: "mutation",
|
|
58303
59249
|
auth: "protected"
|
|
58304
59250
|
}), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
|
|
@@ -67521,6 +68467,7 @@ var NcSystemEventKindSchema = _enum([
|
|
|
67521
68467
|
"recording-degraded",
|
|
67522
68468
|
"device-attention-required",
|
|
67523
68469
|
"device-attention-resolved",
|
|
68470
|
+
"device-command",
|
|
67524
68471
|
"storage-location-low",
|
|
67525
68472
|
"storage-location-critical",
|
|
67526
68473
|
"storage-location-ok",
|
|
@@ -67583,11 +68530,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
|
|
|
67583
68530
|
"alarm-sensor-bypass",
|
|
67584
68531
|
"alarm-disarmed"
|
|
67585
68532
|
];
|
|
67586
|
-
/**
|
|
67587
|
-
* One coherent system-event condition. `kinds` is the required opt-in safety
|
|
67588
|
-
* gate; the remaining lists are optional narrowing filters relevant to the
|
|
67589
|
-
* selected kinds.
|
|
67590
|
-
*/
|
|
67591
68533
|
var NcSystemEventConditionSchema = object({
|
|
67592
68534
|
kinds: array(NcSystemEventKindSchema).min(1),
|
|
67593
68535
|
deviceIds: array(number$1().int()).min(1).optional(),
|
|
@@ -67619,6 +68561,28 @@ var NcSystemEventConditionSchema = object({
|
|
|
67619
68561
|
nodeIds: array(string().min(1)).min(1).optional(),
|
|
67620
68562
|
packageNames: array(string().min(1)).min(1).optional(),
|
|
67621
68563
|
/**
|
|
68564
|
+
* `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
|
|
68565
|
+
* this rule speaks about - the same dictionary the automation action blocks
|
|
68566
|
+
* pick from. The hub refuses an id the action index does not know.
|
|
68567
|
+
*/
|
|
68568
|
+
commandActions: array(string().min(1)).min(1).optional(),
|
|
68569
|
+
/** `device-command` only: how the command settled. A device's own change is not a command. */
|
|
68570
|
+
commandOutcomes: array(_enum([
|
|
68571
|
+
"confirmed",
|
|
68572
|
+
"already",
|
|
68573
|
+
"unconfirmed",
|
|
68574
|
+
"failed"
|
|
68575
|
+
])).min(1).optional(),
|
|
68576
|
+
/** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
|
|
68577
|
+
commandActorKinds: array(_enum([
|
|
68578
|
+
"user",
|
|
68579
|
+
"addon",
|
|
68580
|
+
"action",
|
|
68581
|
+
"scheduler",
|
|
68582
|
+
"composition",
|
|
68583
|
+
"node"
|
|
68584
|
+
])).min(1).optional(),
|
|
68585
|
+
/**
|
|
67622
68586
|
* At or below this remaining-life %, a consumable is LOW for THIS rule
|
|
67623
68587
|
* (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
|
|
67624
68588
|
* {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
|
|
@@ -68599,6 +69563,13 @@ var NcRuleInputSchema = object({
|
|
|
68599
69563
|
*/
|
|
68600
69564
|
groupingSec: number$1().int().min(5).max(60).optional(),
|
|
68601
69565
|
/**
|
|
69566
|
+
* Hold deliveries of this rule to one target and, when two or more arrive
|
|
69567
|
+
* before the window ends, send them as one summary. Absent = the kind's
|
|
69568
|
+
* default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
|
|
69569
|
+
* other kind. `0` sends each delivery as it does today.
|
|
69570
|
+
*/
|
|
69571
|
+
groupWithinSec: number$1().int().min(0).max(300).optional(),
|
|
69572
|
+
/**
|
|
68602
69573
|
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
68603
69574
|
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
68604
69575
|
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
@@ -69035,7 +70006,12 @@ var NcHistoryEntrySchema = object({
|
|
|
69035
70006
|
* Assistant export) must render as "no image right now", never as a
|
|
69036
70007
|
* broken link.
|
|
69037
70008
|
*/
|
|
69038
|
-
artifactIds: array(string().min(1)).optional()
|
|
70009
|
+
artifactIds: array(string().min(1)).optional(),
|
|
70010
|
+
/**
|
|
70011
|
+
* When this row was folded into a group-window summary, the outbox id of
|
|
70012
|
+
* that one notification. Absent on a row that was sent as itself.
|
|
70013
|
+
*/
|
|
70014
|
+
groupedInto: string().min(1).optional()
|
|
69039
70015
|
});
|
|
69040
70016
|
/**
|
|
69041
70017
|
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
@@ -69922,7 +70898,18 @@ var OauthIntegrationDescriptorSchema = object({
|
|
|
69922
70898
|
* The value is baked into the authorization code at `/authorize` and travels
|
|
69923
70899
|
* on the tokens, so editing this field changes FUTURE links only.
|
|
69924
70900
|
*/
|
|
69925
|
-
refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional()
|
|
70901
|
+
refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional(),
|
|
70902
|
+
/**
|
|
70903
|
+
* The integration instances an account can be linked to (planning#415),
|
|
70904
|
+
* beside the default one. `/api/oauth2/authorize?instance=<id>` is accepted
|
|
70905
|
+
* only for an id listed here; with no `instance=` the link is made to the
|
|
70906
|
+
* default instance, which is never listed and always accepted — it is the
|
|
70907
|
+
* address third parties already hold. Omit for a single-instance integration.
|
|
70908
|
+
*/
|
|
70909
|
+
instances: array(object({
|
|
70910
|
+
id: string(),
|
|
70911
|
+
displayName: string()
|
|
70912
|
+
})).optional()
|
|
69926
70913
|
});
|
|
69927
70914
|
method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
|
|
69928
70915
|
/**
|
|
@@ -74664,10 +75651,15 @@ var RecordingSignalStatusSchema = object({
|
|
|
74664
75651
|
});
|
|
74665
75652
|
RecordingSignalStatusSchema.extend({ lastFetchedAt: number$1() });
|
|
74666
75653
|
DeviceType.Camera, method(object({ deviceId: number$1() }), RecordingSignalStatusSchema);
|
|
74667
|
-
var RemoteBindingSchema = object({ action:
|
|
74668
|
-
|
|
74669
|
-
|
|
74670
|
-
|
|
75654
|
+
var RemoteBindingSchema = object({ action: object({
|
|
75655
|
+
kind: literal("cap"),
|
|
75656
|
+
deviceId: number$1().int().nonnegative(),
|
|
75657
|
+
cap: string().min(1),
|
|
75658
|
+
method: string().min(1),
|
|
75659
|
+
args: record(string(), unknown()).optional(),
|
|
75660
|
+
/** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
|
|
75661
|
+
argUnits: record(string(), string().min(1)).optional()
|
|
75662
|
+
}) });
|
|
74671
75663
|
var RemoteCustomButtonSchema = object({
|
|
74672
75664
|
/** The slug after `custom:` in the role. */
|
|
74673
75665
|
key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
|
|
@@ -76244,6 +77236,13 @@ var SsoBridgeClaimsSchema = object({
|
|
|
76244
77236
|
/** OAuth authorization-code binding — set only on `oauth-code` tokens. */
|
|
76245
77237
|
redirectUri: string().optional(),
|
|
76246
77238
|
integrationId: string().optional(),
|
|
77239
|
+
/**
|
|
77240
|
+
* The integration INSTANCE an OAuth link was made for (planning#415). Set on
|
|
77241
|
+
* `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
|
|
77242
|
+
* with `instance=`; absent on a link to the default instance. A cloud relay
|
|
77243
|
+
* reads it off the access token to route; the hub answers from the session.
|
|
77244
|
+
*/
|
|
77245
|
+
instanceId: string().optional(),
|
|
76247
77246
|
/** JWT ID — unique per issued code; consumed-set enforces single-use. */
|
|
76248
77247
|
jti: string().optional(),
|
|
76249
77248
|
/** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
|
|
@@ -78325,6 +79324,8 @@ var OauthSessionSummarySchema = object({
|
|
|
78325
79324
|
userId: string(),
|
|
78326
79325
|
username: string(),
|
|
78327
79326
|
integrationId: string(),
|
|
79327
|
+
/** The instance the link was made for; `null` = the default instance. */
|
|
79328
|
+
instanceId: string().nullable().optional(),
|
|
78328
79329
|
scopes: array(TokenScopeSchema),
|
|
78329
79330
|
createdAt: number$1(),
|
|
78330
79331
|
lastUsedAt: number$1(),
|
|
@@ -78424,6 +79425,9 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
|
|
|
78424
79425
|
access: "view"
|
|
78425
79426
|
}), method(object({
|
|
78426
79427
|
integrationId: string(),
|
|
79428
|
+
/** The integration instance the link is for. Omit for the default
|
|
79429
|
+
* instance — never pass the addon id to mean it. */
|
|
79430
|
+
instanceId: string().optional(),
|
|
78427
79431
|
userId: string(),
|
|
78428
79432
|
username: string(),
|
|
78429
79433
|
scopes: array(TokenScopeSchema),
|
|
@@ -78462,7 +79466,13 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(_void(), ob
|
|
|
78462
79466
|
}), method(object({ token: string() }), object({
|
|
78463
79467
|
userId: string(),
|
|
78464
79468
|
username: string(),
|
|
78465
|
-
scopes: array(TokenScopeSchema)
|
|
79469
|
+
scopes: array(TokenScopeSchema),
|
|
79470
|
+
/** The instance the link was made for, read from the SESSION.
|
|
79471
|
+
* Absent = the default instance. `oauthLinkServesInstance` is the
|
|
79472
|
+
* helper a per-instance route calls to compare it with the instance
|
|
79473
|
+
* of its path; no route declares `perInstance` yet (the Alexa
|
|
79474
|
+
* per-instance route, T3, is the first consumer). */
|
|
79475
|
+
instanceId: string().optional()
|
|
78466
79476
|
}).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
|
|
78467
79477
|
userId: string(),
|
|
78468
79478
|
issuer: string()
|
|
@@ -80062,8 +81072,6 @@ var AccessoryKind = {
|
|
|
80062
81072
|
};
|
|
80063
81073
|
AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
|
|
80064
81074
|
DeviceType.HeatPump;
|
|
80065
|
-
DeviceType.Climate;
|
|
80066
|
-
DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
|
|
80067
81075
|
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;
|
|
80068
81076
|
new Set(Object.values(DeviceType));
|
|
80069
81077
|
/** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
|
|
@@ -80076,6 +81084,13 @@ function contribution(cap, schema, build) {
|
|
|
80076
81084
|
}
|
|
80077
81085
|
};
|
|
80078
81086
|
}
|
|
81087
|
+
/** The fragment, carrying the cap's single measurement when it has one. */
|
|
81088
|
+
function measured(fragment, measurement) {
|
|
81089
|
+
return measurement === void 0 ? fragment : {
|
|
81090
|
+
...fragment,
|
|
81091
|
+
measurement
|
|
81092
|
+
};
|
|
81093
|
+
}
|
|
80079
81094
|
function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
|
|
80080
81095
|
return {
|
|
80081
81096
|
id,
|
|
@@ -81350,10 +82365,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
|
|
|
81350
82365
|
};
|
|
81351
82366
|
});
|
|
81352
82367
|
var CONTROL_LABEL = t("Value", "Valore");
|
|
81353
|
-
/**
|
|
82368
|
+
/**
|
|
82369
|
+
* A number with known bounds is a slider, one without a number field, a choice a picker,
|
|
82370
|
+
* free text a text field; a date stays read-only.
|
|
82371
|
+
*/
|
|
81354
82372
|
function controlRows(slice) {
|
|
81355
82373
|
if (slice.kind === "numeric" && typeof slice.value === "number") {
|
|
81356
|
-
if (slice.min === void 0 || slice.max === void 0) return [
|
|
82374
|
+
if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
|
|
82375
|
+
kind: "number",
|
|
82376
|
+
id: "control.value",
|
|
82377
|
+
label: CONTROL_LABEL,
|
|
82378
|
+
value: slice.value,
|
|
82379
|
+
step: slice.step ?? null,
|
|
82380
|
+
unit: "",
|
|
82381
|
+
call: {
|
|
82382
|
+
cap: "control",
|
|
82383
|
+
method: "setValue",
|
|
82384
|
+
args: { control: { kind: "numeric" } }
|
|
82385
|
+
},
|
|
82386
|
+
valueArg: "control.value"
|
|
82387
|
+
}])];
|
|
81357
82388
|
return [row$1("control", "sliders-horizontal", null, [{
|
|
81358
82389
|
kind: "slider",
|
|
81359
82390
|
id: "control.value",
|
|
@@ -81384,6 +82415,18 @@ function controlRows(slice) {
|
|
|
81384
82415
|
},
|
|
81385
82416
|
valueArg: "control.value"
|
|
81386
82417
|
}])];
|
|
82418
|
+
if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
|
|
82419
|
+
kind: "text",
|
|
82420
|
+
id: "control.value",
|
|
82421
|
+
label: CONTROL_LABEL,
|
|
82422
|
+
value: typeof slice.value === "string" ? slice.value : null,
|
|
82423
|
+
call: {
|
|
82424
|
+
cap: "control",
|
|
82425
|
+
method: "setValue",
|
|
82426
|
+
args: { control: { kind: "text" } }
|
|
82427
|
+
},
|
|
82428
|
+
valueArg: "control.value"
|
|
82429
|
+
}])];
|
|
81387
82430
|
return [];
|
|
81388
82431
|
}
|
|
81389
82432
|
var SENSORS_FAMILY_CONTRIBUTIONS = {
|
|
@@ -81739,15 +82782,15 @@ function sensorFragment(value, id, icon, en, it, text) {
|
|
|
81739
82782
|
tiles: { right: [tile$1(en, it, text)] }
|
|
81740
82783
|
};
|
|
81741
82784
|
}
|
|
81742
|
-
var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
|
|
81743
|
-
var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`));
|
|
82785
|
+
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)));
|
|
82786
|
+
var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => measured(sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`), slice?.humidity == null ? void 0 : humidityMeasurement(slice.humidity, slice.lastFetchedAt)));
|
|
81744
82787
|
var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
|
|
81745
82788
|
var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
|
|
81746
82789
|
var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
|
|
81747
82790
|
var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
|
|
81748
82791
|
if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
|
|
81749
82792
|
if (slice.timestamp === true) return { reading: reading("sensor", "on") };
|
|
81750
|
-
return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
|
|
82793
|
+
return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
|
|
81751
82794
|
});
|
|
81752
82795
|
/** Index bands: the headline of an air-quality sensor is a word, not a number. */
|
|
81753
82796
|
function airQualityWord(aqi) {
|
|
@@ -82716,7 +83759,7 @@ lookOf({
|
|
|
82716
83759
|
});
|
|
82717
83760
|
DeviceType.Climate;
|
|
82718
83761
|
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;
|
|
82719
|
-
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;
|
|
83762
|
+
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;
|
|
82720
83763
|
Object.freeze({
|
|
82721
83764
|
"accessories.getStatus": {
|
|
82722
83765
|
capName: "accessories",
|
|
@@ -84643,6 +85686,13 @@ Object.freeze({
|
|
|
84643
85686
|
access: "view",
|
|
84644
85687
|
role: "admin"
|
|
84645
85688
|
},
|
|
85689
|
+
"deviceExport.setExposedName": {
|
|
85690
|
+
capName: "device-export",
|
|
85691
|
+
capScope: "system",
|
|
85692
|
+
addonId: null,
|
|
85693
|
+
access: "create",
|
|
85694
|
+
role: "admin"
|
|
85695
|
+
},
|
|
84646
85696
|
"deviceExport.unexposeDevice": {
|
|
84647
85697
|
capName: "device-export",
|
|
84648
85698
|
capScope: "system",
|
|
@@ -86582,6 +87632,13 @@ Object.freeze({
|
|
|
86582
87632
|
access: "view",
|
|
86583
87633
|
role: "viewer"
|
|
86584
87634
|
},
|
|
87635
|
+
"irTransmitter.learn": {
|
|
87636
|
+
capName: "ir-transmitter",
|
|
87637
|
+
capScope: "device",
|
|
87638
|
+
addonId: null,
|
|
87639
|
+
access: "create",
|
|
87640
|
+
role: "viewer"
|
|
87641
|
+
},
|
|
86585
87642
|
"irTransmitter.send": {
|
|
86586
87643
|
capName: "ir-transmitter",
|
|
86587
87644
|
capScope: "device",
|
|
@@ -93100,48 +94157,6 @@ Object.freeze({
|
|
|
93100
94157
|
role: "admin"
|
|
93101
94158
|
}
|
|
93102
94159
|
});
|
|
93103
|
-
/**
|
|
93104
|
-
* "Do" actions an operator can pick for a device — presentation-free.
|
|
93105
|
-
*
|
|
93106
|
-
* The wire shape stays `{ cap, method, args }`. Since D920 this module no
|
|
93107
|
-
* longer HOLDS a catalogue: {@link DEVICE_DO_ACTIONS} is a projection of the
|
|
93108
|
-
* cap vocabulary (`cap-vocabulary/`), the one cap-keyed map of every action
|
|
93109
|
-
* and trigger — so a picker built on this module and one built on
|
|
93110
|
-
* `actionsForDevice` (the vocabulary resolver) can never disagree about what
|
|
93111
|
-
* a device can do. Ids, baked args and the matching of saved steps are the
|
|
93112
|
-
* vocabulary's; labels here are its English labels.
|
|
93113
|
-
*
|
|
93114
|
-
* Shared by the admin NC Sequences / rule Do editor and Automations; the
|
|
93115
|
-
* viewer can reuse the same catalogue once its step editor catches up.
|
|
93116
|
-
*/
|
|
93117
|
-
function openArgKind(offer) {
|
|
93118
|
-
if (offer.kind === "number") return "number";
|
|
93119
|
-
if (offer.kind === "dynamic" && offer.valueKind === "number") return "number";
|
|
93120
|
-
if (offer.kind === "enum" && offer.values.every((v) => typeof v.value === "number")) return "number";
|
|
93121
|
-
return "string";
|
|
93122
|
-
}
|
|
93123
|
-
function projectOpenArg(arg) {
|
|
93124
|
-
return {
|
|
93125
|
-
key: arg.key,
|
|
93126
|
-
label: arg.label.en,
|
|
93127
|
-
kind: openArgKind(arg.offer),
|
|
93128
|
-
offer: arg.offer,
|
|
93129
|
-
...arg.optional === true ? { optional: true } : {}
|
|
93130
|
-
};
|
|
93131
|
-
}
|
|
93132
|
-
function projectAction(cap, action) {
|
|
93133
|
-
const open = action.openArgs ?? [];
|
|
93134
|
-
return {
|
|
93135
|
-
id: action.id,
|
|
93136
|
-
label: action.label.en,
|
|
93137
|
-
cap,
|
|
93138
|
-
method: action.method,
|
|
93139
|
-
args: action.args ?? {},
|
|
93140
|
-
...open.length > 0 ? { openArgs: open.map(projectOpenArg) } : {}
|
|
93141
|
-
};
|
|
93142
|
-
}
|
|
93143
|
-
Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
|
|
93144
|
-
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
93145
94160
|
DeviceFeature.BatteryOperated;
|
|
93146
94161
|
function bound(cap, methods = [], authority = "reported") {
|
|
93147
94162
|
return {
|
|
@@ -94458,6 +95473,11 @@ Object.freeze({
|
|
|
94458
95473
|
form: "single",
|
|
94459
95474
|
optional: false
|
|
94460
95475
|
}],
|
|
95476
|
+
"irTransmitter.learn": [{
|
|
95477
|
+
name: "deviceId",
|
|
95478
|
+
form: "single",
|
|
95479
|
+
optional: false
|
|
95480
|
+
}],
|
|
94461
95481
|
"irTransmitter.send": [{
|
|
94462
95482
|
name: "deviceId",
|
|
94463
95483
|
form: "single",
|
|
@@ -96397,7 +97417,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
|
|
|
96397
97417
|
"deviceTypes",
|
|
96398
97418
|
"nodeIds",
|
|
96399
97419
|
"packageNames",
|
|
96400
|
-
"consumableLowPercent"
|
|
97420
|
+
"consumableLowPercent",
|
|
97421
|
+
"commandActions",
|
|
97422
|
+
"commandOutcomes",
|
|
97423
|
+
"commandActorKinds"
|
|
96401
97424
|
];
|
|
96402
97425
|
new Map(Object.entries({
|
|
96403
97426
|
"device-online": "device-events",
|
|
@@ -96420,6 +97443,7 @@ new Map(Object.entries({
|
|
|
96420
97443
|
"recording-degraded": "device-events",
|
|
96421
97444
|
"device-attention-required": "device-events",
|
|
96422
97445
|
"device-attention-resolved": "device-events",
|
|
97446
|
+
"device-command": "device-events",
|
|
96423
97447
|
"node-online": "system",
|
|
96424
97448
|
"node-offline": "system",
|
|
96425
97449
|
"node-restarting": "system",
|
|
@@ -96520,6 +97544,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
|
|
|
96520
97544
|
label: "Needs attention",
|
|
96521
97545
|
kinds: ["device-attention-required", "device-attention-resolved"]
|
|
96522
97546
|
},
|
|
97547
|
+
{
|
|
97548
|
+
id: "device-command",
|
|
97549
|
+
family: "device-events",
|
|
97550
|
+
label: "Commands given to devices",
|
|
97551
|
+
kinds: ["device-command"]
|
|
97552
|
+
},
|
|
96523
97553
|
{
|
|
96524
97554
|
id: "nodes",
|
|
96525
97555
|
family: "system",
|
|
@@ -96597,6 +97627,15 @@ function systemEventKindsOfFamily(family) {
|
|
|
96597
97627
|
return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
|
|
96598
97628
|
}
|
|
96599
97629
|
NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
|
|
97630
|
+
new Set([
|
|
97631
|
+
"alarm.trigger",
|
|
97632
|
+
"alarm.disarm",
|
|
97633
|
+
"alarm.arm.home",
|
|
97634
|
+
"alarm.arm.away",
|
|
97635
|
+
"alarm.arm.night",
|
|
97636
|
+
"alarm.arm.vacation",
|
|
97637
|
+
"alarm.arm.custom_bypass"
|
|
97638
|
+
]);
|
|
96600
97639
|
/**
|
|
96601
97640
|
* WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
|
|
96602
97641
|
* persists (D640 "a sensor rule fires on the raise, the clear, or both").
|
|
@@ -96792,6 +97831,7 @@ var DEVICE_EVENTS = [
|
|
|
96792
97831
|
"recording-healthy",
|
|
96793
97832
|
"recording-degraded",
|
|
96794
97833
|
...DEVICE_ATTENTION,
|
|
97834
|
+
"device-command",
|
|
96795
97835
|
...ALARM
|
|
96796
97836
|
];
|
|
96797
97837
|
/** Every kind a summary may speak about — the two summarisable families. */
|
|
@@ -96945,6 +97985,9 @@ var STATE_SUMMARY_VARS = [
|
|
|
96945
97985
|
[...RULE_BODY_ONLY],
|
|
96946
97986
|
[...RULE_TEXT],
|
|
96947
97987
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
97988
|
+
[...RULE_TEXT],
|
|
97989
|
+
[...RULE_TEXT],
|
|
97990
|
+
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
96948
97991
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96949
97992
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
96950
97993
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
@@ -145072,6 +146115,160 @@ function carryForward(base, existing, keys) {
|
|
|
145072
146115
|
}
|
|
145073
146116
|
return out;
|
|
145074
146117
|
}
|
|
146118
|
+
/**
|
|
146119
|
+
* hap-nodejs' `checkName` regex, verbatim.
|
|
146120
|
+
*
|
|
146121
|
+
* Duplicated rather than imported because it is `@private Private API` in that
|
|
146122
|
+
* package and not exported. Duplicating a private regex is a liability, so the
|
|
146123
|
+
* guard against drift is behavioural, not textual: `service-naming.spec.ts`
|
|
146124
|
+
* builds real services and asserts hap-nodejs emits ZERO characteristic
|
|
146125
|
+
* warnings — if this expression ever diverges from theirs, that test fails.
|
|
146126
|
+
*/
|
|
146127
|
+
var HAP_NAME_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N}\p{Zs}’'&!._:;()/,-]*[\p{L}\p{N}]$/u;
|
|
146128
|
+
/** Characters HAP tolerates INSIDE a name. Anything else becomes a space. */
|
|
146129
|
+
var HAP_NAME_INNER = /[^\p{L}\p{N}\p{Zs}’'&!._:;()/,-]/gu;
|
|
146130
|
+
/** Would hap-nodejs accept this as a `Name` characteristic value? */
|
|
146131
|
+
function isHapServiceName(value) {
|
|
146132
|
+
return HAP_NAME_PATTERN.test(value);
|
|
146133
|
+
}
|
|
146134
|
+
/**
|
|
146135
|
+
* Build one HAP-valid service name from device-derived parts.
|
|
146136
|
+
*
|
|
146137
|
+
* Empty and absent parts are dropped rather than joined, so a missing role
|
|
146138
|
+
* never produces a double space. `fallback` is used ONLY when nothing
|
|
146139
|
+
* device-derived survives sanitisation — it is the last resort, not the
|
|
146140
|
+
* default, because a name that says nothing about the device is the defect
|
|
146141
|
+
* this module exists to end.
|
|
146142
|
+
*/
|
|
146143
|
+
function hapServiceName(parts, fallback) {
|
|
146144
|
+
const trimmed = trimToHapName(parts.map((part) => typeof part === "string" ? part : "").map((part) => part.replace(HAP_NAME_INNER, " ")).join(" ").replace(/\s+/gu, " ").trim());
|
|
146145
|
+
if (trimmed !== null) return trimmed;
|
|
146146
|
+
return trimToHapName(fallback.replace(HAP_NAME_INNER, " ").replace(/\s+/gu, " ").trim()) ?? "";
|
|
146147
|
+
}
|
|
146148
|
+
/**
|
|
146149
|
+
* The privacy-mask switch.
|
|
146150
|
+
*
|
|
146151
|
+
* Just "Privacy". The camera name is NOT prefixed: this service lives inside
|
|
146152
|
+
* the camera's own accessory, iOS already renders it under the camera, and a
|
|
146153
|
+
* round that prefixed it gave the operator "Camera front door Privacy"
|
|
146154
|
+
* sitting inside a tile titled "Camera front door".
|
|
146155
|
+
*
|
|
146156
|
+
* The prefix was added for a real reason — two cameras publishing a switch
|
|
146157
|
+
* called "Privacy" — but that was a symptom of the label being the ONLY thing
|
|
146158
|
+
* shown, which stopped being true once `ConfiguredName` made the service
|
|
146159
|
+
* render in its accessory's context. Uniqueness is required WITHIN one
|
|
146160
|
+
* accessory, not across the bridge, and one camera has one privacy switch.
|
|
146161
|
+
*/
|
|
146162
|
+
function privacyServiceName() {
|
|
146163
|
+
return hapServiceName([PRIVACY_SUFFIX], PRIVACY_SUFFIX);
|
|
146164
|
+
}
|
|
146165
|
+
/**
|
|
146166
|
+
* Deliberately not localised, and deliberately not a translation table.
|
|
146167
|
+
*
|
|
146168
|
+
* The device half of the name is the operator's own text and arrives in the
|
|
146169
|
+
* operator's language. This half names a camstack capability (`privacy-mask`)
|
|
146170
|
+
* and there is no locale in an addon's context to resolve it against; the word
|
|
146171
|
+
* is also identical in the operator's language. A translation layer for one
|
|
146172
|
+
* word would be the kind of leftover that reads as verification.
|
|
146173
|
+
*/
|
|
146174
|
+
var PRIVACY_SUFFIX = "Privacy";
|
|
146175
|
+
/**
|
|
146176
|
+
* An accessory child (siren, floodlight, spotlight) rendered as a service on
|
|
146177
|
+
* the parent camera.
|
|
146178
|
+
*
|
|
146179
|
+
* The child's OWN stored name wins. It is the string the operator typed, in
|
|
146180
|
+
* the operator's language, and an early rule threw it away: `role` was
|
|
146181
|
+
* consulted first and title-cased, so every siren on the fleet published as
|
|
146182
|
+
* the English word "Siren" no matter what the operator had called it.
|
|
146183
|
+
*
|
|
146184
|
+
* Providers name children both ways — "Sirena" and "Camera kitchen
|
|
146185
|
+
* Sirena". The parent half is now REMOVED rather than added, because the
|
|
146186
|
+
* service is published inside the parent camera's own accessory and iOS
|
|
146187
|
+
* already shows it there. The result must be one form, not two.
|
|
146188
|
+
*/
|
|
146189
|
+
function childServiceName(parentName, child) {
|
|
146190
|
+
const own = withoutParent(child.name.trim(), parentName);
|
|
146191
|
+
if (own.length > 0) return hapServiceName([own], own);
|
|
146192
|
+
return hapServiceName([typeof child.role === "string" ? titleCase(child.role) : ""], CHILD_FALLBACK);
|
|
146193
|
+
}
|
|
146194
|
+
/**
|
|
146195
|
+
* Last resort for a child that carries neither a name nor a role. Better than
|
|
146196
|
+
* the parent's name, which would publish a service indistinguishable from the
|
|
146197
|
+
* accessory holding it — the exact defect this module keeps being asked to fix.
|
|
146198
|
+
*
|
|
146199
|
+
* English, like the role slugs it stands in for ("Floodlight", "Siren"): the
|
|
146200
|
+
* only strings this module invents are English, and inventing one Italian word
|
|
146201
|
+
* would be a localisation layer that localises nothing.
|
|
146202
|
+
*/
|
|
146203
|
+
var CHILD_FALLBACK = "Accessory";
|
|
146204
|
+
/**
|
|
146205
|
+
* A PTZ action switch: the bare action, "Preset front door" / "Pan Left" /
|
|
146206
|
+
* "Autotrack".
|
|
146207
|
+
*
|
|
146208
|
+
* The labels themselves stay in `ptz-labels.ts` — they name a HomeKit control,
|
|
146209
|
+
* not a device. This function exists only to put the operator-typed half of a
|
|
146210
|
+
* preset name through the same sanitisation everything else gets; it no longer
|
|
146211
|
+
* qualifies the label with the camera, because all eight PTZ services live on
|
|
146212
|
+
* that camera's accessory and are unique among themselves.
|
|
146213
|
+
*/
|
|
146214
|
+
function ptzServiceName(actionLabel) {
|
|
146215
|
+
return hapServiceName([actionLabel], actionLabel);
|
|
146216
|
+
}
|
|
146217
|
+
/**
|
|
146218
|
+
* Drop `parentName` from the front of `name`.
|
|
146219
|
+
*
|
|
146220
|
+
* A PREFIX only. "Camera kitchen Sirena" → "Sirena"; "Sirena" is already
|
|
146221
|
+
* bare and untouched. A parent name appearing anywhere else in the child's
|
|
146222
|
+
* name is left alone — cutting from the middle of a string the operator typed
|
|
146223
|
+
* would mangle it, and this function must never make a label WORSE.
|
|
146224
|
+
*
|
|
146225
|
+
* Returns `name` unchanged when stripping would leave nothing: a child the
|
|
146226
|
+
* operator called exactly what the camera is called still needs a label.
|
|
146227
|
+
*/
|
|
146228
|
+
function withoutParent(name, parentName) {
|
|
146229
|
+
const needle = parentName.trim();
|
|
146230
|
+
if (needle.length === 0) return name;
|
|
146231
|
+
if (!name.toLowerCase().startsWith(needle.toLowerCase())) return name;
|
|
146232
|
+
const rest = name.slice(needle.length).trim();
|
|
146233
|
+
return rest.length > 0 ? rest : name;
|
|
146234
|
+
}
|
|
146235
|
+
/**
|
|
146236
|
+
* Truncate to the HAP ceiling and shave any leading/trailing character the
|
|
146237
|
+
* pattern forbids. Returns `null` when nothing usable is left — the caller
|
|
146238
|
+
* decides what to do with that, because "fall back" and "drop the part" are
|
|
146239
|
+
* different answers.
|
|
146240
|
+
*/
|
|
146241
|
+
function trimToHapName(value) {
|
|
146242
|
+
let out = value.length > 64 ? value.slice(0, 64) : value;
|
|
146243
|
+
while (out.length > 0 && !isAlphanumeric(out[out.length - 1])) out = out.slice(0, -1);
|
|
146244
|
+
while (out.length > 0 && !isAlphanumeric(out[0])) out = out.slice(1);
|
|
146245
|
+
return isHapServiceName(out) ? out : null;
|
|
146246
|
+
}
|
|
146247
|
+
function isAlphanumeric(ch) {
|
|
146248
|
+
return ch !== void 0 && /[\p{L}\p{N}]/u.test(ch);
|
|
146249
|
+
}
|
|
146250
|
+
function titleCase(raw) {
|
|
146251
|
+
return raw.split(/[-_\s]+/u).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
146252
|
+
}
|
|
146253
|
+
//#endregion
|
|
146254
|
+
//#region src/exposed-name.ts
|
|
146255
|
+
/** Apple's rule: at most 64 characters, begins and ends with a letter or digit, HAP punctuation only. */
|
|
146256
|
+
/** HomeKit's rule, as the derived "Name on <bridge>" field states it (D1049). */
|
|
146257
|
+
var HAP_NAME_RULE = `HomeKit takes up to 64 characters, starting and ending with a letter or digit; inside, only letters, digits, spaces and ' & ! . _ : ; ( ) / , -.`;
|
|
146258
|
+
var hapNameValidator = (name) => {
|
|
146259
|
+
if (name.length > 64) return {
|
|
146260
|
+
ok: false,
|
|
146261
|
+
reason: `The HomeKit name is ${name.length} characters; HomeKit allows at most 64.`
|
|
146262
|
+
};
|
|
146263
|
+
if (!isHapServiceName(name)) return {
|
|
146264
|
+
ok: false,
|
|
146265
|
+
reason: "The HomeKit name must begin and end with a letter or digit and may contain only letters, digits, spaces and ' & ! . _ : ; ( ) / , -"
|
|
146266
|
+
};
|
|
146267
|
+
return {
|
|
146268
|
+
ok: true,
|
|
146269
|
+
name
|
|
146270
|
+
};
|
|
146271
|
+
};
|
|
145075
146272
|
//#endregion
|
|
145076
146273
|
//#region src/hap-export-records.ts
|
|
145077
146274
|
/**
|
|
@@ -147592,141 +148789,6 @@ function reader(schema, toUpdates) {
|
|
|
147592
148789
|
function applyUpdates(service, updates) {
|
|
147593
148790
|
for (const update of updates) service.updateCharacteristic(update.characteristic, update.value);
|
|
147594
148791
|
}
|
|
147595
|
-
/**
|
|
147596
|
-
* hap-nodejs' `checkName` regex, verbatim.
|
|
147597
|
-
*
|
|
147598
|
-
* Duplicated rather than imported because it is `@private Private API` in that
|
|
147599
|
-
* package and not exported. Duplicating a private regex is a liability, so the
|
|
147600
|
-
* guard against drift is behavioural, not textual: `service-naming.spec.ts`
|
|
147601
|
-
* builds real services and asserts hap-nodejs emits ZERO characteristic
|
|
147602
|
-
* warnings — if this expression ever diverges from theirs, that test fails.
|
|
147603
|
-
*/
|
|
147604
|
-
var HAP_NAME_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N}\p{Zs}’'&!._:;()/,-]*[\p{L}\p{N}]$/u;
|
|
147605
|
-
/** Characters HAP tolerates INSIDE a name. Anything else becomes a space. */
|
|
147606
|
-
var HAP_NAME_INNER = /[^\p{L}\p{N}\p{Zs}’'&!._:;()/,-]/gu;
|
|
147607
|
-
/** Would hap-nodejs accept this as a `Name` characteristic value? */
|
|
147608
|
-
function isHapServiceName(value) {
|
|
147609
|
-
return HAP_NAME_PATTERN.test(value);
|
|
147610
|
-
}
|
|
147611
|
-
/**
|
|
147612
|
-
* Build one HAP-valid service name from device-derived parts.
|
|
147613
|
-
*
|
|
147614
|
-
* Empty and absent parts are dropped rather than joined, so a missing role
|
|
147615
|
-
* never produces a double space. `fallback` is used ONLY when nothing
|
|
147616
|
-
* device-derived survives sanitisation — it is the last resort, not the
|
|
147617
|
-
* default, because a name that says nothing about the device is the defect
|
|
147618
|
-
* this module exists to end.
|
|
147619
|
-
*/
|
|
147620
|
-
function hapServiceName(parts, fallback) {
|
|
147621
|
-
const trimmed = trimToHapName(parts.map((part) => typeof part === "string" ? part : "").map((part) => part.replace(HAP_NAME_INNER, " ")).join(" ").replace(/\s+/gu, " ").trim());
|
|
147622
|
-
if (trimmed !== null) return trimmed;
|
|
147623
|
-
return trimToHapName(fallback.replace(HAP_NAME_INNER, " ").replace(/\s+/gu, " ").trim()) ?? "";
|
|
147624
|
-
}
|
|
147625
|
-
/**
|
|
147626
|
-
* The privacy-mask switch.
|
|
147627
|
-
*
|
|
147628
|
-
* Just "Privacy". The camera name is NOT prefixed: this service lives inside
|
|
147629
|
-
* the camera's own accessory, iOS already renders it under the camera, and a
|
|
147630
|
-
* round that prefixed it gave the operator "Camera front door Privacy"
|
|
147631
|
-
* sitting inside a tile titled "Camera front door".
|
|
147632
|
-
*
|
|
147633
|
-
* The prefix was added for a real reason — two cameras publishing a switch
|
|
147634
|
-
* called "Privacy" — but that was a symptom of the label being the ONLY thing
|
|
147635
|
-
* shown, which stopped being true once `ConfiguredName` made the service
|
|
147636
|
-
* render in its accessory's context. Uniqueness is required WITHIN one
|
|
147637
|
-
* accessory, not across the bridge, and one camera has one privacy switch.
|
|
147638
|
-
*/
|
|
147639
|
-
function privacyServiceName() {
|
|
147640
|
-
return hapServiceName([PRIVACY_SUFFIX], PRIVACY_SUFFIX);
|
|
147641
|
-
}
|
|
147642
|
-
/**
|
|
147643
|
-
* Deliberately not localised, and deliberately not a translation table.
|
|
147644
|
-
*
|
|
147645
|
-
* The device half of the name is the operator's own text and arrives in the
|
|
147646
|
-
* operator's language. This half names a camstack capability (`privacy-mask`)
|
|
147647
|
-
* and there is no locale in an addon's context to resolve it against; the word
|
|
147648
|
-
* is also identical in the operator's language. A translation layer for one
|
|
147649
|
-
* word would be the kind of leftover that reads as verification.
|
|
147650
|
-
*/
|
|
147651
|
-
var PRIVACY_SUFFIX = "Privacy";
|
|
147652
|
-
/**
|
|
147653
|
-
* An accessory child (siren, floodlight, spotlight) rendered as a service on
|
|
147654
|
-
* the parent camera.
|
|
147655
|
-
*
|
|
147656
|
-
* The child's OWN stored name wins. It is the string the operator typed, in
|
|
147657
|
-
* the operator's language, and an early rule threw it away: `role` was
|
|
147658
|
-
* consulted first and title-cased, so every siren on the fleet published as
|
|
147659
|
-
* the English word "Siren" no matter what the operator had called it.
|
|
147660
|
-
*
|
|
147661
|
-
* Providers name children both ways — "Sirena" and "Camera kitchen
|
|
147662
|
-
* Sirena". The parent half is now REMOVED rather than added, because the
|
|
147663
|
-
* service is published inside the parent camera's own accessory and iOS
|
|
147664
|
-
* already shows it there. The result must be one form, not two.
|
|
147665
|
-
*/
|
|
147666
|
-
function childServiceName(parentName, child) {
|
|
147667
|
-
const own = withoutParent(child.name.trim(), parentName);
|
|
147668
|
-
if (own.length > 0) return hapServiceName([own], own);
|
|
147669
|
-
return hapServiceName([typeof child.role === "string" ? titleCase(child.role) : ""], CHILD_FALLBACK);
|
|
147670
|
-
}
|
|
147671
|
-
/**
|
|
147672
|
-
* Last resort for a child that carries neither a name nor a role. Better than
|
|
147673
|
-
* the parent's name, which would publish a service indistinguishable from the
|
|
147674
|
-
* accessory holding it — the exact defect this module keeps being asked to fix.
|
|
147675
|
-
*
|
|
147676
|
-
* English, like the role slugs it stands in for ("Floodlight", "Siren"): the
|
|
147677
|
-
* only strings this module invents are English, and inventing one Italian word
|
|
147678
|
-
* would be a localisation layer that localises nothing.
|
|
147679
|
-
*/
|
|
147680
|
-
var CHILD_FALLBACK = "Accessory";
|
|
147681
|
-
/**
|
|
147682
|
-
* A PTZ action switch: the bare action, "Preset front door" / "Pan Left" /
|
|
147683
|
-
* "Autotrack".
|
|
147684
|
-
*
|
|
147685
|
-
* The labels themselves stay in `ptz-labels.ts` — they name a HomeKit control,
|
|
147686
|
-
* not a device. This function exists only to put the operator-typed half of a
|
|
147687
|
-
* preset name through the same sanitisation everything else gets; it no longer
|
|
147688
|
-
* qualifies the label with the camera, because all eight PTZ services live on
|
|
147689
|
-
* that camera's accessory and are unique among themselves.
|
|
147690
|
-
*/
|
|
147691
|
-
function ptzServiceName(actionLabel) {
|
|
147692
|
-
return hapServiceName([actionLabel], actionLabel);
|
|
147693
|
-
}
|
|
147694
|
-
/**
|
|
147695
|
-
* Drop `parentName` from the front of `name`.
|
|
147696
|
-
*
|
|
147697
|
-
* A PREFIX only. "Camera kitchen Sirena" → "Sirena"; "Sirena" is already
|
|
147698
|
-
* bare and untouched. A parent name appearing anywhere else in the child's
|
|
147699
|
-
* name is left alone — cutting from the middle of a string the operator typed
|
|
147700
|
-
* would mangle it, and this function must never make a label WORSE.
|
|
147701
|
-
*
|
|
147702
|
-
* Returns `name` unchanged when stripping would leave nothing: a child the
|
|
147703
|
-
* operator called exactly what the camera is called still needs a label.
|
|
147704
|
-
*/
|
|
147705
|
-
function withoutParent(name, parentName) {
|
|
147706
|
-
const needle = parentName.trim();
|
|
147707
|
-
if (needle.length === 0) return name;
|
|
147708
|
-
if (!name.toLowerCase().startsWith(needle.toLowerCase())) return name;
|
|
147709
|
-
const rest = name.slice(needle.length).trim();
|
|
147710
|
-
return rest.length > 0 ? rest : name;
|
|
147711
|
-
}
|
|
147712
|
-
/**
|
|
147713
|
-
* Truncate to the HAP ceiling and shave any leading/trailing character the
|
|
147714
|
-
* pattern forbids. Returns `null` when nothing usable is left — the caller
|
|
147715
|
-
* decides what to do with that, because "fall back" and "drop the part" are
|
|
147716
|
-
* different answers.
|
|
147717
|
-
*/
|
|
147718
|
-
function trimToHapName(value) {
|
|
147719
|
-
let out = value.length > 64 ? value.slice(0, 64) : value;
|
|
147720
|
-
while (out.length > 0 && !isAlphanumeric(out[out.length - 1])) out = out.slice(0, -1);
|
|
147721
|
-
while (out.length > 0 && !isAlphanumeric(out[0])) out = out.slice(1);
|
|
147722
|
-
return isHapServiceName(out) ? out : null;
|
|
147723
|
-
}
|
|
147724
|
-
function isAlphanumeric(ch) {
|
|
147725
|
-
return ch !== void 0 && /[\p{L}\p{N}]/u.test(ch);
|
|
147726
|
-
}
|
|
147727
|
-
function titleCase(raw) {
|
|
147728
|
-
return raw.split(/[-_\s]+/u).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
147729
|
-
}
|
|
147730
148792
|
//#endregion
|
|
147731
148793
|
//#region src/mappers/builders/service-label.ts
|
|
147732
148794
|
/**
|
|
@@ -147905,7 +148967,8 @@ function errMsg$14(err) {
|
|
|
147905
148967
|
* hands this builder the PARENT accessory + the CHILD's proxy + a
|
|
147906
148968
|
* unique subtype so each service round-trips deterministically through
|
|
147907
148969
|
* HAP serialisation. The builder:
|
|
147908
|
-
* - Maps `switch` cap → `Service.Switch
|
|
148970
|
+
* - Maps `switch` cap → `Service.Switch`, or the service the device's switch
|
|
148971
|
+
* sub-role names (`onOffServiceKind`).
|
|
147909
148972
|
* - Maps `switch` + `brightness` cap → `Service.Lightbulb` with
|
|
147910
148973
|
* Brightness characteristic (lighting devices only — see below).
|
|
147911
148974
|
* - Hydrates initial state from `getStatus({})`.
|
|
@@ -147927,7 +148990,21 @@ function errMsg$14(err) {
|
|
|
147927
148990
|
* Child devices without `switch` / `brightness` cap (status sensors,
|
|
147928
148991
|
* IR LED, etc.) return a no-op handle.
|
|
147929
148992
|
*/
|
|
147930
|
-
|
|
148993
|
+
function onOffServiceKind(deviceType, role, hasBrightness) {
|
|
148994
|
+
const isLightingDevice = deviceType === DeviceType.Light || deviceType === DeviceType.Generic;
|
|
148995
|
+
if (hasBrightness && isLightingDevice) return "dimmable-lightbulb";
|
|
148996
|
+
if (isSwitchLight(deviceType, role)) return "lightbulb";
|
|
148997
|
+
if (isOutlet(deviceType, role)) return "outlet";
|
|
148998
|
+
if (isSwitchFan(deviceType, role)) return "fan";
|
|
148999
|
+
return "switch";
|
|
149000
|
+
}
|
|
149001
|
+
function addOnOffService(accessory, kind, displayName, subtype) {
|
|
149002
|
+
if (kind === "dimmable-lightbulb" || kind === "lightbulb") return accessory.addService(import_dist.Service.Lightbulb, displayName, subtype);
|
|
149003
|
+
if (kind === "outlet") return accessory.addService(import_dist.Service.Outlet, displayName, subtype);
|
|
149004
|
+
if (kind === "fan") return accessory.addService(import_dist.Service.Fan, displayName, subtype);
|
|
149005
|
+
return accessory.addService(import_dist.Service.Switch, displayName, subtype);
|
|
149006
|
+
}
|
|
149007
|
+
async function buildChildSwitch(bctx, subtype, deviceType, role = null) {
|
|
147931
149008
|
const { ctx, accessory, proxy, numericDeviceId, displayName } = bctx;
|
|
147932
149009
|
const log = ctx.logger.withTags({ deviceId: numericDeviceId });
|
|
147933
149010
|
const hasSwitch = !!proxy.switch;
|
|
@@ -147936,17 +149013,21 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
147936
149013
|
log.debug("export-hap: child has no switch/brightness cap — skipping");
|
|
147937
149014
|
return { async dispose() {} };
|
|
147938
149015
|
}
|
|
147939
|
-
const
|
|
147940
|
-
const
|
|
147941
|
-
const service =
|
|
149016
|
+
const kind = onOffServiceKind(deviceType, role, hasBrightness);
|
|
149017
|
+
const dimmable = kind === "dimmable-lightbulb";
|
|
149018
|
+
const service = addOnOffService(accessory, kind, displayName, subtype);
|
|
147942
149019
|
applyServiceLabel(service, displayName);
|
|
149020
|
+
const setOn = (on) => {
|
|
149021
|
+
service.updateCharacteristic(import_dist.Characteristic.On, on);
|
|
149022
|
+
if (kind === "outlet") service.updateCharacteristic(import_dist.Characteristic.OutletInUse, on);
|
|
149023
|
+
};
|
|
147943
149024
|
try {
|
|
147944
149025
|
const switchStatus = await proxy.switch?.getStatus({});
|
|
147945
|
-
if (switchStatus && typeof switchStatus.on === "boolean")
|
|
149026
|
+
if (switchStatus && typeof switchStatus.on === "boolean") setOn(switchStatus.on);
|
|
147946
149027
|
} catch (err) {
|
|
147947
149028
|
log.debug("export-hap: child switch.getStatus failed (non-fatal)", { meta: { error: errMsg$13(err) } });
|
|
147948
149029
|
}
|
|
147949
|
-
if (
|
|
149030
|
+
if (dimmable) try {
|
|
147950
149031
|
const status = await proxy.brightness?.getStatus({});
|
|
147951
149032
|
if (status && typeof status.level === "number") service.updateCharacteristic(import_dist.Characteristic.Brightness, status.level);
|
|
147952
149033
|
} catch (err) {
|
|
@@ -147963,7 +149044,7 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
147963
149044
|
} });
|
|
147964
149045
|
}
|
|
147965
149046
|
});
|
|
147966
|
-
if (
|
|
149047
|
+
if (dimmable) service.getCharacteristic(import_dist.Characteristic.Brightness).onSet(async (value) => {
|
|
147967
149048
|
const percentage = typeof value === "number" ? value : Number(value);
|
|
147968
149049
|
if (!Number.isFinite(percentage)) return;
|
|
147969
149050
|
try {
|
|
@@ -147978,11 +149059,11 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
147978
149059
|
const unsubscribes = [];
|
|
147979
149060
|
if (proxy.state.switch) {
|
|
147980
149061
|
const unsubSwitch = proxy.state.switch.subscribe((value) => {
|
|
147981
|
-
if (value && typeof value.on === "boolean")
|
|
149062
|
+
if (value && typeof value.on === "boolean") setOn(value.on);
|
|
147982
149063
|
});
|
|
147983
149064
|
unsubscribes.push(unsubSwitch);
|
|
147984
149065
|
}
|
|
147985
|
-
if (
|
|
149066
|
+
if (dimmable && proxy.state.brightness) {
|
|
147986
149067
|
const unsubBrightness = proxy.state.brightness.subscribe((value) => {
|
|
147987
149068
|
if (value && typeof value.level === "number") service.updateCharacteristic(import_dist.Characteristic.Brightness, value.level);
|
|
147988
149069
|
});
|
|
@@ -148590,10 +149671,10 @@ var HAP_CAP_SERVICES = [
|
|
|
148590
149671
|
{
|
|
148591
149672
|
caps: ["switch", "brightness"],
|
|
148592
149673
|
label: "Power",
|
|
148593
|
-
build: ({ bctx, name, deviceType }) => buildChildSwitch({
|
|
149674
|
+
build: ({ bctx, name, deviceType, role }) => buildChildSwitch({
|
|
148594
149675
|
...bctx,
|
|
148595
149676
|
displayName: name
|
|
148596
|
-
}, "switch", deviceType)
|
|
149677
|
+
}, "switch", deviceType, role)
|
|
148597
149678
|
},
|
|
148598
149679
|
{
|
|
148599
149680
|
caps: ["lock-control"],
|
|
@@ -148651,7 +149732,17 @@ var ACCESSORY_CATEGORY_BY_TYPE = {
|
|
|
148651
149732
|
[DeviceType.Presence]: import_dist.Categories.SENSOR,
|
|
148652
149733
|
[DeviceType.AlarmPanel]: import_dist.Categories.SECURITY_SYSTEM
|
|
148653
149734
|
};
|
|
148654
|
-
|
|
149735
|
+
/**
|
|
149736
|
+
* The category, by type and then by the switch's sub-role (read only through
|
|
149737
|
+
* the `@camstack/types` accessors). A heater keeps a Switch service (see
|
|
149738
|
+
* `onOffServiceKind`) and takes HomeKit's heater category, which is an icon
|
|
149739
|
+
* and promises no characteristic. A helper boolean stays a SWITCH.
|
|
149740
|
+
*/
|
|
149741
|
+
function accessoryCategoryFor(deviceType, role) {
|
|
149742
|
+
if (isSwitchLight(deviceType, role)) return import_dist.Categories.LIGHTBULB;
|
|
149743
|
+
if (isOutlet(deviceType, role)) return import_dist.Categories.OUTLET;
|
|
149744
|
+
if (isSwitchFan(deviceType, role)) return import_dist.Categories.FAN;
|
|
149745
|
+
if (isSwitchHeater(deviceType, role)) return import_dist.Categories.AIR_HEATER;
|
|
148655
149746
|
return ACCESSORY_CATEGORY_BY_TYPE[deviceType] ?? import_dist.Categories.OTHER;
|
|
148656
149747
|
}
|
|
148657
149748
|
//#endregion
|
|
@@ -163638,7 +164729,7 @@ async function buildChildServicesFor(input) {
|
|
|
163638
164729
|
options
|
|
163639
164730
|
};
|
|
163640
164731
|
const subtype = `child-${child.id}`;
|
|
163641
|
-
handles.push(await buildChildSwitch(childCtx, subtype, asDeviceType(child.type)));
|
|
164732
|
+
handles.push(await buildChildSwitch(childCtx, subtype, asDeviceType(child.type), child.role ?? null));
|
|
163642
164733
|
}
|
|
163643
164734
|
return { async dispose() {
|
|
163644
164735
|
for (const h of handles) try {
|
|
@@ -164616,9 +165707,9 @@ async function buildGenericAccessory(input) {
|
|
|
164616
165707
|
const capNames = new Set(proxy.binding?.entries.map((e) => e.capName) ?? []);
|
|
164617
165708
|
const rows = rowsForCaps(capNames);
|
|
164618
165709
|
if (rows.length === 0) throw new Error(`export-hap: device ${numericId} carries no capability HomeKit can export (bound: ${[...capNames].toSorted().join(", ") || "none"})`);
|
|
164619
|
-
const deviceType = await
|
|
165710
|
+
const { type: deviceType, role } = await resolveDeviceKind(proxy);
|
|
164620
165711
|
const accessory = new import_dist.Accessory(displayName, accessoryUuidFor("generic", numericId, options.instanceId));
|
|
164621
|
-
accessory.category = accessoryCategoryFor(deviceType);
|
|
165712
|
+
accessory.category = accessoryCategoryFor(deviceType, role);
|
|
164622
165713
|
await populateAccessoryInfo(accessory, proxy, displayName, "Accessory");
|
|
164623
165714
|
const bctx = {
|
|
164624
165715
|
ctx,
|
|
@@ -164634,11 +165725,13 @@ async function buildGenericAccessory(input) {
|
|
|
164634
165725
|
handles.push(await row.build({
|
|
164635
165726
|
bctx,
|
|
164636
165727
|
name,
|
|
164637
|
-
deviceType
|
|
165728
|
+
deviceType,
|
|
165729
|
+
role
|
|
164638
165730
|
}));
|
|
164639
165731
|
}
|
|
164640
165732
|
log.info("export-hap: built generic accessory", { meta: {
|
|
164641
165733
|
deviceType,
|
|
165734
|
+
role,
|
|
164642
165735
|
services: rows.map((row) => row.caps[0]).join(",")
|
|
164643
165736
|
} });
|
|
164644
165737
|
return {
|
|
@@ -164654,20 +165747,27 @@ async function buildGenericAccessory(input) {
|
|
|
164654
165747
|
};
|
|
164655
165748
|
}
|
|
164656
165749
|
/**
|
|
164657
|
-
* The device's own type, or `Generic
|
|
165750
|
+
* The device's own type, or `Generic`, and its role (null when unread).
|
|
164658
165751
|
*
|
|
164659
165752
|
* Used ONLY where one capability has two HomeKit shapes — a siren's
|
|
164660
|
-
* `brightness` is alarm volume, not luminosity
|
|
165753
|
+
* `brightness` is alarm volume, not luminosity; a `switch-light` relay is a
|
|
165754
|
+
* Lightbulb, not a Switch — and for the accessory's icon.
|
|
164661
165755
|
* `Generic` is the safe reading: it is the shape `child-switch.ts` already
|
|
164662
165756
|
* treats as "a lamp if it dims, a switch otherwise".
|
|
164663
165757
|
*/
|
|
164664
|
-
async function
|
|
165758
|
+
async function resolveDeviceKind(proxy) {
|
|
164665
165759
|
try {
|
|
164666
165760
|
const device = await proxy.deviceManager?.getDevice({});
|
|
164667
165761
|
const raw = typeof device?.type === "string" ? device.type.toLowerCase() : "";
|
|
164668
|
-
return
|
|
165762
|
+
return {
|
|
165763
|
+
type: Object.values(DeviceType).find((value) => value === raw) ?? DeviceType.Generic,
|
|
165764
|
+
role: typeof device?.role === "string" ? device.role : null
|
|
165765
|
+
};
|
|
164669
165766
|
} catch {
|
|
164670
|
-
return
|
|
165767
|
+
return {
|
|
165768
|
+
type: DeviceType.Generic,
|
|
165769
|
+
role: null
|
|
165770
|
+
};
|
|
164671
165771
|
}
|
|
164672
165772
|
}
|
|
164673
165773
|
function errMsg$1(err) {
|
|
@@ -165191,8 +166291,19 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165191
166291
|
for (const uuid of uuids) clearPairingFiles(uuid, this.ctx.logger);
|
|
165192
166292
|
await this.exposureHandle().delete(id);
|
|
165193
166293
|
if (id === "export-hap") await this.exportSyncState.set({});
|
|
166294
|
+
await this.pruneBridgeNames(id);
|
|
165194
166295
|
this.ctx.logger.info("export-hap: bridge removed", { meta: { instanceId: id } });
|
|
165195
166296
|
}
|
|
166297
|
+
/** A removed bridge's device names go too, so a bridge that reuses the id inherits none (D1049). */
|
|
166298
|
+
async pruneBridgeNames(id) {
|
|
166299
|
+
const settings = this.ctx.settings;
|
|
166300
|
+
if (settings === void 0) return;
|
|
166301
|
+
const pruned = await pruneExposedNames(settings, id);
|
|
166302
|
+
if (pruned.length > 0) this.ctx.logger.info("export-hap: removed bridge names deleted", { meta: {
|
|
166303
|
+
instanceId: id,
|
|
166304
|
+
devices: pruned.length
|
|
166305
|
+
} });
|
|
166306
|
+
}
|
|
165196
166307
|
/**
|
|
165197
166308
|
* "Regenerate" (operator decision): a new setup code, every pairing of this bridge cleared and
|
|
165198
166309
|
* the bridge republished. Every controller has to pair again; the instance and its exposed
|
|
@@ -165288,21 +166399,33 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165288
166399
|
instanceId: row.id,
|
|
165289
166400
|
name: row.body.name,
|
|
165290
166401
|
enabled: row.enabled,
|
|
165291
|
-
kind: "hap-bridge"
|
|
166402
|
+
kind: "hap-bridge",
|
|
166403
|
+
nameRule: HAP_NAME_RULE
|
|
165292
166404
|
})),
|
|
165293
166405
|
listSupportedDeviceKinds: async ({ instanceId }) => {
|
|
165294
166406
|
this.bridgesOf(instanceId);
|
|
165295
166407
|
return [...HAP_EXPORTABLE_DEVICE_TYPES];
|
|
165296
166408
|
},
|
|
165297
|
-
listExposedDevices: async ({ instanceId }) =>
|
|
165298
|
-
const
|
|
165299
|
-
|
|
165300
|
-
deviceId
|
|
165301
|
-
|
|
165302
|
-
|
|
165303
|
-
|
|
165304
|
-
|
|
165305
|
-
|
|
166409
|
+
listExposedDevices: async ({ instanceId }) => {
|
|
166410
|
+
const out = [];
|
|
166411
|
+
for (const inst of this.bridgesOf(instanceId)) for (const [deviceId, m] of inst.exposed.entries()) {
|
|
166412
|
+
const entry = inst.exposure.devices.find((e) => e.deviceId === deviceId);
|
|
166413
|
+
const exposedName = await this.exposedNameOf(inst.id, deviceId);
|
|
166414
|
+
out.push({
|
|
166415
|
+
deviceId,
|
|
166416
|
+
exposedAs: m.accessory.displayName,
|
|
166417
|
+
...exposedName !== null ? { exposedName } : {},
|
|
166418
|
+
...entry?.capabilities ? { capabilities: [...entry.capabilities] } : {}
|
|
166419
|
+
});
|
|
166420
|
+
}
|
|
166421
|
+
return out;
|
|
166422
|
+
},
|
|
166423
|
+
exposeDevice: async ({ instanceId, deviceId, capabilities, exposedName }) => {
|
|
166424
|
+
const inst = this.requireBridge(instanceId);
|
|
166425
|
+
if (exposedName !== void 0) await this.saveExposedName(inst, deviceId, exposedName);
|
|
166426
|
+
return this.exposeDevice(inst, deviceId, capabilities);
|
|
166427
|
+
},
|
|
166428
|
+
setExposedName: async ({ instanceId, deviceId, name, dryRun }) => this.setExposedName(this.requireBridge(instanceId), deviceId, name, dryRun === true),
|
|
165306
166429
|
unexposeDevice: async ({ instanceId, deviceId }) => this.unexposeDevice(this.requireBridge(instanceId), deviceId),
|
|
165307
166430
|
listSupportedEntityKinds: async () => ["device", "action"],
|
|
165308
166431
|
listExposedEntities: async ({ instanceId }) => {
|
|
@@ -165445,7 +166568,7 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165445
166568
|
const summary = await this.fetchDeviceSummary(numericId);
|
|
165446
166569
|
const mapperKind = pickMapperKind(summary?.type);
|
|
165447
166570
|
if (!mapperKind) throw new Error(`export-hap: device ${numericId} has type '${summary?.type ?? "unknown"}', which HomeKit export does not support`);
|
|
165448
|
-
const displayName = summary?.name ?? `Device ${deviceId}`;
|
|
166571
|
+
const displayName = await this.exposedNameOf(inst.id, deviceId) ?? summary?.name ?? `Device ${deviceId}`;
|
|
165449
166572
|
const previous = inst.exposure.devices.find((e) => e.deviceId === deviceId);
|
|
165450
166573
|
const rebuilt = {
|
|
165451
166574
|
deviceId,
|
|
@@ -165477,6 +166600,54 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
165477
166600
|
childCount: attached.childAccessoryUuids.length
|
|
165478
166601
|
} });
|
|
165479
166602
|
}
|
|
166603
|
+
nameStore() {
|
|
166604
|
+
return exposedNameStoreOf(this.ctx.settings, "export-hap");
|
|
166605
|
+
}
|
|
166606
|
+
async exposedNameOf(instanceId, deviceId) {
|
|
166607
|
+
const numericId = Number.parseInt(deviceId, 10);
|
|
166608
|
+
if (!Number.isFinite(numericId)) return null;
|
|
166609
|
+
try {
|
|
166610
|
+
return readExposedName(await this.nameStore().read(numericId), instanceId, hapNameValidator);
|
|
166611
|
+
} catch (err) {
|
|
166612
|
+
this.ctx.logger.warn("export-hap: HomeKit name unreadable", {
|
|
166613
|
+
tags: { deviceId: numericId },
|
|
166614
|
+
meta: {
|
|
166615
|
+
instanceId,
|
|
166616
|
+
error: err instanceof Error ? err.message : String(err)
|
|
166617
|
+
}
|
|
166618
|
+
});
|
|
166619
|
+
return null;
|
|
166620
|
+
}
|
|
166621
|
+
}
|
|
166622
|
+
/** Validate and store the HomeKit name; a refusal throws before anything is written. */
|
|
166623
|
+
async saveExposedName(inst, deviceIdStr, raw, dryRun = false) {
|
|
166624
|
+
const deviceId = Number.parseInt(deviceIdStr, 10);
|
|
166625
|
+
if (!Number.isFinite(deviceId)) throw new Error(`export-hap: invalid device id '${deviceIdStr}'`);
|
|
166626
|
+
const saved = await saveExposedName({
|
|
166627
|
+
store: this.nameStore(),
|
|
166628
|
+
deviceId,
|
|
166629
|
+
instanceId: inst.id,
|
|
166630
|
+
raw,
|
|
166631
|
+
validate: hapNameValidator,
|
|
166632
|
+
...dryRun ? { dryRun: true } : {}
|
|
166633
|
+
});
|
|
166634
|
+
if (saved.changed) this.ctx.logger.info("export-hap: HomeKit name saved", {
|
|
166635
|
+
tags: { deviceId },
|
|
166636
|
+
meta: {
|
|
166637
|
+
instanceId: inst.id,
|
|
166638
|
+
name: saved.name
|
|
166639
|
+
}
|
|
166640
|
+
});
|
|
166641
|
+
return saved.changed;
|
|
166642
|
+
}
|
|
166643
|
+
/**
|
|
166644
|
+
* Rename on HomeKit (D1049). An exposed device is re-exposed in place — the same accessory
|
|
166645
|
+
* UUID, the pairing untouched (no unexpose, which would wipe it) — so Home shows the new name
|
|
166646
|
+
* on the same tile. A dry run only validates.
|
|
166647
|
+
*/
|
|
166648
|
+
async setExposedName(inst, deviceIdStr, raw, dryRun = false) {
|
|
166649
|
+
if (await this.saveExposedName(inst, deviceIdStr, raw, dryRun) && inst.exposed.has(deviceIdStr)) await this.exposeDevice(inst, deviceIdStr);
|
|
166650
|
+
}
|
|
165480
166651
|
async unexposeDevice(inst, deviceId, options = {}) {
|
|
165481
166652
|
const numericId = Number.parseInt(deviceId, 10);
|
|
165482
166653
|
const log = this.ctx.logger.withTags({ deviceId: numericId });
|