@camstack/addon-provider-homematic 1.2.191 → 1.2.193

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/dist/addon.mjs CHANGED
@@ -9,7 +9,7 @@ import { networkInterfaces } from "node:os";
9
9
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
10
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
11
11
  //#endregion
12
- //#region ../types/dist/event-category-78tcBemo.mjs
12
+ //#region ../types/dist/event-category-Dv-Gcv1f.mjs
13
13
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
14
14
  EventCategory["SystemBoot"] = "system.boot";
15
15
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -450,6 +450,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
450
450
  */
451
451
  EventCategory["DeviceStateChanged"] = "device.state-changed";
452
452
  /**
453
+ * A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
454
+ * transition audit (D1022): confirmed, already in place, unconfirmed or
455
+ * failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
456
+ * (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
457
+ * the Notification Center `device-command` kind. Telemetry (D8): losing one
458
+ * costs a notification, never state; the audit row is the record.
459
+ */
460
+ EventCategory["DeviceCommandSettled"] = "device.command-settled";
461
+ /**
453
462
  * The NATIVE shadow of a cap a composition has claimed fields of moved
454
463
  * (D663). Payload: `{ deviceId, capName, native }` — what the provider
455
464
  * wrote, BEFORE the owned fields are overlaid. Owner-only (D224): it is for
@@ -812,7 +821,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
812
821
  return EventCategory;
813
822
  }({});
814
823
  //#endregion
815
- //#region ../types/dist/composed-stable-id-CPp3votu.mjs
824
+ //#region ../types/dist/composed-stable-id-iddnCQ51.mjs
816
825
  /**
817
826
  import { errMsg } from '@camstack/types'
818
827
  * Extract a human-readable message from an unknown error value.
@@ -1154,6 +1163,11 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1154
1163
  * with the switch's on/off only. Speed or oscillation appear only when the
1155
1164
  * device also has a fan cap (D1033). */
1156
1165
  DeviceRole["SwitchFan"] = "switch-fan";
1166
+ /** A relay driving an on/off-only lamp: drawn as a light (bulb and glow, no
1167
+ * slider), presented to the exports as a light with power only. Not a
1168
+ * `light` type: the provider owns the type, and a light implies brightness
1169
+ * or colour this relay lacks. */
1170
+ DeviceRole["SwitchLight"] = "switch-light";
1157
1171
  /** Air conditioner / split unit: cooling, fan speed, louvres. */
1158
1172
  DeviceRole["ClimateAc"] = "climate-ac";
1159
1173
  /** Room thermostat: a setpoint and a room temperature. The default. */
@@ -6054,7 +6068,7 @@ var ZodIssueCode = {
6054
6068
  var ZodFirstPartyTypeKind;
6055
6069
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6056
6070
  //#endregion
6057
- //#region ../types/dist/sleep-D0roI_CZ.mjs
6071
+ //#region ../types/dist/sleep-BvVGLl30.mjs
6058
6072
  /**
6059
6073
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6060
6074
  * window to float samples (D455).
@@ -6737,6 +6751,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6737
6751
  else skipped.push(id);
6738
6752
  };
6739
6753
  const selected = options.only === void 0 ? null : new Set(options.only);
6754
+ const deferred = /* @__PURE__ */ new Set();
6755
+ const deferredBy = (reason) => {
6756
+ if (selected === null || reason === null) return null;
6757
+ const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
6758
+ if (dep === void 0 || !byId.has(dep)) return null;
6759
+ return !selected.has(dep) || deferred.has(dep) ? dep : null;
6760
+ };
6740
6761
  for (const step of declaration.steps) {
6741
6762
  if (selected !== null && !selected.has(step.id)) continue;
6742
6763
  const bound = byId.get(step.id);
@@ -6748,6 +6769,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6748
6769
  try {
6749
6770
  const gate = await host.startMigration({ id: step.id });
6750
6771
  if (!gate.proceed) {
6772
+ const waitsFor = deferredBy(gate.reason);
6773
+ if (waitsFor !== null) {
6774
+ log.info("migration deferred: its predecessor runs in another phase of this owner", {
6775
+ tags,
6776
+ meta: {
6777
+ waitsFor,
6778
+ reason: gate.reason
6779
+ }
6780
+ });
6781
+ deferred.add(step.id);
6782
+ skipped.push(step.id);
6783
+ continue;
6784
+ }
6751
6785
  log.warn("migration not run", {
6752
6786
  tags,
6753
6787
  meta: {
@@ -10225,6 +10259,13 @@ var DeviceTransitionSchema = object({
10225
10259
  actor: TransitionActorSchema,
10226
10260
  command: TransitionCommandSchema.optional()
10227
10261
  });
10262
+ object({
10263
+ deviceId: number$1().int(),
10264
+ action: string(),
10265
+ outcome: TransitionOutcomeSchema,
10266
+ actor: TransitionActorSchema,
10267
+ at: number$1()
10268
+ });
10228
10269
  var READING_QUANTITIES = [
10229
10270
  "temperature",
10230
10271
  "pressure",
@@ -10768,6 +10809,13 @@ var ACTUATOR_CAP_VOCABULARY = {
10768
10809
  },
10769
10810
  state: { on: { icon: "lightbulb" } }
10770
10811
  },
10812
+ [DeviceRole.SwitchLight]: {
10813
+ actions: {
10814
+ "switch.on": { icon: "lightbulb" },
10815
+ "switch.off": { icon: "lightbulb-off" }
10816
+ },
10817
+ state: { on: { icon: "lightbulb" } }
10818
+ },
10771
10819
  [DeviceRole.Chime]: { actions: {
10772
10820
  "switch.on": {
10773
10821
  label: t("Enable chime", "Attiva il campanello"),
@@ -12248,7 +12296,10 @@ var ACTUATOR_CAP_VOCABULARY = {
12248
12296
  "ir-transmitter": {
12249
12297
  scope: "device",
12250
12298
  noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
12251
- notOperatorFacing: { send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it" }
12299
+ notOperatorFacing: {
12300
+ send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
12301
+ learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
12302
+ }
12252
12303
  },
12253
12304
  control: {
12254
12305
  scope: "device",
@@ -15169,6 +15220,32 @@ var CAP_VOCABULARY_BY_NAME = {
15169
15220
  ...SYSTEM_CAP_VOCABULARY
15170
15221
  };
15171
15222
  /**
15223
+ * Vocabulary actions by id (D983). An action step names a vocabulary action
15224
+ * (`cover.open`), never a raw cap method; this is the one lookup that turns the
15225
+ * id into its cap, method and effect — and a persisted legacy `cap` + `method`
15226
+ * pair back into the action id when exactly one action matches.
15227
+ */
15228
+ function buildIndex() {
15229
+ const byId = /* @__PURE__ */ new Map();
15230
+ for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
15231
+ if (entry.scope !== "device") continue;
15232
+ for (const action of entry.actions ?? []) byId.set(action.id, {
15233
+ cap,
15234
+ action
15235
+ });
15236
+ }
15237
+ return byId;
15238
+ }
15239
+ var index;
15240
+ function actionIndex() {
15241
+ index ??= buildIndex();
15242
+ return index;
15243
+ }
15244
+ /** The vocabulary action with this id, or `undefined`. */
15245
+ function findVocabAction(actionId) {
15246
+ return actionIndex().get(actionId);
15247
+ }
15248
+ /**
15172
15249
  * `addon-pages-source` — collection cap exposing per-provider raw page
15173
15250
  * declarations. Every addon that contributes a UI page registers a
15174
15251
  * provider here. The hub-side singleton aggregator (`addon-pages` cap,
@@ -17476,7 +17553,7 @@ Object.freeze({
17476
17553
  }
17477
17554
  });
17478
17555
  //#endregion
17479
- //#region ../types/dist/implemented-methods-5YMDeE3f.mjs
17556
+ //#region ../types/dist/implemented-methods-CSTk6zYK.mjs
17480
17557
  /**
17481
17558
  * The ffmpeg build every CamStack node downloads, per platform and arch.
17482
17559
  *
@@ -17530,6 +17607,30 @@ function portable(target) {
17530
17607
  }
17531
17608
  portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac64"), `${BASE}${FFMPEG_RELEASE}`;
17532
17609
  /**
17610
+ * A device's KIND is its type plus its role (D1033): the type is the set of
17611
+ * controls it has, the role says which thing it is among the devices that
17612
+ * share those controls. A plug-in heater is a `switch` with role
17613
+ * `switch-heater`; an air conditioner and a radiator valve are both `climate`,
17614
+ * told apart by their `climate-*` role.
17615
+ */
17616
+ /**
17617
+ * Type values a persisted row may still carry after the type was retired, and
17618
+ * the type each one is read as. The row is rewritten by the next registration
17619
+ * of the device (its provider stamps the live type), so this is a read alias,
17620
+ * not a migration.
17621
+ *
17622
+ * `heater` is deliberately absent: the only heaters were composed devices the
17623
+ * operator deletes. Such a row stays an unknown type, which every reader
17624
+ * treats as a generic device.
17625
+ */
17626
+ var RETIRED_DEVICE_TYPES = { thermostat: DeviceType.Climate };
17627
+ /** The live type a stored `type` value stands for (itself unless retired). */
17628
+ function canonicalStoredDeviceType(stored) {
17629
+ return RETIRED_DEVICE_TYPES[stored] ?? stored;
17630
+ }
17631
+ preprocess((value) => typeof value === "string" ? canonicalStoredDeviceType(value) : value, _enum(DeviceType));
17632
+ DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
17633
+ /**
17533
17634
  * THE table "which boolean of this device type counts as HIGH", and the
17534
17635
  * pure evaluator of its EDGE.
17535
17636
  *
@@ -23380,7 +23481,7 @@ var DeviceTokenScopeSchema = object({
23380
23481
  function migrateLegacyTokenScope(raw) {
23381
23482
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
23382
23483
  if (Reflect.get(raw, "type") !== "device") return raw;
23383
- if (Reflect.get(raw, "selector") !== void 0) return raw;
23484
+ if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
23384
23485
  const targets = Reflect.get(raw, "targets");
23385
23486
  if (!Array.isArray(targets)) return raw;
23386
23487
  return {
@@ -23392,6 +23493,27 @@ function migrateLegacyTokenScope(raw) {
23392
23493
  access: Reflect.get(raw, "access")
23393
23494
  };
23394
23495
  }
23496
+ /**
23497
+ * A stored `types` selector may name a type D1033 retired (`thermostat`). The
23498
+ * grant is read back through this same preprocess, so the retired name is
23499
+ * rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
23500
+ * stays a strict enum on the wire.
23501
+ */
23502
+ function canonicalSelectorTypes(raw) {
23503
+ const selector = Reflect.get(raw, "selector");
23504
+ if (selector === null || typeof selector !== "object") return raw;
23505
+ if (Reflect.get(selector, "kind") !== "types") return raw;
23506
+ const types = Reflect.get(selector, "types");
23507
+ if (!Array.isArray(types)) return raw;
23508
+ const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
23509
+ return {
23510
+ ...raw,
23511
+ selector: {
23512
+ ...selector,
23513
+ types: canonical
23514
+ }
23515
+ };
23516
+ }
23395
23517
  var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
23396
23518
  object({
23397
23519
  type: literal("category"),
@@ -44083,6 +44205,59 @@ function macroOnly(macro) {
44083
44205
  };
44084
44206
  }
44085
44207
  }
44208
+ var EventVocabularyKindSchema = _enum([
44209
+ "press",
44210
+ "long-press",
44211
+ "long-press-start",
44212
+ "release",
44213
+ "repeat",
44214
+ "double-press",
44215
+ "other"
44216
+ ]);
44217
+ /** The part of the device an event comes from: a button, a channel. */
44218
+ var EventVocabularySourceSchema = object({
44219
+ id: string().min(1),
44220
+ label: string().min(1)
44221
+ });
44222
+ /** One scalar field of an event's `data`, by dotted path. */
44223
+ var EventVocabularyFieldSchema = object({
44224
+ path: string().min(1),
44225
+ kind: _enum([
44226
+ "string",
44227
+ "number",
44228
+ "boolean",
44229
+ "enum"
44230
+ ]),
44231
+ enumValues: array(string()).optional(),
44232
+ label: string().min(1).optional()
44233
+ });
44234
+ var EventVocabularyEntrySchema = object({
44235
+ /** The native token, verbatim. */
44236
+ id: string().min(1),
44237
+ source: EventVocabularySourceSchema.optional(),
44238
+ label: string().min(1),
44239
+ description: string().optional(),
44240
+ kind: EventVocabularyKindSchema.optional(),
44241
+ payload: array(EventVocabularyFieldSchema).optional()
44242
+ });
44243
+ /**
44244
+ * The vocabulary of a source that declares tokens and nothing else: one
44245
+ * entry per token, labelled with the token itself.
44246
+ */
44247
+ function plainEventVocabulary(eventTypes) {
44248
+ return [...new Set(eventTypes)].filter((eventType) => eventType !== "").map((eventType) => ({
44249
+ id: eventType,
44250
+ label: eventType
44251
+ }));
44252
+ }
44253
+ /** The native tokens of a vocabulary, each once, in declaration order. */
44254
+ function eventTypesOfVocabulary(vocabulary) {
44255
+ return [...new Set(vocabulary.map((entry) => entry.id))];
44256
+ }
44257
+ /** The entry a fire belongs to: same token, same source (or both without one). */
44258
+ function findVocabularyEntry(vocabulary, eventType, sourceId) {
44259
+ return vocabulary.find((entry) => entry.id === eventType && entry.source?.id === sourceId);
44260
+ }
44086
44261
  Math.PI / 180;
44087
44262
  /**
44088
44263
  * WHEN something happens, as data (D983) — the one time vocabulary of the
@@ -44290,6 +44465,33 @@ var ScheduleLeafSchema = object({
44290
44465
  /** @deprecated legacy cron — new schedules use `at`. */
44291
44466
  cron: string().min(1).max(120).optional()
44292
44467
  }).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" });
44468
+ /**
44469
+ * One payload predicate of a `device-fired` row: the value at `path` inside
44470
+ * the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
44471
+ */
44472
+ var DeviceFiredMatchSchema = object({
44473
+ path: string().min(1).max(120),
44474
+ equals: union([
44475
+ string(),
44476
+ number$1(),
44477
+ boolean()
44478
+ ])
44479
+ });
44480
+ /**
44481
+ * "fires": one device of the `event-emitter` capability reported an event
44482
+ * (D1045). Every list is an OR, the lists together an AND; an absent list does
44483
+ * not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
44484
+ * the device (a button), `kinds` the shared press kinds of its vocabulary.
44485
+ */
44486
+ var DeviceFiredLeafSchema = object({
44487
+ kind: literal("device-fired"),
44488
+ ...eventLeafId,
44489
+ deviceId: number$1().int().nonnegative(),
44490
+ eventIds: array(string().min(1)).min(1).max(64).optional(),
44491
+ sourceIds: array(string().min(1)).min(1).max(64).optional(),
44492
+ kinds: array(EventVocabularyKindSchema).min(1).optional(),
44493
+ match: array(DeviceFiredMatchSchema).min(1).max(8).optional()
44494
+ });
44293
44495
  var ManualLeafSchema = object({
44294
44496
  kind: literal("manual"),
44295
44497
  ...eventLeafId
@@ -44431,6 +44633,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
44431
44633
  }),
44432
44634
  DeviceBecomesLeafSchema,
44433
44635
  DeviceEventLeafSchema,
44636
+ DeviceFiredLeafSchema,
44434
44637
  ScheduleLeafSchema,
44435
44638
  ManualLeafSchema,
44436
44639
  IntervalLeafSchema,
@@ -44445,6 +44648,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
44445
44648
  var EVENT_KINDS = new Set([
44446
44649
  "device-becomes",
44447
44650
  "device-event",
44651
+ "device-fired",
44448
44652
  "schedule",
44449
44653
  "manual",
44450
44654
  "interval",
@@ -44525,6 +44729,7 @@ function hasEmptyContainer(node) {
44525
44729
  var LEAF_WORDS = {
44526
44730
  "device-becomes": "a device value that becomes",
44527
44731
  "device-event": "a device event",
44732
+ "device-fired": "a device firing an event",
44528
44733
  schedule: "a schedule",
44529
44734
  manual: "a manual run",
44530
44735
  interval: "an interval",
@@ -44774,21 +44979,23 @@ function convertLegacyWhen(half) {
44774
44979
  * (instants) and state leaves (durations). It replaces the flat trigger list
44775
44980
  * plus the separate condition tree; the firing rule is in that file and in
44776
44981
  * ADR "one tree".
44777
- * - **Actions** — the `wait` and `cap` steps, plus the `{kind:'code'}`
44982
+ * - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
44778
44983
  * fragment of §3.2.2. See {@link AutomationActionSchema}.
44779
44984
  *
44780
44985
  * A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
44781
44986
  * {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
44782
44987
  */
44783
44988
  /**
44784
- * One action step: `wait`, or a `cap` call.
44989
+ * One action step: `wait`, or a device `command`.
44785
44990
  *
44786
- * A cap step's target is who it acts on (D983: `devices`, a `domain`, or a
44787
- * `{ $var }` resolved from the run's variables); the legacy `deviceId` is still
44788
- * READ, never written. The step runner (`runSteps`) owns the device-scope
44789
- * check, the stop-at-first-failure and the variable substitution, once, for
44790
- * every caller — automations, Actions, and the notification centre, which runs
44791
- * only Actions (planning#473).
44991
+ * A command step names a VOCABULARY action (`cover.open`) and who it acts on
44992
+ * (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
44993
+ * variables). It never names a cap method: the step runner turns the action
44994
+ * id into its cap + method through the vocabulary index when the step runs
44995
+ * (`vocabCall`), the one place that mapping happens. The step runner
44996
+ * (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
44997
+ * variable substitution, once, for every caller — automations, Actions, and
44998
+ * the notification centre, which runs only Actions (planning#473).
44792
44999
  */
44793
45000
  /** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
44794
45001
  var WAIT_MAX_SECONDS = 3600;
@@ -44797,39 +45004,22 @@ var AutomationWaitStepSchema = object({
44797
45004
  kind: literal("wait"),
44798
45005
  seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
44799
45006
  });
44800
- /** The legacy `deviceId` of a cap step: still READ, never written (D983). */
44801
- var LegacyStepDeviceSchema = union([
44802
- number$1().int(),
44803
- array(number$1().int()).min(1),
44804
- object({ $var: string().min(1) })
44805
- ]);
44806
45007
  /**
44807
- * The fields of a cap step, before the target rules are applied. Exported for
44808
- * a shape that is "a cap call, narrowed" (a remote-control binding is one
44809
- * device); a step is {@link AutomationCapStepSchema}.
45008
+ * The fields of a command step, before the vocabulary check. A step is
45009
+ * {@link AutomationCommandStepSchema}.
44810
45010
  */
44811
- var AutomationCapStepBaseSchema = object({
44812
- kind: literal("cap"),
44813
- /**
44814
- * The vocabulary action this step performs (`cover.open`). Required when
44815
- * `target` is a `domain` (the domain is "every device offering this
44816
- * action"); filled by {@link normalizeCapStep} for a legacy step whose
44817
- * cap + method match exactly one vocabulary action.
44818
- */
44819
- actionId: string().min(1).optional(),
44820
- /** WHO the step acts on. The only shape that is written. */
44821
- target: ActionTargetSchema.optional(),
45011
+ var AutomationCommandStepBaseSchema = object({
45012
+ kind: literal("command"),
45013
+ /** WHO the step acts on. */
45014
+ target: ActionTargetSchema,
45015
+ /** The vocabulary action this step performs (`cover.open`). */
45016
+ actionId: string().min(1),
44822
45017
  /**
44823
- * @deprecated The pre-D983 target: one device, several, or `{ $var }`.
44824
- * Still READ — {@link normalizeCapStep} maps it to `target` — and never
44825
- * written.
45018
+ * The values of the action's OPEN args (`position`, `presetId`); the args
45019
+ * the vocabulary bakes into the action are added when the step runs. Values
45020
+ * may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
45021
+ * SUBSTITUTE and do not evaluate (§3.2.3).
44826
45022
  */
44827
- deviceId: LegacyStepDeviceSchema.optional(),
44828
- cap: string().min(1),
44829
- method: string().min(1),
44830
- /** Values may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
44831
- * SUBSTITUTE and do not evaluate (§3.2.3). Anything beyond substitution is
44832
- * the expression leaf. */
44833
45023
  args: record(string(), unknown()).optional(),
44834
45024
  /**
44835
45025
  * The unit the person picked per arg (display only). `args` always hold the
@@ -44838,18 +45028,20 @@ var AutomationCapStepBaseSchema = object({
44838
45028
  */
44839
45029
  argUnits: record(string(), string().min(1)).optional()
44840
45030
  });
45031
+ /** The vocabulary check every command step passes: the action exists. */
45032
+ function refineKnownAction(step, ctx) {
45033
+ if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
45034
+ code: "custom",
45035
+ message: `"${step.actionId}" is not a vocabulary action id`,
45036
+ path: ["actionId"]
45037
+ });
45038
+ }
44841
45039
  /**
44842
- * The steps an internal Action may contain: cap and wait, and nothing that can
45040
+ * The steps an internal Action may contain: command and wait, and nothing that can
44843
45041
  * call back into an Action — so an Action can never reach itself (no cycles).
44844
45042
  * This is the LEAF shape: no condition of its own.
44845
45043
  */
44846
- var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCapStepBaseSchema.refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44847
- message: "a cap step needs a target",
44848
- path: ["target"]
44849
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44850
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44851
- path: ["actionId"]
44852
- })]);
45044
+ var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
44853
45045
  /**
44854
45046
  * The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
44855
45047
  * on the state mirror when the step is reached; `else` runs when it is false.
@@ -44870,13 +45062,7 @@ var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refi
44870
45062
  * same two step kinds an automation runs, minus a guard that reads the
44871
45063
  * automation's trigger, which such a list does not have.
44872
45064
  */
44873
- var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44874
- message: "a cap step needs a target",
44875
- path: ["target"]
44876
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44877
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44878
- path: ["actionId"]
44879
- }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
45065
+ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCommandStepBaseSchema.extend(stepGuardShape).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
44880
45066
  if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
44881
45067
  code: "custom",
44882
45068
  message: TRIGGERED_BY_NEEDS_AUTOMATION,
@@ -44891,17 +45077,11 @@ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, Automa
44891
45077
  var continueOnErrorShape = {
44892
45078
  /** A failure of this step is traced `failed-continued` and the next step runs. */
44893
45079
  continueOnError: literal(true).optional() };
44894
- /** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
44895
- var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
45080
+ /** An automation's command step: the shared guarded command step, plus `continueOnError`. */
45081
+ var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
44896
45082
  ...stepGuardShape,
44897
45083
  ...continueOnErrorShape
44898
- }).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44899
- message: "a cap step needs a target",
44900
- path: ["target"]
44901
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44902
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44903
- path: ["actionId"]
44904
- }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
45084
+ }).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
44905
45085
  /** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
44906
45086
  var AutomationStopStepSchema = object({
44907
45087
  kind: literal("stop"),
@@ -44981,13 +45161,7 @@ function nestTooDeep(issue) {
44981
45161
  }
44982
45162
  var plainStepSchemas = [
44983
45163
  AutomationWaitStepSchema.strict(),
44984
- AutomationCapStepBaseSchema.extend(continueOnErrorShape).strict().refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44985
- message: "a cap step needs a target",
44986
- path: ["target"]
44987
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44988
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44989
- path: ["actionId"]
44990
- }),
45164
+ AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
44991
45165
  AutomationStopStepSchema.omit({ if: true }).strict(),
44992
45166
  AutomationSetStepSchema.omit({ if: true }).strict(),
44993
45167
  AutomationRunActionStepSchema.strict()
@@ -44998,7 +45172,7 @@ var plainStepSchemas = [
44998
45172
  */
44999
45173
  var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
45000
45174
  /** A step that can run beside others: it writes no variable and does not end the run. */
45001
- var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "cap" || 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");
45175
+ 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");
45002
45176
  /**
45003
45177
  * Several steps at once (#500): all are started together and all are awaited.
45004
45178
  * A failure fails the run once the others finished, as in a sequence; a member
@@ -45078,7 +45252,7 @@ var AutomationBodyStepSchema = discriminatedUnion("kind", [
45078
45252
  var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
45079
45253
  var AutomationActionSchema = discriminatedUnion("kind", [
45080
45254
  GuardedWaitStepSchema,
45081
- AutomationGuardedCapStepSchema,
45255
+ AutomationGuardedCommandStepSchema,
45082
45256
  AutomationStopStepSchema,
45083
45257
  AutomationSetStepSchema,
45084
45258
  chooseSchemaOf(AutomationBodyStepSchema),
@@ -45149,38 +45323,6 @@ function convertLegacyRecipe(legacy) {
45149
45323
  };
45150
45324
  }
45151
45325
  var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
45152
- var DETECTION_DESCRIPTIONS = {
45153
- deviceId: "the camera that saw it",
45154
- className: "what it saw",
45155
- trackId: "the track",
45156
- score: "how sure the detector was",
45157
- label: "the label it matched (a name, a plate), empty when none"
45158
- };
45159
- var STATIONARY_DESCRIPTIONS = {
45160
- deviceId: "the camera that saw it",
45161
- className: "what it saw",
45162
- zones: "the zones it is in",
45163
- phase: "appeared or departed",
45164
- entryId: "the stopped object"
45165
- };
45166
- var BECOMES_DESCRIPTIONS = {
45167
- deviceId: "the device that changed",
45168
- from: "the value before the change, empty when it is not known",
45169
- to: "the value it changed to"
45170
- };
45171
- function describe$1(descriptions) {
45172
- return Object.entries(descriptions).map(([name, description]) => ({
45173
- name,
45174
- description
45175
- }));
45176
- }
45177
- describe$1(DETECTION_DESCRIPTIONS);
45178
- describe$1(STATIONARY_DESCRIPTIONS);
45179
- describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45180
- ...v,
45181
- hintKey: "becomesDeviceId"
45182
- } : v);
45183
- new Set(Object.values(COCO_TO_MACRO.mapping));
45184
45326
  /**
45185
45327
  * Schedulers (D983) — an entity that performs actions over the day.
45186
45328
  *
@@ -45439,6 +45581,7 @@ var AutomationConditionTraceNodeSchema = object({
45439
45581
  "triggered-by",
45440
45582
  "device-becomes",
45441
45583
  "device-event",
45584
+ "device-fired",
45442
45585
  "schedule",
45443
45586
  "interval",
45444
45587
  "manual",
@@ -45578,6 +45721,110 @@ var AutomationStateDocSchema = object({
45578
45721
  lastRunStartedAt: number$1().nullable(),
45579
45722
  traces: array(AutomationRunTraceSchema)
45580
45723
  });
45724
+ var DETECTION_DESCRIPTIONS = {
45725
+ deviceId: "the camera that saw it",
45726
+ className: "what it saw",
45727
+ trackId: "the track",
45728
+ score: "how sure the detector was",
45729
+ label: "the label it matched (a name, a plate), empty when none"
45730
+ };
45731
+ var STATIONARY_DESCRIPTIONS = {
45732
+ deviceId: "the camera that saw it",
45733
+ className: "what it saw",
45734
+ zones: "the zones it is in",
45735
+ phase: "appeared or departed",
45736
+ entryId: "the stopped object"
45737
+ };
45738
+ var BECOMES_DESCRIPTIONS = {
45739
+ deviceId: "the device that changed",
45740
+ from: "the value before the change, empty when it is not known",
45741
+ to: "the value it changed to"
45742
+ };
45743
+ /**
45744
+ * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
45745
+ * those names depend on the device, so they are not in this list.
45746
+ */
45747
+ var FIRED_DESCRIPTIONS = {
45748
+ deviceId: "the device that fired",
45749
+ eventType: "the event, as the device names it",
45750
+ sourceId: "the part of the device that fired (a button), empty when it names none",
45751
+ eventKind: "the kind of press (press, long-press …), empty when the device declares none"
45752
+ };
45753
+ function describe$1(descriptions) {
45754
+ return Object.entries(descriptions).map(([name, description]) => ({
45755
+ name,
45756
+ description
45757
+ }));
45758
+ }
45759
+ describe$1(DETECTION_DESCRIPTIONS);
45760
+ describe$1(STATIONARY_DESCRIPTIONS);
45761
+ describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45762
+ ...v,
45763
+ hintKey: "firedDeviceId"
45764
+ } : v);
45765
+ describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45766
+ ...v,
45767
+ hintKey: "becomesDeviceId"
45768
+ } : v);
45769
+ new Set(Object.values(COCO_TO_MACRO.mapping));
45770
+ /**
45771
+ * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
45772
+ * device. Carries the device's EXACT declared event vocabulary verbatim
45773
+ * (NO normalization). Two shapes:
45774
+ * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
45775
+ * declared set (e.g. press_short, press_long, …).
45776
+ * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
45777
+ * is [] (open) and `lastEvent.data` carries the complex payload.
45778
+ * `vocabulary` (D1044) names each event for a person and types it for a
45779
+ * rule; `eventTypes` is its list of native tokens, kept for older readers.
45780
+ * A fire names the part of the device it came from in `sourceId` when the
45781
+ * vocabulary declares sources (a remote's buttons).
45782
+ * `seq` is monotonic so two identical events still produce distinct slice writes.
45783
+ */
45784
+ var EventFireSchema = object({
45785
+ deviceId: number$1(),
45786
+ eventType: string(),
45787
+ sourceId: string().optional(),
45788
+ data: record(string(), unknown()).nullable(),
45789
+ timestamp: number$1().meta(readingMeta("none")),
45790
+ seq: number$1().meta(readingMeta("count"))
45791
+ });
45792
+ var EventEmitterStatusSchema = object({
45793
+ eventTypes: array(string()),
45794
+ /**
45795
+ * Required of a provider by the type. A status written before the field
45796
+ * existed still parses, as an empty vocabulary: read it through
45797
+ * `readEventVocabulary`, which then answers with the plain tokens.
45798
+ */
45799
+ vocabulary: array(EventVocabularyEntrySchema).default([]),
45800
+ lastEvent: EventFireSchema.nullable(),
45801
+ eventCountSinceStart: number$1().meta(readingMeta("count"))
45802
+ });
45803
+ var eventEmitterCapability = {
45804
+ name: "event-emitter",
45805
+ scope: "device",
45806
+ deviceNative: true,
45807
+ mode: "singleton",
45808
+ deviceTypes: [DeviceType.EventEmitter],
45809
+ methods: {},
45810
+ events: { onEvent: { data: EventFireSchema } },
45811
+ status: {
45812
+ schema: EventEmitterStatusSchema,
45813
+ kind: "push"
45814
+ },
45815
+ runtimeState: EventEmitterStatusSchema,
45816
+ /**
45817
+ * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
45818
+ *
45819
+ * See `RuntimeStateDurability`. Enforced by
45820
+ * `scripts/check-runtime-state-durability.ts`.
45821
+ */
45822
+ durability: "session",
45823
+ /**
45824
+ * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
45825
+ */
45826
+ history: "none"
45827
+ };
45581
45828
  /**
45582
45829
  * Actions — named, runnable things an operator (or an automation) can start,
45583
45830
  * declared as LIST ENTRIES, never as devices.
@@ -45757,6 +46004,177 @@ var UnitWarningSchema = object({
45757
46004
  assumedUnit: string(),
45758
46005
  message: string()
45759
46006
  });
46007
+ /**
46008
+ * `device-export` — collection cap for addons that export camstack
46009
+ * devices to external ecosystems (HomeAssistant via MQTT discovery,
46010
+ * HomeKit/HAP, Alexa Smart Home, …).
46011
+ *
46012
+ * No `ecosystem` enum — the addon id identifies the export target.
46013
+ * Each addon owns its mapping logic in its own settings UI. The cap
46014
+ * exposes only the COMMON surface: link state, supported device
46015
+ * kinds (so the UI can filter the device picker), and per-device
46016
+ * expose/unexpose.
46017
+ *
46018
+ * INSTANCES. One export addon can serve several independent targets (a
46019
+ * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
46020
+ * `instanceId` on a READ is optional: absent = the whole addon (linked if any
46021
+ * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
46022
+ * default instance's); present = that instance; an id the provider does not
46023
+ * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
46024
+ * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
46025
+ * change always names the target it changes. A single-instance provider
46026
+ * accepts an absent id on a read or its own id, and refuses any other.
46027
+ */
46028
+ /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
46029
+ var InstanceIdSchema$1 = string().min(1);
46030
+ var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
46031
+ /** One independent export target of an addon. */
46032
+ var ExportInstanceSchema = object({
46033
+ instanceId: InstanceIdSchema$1,
46034
+ name: string(),
46035
+ enabled: boolean(),
46036
+ kind: string().optional(),
46037
+ /**
46038
+ * What this instance's platform accepts as a device name, in one operator-facing sentence
46039
+ * (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
46040
+ * about the rule.
46041
+ */
46042
+ nameRule: string().optional()
46043
+ });
46044
+ var LinkStateSchema = _enum([
46045
+ "unlinked",
46046
+ "linked",
46047
+ "error"
46048
+ ]);
46049
+ /**
46050
+ * A single label/value row surfaced in the export panel's "Setup"
46051
+ * section. Rendered with a copy-to-clipboard button. `secret: true`
46052
+ * rows are masked by default with a reveal toggle (client ids,
46053
+ * secrets, …).
46054
+ */
46055
+ var ExportSetupFieldSchema = object({
46056
+ label: string(),
46057
+ value: string(),
46058
+ /** Mask the value by default + render a reveal toggle (client id, secrets). */
46059
+ secret: boolean().optional()
46060
+ });
46061
+ /**
46062
+ * Generic, addon-agnostic pairing/account block. Any export addon can
46063
+ * surface a scannable QR, a set of copyable label/value rows, and a
46064
+ * free-form operator note — the `DeviceExportPanel` renders whatever
46065
+ * the provider supplies and skips the section entirely when `setup`
46066
+ * is unset.
46067
+ */
46068
+ var ExportSetupSchema = object({
46069
+ /** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
46070
+ qr: string().optional(),
46071
+ /** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
46072
+ fields: array(ExportSetupFieldSchema).readonly().optional(),
46073
+ /** Free-form operator instructions rendered above the fields. */
46074
+ note: string().optional()
46075
+ });
46076
+ var DeviceExportStatusSchema = object({
46077
+ linkState: LinkStateSchema,
46078
+ exposedDeviceCount: number$1(),
46079
+ error: string().optional(),
46080
+ /**
46081
+ * Optional pairing/account info the panel renders in a generic
46082
+ * "Setup" section. Addon-agnostic — the addon id identifies the
46083
+ * export target, never an `ecosystem` key here.
46084
+ */
46085
+ setup: ExportSetupSchema.optional()
46086
+ });
46087
+ var DeviceKindSchema = string();
46088
+ /**
46089
+ * EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
46090
+ * device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
46091
+ * store (D865), validated by the exporter against its platform's naming rules, and never reaches
46092
+ * the exported id — a rename updates the SAME device on the platform, never a second one.
46093
+ * Blank or `null` = the device's own name. A name the platform would refuse is refused with
46094
+ * `ExportNameRefusedError` (`export-name-refused`), whose message says why.
46095
+ */
46096
+ var ExposedDeviceSchema = object({
46097
+ deviceId: string(),
46098
+ exposedAs: string().optional(),
46099
+ /** The operator's name for this device on this instance; absent = the device's own name. */
46100
+ exposedName: string().optional(),
46101
+ capabilities: array(string()).optional()
46102
+ });
46103
+ var ExposeInputSchema = object({
46104
+ instanceId: InstanceIdSchema$1,
46105
+ deviceId: string(),
46106
+ capabilities: array(string()).optional(),
46107
+ /** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
46108
+ exposedName: string().nullable().optional()
46109
+ });
46110
+ var SetExposedNameInputSchema = object({
46111
+ instanceId: InstanceIdSchema$1,
46112
+ deviceId: string(),
46113
+ /** Blank or null = the device's own name. */
46114
+ name: string().nullable(),
46115
+ /**
46116
+ * Validate only: refuse exactly as a real call would, write nothing. A caller saving several
46117
+ * names at once checks every one first, so one refusal writes none (D1049).
46118
+ */
46119
+ dryRun: boolean().optional()
46120
+ });
46121
+ var UnexposeInputSchema = object({
46122
+ instanceId: InstanceIdSchema$1,
46123
+ deviceId: string()
46124
+ });
46125
+ /**
46126
+ * What an exporter may expose besides devices (D968). An action and a
46127
+ * notification target are LIST ENTRIES, never devices (D954): they enter an
46128
+ * exporter's own selection, not the device registry.
46129
+ */
46130
+ var ExportEntityKindSchema = _enum([
46131
+ "device",
46132
+ "action",
46133
+ "notifier"
46134
+ ]);
46135
+ var ExportEntityRefSchema = discriminatedUnion("kind", [
46136
+ object({
46137
+ kind: literal("device"),
46138
+ deviceId: string()
46139
+ }),
46140
+ object({
46141
+ kind: literal("action"),
46142
+ actionId: string().min(1)
46143
+ }),
46144
+ object({
46145
+ kind: literal("notifier"),
46146
+ targetId: string().min(1)
46147
+ })
46148
+ ]);
46149
+ var ExposedEntitySchema = object({
46150
+ entity: ExportEntityRefSchema,
46151
+ exposedAs: string().optional()
46152
+ });
46153
+ var ExposeEntityInputSchema = object({
46154
+ instanceId: InstanceIdSchema$1,
46155
+ entity: ExportEntityRefSchema
46156
+ });
46157
+ var UnexposeEntityInputSchema = object({
46158
+ instanceId: InstanceIdSchema$1,
46159
+ entity: ExportEntityRefSchema
46160
+ });
46161
+ method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
46162
+ kind: "mutation",
46163
+ auth: "admin"
46164
+ }), method(UnexposeInputSchema, _void(), {
46165
+ kind: "mutation",
46166
+ auth: "admin"
46167
+ }), method(SetExposedNameInputSchema, _void(), {
46168
+ kind: "mutation",
46169
+ auth: "admin"
46170
+ }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
46171
+ kind: "mutation",
46172
+ auth: "admin"
46173
+ }), optionalMethod(UnexposeEntityInputSchema, _void(), {
46174
+ kind: "mutation",
46175
+ auth: "admin"
46176
+ });
46177
+ record(string(), string());
45760
46178
  _enum([
45761
46179
  "automation",
45762
46180
  "action",
@@ -50960,11 +51378,13 @@ var IrCodecError = class extends Error {
50960
51378
  this.code = code;
50961
51379
  }
50962
51380
  };
51381
+ /** Maximum number of mark/space entries one pulse train may carry. */
51382
+ var IR_TIMINGS_MAX = 1024;
50963
51383
  /**
50964
51384
  * A pulse train in signed microseconds: mark (+) first, then space (-), strictly
50965
51385
  * alternating, no zeros, 2..1024 entries.
50966
51386
  */
50967
- var IrTimingsSchema = array(number$1().int()).min(2).max(1024).superRefine((timings, ctx) => {
51387
+ var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
50968
51388
  timings.forEach((value, index) => {
50969
51389
  const expectMark = index % 2 === 0;
50970
51390
  if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
@@ -51011,15 +51431,186 @@ function decodePronto(code) {
51011
51431
  carrierHz: Math.round(1e6 / unitUs)
51012
51432
  };
51013
51433
  }
51014
- /** What a remote command stores: a raw pulse train, or a learned Pronto code. */
51015
- var IrPayloadSchema = discriminatedUnion("kind", [object({
51016
- kind: literal("raw"),
51017
- timings: array(number$1().int()),
51018
- settings: TransmitSettingsSchema.optional()
51019
- }), object({
51020
- kind: literal("pronto"),
51021
- code: string()
51022
- })]);
51434
+ /**
51435
+ * FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
51436
+ * literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
51437
+ * is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
51438
+ * between the low 5 bits and the next byte.
51439
+ */
51440
+ var MAX_DISTANCE = 8192;
51441
+ var MAX_LITERAL_RUN = 32;
51442
+ var MIN_MATCH = 3;
51443
+ var MAX_MATCH = 264;
51444
+ /**
51445
+ * Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
51446
+ * can expand ~130x, so the decoder checks this bound before every write.
51447
+ */
51448
+ var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
51449
+ function fastlzDecompress(input) {
51450
+ const out = [];
51451
+ let ip = 0;
51452
+ const room = (count) => {
51453
+ if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
51454
+ };
51455
+ const next = () => {
51456
+ const byte = input[ip++];
51457
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
51458
+ return byte;
51459
+ };
51460
+ while (ip < input.length) {
51461
+ const ctrl = next();
51462
+ if (ctrl < 32) {
51463
+ room(ctrl + 1);
51464
+ for (let i = 0; i <= ctrl; i++) out.push(next());
51465
+ continue;
51466
+ }
51467
+ let len = (ctrl >> 5) - 1;
51468
+ if (len === 6) len += next();
51469
+ const distance = ((ctrl & 31) << 8) + next() + 1;
51470
+ const start = out.length - distance;
51471
+ if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
51472
+ room(len + 3);
51473
+ for (let i = 0; i < len + 3; i++) {
51474
+ const byte = out[start + i];
51475
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
51476
+ out.push(byte);
51477
+ }
51478
+ }
51479
+ return Uint8Array.from(out);
51480
+ }
51481
+ function fastlzCompress(input) {
51482
+ const out = [];
51483
+ const lastSeen = /* @__PURE__ */ new Map();
51484
+ let literalStart = 0;
51485
+ const flushLiterals = (end) => {
51486
+ for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
51487
+ const to = Math.min(from + MAX_LITERAL_RUN, end);
51488
+ out.push(to - from - 1);
51489
+ for (let i = from; i < to; i++) out.push(input[i] ?? 0);
51490
+ }
51491
+ };
51492
+ let pos = 0;
51493
+ while (pos < input.length) {
51494
+ let matchLen = 0;
51495
+ let matchDistance = 0;
51496
+ if (pos + MIN_MATCH <= input.length) {
51497
+ const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
51498
+ const candidate = lastSeen.get(key);
51499
+ lastSeen.set(key, pos);
51500
+ if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
51501
+ let len = 0;
51502
+ while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
51503
+ if (len >= MIN_MATCH) {
51504
+ matchLen = len;
51505
+ matchDistance = pos - candidate - 1;
51506
+ }
51507
+ }
51508
+ }
51509
+ if (matchLen === 0) {
51510
+ pos++;
51511
+ continue;
51512
+ }
51513
+ flushLiterals(pos);
51514
+ const enc = matchLen - 2;
51515
+ if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
51516
+ else out.push(224 | matchDistance >> 8, enc - 7);
51517
+ out.push(matchDistance & 255);
51518
+ pos += matchLen;
51519
+ literalStart = pos;
51520
+ }
51521
+ flushLiterals(input.length);
51522
+ return Uint8Array.from(out);
51523
+ }
51524
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
51525
+ var MAX_DURATION_US = 65535;
51526
+ function toBase64(bytes) {
51527
+ let out = "";
51528
+ for (let i = 0; i < bytes.length; i += 3) {
51529
+ const a = bytes[i] ?? 0;
51530
+ const b = bytes[i + 1] ?? 0;
51531
+ const c = bytes[i + 2] ?? 0;
51532
+ const word = a << 16 | b << 8 | c;
51533
+ out += ALPHABET[word >> 18 & 63];
51534
+ out += ALPHABET[word >> 12 & 63];
51535
+ out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
51536
+ out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
51537
+ }
51538
+ return out;
51539
+ }
51540
+ function fromBase64(text) {
51541
+ const clean = text.trim().replace(/=+$/, "");
51542
+ if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
51543
+ const out = [];
51544
+ let bits = 0;
51545
+ let acc = 0;
51546
+ for (const ch of clean) {
51547
+ const value = ALPHABET.indexOf(ch);
51548
+ if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
51549
+ acc = acc << 6 | value;
51550
+ bits += 6;
51551
+ if (bits >= 8) {
51552
+ bits -= 8;
51553
+ out.push(acc >> bits & 255);
51554
+ }
51555
+ }
51556
+ return Uint8Array.from(out);
51557
+ }
51558
+ /** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
51559
+ function encodeTuya(timings) {
51560
+ const bytes = new Uint8Array(timings.length * 2);
51561
+ timings.forEach((value, index) => {
51562
+ const duration = Math.abs(value);
51563
+ if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
51564
+ bytes[index * 2] = duration & 255;
51565
+ bytes[index * 2 + 1] = duration >> 8;
51566
+ });
51567
+ return toBase64(fastlzCompress(bytes));
51568
+ }
51569
+ /** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
51570
+ function decodeTuya(code) {
51571
+ const bytes = fastlzDecompress(fromBase64(code));
51572
+ if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
51573
+ const timings = [];
51574
+ for (let i = 0; i < bytes.length; i += 2) {
51575
+ const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
51576
+ timings.push(i / 2 % 2 === 0 ? duration : -duration);
51577
+ }
51578
+ const checked = IrTimingsSchema.safeParse(timings);
51579
+ if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
51580
+ return checked.data;
51581
+ }
51582
+ /** Device-native IR code formats a transmitter can replay verbatim. */
51583
+ var IrNativeFormatSchema = _enum(["tuya"]);
51584
+ /**
51585
+ * Longest native code accepted: base64 of the worst-case compressed stream
51586
+ * (every decoded byte as a literal, plus one control byte per 32), with margin.
51587
+ */
51588
+ var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
51589
+ var IrNativeCodeSchema = object({
51590
+ format: IrNativeFormatSchema,
51591
+ code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
51592
+ });
51593
+ var IR_NATIVE_CODECS = { tuya: {
51594
+ encode: encodeTuya,
51595
+ decode: decodeTuya
51596
+ } };
51597
+ /** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
51598
+ var IrPayloadSchema = discriminatedUnion("kind", [
51599
+ object({
51600
+ kind: literal("raw"),
51601
+ timings: array(number$1().int()),
51602
+ settings: TransmitSettingsSchema.optional()
51603
+ }),
51604
+ object({
51605
+ kind: literal("pronto"),
51606
+ code: string()
51607
+ }),
51608
+ object({
51609
+ kind: literal("native"),
51610
+ format: IrNativeFormatSchema,
51611
+ code: string()
51612
+ })
51613
+ ]);
51023
51614
  /** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
51024
51615
  function toTimings(payload) {
51025
51616
  if (payload.kind === "pronto") {
@@ -51029,6 +51620,10 @@ function toTimings(payload) {
51029
51620
  settings: { carrierHz: decoded.carrierHz }
51030
51621
  };
51031
51622
  }
51623
+ if (payload.kind === "native") return {
51624
+ timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
51625
+ settings: {}
51626
+ };
51032
51627
  const checked = IrTimingsSchema.safeParse(payload.timings);
51033
51628
  if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
51034
51629
  return {
@@ -51900,8 +52495,8 @@ function actuator(input) {
51900
52495
  };
51901
52496
  }
51902
52497
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
51903
- DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
51904
52498
  DeviceType.Camera;
52499
+ DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
51905
52500
  var PowerSourceRefusalReasonSchema = _enum([
51906
52501
  "no-power-source",
51907
52502
  "switch-missing",
@@ -53361,144 +53956,6 @@ method(object({
53361
53956
  kind: "mutation",
53362
53957
  auth: "admin"
53363
53958
  });
53364
- /**
53365
- * `device-export` — collection cap for addons that export camstack
53366
- * devices to external ecosystems (HomeAssistant via MQTT discovery,
53367
- * HomeKit/HAP, Alexa Smart Home, …).
53368
- *
53369
- * No `ecosystem` enum — the addon id identifies the export target.
53370
- * Each addon owns its mapping logic in its own settings UI. The cap
53371
- * exposes only the COMMON surface: link state, supported device
53372
- * kinds (so the UI can filter the device picker), and per-device
53373
- * expose/unexpose.
53374
- *
53375
- * INSTANCES. One export addon can serve several independent targets (a
53376
- * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
53377
- * `instanceId` on a READ is optional: absent = the whole addon (linked if any
53378
- * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
53379
- * default instance's); present = that instance; an id the provider does not
53380
- * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
53381
- * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
53382
- * change always names the target it changes. A single-instance provider
53383
- * accepts an absent id on a read or its own id, and refuses any other.
53384
- */
53385
- /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
53386
- var InstanceIdSchema$1 = string().min(1);
53387
- var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
53388
- /** One independent export target of an addon. */
53389
- var ExportInstanceSchema = object({
53390
- instanceId: InstanceIdSchema$1,
53391
- name: string(),
53392
- enabled: boolean(),
53393
- kind: string().optional()
53394
- });
53395
- var LinkStateSchema = _enum([
53396
- "unlinked",
53397
- "linked",
53398
- "error"
53399
- ]);
53400
- /**
53401
- * A single label/value row surfaced in the export panel's "Setup"
53402
- * section. Rendered with a copy-to-clipboard button. `secret: true`
53403
- * rows are masked by default with a reveal toggle (client ids,
53404
- * secrets, …).
53405
- */
53406
- var ExportSetupFieldSchema = object({
53407
- label: string(),
53408
- value: string(),
53409
- /** Mask the value by default + render a reveal toggle (client id, secrets). */
53410
- secret: boolean().optional()
53411
- });
53412
- /**
53413
- * Generic, addon-agnostic pairing/account block. Any export addon can
53414
- * surface a scannable QR, a set of copyable label/value rows, and a
53415
- * free-form operator note — the `DeviceExportPanel` renders whatever
53416
- * the provider supplies and skips the section entirely when `setup`
53417
- * is unset.
53418
- */
53419
- var ExportSetupSchema = object({
53420
- /** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
53421
- qr: string().optional(),
53422
- /** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
53423
- fields: array(ExportSetupFieldSchema).readonly().optional(),
53424
- /** Free-form operator instructions rendered above the fields. */
53425
- note: string().optional()
53426
- });
53427
- var DeviceExportStatusSchema = object({
53428
- linkState: LinkStateSchema,
53429
- exposedDeviceCount: number$1(),
53430
- error: string().optional(),
53431
- /**
53432
- * Optional pairing/account info the panel renders in a generic
53433
- * "Setup" section. Addon-agnostic — the addon id identifies the
53434
- * export target, never an `ecosystem` key here.
53435
- */
53436
- setup: ExportSetupSchema.optional()
53437
- });
53438
- var DeviceKindSchema = string();
53439
- var ExposedDeviceSchema = object({
53440
- deviceId: string(),
53441
- exposedAs: string().optional(),
53442
- capabilities: array(string()).optional()
53443
- });
53444
- var ExposeInputSchema = object({
53445
- instanceId: InstanceIdSchema$1,
53446
- deviceId: string(),
53447
- capabilities: array(string()).optional()
53448
- });
53449
- var UnexposeInputSchema = object({
53450
- instanceId: InstanceIdSchema$1,
53451
- deviceId: string()
53452
- });
53453
- /**
53454
- * What an exporter may expose besides devices (D968). An action and a
53455
- * notification target are LIST ENTRIES, never devices (D954): they enter an
53456
- * exporter's own selection, not the device registry.
53457
- */
53458
- var ExportEntityKindSchema = _enum([
53459
- "device",
53460
- "action",
53461
- "notifier"
53462
- ]);
53463
- var ExportEntityRefSchema = discriminatedUnion("kind", [
53464
- object({
53465
- kind: literal("device"),
53466
- deviceId: string()
53467
- }),
53468
- object({
53469
- kind: literal("action"),
53470
- actionId: string().min(1)
53471
- }),
53472
- object({
53473
- kind: literal("notifier"),
53474
- targetId: string().min(1)
53475
- })
53476
- ]);
53477
- var ExposedEntitySchema = object({
53478
- entity: ExportEntityRefSchema,
53479
- exposedAs: string().optional()
53480
- });
53481
- var ExposeEntityInputSchema = object({
53482
- instanceId: InstanceIdSchema$1,
53483
- entity: ExportEntityRefSchema
53484
- });
53485
- var UnexposeEntityInputSchema = object({
53486
- instanceId: InstanceIdSchema$1,
53487
- entity: ExportEntityRefSchema
53488
- });
53489
- method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
53490
- kind: "mutation",
53491
- auth: "admin"
53492
- }), method(UnexposeInputSchema, _void(), {
53493
- kind: "mutation",
53494
- auth: "admin"
53495
- }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
53496
- kind: "mutation",
53497
- auth: "admin"
53498
- }), optionalMethod(UnexposeEntityInputSchema, _void(), {
53499
- kind: "mutation",
53500
- auth: "admin"
53501
- });
53502
53959
  var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
53503
53960
  var DeviceTemplateSchema = string().min(1).max(4096);
53504
53961
  /** One value a caller hands the renderer for `thisDevice`. */
@@ -56668,117 +57125,6 @@ var enumSensorCapability = {
56668
57125
  * whether persisting is worth a SQLite commit. */
56669
57126
  volatileStateFields: ["lastFetchedAt", "timestamp"]
56670
57127
  };
56671
- var EventVocabularyKindSchema = _enum([
56672
- "press",
56673
- "long-press",
56674
- "long-press-start",
56675
- "release",
56676
- "repeat",
56677
- "double-press",
56678
- "other"
56679
- ]);
56680
- /** The part of the device an event comes from: a button, a channel. */
56681
- var EventVocabularySourceSchema = object({
56682
- id: string().min(1),
56683
- label: string().min(1)
56684
- });
56685
- /** One scalar field of an event's `data`, by dotted path. */
56686
- var EventVocabularyFieldSchema = object({
56687
- path: string().min(1),
56688
- kind: _enum([
56689
- "string",
56690
- "number",
56691
- "boolean",
56692
- "enum"
56693
- ]),
56694
- enumValues: array(string()).optional(),
56695
- label: string().min(1).optional()
56696
- });
56697
- var EventVocabularyEntrySchema = object({
56698
- /** The native token, verbatim. */
56699
- id: string().min(1),
56700
- source: EventVocabularySourceSchema.optional(),
56701
- label: string().min(1),
56702
- description: string().optional(),
56703
- kind: EventVocabularyKindSchema.optional(),
56704
- payload: array(EventVocabularyFieldSchema).optional()
56705
- });
56706
- /**
56707
- * The vocabulary of a source that declares tokens and nothing else: one
56708
- * entry per token, labelled with the token itself.
56709
- */
56710
- function plainEventVocabulary(eventTypes) {
56711
- return [...new Set(eventTypes)].filter((eventType) => eventType !== "").map((eventType) => ({
56712
- id: eventType,
56713
- label: eventType
56714
- }));
56715
- }
56716
- /** The native tokens of a vocabulary, each once, in declaration order. */
56717
- function eventTypesOfVocabulary(vocabulary) {
56718
- return [...new Set(vocabulary.map((entry) => entry.id))];
56719
- }
56720
- /** The entry a fire belongs to: same token, same source (or both without one). */
56721
- function findVocabularyEntry(vocabulary, eventType, sourceId) {
56722
- return vocabulary.find((entry) => entry.id === eventType && entry.source?.id === sourceId);
56723
- }
56724
- /**
56725
- * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
56726
- * device. Carries the device's EXACT declared event vocabulary verbatim
56727
- * (NO normalization). Two shapes:
56728
- * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
56729
- * declared set (e.g. press_short, press_long, …).
56730
- * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
56731
- * is [] (open) and `lastEvent.data` carries the complex payload.
56732
- * `vocabulary` (D1044) names each event for a person and types it for a
56733
- * rule; `eventTypes` is its list of native tokens, kept for older readers.
56734
- * A fire names the part of the device it came from in `sourceId` when the
56735
- * vocabulary declares sources (a remote's buttons).
56736
- * `seq` is monotonic so two identical events still produce distinct slice writes.
56737
- */
56738
- var EventFireSchema = object({
56739
- deviceId: number$1(),
56740
- eventType: string(),
56741
- sourceId: string().optional(),
56742
- data: record(string(), unknown()).nullable(),
56743
- timestamp: number$1().meta(readingMeta("none")),
56744
- seq: number$1().meta(readingMeta("count"))
56745
- });
56746
- var EventEmitterStatusSchema = object({
56747
- eventTypes: array(string()),
56748
- /**
56749
- * Required of a provider by the type. A status written before the field
56750
- * existed still parses, as an empty vocabulary: read it through
56751
- * `readEventVocabulary`, which then answers with the plain tokens.
56752
- */
56753
- vocabulary: array(EventVocabularyEntrySchema).default([]),
56754
- lastEvent: EventFireSchema.nullable(),
56755
- eventCountSinceStart: number$1().meta(readingMeta("count"))
56756
- });
56757
- var eventEmitterCapability = {
56758
- name: "event-emitter",
56759
- scope: "device",
56760
- deviceNative: true,
56761
- mode: "singleton",
56762
- deviceTypes: [DeviceType.EventEmitter],
56763
- methods: {},
56764
- events: { onEvent: { data: EventFireSchema } },
56765
- status: {
56766
- schema: EventEmitterStatusSchema,
56767
- kind: "push"
56768
- },
56769
- runtimeState: EventEmitterStatusSchema,
56770
- /**
56771
- * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
56772
- *
56773
- * See `RuntimeStateDurability`. Enforced by
56774
- * `scripts/check-runtime-state-durability.ts`.
56775
- */
56776
- durability: "session",
56777
- /**
56778
- * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
56779
- */
56780
- history: "none"
56781
- };
56782
57128
  var IdentitySchema = object({
56783
57129
  id: string(),
56784
57130
  name: string(),
@@ -58464,6 +58810,193 @@ var StateLookSchema = object({
58464
58810
  background: _enum(HERO_BACKGROUNDS),
58465
58811
  animation: HeroAnimationSchema
58466
58812
  });
58813
+ /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
58814
+ var HeroTextSchema = object({
58815
+ en: string(),
58816
+ it: string()
58817
+ });
58818
+ /**
58819
+ * What a device that has not reported says in place of its value: an empty "—",
58820
+ * never a word like "Unknown" and never a 0 (D393). The card stays its normal
58821
+ * self; only the value is empty.
58822
+ */
58823
+ var NOT_REPORTED = {
58824
+ en: "—",
58825
+ it: "—"
58826
+ };
58827
+ /**
58828
+ * The ONE measurement a simple sensor shows (card wave, phase 1).
58829
+ *
58830
+ * A sensor that measures a single quantity (a temperature, a humidity, a power,
58831
+ * a contact, a text state) is drawn as that reading, once, big, inside a scene
58832
+ * whose motion says what the number means: heat rising when hot, flakes when
58833
+ * cold, a wire flowing at the speed of the power, a ring while a window is
58834
+ * open. Everything the card draws is decided here; a client only paints it.
58835
+ */
58836
+ var HERO_MEASUREMENT_QUANTITIES = [
58837
+ "temperature",
58838
+ "humidity",
58839
+ "power",
58840
+ "contact",
58841
+ "text"
58842
+ ];
58843
+ /** How a temperature reads to a person; drives the heat or the cold scene. */
58844
+ var HERO_MEASUREMENT_BANDS = [
58845
+ "hot",
58846
+ "mild",
58847
+ "cold"
58848
+ ];
58849
+ /** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
58850
+ var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
58851
+ var HeroMeasurementReadingSchema = object({
58852
+ value: number$1(),
58853
+ quantity: ReadingQuantitySchema
58854
+ });
58855
+ var HeroMeasurementSchema = object({
58856
+ quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
58857
+ reading: HeroMeasurementReadingSchema.nullable(),
58858
+ icon: IconKeySchema.nullable(),
58859
+ value: HeroTextSchema,
58860
+ unit: string().nullable(),
58861
+ band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
58862
+ level: number$1().min(0).max(1).nullable(),
58863
+ word: HeroTextSchema,
58864
+ tone: _enum(HERO_TONES),
58865
+ since: number$1().nullable(),
58866
+ sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
58867
+ historyKey: string().nullable()
58868
+ });
58869
+ var same$2 = (text) => t(text, text);
58870
+ var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
58871
+ var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
58872
+ function temperatureBand(celsius) {
58873
+ if (celsius < 12) return "cold";
58874
+ if (celsius > 28) return "hot";
58875
+ return "mild";
58876
+ }
58877
+ var BAND_WORD = {
58878
+ hot: t("Hot", "Caldo"),
58879
+ mild: t("Normal", "Normale"),
58880
+ cold: t("Cold", "Freddo")
58881
+ };
58882
+ var BAND_TONE = {
58883
+ hot: "warning",
58884
+ mild: "muted",
58885
+ cold: "info"
58886
+ };
58887
+ function temperatureMeasurement(celsius, since) {
58888
+ const band = temperatureBand(celsius);
58889
+ return {
58890
+ quantity: "temperature",
58891
+ reading: {
58892
+ value: celsius,
58893
+ quantity: "temperature"
58894
+ },
58895
+ icon: "thermometer",
58896
+ value: same$2(trimmed(celsius, 1)),
58897
+ unit: "°C",
58898
+ band,
58899
+ level: null,
58900
+ word: BAND_WORD[band],
58901
+ tone: BAND_TONE[band],
58902
+ since,
58903
+ sinceKind: "updated",
58904
+ historyKey: "cap:temperature-sensor.temperature"
58905
+ };
58906
+ }
58907
+ function humidityMeasurement(percent, since) {
58908
+ const dry = percent < 30;
58909
+ const humid = percent > 70;
58910
+ return {
58911
+ quantity: "humidity",
58912
+ reading: {
58913
+ value: percent,
58914
+ quantity: "humidity"
58915
+ },
58916
+ icon: "droplets",
58917
+ value: same$2(String(Math.round(percent))),
58918
+ unit: "%",
58919
+ band: null,
58920
+ level: clamp01$1(percent / 100),
58921
+ word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
58922
+ tone: dry || humid ? "warning" : "info",
58923
+ since,
58924
+ sinceKind: "updated",
58925
+ historyKey: "cap:humidity-sensor.humidity"
58926
+ };
58927
+ }
58928
+ function textMeasurement(text, since) {
58929
+ return {
58930
+ quantity: "text",
58931
+ reading: null,
58932
+ icon: null,
58933
+ value: same$2(text),
58934
+ unit: null,
58935
+ band: null,
58936
+ level: null,
58937
+ word: t("Changed", "Cambiato"),
58938
+ tone: "muted",
58939
+ since,
58940
+ sinceKind: "updated",
58941
+ historyKey: null
58942
+ };
58943
+ }
58944
+ /** What each quantity draws beside its value, reported or not. */
58945
+ var QUANTITY_FACE = {
58946
+ temperature: {
58947
+ icon: "thermometer",
58948
+ unit: "°C",
58949
+ sinceKind: "updated",
58950
+ historyKey: "cap:temperature-sensor.temperature"
58951
+ },
58952
+ humidity: {
58953
+ icon: "droplets",
58954
+ unit: "%",
58955
+ sinceKind: "updated",
58956
+ historyKey: "cap:humidity-sensor.humidity"
58957
+ },
58958
+ power: {
58959
+ icon: "zap",
58960
+ unit: "W",
58961
+ sinceKind: "updated",
58962
+ historyKey: "cap:power-meter.power"
58963
+ },
58964
+ contact: {
58965
+ icon: null,
58966
+ unit: null,
58967
+ sinceKind: "changed",
58968
+ historyKey: null
58969
+ },
58970
+ text: {
58971
+ icon: null,
58972
+ unit: null,
58973
+ sinceKind: "updated",
58974
+ historyKey: null
58975
+ }
58976
+ };
58977
+ /**
58978
+ * The measurement of a sensor that has not reported yet: its normal card with
58979
+ * an empty "—" value and its unit — never a placeholder, never a 0 (D393). The
58980
+ * reading is `null` (nothing to format), the scene does not move, and nothing
58981
+ * claims a moment.
58982
+ */
58983
+ function emptyMeasurement(quantity) {
58984
+ const face = QUANTITY_FACE[quantity];
58985
+ return {
58986
+ quantity,
58987
+ reading: null,
58988
+ icon: face.icon,
58989
+ value: NOT_REPORTED,
58990
+ unit: face.unit,
58991
+ band: null,
58992
+ level: null,
58993
+ word: NOT_REPORTED,
58994
+ tone: "muted",
58995
+ since: null,
58996
+ sinceKind: face.sinceKind,
58997
+ historyKey: face.historyKey
58998
+ };
58999
+ }
58467
59000
  /** The scene as the model carries it. `null` = the device did not say (never a guess). */
58468
59001
  var HeroSceneSchema = object({
58469
59002
  id: _enum([
@@ -58514,12 +59047,7 @@ var HeroSceneSchema = object({
58514
59047
  level: number$1().min(0).max(1).nullable()
58515
59048
  });
58516
59049
  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;
58517
- 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;
58518
- /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
58519
- var HeroTextSchema = object({
58520
- en: string(),
58521
- it: string()
58522
- });
59050
+ 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;
58523
59051
  var HeroRowIdSchema = _enum([
58524
59052
  "progress",
58525
59053
  "run-for",
@@ -58625,6 +59153,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
58625
59153
  optionLabels: record(string(), HeroTextSchema).optional(),
58626
59154
  call: HeroCallSchema,
58627
59155
  valueArg: string()
59156
+ }),
59157
+ object({
59158
+ kind: literal("number"),
59159
+ id: string(),
59160
+ label: HeroTextSchema,
59161
+ value: number$1().nullable(),
59162
+ /** `null` = any number; the device rounds what it does not accept. */
59163
+ step: number$1().nullable(),
59164
+ unit: string(),
59165
+ call: HeroCallSchema,
59166
+ valueArg: string()
59167
+ }),
59168
+ object({
59169
+ kind: literal("text"),
59170
+ id: string(),
59171
+ label: HeroTextSchema,
59172
+ value: string().nullable(),
59173
+ call: HeroCallSchema,
59174
+ valueArg: string()
58628
59175
  })
58629
59176
  ]);
58630
59177
  /** Declared by its interface: a `z.infer` of one more icon union pushes the cap's inferred type past what the compiler can print. */
@@ -58826,6 +59373,11 @@ var HeroModelSchema = object({
58826
59373
  timedRun: HeroTimedRunSlotSchema.nullable(),
58827
59374
  powerSupply: HeroPowerSupplySlotSchema.nullable(),
58828
59375
  rows: array(HeroRowSchema),
59376
+ /**
59377
+ * The ONE measurement of a simple sensor, drawn once inside the scene in place of
59378
+ * the caption, tiles and value chips. Absent = the card draws as before.
59379
+ */
59380
+ measurement: HeroMeasurementSchema.optional(),
58829
59381
  /** Ids of parts that actuate the device, hidden from a session that may not act on it. */
58830
59382
  gated: array(string()),
58831
59383
  provenance: array(HeroProvenanceSchema)
@@ -58897,8 +59449,23 @@ var HeroRowModelSchema = object({
58897
59449
  * the call. Absent or empty = `primary` alone.
58898
59450
  */
58899
59451
  extras: array(HeroControlSchema).max(2).optional(),
58900
- trailing: HeroFactSchema.nullable()
59452
+ trailing: HeroFactSchema.nullable(),
59453
+ /**
59454
+ * The simple sensor's one reading (the hero's `measurement`): the row draws its value
59455
+ * at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
59456
+ * older server or a device that is not a simple sensor: draw `trailing`.
59457
+ */
59458
+ measurement: HeroMeasurementSchema.optional()
58901
59459
  });
59460
+ new Set([
59461
+ "temperature",
59462
+ "humidity",
59463
+ "pressure",
59464
+ "illuminance",
59465
+ "reading",
59466
+ "air-quality",
59467
+ "valve"
59468
+ ]);
58902
59469
  DeviceType.Climate;
58903
59470
  DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
58904
59471
  /**
@@ -59354,6 +59921,12 @@ var IntegrationLiteSchema = object({
59354
59921
  var AvailableIntegrationTypeSchema = object({
59355
59922
  addonId: string(),
59356
59923
  name: string(),
59924
+ /**
59925
+ * Product name a new integration is prefilled from (`<label> - Home`).
59926
+ * Absent: the client uses `name`. Set when the catalog title is not the
59927
+ * product (Bosch SHC, MQTT).
59928
+ */
59929
+ providerLabel: string().optional(),
59357
59930
  description: string(),
59358
59931
  iconUrl: string().nullable(),
59359
59932
  color: string(),
@@ -59981,13 +60554,32 @@ var IrSendResultSchema = object({
59981
60554
  var IrTransmitterInfoSchema = object({
59982
60555
  media: array(IrMediumSchema),
59983
60556
  settable: array(TransmitSettingKeySchema),
59984
- maxTimings: number$1().int().positive()
60557
+ maxTimings: number$1().int().positive(),
60558
+ /** The transmitter can learn a code (`learn`). */
60559
+ learn: boolean().default(false),
60560
+ /** Native code formats the transmitter replays verbatim (`send.native`). */
60561
+ formats: array(IrNativeFormatSchema).default([])
60562
+ });
60563
+ var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
60564
+ var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
60565
+ var IrLearnResultSchema = object({
60566
+ /** The code in the device's own format, when it reports one. */
60567
+ native: IrNativeCodeSchema.nullable(),
60568
+ timings: IrTimingsSchema,
60569
+ carrierHz: number$1().int().positive().nullable()
59985
60570
  });
59986
60571
  DeviceType.Generic, method(object({
59987
60572
  deviceId: number$1().int().nonnegative(),
59988
- timings: IrTimingsSchema,
60573
+ timings: IrTimingsSchema.optional(),
60574
+ native: IrNativeCodeSchema.optional(),
59989
60575
  settings: TransmitSettingsSchema.optional()
59990
- }), IrSendResultSchema, {
60576
+ }).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
60577
+ kind: "mutation",
60578
+ auth: "protected"
60579
+ }), method(object({
60580
+ deviceId: number$1().int().nonnegative(),
60581
+ timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
60582
+ }), IrLearnResultSchema, {
59991
60583
  kind: "mutation",
59992
60584
  auth: "protected"
59993
60585
  }), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
@@ -69773,6 +70365,7 @@ var NcSystemEventKindSchema = _enum([
69773
70365
  "recording-degraded",
69774
70366
  "device-attention-required",
69775
70367
  "device-attention-resolved",
70368
+ "device-command",
69776
70369
  "storage-location-low",
69777
70370
  "storage-location-critical",
69778
70371
  "storage-location-ok",
@@ -69835,11 +70428,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
69835
70428
  "alarm-sensor-bypass",
69836
70429
  "alarm-disarmed"
69837
70430
  ];
69838
- /**
69839
- * One coherent system-event condition. `kinds` is the required opt-in safety
69840
- * gate; the remaining lists are optional narrowing filters relevant to the
69841
- * selected kinds.
69842
- */
69843
70431
  var NcSystemEventConditionSchema = object({
69844
70432
  kinds: array(NcSystemEventKindSchema).min(1),
69845
70433
  deviceIds: array(number$1().int()).min(1).optional(),
@@ -69871,6 +70459,28 @@ var NcSystemEventConditionSchema = object({
69871
70459
  nodeIds: array(string().min(1)).min(1).optional(),
69872
70460
  packageNames: array(string().min(1)).min(1).optional(),
69873
70461
  /**
70462
+ * `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
70463
+ * this rule speaks about - the same dictionary the automation action blocks
70464
+ * pick from. The hub refuses an id the action index does not know.
70465
+ */
70466
+ commandActions: array(string().min(1)).min(1).optional(),
70467
+ /** `device-command` only: how the command settled. A device's own change is not a command. */
70468
+ commandOutcomes: array(_enum([
70469
+ "confirmed",
70470
+ "already",
70471
+ "unconfirmed",
70472
+ "failed"
70473
+ ])).min(1).optional(),
70474
+ /** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
70475
+ commandActorKinds: array(_enum([
70476
+ "user",
70477
+ "addon",
70478
+ "action",
70479
+ "scheduler",
70480
+ "composition",
70481
+ "node"
70482
+ ])).min(1).optional(),
70483
+ /**
69874
70484
  * At or below this remaining-life %, a consumable is LOW for THIS rule
69875
70485
  * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
69876
70486
  * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
@@ -70851,6 +71461,13 @@ var NcRuleInputSchema = object({
70851
71461
  */
70852
71462
  groupingSec: number$1().int().min(5).max(60).optional(),
70853
71463
  /**
71464
+ * Hold deliveries of this rule to one target and, when two or more arrive
71465
+ * before the window ends, send them as one summary. Absent = the kind's
71466
+ * default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
71467
+ * other kind. `0` sends each delivery as it does today.
71468
+ */
71469
+ groupWithinSec: number$1().int().min(0).max(300).optional(),
71470
+ /**
70854
71471
  * ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
70855
71472
  * carries "Correct" / "Wrong" buttons (and, where the channel has room, a
70856
71473
  * "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
@@ -71287,7 +71904,12 @@ var NcHistoryEntrySchema = object({
71287
71904
  * Assistant export) must render as "no image right now", never as a
71288
71905
  * broken link.
71289
71906
  */
71290
- artifactIds: array(string().min(1)).optional()
71907
+ artifactIds: array(string().min(1)).optional(),
71908
+ /**
71909
+ * When this row was folded into a group-window summary, the outbox id of
71910
+ * that one notification. Absent on a row that was sent as itself.
71911
+ */
71912
+ groupedInto: string().min(1).optional()
71291
71913
  });
71292
71914
  /**
71293
71915
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -77360,10 +77982,15 @@ getStatus: method(object({ deviceId: number$1() }), RecordingSignalStatusSchema)
77360
77982
  */
77361
77983
  history: "none"
77362
77984
  };
77363
- var RemoteBindingSchema = object({ action: AutomationCapStepBaseSchema.omit({
77364
- target: true,
77365
- actionId: true
77366
- }).extend({ deviceId: number$1().int().nonnegative() }) });
77985
+ var RemoteBindingSchema = object({ action: object({
77986
+ kind: literal("cap"),
77987
+ deviceId: number$1().int().nonnegative(),
77988
+ cap: string().min(1),
77989
+ method: string().min(1),
77990
+ args: record(string(), unknown()).optional(),
77991
+ /** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
77992
+ argUnits: record(string(), string().min(1)).optional()
77993
+ }) });
77367
77994
  var RemoteCustomButtonSchema = object({
77368
77995
  /** The slug after `custom:` in the role. */
77369
77996
  key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
@@ -78353,7 +78980,7 @@ var sceneMonitorCapability = {
78353
78980
  * instead of failing silently weeks later.
78354
78981
  *
78355
78982
  * Reachable from three surfaces on this one mutation: the scene card, a
78356
- * notification button (an `onTrigger` sequence with a `kind:'cap'` step —
78983
+ * notification button (an `onTrigger` sequence with a `kind:'command'` step —
78357
78984
  * no new Notification-Center code at all), and tRPC for scripts.
78358
78985
  */
78359
78986
  resetScene: method(object({
@@ -85332,8 +85959,6 @@ var BaseDeviceProvider = class extends BaseAddon {
85332
85959
  }
85333
85960
  };
85334
85961
  DeviceType.HeatPump;
85335
- DeviceType.Climate;
85336
- DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
85337
85962
  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;
85338
85963
  new Set(Object.values(DeviceType));
85339
85964
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
@@ -85346,6 +85971,13 @@ function contribution(cap, schema, build) {
85346
85971
  }
85347
85972
  };
85348
85973
  }
85974
+ /** The fragment, carrying the cap's single measurement when it has one. */
85975
+ function measured(fragment, measurement) {
85976
+ return measurement === void 0 ? fragment : {
85977
+ ...fragment,
85978
+ measurement
85979
+ };
85980
+ }
85349
85981
  function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
85350
85982
  return {
85351
85983
  id,
@@ -85465,7 +86097,7 @@ var lockContribution = contribution("lock-control", LockControlStatusSchema, (sl
85465
86097
  const state = slice?.state ?? null;
85466
86098
  const words = state === null ? null : LOCK_WORDS[state];
85467
86099
  const since = slice === void 0 ? null : elapsedText(slice.lastChangedAt, ctx.now);
85468
- const title = words?.title ?? t("Unknown", "Sconosciuto");
86100
+ const title = words?.title ?? NOT_REPORTED;
85469
86101
  return {
85470
86102
  reading: reading("lock-control", words?.state ?? "unknown", false, words?.title),
85471
86103
  rows: [row$1("lock", state === "locked" || state === "locking" ? "lock" : "lock-open", joinText([title, since]), lockControls(state, ctx.features.includes(DeviceFeature.LockOpen)))],
@@ -85557,7 +86189,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85557
86189
  const modes = slice === void 0 ? ALARM_MODES : slice.availableModes;
85558
86190
  return {
85559
86191
  reading: reading("alarm-panel", words?.state ?? "unknown", false, words?.title),
85560
- rows: [row$1("alarm", state === "triggered" ? "shield-alert" : state === "disarmed" ? "shield-off" : "shield-check", joinText([words?.title ?? t("Unknown", "Sconosciuto"), since]), alarmControls(state, modes, slice?.requiresCode ?? false))],
86192
+ rows: [row$1("alarm", state === "triggered" ? "shield-alert" : state === "disarmed" ? "shield-off" : "shield-check", joinText([words?.title ?? NOT_REPORTED, since]), alarmControls(state, modes, slice?.requiresCode ?? false))],
85561
86193
  ...since === null || words === null ? {} : { facts: [fact("since", "clock", since, state === "triggered" ? "danger" : "muted")] },
85562
86194
  ...words === null ? {} : { tiles: {
85563
86195
  left: [{
@@ -85588,7 +86220,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85588
86220
  return {
85589
86221
  reading: reading("automation-control", state, false, title),
85590
86222
  rows: [row$1("automation", "workflow", joinText([
85591
- title ?? t("Unknown", "Sconosciuto"),
86223
+ title ?? NOT_REPORTED,
85592
86224
  last === null ? null : t(`Ran ${last.en}`, `Eseguita ${last.it}`),
85593
86225
  slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
85594
86226
  ]), [asAction(run), toggle])],
@@ -85604,7 +86236,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85604
86236
  return {
85605
86237
  reading: reading("script-runner", state, false, title),
85606
86238
  rows: [row$1("script", "scroll-text", joinText([
85607
- title ?? t("Unknown", "Sconosciuto"),
86239
+ title ?? NOT_REPORTED,
85608
86240
  last === null ? null : t(`Ran ${last.en}`, `Eseguito ${last.it}`),
85609
86241
  slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
85610
86242
  ]), [asAction(control)])],
@@ -85613,7 +86245,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85613
86245
  }),
85614
86246
  "do-not-disturb": contribution("do-not-disturb", DoNotDisturbStatusSchema, (slice) => {
85615
86247
  const on = slice?.enabled ?? null;
85616
- return { rows: [row$1("do-not-disturb", "bell-off", on === null ? t("Unknown", "Sconosciuto") : on ? t("Do not disturb on", "Non disturbare attivo") : t("Do not disturb off", "Non disturbare spento"), [{
86248
+ return { rows: [row$1("do-not-disturb", "bell-off", on === null ? NOT_REPORTED : on ? t("Do not disturb on", "Non disturbare attivo") : t("Do not disturb off", "Non disturbare spento"), [{
85617
86249
  kind: "toggle",
85618
86250
  id: "do-not-disturb.toggle",
85619
86251
  label: t("Do not disturb", "Non disturbare"),
@@ -85631,7 +86263,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85631
86263
  * is absent from the facts, never a zero (D393).
85632
86264
  */
85633
86265
  var has$3 = (ctx, f) => ctx.features.includes(f);
85634
- var unknownText = t("Unknown", "Sconosciuto");
86266
+ var unknownText = NOT_REPORTED;
85635
86267
  var pct$2 = (n) => t(`${Math.round(n)}%`, `${Math.round(n)}%`);
85636
86268
  var unit = (n) => Math.min(1, Math.max(0, n / 100));
85637
86269
  /** Battery as a fact, unless the device is also bound to the `battery` cap (it already says so). */
@@ -86620,10 +87252,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
86620
87252
  };
86621
87253
  });
86622
87254
  var CONTROL_LABEL = t("Value", "Valore");
86623
- /** A number with known bounds is a slider, a choice a picker; text and dates stay read-only. */
87255
+ /**
87256
+ * A number with known bounds is a slider, one without a number field, a choice a picker,
87257
+ * free text a text field; a date stays read-only.
87258
+ */
86624
87259
  function controlRows(slice) {
86625
87260
  if (slice.kind === "numeric" && typeof slice.value === "number") {
86626
- if (slice.min === void 0 || slice.max === void 0) return [];
87261
+ if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
87262
+ kind: "number",
87263
+ id: "control.value",
87264
+ label: CONTROL_LABEL,
87265
+ value: slice.value,
87266
+ step: slice.step ?? null,
87267
+ unit: "",
87268
+ call: {
87269
+ cap: "control",
87270
+ method: "setValue",
87271
+ args: { control: { kind: "numeric" } }
87272
+ },
87273
+ valueArg: "control.value"
87274
+ }])];
86627
87275
  return [row$1("control", "sliders-horizontal", null, [{
86628
87276
  kind: "slider",
86629
87277
  id: "control.value",
@@ -86654,6 +87302,18 @@ function controlRows(slice) {
86654
87302
  },
86655
87303
  valueArg: "control.value"
86656
87304
  }])];
87305
+ if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
87306
+ kind: "text",
87307
+ id: "control.value",
87308
+ label: CONTROL_LABEL,
87309
+ value: typeof slice.value === "string" ? slice.value : null,
87310
+ call: {
87311
+ cap: "control",
87312
+ method: "setValue",
87313
+ args: { control: { kind: "text" } }
87314
+ },
87315
+ valueArg: "control.value"
87316
+ }])];
86657
87317
  return [];
86658
87318
  }
86659
87319
  var SENSORS_FAMILY_CONTRIBUTIONS = {
@@ -87009,15 +87669,15 @@ function sensorFragment(value, id, icon, en, it, text) {
87009
87669
  tiles: { right: [tile$1(en, it, text)] }
87010
87670
  };
87011
87671
  }
87012
- var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
87013
- var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`));
87672
+ var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => measured(sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)), slice?.temperature == null ? emptyMeasurement("temperature") : temperatureMeasurement(slice.temperature, slice.lastFetchedAt)));
87673
+ var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => measured(sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`), slice?.humidity == null ? emptyMeasurement("humidity") : humidityMeasurement(slice.humidity, slice.lastFetchedAt)));
87014
87674
  var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
87015
87675
  var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
87016
87676
  var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
87017
87677
  var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
87018
- if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
87678
+ if (slice === void 0 || slice.value === "") return measured({ reading: reading("sensor", "unknown") }, emptyMeasurement("text"));
87019
87679
  if (slice.timestamp === true) return { reading: reading("sensor", "on") };
87020
- return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
87680
+ return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
87021
87681
  });
87022
87682
  /** Index bands: the headline of an air-quality sensor is a word, not a number. */
87023
87683
  function airQualityWord(aqi) {
@@ -87139,7 +87799,7 @@ function circuitControl(circuit) {
87139
87799
  return picker(`heat-pump.${circuit.id}.mode`, t("Mode", "Modalità"), circuit.operationMode, method, args);
87140
87800
  }
87141
87801
  /** A circuit with no reading is still a row: it shows that nothing is known, not nothing. */
87142
- var UNKNOWN_STATUS = same("—");
87802
+ var UNKNOWN_STATUS = NOT_REPORTED;
87143
87803
  function circuitRow(circuit) {
87144
87804
  const control = circuitControl(circuit);
87145
87805
  const status = thermalStatusText(circuit.targetTemp, circuit.currentTemp) ?? UNKNOWN_STATUS;
@@ -87363,9 +88023,8 @@ function look(icon, tone, background, animation) {
87363
88023
  animation
87364
88024
  };
87365
88025
  }
87366
- /** A state a device is in whatever it is: unreachable, or silent. Identical for every look. */
88026
+ /** Unreachable: identical for every look. */
87367
88027
  var OFFLINE = look("wifi-off", "muted", "plain", "none");
87368
- var UNKNOWN = look("circle-question-mark", "muted", "plain", "none");
87369
88028
  var ALERT = look("triangle-alert", "danger", "alert-wash", "pulse");
87370
88029
  function lookOf(spec) {
87371
88030
  const at = (s) => look(spec.icon, s[0], s[1], s[2]);
@@ -87377,7 +88036,7 @@ function lookOf(spec) {
87377
88036
  standby: at(spec.standby),
87378
88037
  alert: spec.alert ?? ALERT,
87379
88038
  offline: OFFLINE,
87380
- unknown: UNKNOWN
88039
+ unknown: look(spec.icon, "muted", "plain", "none")
87381
88040
  };
87382
88041
  }
87383
88042
  var MUTED = [
@@ -87986,7 +88645,7 @@ lookOf({
87986
88645
  });
87987
88646
  DeviceType.Climate;
87988
88647
  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;
87989
- 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;
88648
+ 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;
87990
88649
  Object.freeze({
87991
88650
  "accessories.getStatus": {
87992
88651
  capName: "accessories",
@@ -89913,6 +90572,13 @@ Object.freeze({
89913
90572
  access: "view",
89914
90573
  role: "admin"
89915
90574
  },
90575
+ "deviceExport.setExposedName": {
90576
+ capName: "device-export",
90577
+ capScope: "system",
90578
+ addonId: null,
90579
+ access: "create",
90580
+ role: "admin"
90581
+ },
89916
90582
  "deviceExport.unexposeDevice": {
89917
90583
  capName: "device-export",
89918
90584
  capScope: "system",
@@ -91852,6 +92518,13 @@ Object.freeze({
91852
92518
  access: "view",
91853
92519
  role: "viewer"
91854
92520
  },
92521
+ "irTransmitter.learn": {
92522
+ capName: "ir-transmitter",
92523
+ capScope: "device",
92524
+ addonId: null,
92525
+ access: "create",
92526
+ role: "viewer"
92527
+ },
91855
92528
  "irTransmitter.send": {
91856
92529
  capName: "ir-transmitter",
91857
92530
  capScope: "device",
@@ -98370,48 +99043,6 @@ Object.freeze({
98370
99043
  role: "admin"
98371
99044
  }
98372
99045
  });
98373
- /**
98374
- * "Do" actions an operator can pick for a device — presentation-free.
98375
- *
98376
- * The wire shape stays `{ cap, method, args }`. Since D920 this module no
98377
- * longer HOLDS a catalogue: {@link DEVICE_DO_ACTIONS} is a projection of the
98378
- * cap vocabulary (`cap-vocabulary/`), the one cap-keyed map of every action
98379
- * and trigger — so a picker built on this module and one built on
98380
- * `actionsForDevice` (the vocabulary resolver) can never disagree about what
98381
- * a device can do. Ids, baked args and the matching of saved steps are the
98382
- * vocabulary's; labels here are its English labels.
98383
- *
98384
- * Shared by the admin NC Sequences / rule Do editor and Automations; the
98385
- * viewer can reuse the same catalogue once its step editor catches up.
98386
- */
98387
- function openArgKind(offer) {
98388
- if (offer.kind === "number") return "number";
98389
- if (offer.kind === "dynamic" && offer.valueKind === "number") return "number";
98390
- if (offer.kind === "enum" && offer.values.every((v) => typeof v.value === "number")) return "number";
98391
- return "string";
98392
- }
98393
- function projectOpenArg(arg) {
98394
- return {
98395
- key: arg.key,
98396
- label: arg.label.en,
98397
- kind: openArgKind(arg.offer),
98398
- offer: arg.offer,
98399
- ...arg.optional === true ? { optional: true } : {}
98400
- };
98401
- }
98402
- function projectAction(cap, action) {
98403
- const open = action.openArgs ?? [];
98404
- return {
98405
- id: action.id,
98406
- label: action.label.en,
98407
- cap,
98408
- method: action.method,
98409
- args: action.args ?? {},
98410
- ...open.length > 0 ? { openArgs: open.map(projectOpenArg) } : {}
98411
- };
98412
- }
98413
- Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
98414
- 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;
98415
99046
  DeviceFeature.BatteryOperated;
98416
99047
  function bound(cap, methods = [], authority = "reported") {
98417
99048
  return {
@@ -98470,6 +99101,10 @@ function offered(received) {
98470
99101
  };
98471
99102
  }
98472
99103
  offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
99104
+ DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.HeatPump, 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.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;
99105
+ 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;
99106
+ new Set(Object.values(DeviceType));
99107
+ new Set(Object.values(DeviceRole));
98473
99108
  var PowerSwitchRefusedError = class extends Error {
98474
99109
  reason;
98475
99110
  constructor(reason, message) {
@@ -99846,6 +100481,11 @@ Object.freeze({
99846
100481
  form: "single",
99847
100482
  optional: false
99848
100483
  }],
100484
+ "irTransmitter.learn": [{
100485
+ name: "deviceId",
100486
+ form: "single",
100487
+ optional: false
100488
+ }],
99849
100489
  "irTransmitter.send": [{
99850
100490
  name: "deviceId",
99851
100491
  form: "single",
@@ -101785,7 +102425,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
101785
102425
  "deviceTypes",
101786
102426
  "nodeIds",
101787
102427
  "packageNames",
101788
- "consumableLowPercent"
102428
+ "consumableLowPercent",
102429
+ "commandActions",
102430
+ "commandOutcomes",
102431
+ "commandActorKinds"
101789
102432
  ];
101790
102433
  new Map(Object.entries({
101791
102434
  "device-online": "device-events",
@@ -101808,6 +102451,7 @@ new Map(Object.entries({
101808
102451
  "recording-degraded": "device-events",
101809
102452
  "device-attention-required": "device-events",
101810
102453
  "device-attention-resolved": "device-events",
102454
+ "device-command": "device-events",
101811
102455
  "node-online": "system",
101812
102456
  "node-offline": "system",
101813
102457
  "node-restarting": "system",
@@ -101908,6 +102552,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
101908
102552
  label: "Needs attention",
101909
102553
  kinds: ["device-attention-required", "device-attention-resolved"]
101910
102554
  },
102555
+ {
102556
+ id: "device-command",
102557
+ family: "device-events",
102558
+ label: "Commands given to devices",
102559
+ kinds: ["device-command"]
102560
+ },
101911
102561
  {
101912
102562
  id: "nodes",
101913
102563
  family: "system",
@@ -101985,6 +102635,15 @@ function systemEventKindsOfFamily(family) {
101985
102635
  return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
101986
102636
  }
101987
102637
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
102638
+ new Set([
102639
+ "alarm.trigger",
102640
+ "alarm.disarm",
102641
+ "alarm.arm.home",
102642
+ "alarm.arm.away",
102643
+ "alarm.arm.night",
102644
+ "alarm.arm.vacation",
102645
+ "alarm.arm.custom_bypass"
102646
+ ]);
101988
102647
  /**
101989
102648
  * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
101990
102649
  * persists (D640 "a sensor rule fires on the raise, the clear, or both").
@@ -102180,6 +102839,7 @@ var DEVICE_EVENTS = [
102180
102839
  "recording-healthy",
102181
102840
  "recording-degraded",
102182
102841
  ...DEVICE_ATTENTION,
102842
+ "device-command",
102183
102843
  ...ALARM
102184
102844
  ];
102185
102845
  /** Every kind a summary may speak about — the two summarisable families. */
@@ -102333,6 +102993,9 @@ var STATE_SUMMARY_VARS = [
102333
102993
  [...RULE_BODY_ONLY],
102334
102994
  [...RULE_TEXT],
102335
102995
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
102996
+ [...RULE_TEXT],
102997
+ [...RULE_TEXT],
102998
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
102336
102999
  ([...RULE_TEXT], [...COMBINED_ALARM]),
102337
103000
  ([...RULE_TEXT], [...COMBINED_ALARM]),
102338
103001
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
@@ -103185,6 +103848,38 @@ function bestLocationMatch(externalName, existing, threshold = .8) {
103185
103848
  return best;
103186
103849
  }
103187
103850
  /**
103851
+ * Names chosen when an integration or a Gateway device is created.
103852
+ * A stored name is never rewritten from these helpers.
103853
+ */
103854
+ var HOME_SUFFIX = "Home";
103855
+ function collapse(value) {
103856
+ return value.trim().replace(/\s+/g, " ");
103857
+ }
103858
+ /** "KLF-200" → "KLF200". A hyphen between words ("Home Hub") stays. */
103859
+ function compactModelToken(value) {
103860
+ return value.replace(/([A-Za-z])-(\d)/g, "$1$2");
103861
+ }
103862
+ /** Prefill for a new integration: "<provider> - Home". The operator can edit it. */
103863
+ function defaultIntegrationName(providerLabel) {
103864
+ const label = collapse(providerLabel);
103865
+ if (label.length === 0) return HOME_SUFFIX;
103866
+ return `${label} - ${HOME_SUFFIX}`;
103867
+ }
103868
+ /**
103869
+ * A Gateway device: "<Brand> <Model>". An unknown model is the brand alone
103870
+ * (the caller passes the brand-level fallback it already has, e.g. "Velux KLF-200").
103871
+ */
103872
+ function gatewayDeviceName(brand, model) {
103873
+ const brandPart = compactModelToken(collapse(brand));
103874
+ const raw = collapse(model ?? "");
103875
+ if (raw.length === 0) return brandPart;
103876
+ const modelPart = compactModelToken(raw);
103877
+ const prefix = `${brandPart.toLowerCase()} `;
103878
+ if (modelPart.toLowerCase() === brandPart.toLowerCase()) return brandPart;
103879
+ if (modelPart.toLowerCase().startsWith(prefix)) return modelPart;
103880
+ return `${brandPart} ${modelPart}`;
103881
+ }
103882
+ /**
103188
103883
  * Closes the gap D49 leaves: an integration deleted while its provider was down never emits an
103189
103884
  * event the provider sees. An integration id absent from an ANSWERED list is only a suspect; its
103190
103885
  * devices go (through the provider's own removeDevices) when a SECOND answered read, at least
@@ -103369,6 +104064,284 @@ var HomematicReconciler = class {
103369
104064
  }
103370
104065
  };
103371
104066
  //#endregion
104067
+ //#region src/homematic-mapping.ts
104068
+ /**
104069
+ * Map a single Homematic channel to its CamStack triplet. The channel
104070
+ * `TYPE` is the discriminator. Only the controllable / primary channel
104071
+ * types map; status-only `*_TRANSMITTER` mirrors and the various key /
104072
+ * remote / week-profile channels return `null` (their datapoints are
104073
+ * still decoded into the owning cap's slice via the device's
104074
+ * `valueChanged` handler, keyed by parameter name).
104075
+ */
104076
+ function mapHmChannel(channelType) {
104077
+ if (!channelType) return null;
104078
+ switch (channelType.toUpperCase()) {
104079
+ case "SWITCH_VIRTUAL_RECEIVER": return {
104080
+ deviceType: DeviceType.Switch,
104081
+ role: null,
104082
+ capabilities: ["switch"]
104083
+ };
104084
+ case "SHUTTER_VIRTUAL_RECEIVER": return {
104085
+ deviceType: DeviceType.Cover,
104086
+ role: null,
104087
+ capabilities: ["cover"]
104088
+ };
104089
+ case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
104090
+ deviceType: DeviceType.Climate,
104091
+ role: null,
104092
+ capabilities: [
104093
+ "climate-control",
104094
+ "temperature-sensor",
104095
+ "humidity-sensor"
104096
+ ]
104097
+ };
104098
+ case "MOTIONDETECTOR_TRANSCEIVER": return {
104099
+ deviceType: DeviceType.Sensor,
104100
+ role: DeviceRole.MotionSensor,
104101
+ capabilities: ["motion", "ambient-light-sensor"]
104102
+ };
104103
+ case "DOOR_LOCK_STATE_TRANSMITTER": return {
104104
+ deviceType: DeviceType.Lock,
104105
+ role: null,
104106
+ capabilities: ["lock-control"]
104107
+ };
104108
+ case "ENERGIE_METER_TRANSMITTER": return {
104109
+ deviceType: DeviceType.Sensor,
104110
+ role: DeviceRole.PowerSensor,
104111
+ capabilities: ["power-meter"]
104112
+ };
104113
+ case "KEY_TRANSCEIVER":
104114
+ case "KEY_TRANSMITTER":
104115
+ case "VIRTUAL_KEY":
104116
+ case "KEY": return {
104117
+ deviceType: DeviceType.EventEmitter,
104118
+ role: null,
104119
+ capabilities: ["event-emitter"]
104120
+ };
104121
+ default: return null;
104122
+ }
104123
+ }
104124
+ /**
104125
+ * Best-effort parent DeviceType for a whole Homematic device, derived
104126
+ * from the union of its channel mappings. Actuators win over sensors so
104127
+ * a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
104128
+ * Sensor, and a thermostat with a humidity sensor reports as a
104129
+ * Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
104130
+ * ranked above Sensor so its battery / maintenance sensor channels don't
104131
+ * win the parent type. Returns `DeviceType.Generic` when no channel maps.
104132
+ */
104133
+ var PARENT_TYPE_PRIORITY = [
104134
+ DeviceType.Climate,
104135
+ DeviceType.Lock,
104136
+ DeviceType.Cover,
104137
+ DeviceType.Light,
104138
+ DeviceType.Switch,
104139
+ DeviceType.EventEmitter,
104140
+ DeviceType.Sensor
104141
+ ];
104142
+ function inferHmDeviceType(device) {
104143
+ const present = /* @__PURE__ */ new Set();
104144
+ for (const channel of device.channels) {
104145
+ const mapping = mapHmChannel(channel.type);
104146
+ if (mapping) present.add(mapping.deviceType);
104147
+ }
104148
+ for (const dt of PARENT_TYPE_PRIORITY) if (present.has(dt)) return dt;
104149
+ return DeviceType.Generic;
104150
+ }
104151
+ function mapHmDeviceChannels(device) {
104152
+ const out = [];
104153
+ for (const channel of device.channels) {
104154
+ const mapping = mapHmChannel(channel.type);
104155
+ if (mapping) out.push({
104156
+ channel,
104157
+ mapping
104158
+ });
104159
+ }
104160
+ return out;
104161
+ }
104162
+ //#endregion
104163
+ //#region src/devices/hm-cold-start.ts
104164
+ /**
104165
+ * Shared cold-start defaults + the key-channel press vocabulary helpers,
104166
+ * extracted from the (legacy) flat `homematic-device.ts` so the Container +
104167
+ * accessory-child classes reuse the SAME seeds and decoders without
104168
+ * duplicating them. Pure: no `BaseDevice` / facade dependency.
104169
+ */
104170
+ /**
104171
+ * Cold-start defaults so reads never miss a slice before the first push.
104172
+ * `lastChangedAt: 0` marks each as a PLACEHOLDER — the value is a guess, and
104173
+ * consumers read it as unknown. A replayed CCU value is stamped
104174
+ * `HM_SEEDED_CHANGED_AT` instead (`hm-change-stamp.ts`).
104175
+ */
104176
+ var COLD_SWITCH = {
104177
+ on: false,
104178
+ lastChangedAt: 0
104179
+ };
104180
+ var COLD_COVER = {
104181
+ state: "closed",
104182
+ position: null,
104183
+ tiltPosition: null,
104184
+ lastChangedAt: 0
104185
+ };
104186
+ var COLD_LOCK = {
104187
+ state: "unlocked",
104188
+ lastChangedAt: 0
104189
+ };
104190
+ var COLD_MOTION = {
104191
+ detected: false,
104192
+ lastDetectedAt: null,
104193
+ autoClearAfterMs: null
104194
+ };
104195
+ /**
104196
+ * The motion seed a constructor writes OVER the slice hydrated from the
104197
+ * persisted runtime state. The level is a placeholder (`false`) until the
104198
+ * CCU says otherwise, but a stored rise is a fact: `lastDetectedAt: null`
104199
+ * means "never detected" (`motion.cap.ts`), and a restart must not turn
104200
+ * "fired an hour ago" into that.
104201
+ */
104202
+ function coldMotionKeepingRise(stored) {
104203
+ const rise = stored?.lastDetectedAt;
104204
+ return {
104205
+ ...COLD_MOTION,
104206
+ lastDetectedAt: typeof rise === "number" && Number.isFinite(rise) && rise > 0 ? rise : null
104207
+ };
104208
+ }
104209
+ var COLD_CLIMATE = {
104210
+ mode: "auto",
104211
+ availableModes: [...[
104212
+ "off",
104213
+ "heat",
104214
+ "auto"
104215
+ ]],
104216
+ fanMode: "",
104217
+ availableFanModes: [],
104218
+ preset: "",
104219
+ availablePresets: ["boost"],
104220
+ target: null,
104221
+ targetHigh: null,
104222
+ targetLow: null,
104223
+ targetHumidity: null,
104224
+ currentTemp: null,
104225
+ currentHumidity: null,
104226
+ swingVertical: null,
104227
+ swingHorizontal: null,
104228
+ lastFetchedAt: 0
104229
+ };
104230
+ /**
104231
+ * The standard HmIP key-channel datapoint vocabulary, used VERBATIM (NO
104232
+ * normalization) as the `event-emitter` event types — the native uppercase
104233
+ * tokens a `KEY_TRANSCEIVER` / `KEY_TRANSMITTER` / `VIRTUAL_KEY` / `KEY`
104234
+ * channel emits on the facade `valueChanged` stream.
104235
+ */
104236
+ var HM_KEY_PRESS_DATAPOINTS = [
104237
+ "PRESS_SHORT",
104238
+ "PRESS_LONG",
104239
+ "PRESS_LONG_START",
104240
+ "PRESS_LONG_RELEASE",
104241
+ "PRESS_CONT"
104242
+ ];
104243
+ /** Set form for O(1) fire-detection membership tests. */
104244
+ var HM_KEY_PRESS_SET = new Set(HM_KEY_PRESS_DATAPOINTS);
104245
+ /** Cold-start event-emitter slice; vocabulary supplied per-device. */
104246
+ function coldEventEmitter(vocabulary) {
104247
+ return {
104248
+ eventTypes: eventTypesOfVocabulary(vocabulary),
104249
+ vocabulary: [...vocabulary],
104250
+ lastEvent: null,
104251
+ eventCountSinceStart: 0
104252
+ };
104253
+ }
104254
+ /**
104255
+ * Collect the union of native `PRESS_*` datapoints a device's key channels
104256
+ * support, VERBATIM. Falls back to the standard HmIP key vocabulary when no
104257
+ * datapoints were enumerated, so the cap always advertises a non-empty set.
104258
+ */
104259
+ function keyEventVocabulary(keyChannels) {
104260
+ const found = /* @__PURE__ */ new Set();
104261
+ for (const channel of keyChannels) for (const dp of channel.dataPoints ?? []) if (HM_KEY_PRESS_SET.has(dp.parameter)) found.add(dp.parameter);
104262
+ if (found.size === 0) return HM_KEY_PRESS_DATAPOINTS;
104263
+ return HM_KEY_PRESS_DATAPOINTS.filter((dp) => found.has(dp));
104264
+ }
104265
+ /**
104266
+ * The CamStack cap names that are ACTUATORS — driven by the library's typed
104267
+ * custom entities (correct channel), NOT by the raw mapped channels. The
104268
+ * raw-channel sensor/event loop skips these so they are not double-registered.
104269
+ */
104270
+ var ACTUATOR_CAP_NAMES = new Set([
104271
+ "switch",
104272
+ "cover",
104273
+ "light",
104274
+ "lock-control",
104275
+ "climate-control"
104276
+ ]);
104277
+ /** Parse the numeric channel index suffix (`:N`) from a channel address.
104278
+ * Null when absent. Kept as a string for the event payload, mirroring the
104279
+ * CCU's `device:index` addressing. */
104280
+ function channelIndexFromAddress(channelAddress) {
104281
+ const idx = channelAddress.lastIndexOf(":");
104282
+ if (idx === -1) return null;
104283
+ const suffix = channelAddress.slice(idx + 1);
104284
+ return suffix.length > 0 ? suffix : null;
104285
+ }
104286
+ //#endregion
104287
+ //#region src/devices/hm-key-vocabulary.ts
104288
+ var PRESS_MEANING = {
104289
+ PRESS_SHORT: {
104290
+ label: "Short press",
104291
+ kind: "press"
104292
+ },
104293
+ PRESS_LONG: {
104294
+ label: "Long press",
104295
+ kind: "long-press"
104296
+ },
104297
+ PRESS_LONG_START: {
104298
+ label: "Long press started",
104299
+ kind: "long-press-start"
104300
+ },
104301
+ PRESS_LONG_RELEASE: {
104302
+ label: "Long press released",
104303
+ kind: "release"
104304
+ },
104305
+ PRESS_CONT: {
104306
+ label: "Long press held",
104307
+ kind: "repeat"
104308
+ }
104309
+ };
104310
+ /** The channels of a device that are buttons, in channel order. */
104311
+ function hmKeyChannels(device) {
104312
+ return mapHmDeviceChannels(device).filter(({ mapping }) => mapping.capabilities.includes("event-emitter")).map(({ channel }) => channel);
104313
+ }
104314
+ /** The presses one key channel has; the standard set when it lists none. */
104315
+ function pressesOf(channel) {
104316
+ const listed = new Set((channel.dataPoints ?? []).map((dataPoint) => dataPoint.parameter).filter((parameter) => HM_KEY_PRESS_SET.has(parameter)));
104317
+ if (listed.size === 0) return HM_KEY_PRESS_DATAPOINTS;
104318
+ return HM_KEY_PRESS_DATAPOINTS.filter((parameter) => listed.has(parameter));
104319
+ }
104320
+ function entryOf(parameter, source) {
104321
+ const meaning = PRESS_MEANING[parameter];
104322
+ if (meaning === void 0) return {
104323
+ id: parameter,
104324
+ source,
104325
+ label: parameter
104326
+ };
104327
+ return {
104328
+ id: parameter,
104329
+ source,
104330
+ label: meaning.label,
104331
+ kind: meaning.kind
104332
+ };
104333
+ }
104334
+ function hmKeyVocabulary(device) {
104335
+ return hmKeyChannels(device).flatMap((channel, position) => {
104336
+ const index = channelIndexFromAddress(channel.address) ?? String(channel.index);
104337
+ const source = {
104338
+ id: index,
104339
+ label: `Button ${position + 1} (channel ${index})`
104340
+ };
104341
+ return pressesOf(channel).map((parameter) => entryOf(parameter, source));
104342
+ });
104343
+ }
104344
+ //#endregion
103372
104345
  //#region src/ccu/ccu-facade.ts
103373
104346
  function errorText(err) {
103374
104347
  return err instanceof Error ? err.message : String(err);
@@ -103384,6 +104357,144 @@ function requireConfirmed(confirmed) {
103384
104357
  if (confirmed !== true) throw new Error("A CCU write needs the operator confirmation (confirmed: true)");
103385
104358
  }
103386
104359
  //#endregion
104360
+ //#region src/ccu/hm-channel-links.ts
104361
+ /**
104362
+ * The slice of nodehomematic the button-event actions need. Specs hand in a
104363
+ * fake. The installed 0.5.1 build has none of these methods: the adapter
104364
+ * feature-checks and answers `unsupported` instead of calling them.
104365
+ *
104366
+ * What 0.6 must provide, on the facade object:
104367
+ * - `getChannelLinkState(address) → { central: boolean; links: { sender, receiver, name }[] }`
104368
+ * - `createCentralLink(address)` idempotent
104369
+ * - `removeCentralLink(address)` idempotent, throwing a typed error on failure
104370
+ * - `name: string | null` on devices and channels (read separately, not here)
104371
+ */
104372
+ var ChannelLinkSchema = object({
104373
+ sender: string(),
104374
+ receiver: string(),
104375
+ name: string()
104376
+ });
104377
+ var ChannelLinkStateSchema = object({
104378
+ central: boolean(),
104379
+ links: array(ChannelLinkSchema)
104380
+ });
104381
+ var GET_CHANNEL_LINK_STATE = "getChannelLinkState";
104382
+ var CREATE_CENTRAL_LINK = "createCentralLink";
104383
+ var REMOVE_CENTRAL_LINK = "removeCentralLink";
104384
+ /** A method the installed library actually has, bound to its facade. */
104385
+ function lookup$1(target, name) {
104386
+ const value = Reflect.get(target, name);
104387
+ if (typeof value !== "function") return null;
104388
+ const fn = (...args) => Reflect.apply(value, target, [...args]);
104389
+ return fn;
104390
+ }
104391
+ function errorMessage$1(err) {
104392
+ return err instanceof Error ? err.message : String(err);
104393
+ }
104394
+ async function write(target, name, address) {
104395
+ const fn = lookup$1(target, name);
104396
+ if (fn === null) return { kind: "unsupported" };
104397
+ try {
104398
+ await fn(address);
104399
+ return { kind: "ok" };
104400
+ } catch (err) {
104401
+ return {
104402
+ kind: "error",
104403
+ message: errorMessage$1(err)
104404
+ };
104405
+ }
104406
+ }
104407
+ /** Adapt a live facade. Missing methods are `unsupported`, never a cast. */
104408
+ function channelLinkPort(target) {
104409
+ return {
104410
+ async getChannelLinkState(address) {
104411
+ const fn = lookup$1(target, GET_CHANNEL_LINK_STATE);
104412
+ if (fn === null) return { kind: "unsupported" };
104413
+ try {
104414
+ const parsed = ChannelLinkStateSchema.safeParse(await fn(address));
104415
+ if (!parsed.success) return {
104416
+ kind: "error",
104417
+ message: "Channel link state did not match the expected shape"
104418
+ };
104419
+ return {
104420
+ kind: "ok",
104421
+ state: parsed.data
104422
+ };
104423
+ } catch (err) {
104424
+ return {
104425
+ kind: "error",
104426
+ message: errorMessage$1(err)
104427
+ };
104428
+ }
104429
+ },
104430
+ createCentralLink: (address) => write(target, CREATE_CENTRAL_LINK, address),
104431
+ removeCentralLink: (address) => write(target, REMOVE_CENTRAL_LINK, address)
104432
+ };
104433
+ }
104434
+ /**
104435
+ * A CCU name on a device or channel (`name: string | null` in nodehomematic
104436
+ * 0.6). 0.5.1 omits the field: that is "no name", not a failure.
104437
+ */
104438
+ function readHmName(value) {
104439
+ if (!("name" in value)) return null;
104440
+ const raw = Reflect.get(value, "name");
104441
+ if (typeof raw !== "string") return null;
104442
+ const trimmed = raw.trim();
104443
+ return trimmed.length > 0 ? trimmed : null;
104444
+ }
104445
+ //#endregion
104446
+ //#region src/ccu/ccu-button-events.ts
104447
+ var UNSUPPORTED = "This CCU library cannot read or change central links yet";
104448
+ function centralOf(read) {
104449
+ if (read.kind === "unsupported") return "unsupported";
104450
+ if (read.kind === "error") return "unknown";
104451
+ return read.state.central ? "on" : "off";
104452
+ }
104453
+ async function keyChannelRow(port, channel) {
104454
+ const read = await port.getChannelLinkState(channel.address);
104455
+ return {
104456
+ address: channel.address,
104457
+ index: channelIndexFromAddress(channel.address) ?? String(channel.index),
104458
+ name: readHmName(channel),
104459
+ central: centralOf(read)
104460
+ };
104461
+ }
104462
+ /** Key-channel central-link rows for adopted devices. Direct links are not touched. */
104463
+ async function keyChannelsForDevice(deps, integrationId, device, adopted) {
104464
+ if (!adopted.has(device.address)) return [];
104465
+ const keys = hmKeyChannels(device);
104466
+ if (keys.length === 0) return [];
104467
+ const port = deps.channelLinks(integrationId);
104468
+ if (port === null) return [];
104469
+ return Promise.all(keys.map((channel) => keyChannelRow(port, channel)));
104470
+ }
104471
+ function withKeyChannels(row, keyChannels) {
104472
+ return {
104473
+ ...row,
104474
+ keyChannels: [...keyChannels]
104475
+ };
104476
+ }
104477
+ /** Enable or disable the central link of one key channel. Other links stay. */
104478
+ function buildButtonEventHandlers(deps) {
104479
+ return { setButtonEvents: async (input) => {
104480
+ requireConfirmed(input.confirmed);
104481
+ requireFacade(deps, input.integrationId);
104482
+ const port = deps.channelLinks(input.integrationId);
104483
+ if (port === null) throw new Error(UNSUPPORTED);
104484
+ const result = input.enabled ? await port.createCentralLink(input.address) : await port.removeCentralLink(input.address);
104485
+ if (result.kind === "unsupported") throw new Error(UNSUPPORTED);
104486
+ if (result.kind === "error") {
104487
+ deps.logger.warn("Homematic central link change failed", { meta: {
104488
+ integrationId: input.integrationId,
104489
+ address: input.address,
104490
+ error: result.message
104491
+ } });
104492
+ throw new Error(result.message);
104493
+ }
104494
+ return { ok: true };
104495
+ } };
104496
+ }
104497
+ //#endregion
103387
104498
  //#region src/ccu/ccu-device-rows.ts
103388
104499
  /** `RSSI_*` reports this when the device has no signal reading. */
103389
104500
  var RSSI_UNKNOWN = 65535;
@@ -103430,7 +104541,8 @@ function toCcuDeviceRow(device) {
103430
104541
  lowBattery: asBool$1(readParam(maintenance, ["LOW_BAT", "LOWBAT"])),
103431
104542
  unreach: asBool$1(readParam(maintenance, ["UNREACH", "STICKY_UNREACH"])),
103432
104543
  configPending: asBool$1(readParam(maintenance, ["CONFIG_PENDING"])),
103433
- sabotage: asBool$1(readParam(maintenance, ["SABOTAGE", "ERROR_SABOTAGE"]))
104544
+ sabotage: asBool$1(readParam(maintenance, ["SABOTAGE", "ERROR_SABOTAGE"])),
104545
+ keyChannels: []
103434
104546
  };
103435
104547
  }
103436
104548
  //#endregion
@@ -103438,7 +104550,12 @@ function toCcuDeviceRow(device) {
103438
104550
  /** The CCU device list: every device the CCU knows, with its radio and maintenance health. */
103439
104551
  function buildCcuDevicesHandlers(deps) {
103440
104552
  return { listCcuDevices: async (input) => {
103441
- return { devices: requireFacade(deps, input.integrationId).devices().map(toCcuDeviceRow) };
104553
+ const facade = requireFacade(deps, input.integrationId);
104554
+ const adopted = await deps.adoptedAddresses(input.integrationId);
104555
+ return { devices: await Promise.all(facade.devices().map(async (device) => {
104556
+ const links = await keyChannelsForDevice(deps, input.integrationId, device, adopted);
104557
+ return withKeyChannels(toCcuDeviceRow(device), links);
104558
+ })) };
103442
104559
  } };
103443
104560
  }
103444
104561
  //#endregion
@@ -103583,6 +104700,24 @@ var AcknowledgeInputSchema = IntegrationRefSchema.extend({
103583
104700
  confirmed: ConfirmedSchema
103584
104701
  });
103585
104702
  var OkResultSchema = object({ ok: literal(true) });
104703
+ var SetButtonEventsInputSchema = IntegrationRefSchema.extend({
104704
+ /** Key-channel address, e.g. `00315F298E5093:1`. */
104705
+ address: string().min(1),
104706
+ enabled: boolean(),
104707
+ confirmed: ConfirmedSchema
104708
+ });
104709
+ /** One key channel's central-link state. `unknown` is a read that failed. */
104710
+ var KeyChannelLinkSchema = object({
104711
+ address: string(),
104712
+ index: string(),
104713
+ name: string().nullable(),
104714
+ central: _enum([
104715
+ "on",
104716
+ "off",
104717
+ "unsupported",
104718
+ "unknown"
104719
+ ])
104720
+ });
103586
104721
  var CcuDevicesResultSchema = object({ devices: array(object({
103587
104722
  address: string(),
103588
104723
  type: string(),
@@ -103603,7 +104738,12 @@ var CcuDevicesResultSchema = object({ devices: array(object({
103603
104738
  lowBattery: boolean().nullable(),
103604
104739
  unreach: boolean().nullable(),
103605
104740
  configPending: boolean().nullable(),
103606
- sabotage: boolean().nullable()
104741
+ sabotage: boolean().nullable(),
104742
+ /**
104743
+ * Key channels of an ADOPTED device, and whether the CCU sends their presses
104744
+ * (a central link). Empty for a device that is not adopted or has no keys.
104745
+ */
104746
+ keyChannels: array(KeyChannelLinkSchema).default([])
103607
104747
  })) });
103608
104748
  /** The group types the CCU can create (nodehomematic `HmGroupCreate.type`). */
103609
104749
  var HEATING_GROUP_TYPES = ["hmip.heating.group", "HomeMatic.heating"];
@@ -127309,6 +128449,10 @@ var homematicActions = defineCustomActions({
127309
128449
  acknowledgeServiceMessage: customAction(AcknowledgeInputSchema, OkResultSchema, {
127310
128450
  kind: "mutation",
127311
128451
  auth: "admin"
128452
+ }),
128453
+ setButtonEvents: customAction(SetButtonEventsInputSchema, OkResultSchema, {
128454
+ kind: "mutation",
128455
+ auth: "admin"
127312
128456
  })
127313
128457
  });
127314
128458
  //#endregion
@@ -127356,7 +128500,7 @@ function inferCallbackHost(ccuHost) {
127356
128500
  var homematicConfigSchema = object({
127357
128501
  host: string().min(1).describe("CCU3 / RaspberryMatic host name or IP address"),
127358
128502
  enableHmipRf: boolean().default(true).describe("Enable Homematic IP (HmIP-RF)"),
127359
- enableBidcosRf: boolean().default(false).describe("Enable Homematic (BidCos-RF)"),
128503
+ enableBidcosRf: boolean().default(false).describe("Enable Homematic (BidCos-RF). HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on"),
127360
128504
  enableGroups: boolean().default(true).describe("Enable groups (heating groups / VirtualDevices)"),
127361
128505
  enableBidcosWired: boolean().default(false).describe("Enable BidCos-Wired (HM-Wired)"),
127362
128506
  username: string().default("Admin").describe("WebUI username (optional — enables names / rooms / sysvars)"),
@@ -127502,6 +128646,8 @@ function buildConnectionFormSchema() {
127502
128646
  key: "enableBidcosRf",
127503
128647
  label: "Enable Homematic (BidCos-RF)",
127504
128648
  labelKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.label",
128649
+ description: "HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on.",
128650
+ descriptionKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.description",
127505
128651
  default: false
127506
128652
  },
127507
128653
  {
@@ -127771,81 +128917,6 @@ var HOMEMATIC_ROWS_TO_RECORD_MIGRATION = {
127771
128917
  })
127772
128918
  };
127773
128919
  //#endregion
127774
- //#region src/homematic-facade-resolver.ts
127775
- /**
127776
- * Per-integration registry that device classes use to reach the live
127777
- * `Homematic` facade (and the session state) of their CCU.
127778
- *
127779
- * The kernel constructs device classes through the `deviceClasses` map with
127780
- * only a `DeviceContext` — it cannot thread the facade in as a constructor
127781
- * arg. The connection lives on the INTEGRATION, so the CCU box and every device
127782
- * adopted from it resolve the same session by `integrationId`. A device
127783
- * persisted without an `integrationId` cannot be attributed to a CCU and
127784
- * resolves nothing.
127785
- */
127786
- var HmFacadeResolver = class {
127787
- #facades = /* @__PURE__ */ new Map();
127788
- #sessions = /* @__PURE__ */ new Map();
127789
- /** Per-integration state-change fan-out (connect, disconnect, error). */
127790
- #snapshotSubs = /* @__PURE__ */ new Map();
127791
- /** Publish or remove the facade for an integration id. `null` removes the entry. */
127792
- set(integrationId, facade) {
127793
- if (facade === null) {
127794
- this.#facades.delete(integrationId);
127795
- return;
127796
- }
127797
- this.#facades.set(integrationId, facade);
127798
- }
127799
- /** The live facade for an integration id, or null when unknown / absent / not running. */
127800
- get(integrationId) {
127801
- if (integrationId === void 0 || integrationId === null) return null;
127802
- return this.#facades.get(integrationId) ?? null;
127803
- }
127804
- /** Publish or remove the session (state + connection) for an integration id. */
127805
- setSession(integrationId, session) {
127806
- if (session === null) {
127807
- this.#sessions.delete(integrationId);
127808
- return;
127809
- }
127810
- this.#sessions.set(integrationId, session);
127811
- }
127812
- /** The session of an integration, or null when it is not registered. */
127813
- getSession(integrationId) {
127814
- if (integrationId === void 0 || integrationId === null) return null;
127815
- return this.#sessions.get(integrationId) ?? null;
127816
- }
127817
- /** Subscribe a device to the state changes of one integration. Returns an unsubscribe fn. */
127818
- onSnapshot(integrationId, cb) {
127819
- let set = this.#snapshotSubs.get(integrationId);
127820
- if (!set) {
127821
- set = /* @__PURE__ */ new Set();
127822
- this.#snapshotSubs.set(integrationId, set);
127823
- }
127824
- set.add(cb);
127825
- return () => {
127826
- const current = this.#snapshotSubs.get(integrationId);
127827
- current?.delete(cb);
127828
- if (current && current.size === 0) this.#snapshotSubs.delete(integrationId);
127829
- };
127830
- }
127831
- /** Fan one state change out to every subscribed device of an integration. */
127832
- emitSnapshot(integrationId) {
127833
- const set = this.#snapshotSubs.get(integrationId);
127834
- if (!set) return;
127835
- for (const cb of [...set]) try {
127836
- cb();
127837
- } catch {}
127838
- }
127839
- /** Remove everything (called on full shutdown). */
127840
- clear() {
127841
- this.#facades.clear();
127842
- this.#sessions.clear();
127843
- this.#snapshotSubs.clear();
127844
- }
127845
- };
127846
- /** The single in-process resolver shared between the integration and its devices. */
127847
- var homematicFacades = new HmFacadeResolver();
127848
- //#endregion
127849
128920
  //#region src/homematic-diagnostics-mapping.ts
127850
128921
  var MAINTENANCE_CHANNEL_TYPE$1 = "MAINTENANCE";
127851
128922
  /** Reachability parameters that drive the Container's `online`, not a child. */
@@ -127976,226 +129047,6 @@ function readReachability(device) {
127976
129047
  return null;
127977
129048
  }
127978
129049
  //#endregion
127979
- //#region src/homematic-mapping.ts
127980
- /**
127981
- * Map a single Homematic channel to its CamStack triplet. The channel
127982
- * `TYPE` is the discriminator. Only the controllable / primary channel
127983
- * types map; status-only `*_TRANSMITTER` mirrors and the various key /
127984
- * remote / week-profile channels return `null` (their datapoints are
127985
- * still decoded into the owning cap's slice via the device's
127986
- * `valueChanged` handler, keyed by parameter name).
127987
- */
127988
- function mapHmChannel(channelType) {
127989
- if (!channelType) return null;
127990
- switch (channelType.toUpperCase()) {
127991
- case "SWITCH_VIRTUAL_RECEIVER": return {
127992
- deviceType: DeviceType.Switch,
127993
- role: null,
127994
- capabilities: ["switch"]
127995
- };
127996
- case "SHUTTER_VIRTUAL_RECEIVER": return {
127997
- deviceType: DeviceType.Cover,
127998
- role: null,
127999
- capabilities: ["cover"]
128000
- };
128001
- case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
128002
- deviceType: DeviceType.Climate,
128003
- role: null,
128004
- capabilities: [
128005
- "climate-control",
128006
- "temperature-sensor",
128007
- "humidity-sensor"
128008
- ]
128009
- };
128010
- case "MOTIONDETECTOR_TRANSCEIVER": return {
128011
- deviceType: DeviceType.Sensor,
128012
- role: DeviceRole.MotionSensor,
128013
- capabilities: ["motion", "ambient-light-sensor"]
128014
- };
128015
- case "DOOR_LOCK_STATE_TRANSMITTER": return {
128016
- deviceType: DeviceType.Lock,
128017
- role: null,
128018
- capabilities: ["lock-control"]
128019
- };
128020
- case "ENERGIE_METER_TRANSMITTER": return {
128021
- deviceType: DeviceType.Sensor,
128022
- role: DeviceRole.PowerSensor,
128023
- capabilities: ["power-meter"]
128024
- };
128025
- case "KEY_TRANSCEIVER":
128026
- case "KEY_TRANSMITTER":
128027
- case "VIRTUAL_KEY":
128028
- case "KEY": return {
128029
- deviceType: DeviceType.EventEmitter,
128030
- role: null,
128031
- capabilities: ["event-emitter"]
128032
- };
128033
- default: return null;
128034
- }
128035
- }
128036
- /**
128037
- * Best-effort parent DeviceType for a whole Homematic device, derived
128038
- * from the union of its channel mappings. Actuators win over sensors so
128039
- * a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
128040
- * Sensor, and a thermostat with a humidity sensor reports as a
128041
- * Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
128042
- * ranked above Sensor so its battery / maintenance sensor channels don't
128043
- * win the parent type. Returns `DeviceType.Generic` when no channel maps.
128044
- */
128045
- var PARENT_TYPE_PRIORITY = [
128046
- DeviceType.Climate,
128047
- DeviceType.Lock,
128048
- DeviceType.Cover,
128049
- DeviceType.Light,
128050
- DeviceType.Switch,
128051
- DeviceType.EventEmitter,
128052
- DeviceType.Sensor
128053
- ];
128054
- function inferHmDeviceType(device) {
128055
- const present = /* @__PURE__ */ new Set();
128056
- for (const channel of device.channels) {
128057
- const mapping = mapHmChannel(channel.type);
128058
- if (mapping) present.add(mapping.deviceType);
128059
- }
128060
- for (const dt of PARENT_TYPE_PRIORITY) if (present.has(dt)) return dt;
128061
- return DeviceType.Generic;
128062
- }
128063
- function mapHmDeviceChannels(device) {
128064
- const out = [];
128065
- for (const channel of device.channels) {
128066
- const mapping = mapHmChannel(channel.type);
128067
- if (mapping) out.push({
128068
- channel,
128069
- mapping
128070
- });
128071
- }
128072
- return out;
128073
- }
128074
- //#endregion
128075
- //#region src/devices/hm-cold-start.ts
128076
- /**
128077
- * Shared cold-start defaults + the key-channel press vocabulary helpers,
128078
- * extracted from the (legacy) flat `homematic-device.ts` so the Container +
128079
- * accessory-child classes reuse the SAME seeds and decoders without
128080
- * duplicating them. Pure: no `BaseDevice` / facade dependency.
128081
- */
128082
- /**
128083
- * Cold-start defaults so reads never miss a slice before the first push.
128084
- * `lastChangedAt: 0` marks each as a PLACEHOLDER — the value is a guess, and
128085
- * consumers read it as unknown. A replayed CCU value is stamped
128086
- * `HM_SEEDED_CHANGED_AT` instead (`hm-change-stamp.ts`).
128087
- */
128088
- var COLD_SWITCH = {
128089
- on: false,
128090
- lastChangedAt: 0
128091
- };
128092
- var COLD_COVER = {
128093
- state: "closed",
128094
- position: null,
128095
- tiltPosition: null,
128096
- lastChangedAt: 0
128097
- };
128098
- var COLD_LOCK = {
128099
- state: "unlocked",
128100
- lastChangedAt: 0
128101
- };
128102
- var COLD_MOTION = {
128103
- detected: false,
128104
- lastDetectedAt: null,
128105
- autoClearAfterMs: null
128106
- };
128107
- /**
128108
- * The motion seed a constructor writes OVER the slice hydrated from the
128109
- * persisted runtime state. The level is a placeholder (`false`) until the
128110
- * CCU says otherwise, but a stored rise is a fact: `lastDetectedAt: null`
128111
- * means "never detected" (`motion.cap.ts`), and a restart must not turn
128112
- * "fired an hour ago" into that.
128113
- */
128114
- function coldMotionKeepingRise(stored) {
128115
- const rise = stored?.lastDetectedAt;
128116
- return {
128117
- ...COLD_MOTION,
128118
- lastDetectedAt: typeof rise === "number" && Number.isFinite(rise) && rise > 0 ? rise : null
128119
- };
128120
- }
128121
- var COLD_CLIMATE = {
128122
- mode: "auto",
128123
- availableModes: [...[
128124
- "off",
128125
- "heat",
128126
- "auto"
128127
- ]],
128128
- fanMode: "",
128129
- availableFanModes: [],
128130
- preset: "",
128131
- availablePresets: ["boost"],
128132
- target: null,
128133
- targetHigh: null,
128134
- targetLow: null,
128135
- targetHumidity: null,
128136
- currentTemp: null,
128137
- currentHumidity: null,
128138
- swingVertical: null,
128139
- swingHorizontal: null,
128140
- lastFetchedAt: 0
128141
- };
128142
- /**
128143
- * The standard HmIP key-channel datapoint vocabulary, used VERBATIM (NO
128144
- * normalization) as the `event-emitter` event types — the native uppercase
128145
- * tokens a `KEY_TRANSCEIVER` / `KEY_TRANSMITTER` / `VIRTUAL_KEY` / `KEY`
128146
- * channel emits on the facade `valueChanged` stream.
128147
- */
128148
- var HM_KEY_PRESS_DATAPOINTS = [
128149
- "PRESS_SHORT",
128150
- "PRESS_LONG",
128151
- "PRESS_LONG_START",
128152
- "PRESS_LONG_RELEASE",
128153
- "PRESS_CONT"
128154
- ];
128155
- /** Set form for O(1) fire-detection membership tests. */
128156
- var HM_KEY_PRESS_SET = new Set(HM_KEY_PRESS_DATAPOINTS);
128157
- /** Cold-start event-emitter slice; vocabulary supplied per-device. */
128158
- function coldEventEmitter(vocabulary) {
128159
- return {
128160
- eventTypes: eventTypesOfVocabulary(vocabulary),
128161
- vocabulary: [...vocabulary],
128162
- lastEvent: null,
128163
- eventCountSinceStart: 0
128164
- };
128165
- }
128166
- /**
128167
- * Collect the union of native `PRESS_*` datapoints a device's key channels
128168
- * support, VERBATIM. Falls back to the standard HmIP key vocabulary when no
128169
- * datapoints were enumerated, so the cap always advertises a non-empty set.
128170
- */
128171
- function keyEventVocabulary(keyChannels) {
128172
- const found = /* @__PURE__ */ new Set();
128173
- for (const channel of keyChannels) for (const dp of channel.dataPoints ?? []) if (HM_KEY_PRESS_SET.has(dp.parameter)) found.add(dp.parameter);
128174
- if (found.size === 0) return HM_KEY_PRESS_DATAPOINTS;
128175
- return HM_KEY_PRESS_DATAPOINTS.filter((dp) => found.has(dp));
128176
- }
128177
- /**
128178
- * The CamStack cap names that are ACTUATORS — driven by the library's typed
128179
- * custom entities (correct channel), NOT by the raw mapped channels. The
128180
- * raw-channel sensor/event loop skips these so they are not double-registered.
128181
- */
128182
- var ACTUATOR_CAP_NAMES = new Set([
128183
- "switch",
128184
- "cover",
128185
- "light",
128186
- "lock-control",
128187
- "climate-control"
128188
- ]);
128189
- /** Parse the numeric channel index suffix (`:N`) from a channel address.
128190
- * Null when absent. Kept as a string for the event payload, mirroring the
128191
- * CCU's `device:index` addressing. */
128192
- function channelIndexFromAddress(channelAddress) {
128193
- const idx = channelAddress.lastIndexOf(":");
128194
- if (idx === -1) return null;
128195
- const suffix = channelAddress.slice(idx + 1);
128196
- return suffix.length > 0 ? suffix : null;
128197
- }
128198
- //#endregion
128199
129050
  //#region src/devices/hm-entity-spec.ts
128200
129051
  var MAINTENANCE_CHANNEL_TYPE = "MAINTENANCE";
128201
129052
  /**
@@ -128374,6 +129225,113 @@ function deriveHmEntitySpecs(device, customEntities) {
128374
129225
  ];
128375
129226
  }
128376
129227
  //#endregion
129228
+ //#region src/devices/hm-primary-child.ts
129229
+ var ACT_PREFIX = "act-";
129230
+ function channelIndex(key) {
129231
+ const suffix = channelIndexFromAddress(key.slice(4));
129232
+ if (suffix === null) return Number.MAX_SAFE_INTEGER;
129233
+ const parsed = Number(suffix);
129234
+ return Number.isFinite(parsed) ? parsed : Number.MAX_SAFE_INTEGER;
129235
+ }
129236
+ /**
129237
+ * Which child a Homematic container stands for.
129238
+ *
129239
+ * A device with relay channels stands for the first relay (lowest channel
129240
+ * index), so a two-relay switch is not left to the namesake tie-break. A
129241
+ * key-only device (no actuator) stands for its event-emitter. Anything else
129242
+ * declares nothing and the shared heuristic decides.
129243
+ */
129244
+ function hmPrimaryChildKeys(specs) {
129245
+ const first = specs.filter((spec) => spec.key.startsWith(ACT_PREFIX) && spec.config["kind"] === "switch").toSorted((a, b) => channelIndex(a.key) - channelIndex(b.key))[0];
129246
+ if (first !== void 0) return [first.key];
129247
+ if (specs.some((spec) => spec.key.startsWith(ACT_PREFIX))) return [];
129248
+ return specs.some((spec) => spec.key === "events") ? ["events"] : [];
129249
+ }
129250
+ /**
129251
+ * The preference to write, or null when the container already has one or
129252
+ * there is nothing to declare. An operator pick is a different column.
129253
+ */
129254
+ function preferenceToStamp(stored, declared) {
129255
+ if (stored !== void 0 && stored.length > 0) return null;
129256
+ if (declared.length === 0) return null;
129257
+ return declared;
129258
+ }
129259
+ //#endregion
129260
+ //#region src/homematic-facade-resolver.ts
129261
+ /**
129262
+ * Per-integration registry that device classes use to reach the live
129263
+ * `Homematic` facade (and the session state) of their CCU.
129264
+ *
129265
+ * The kernel constructs device classes through the `deviceClasses` map with
129266
+ * only a `DeviceContext` — it cannot thread the facade in as a constructor
129267
+ * arg. The connection lives on the INTEGRATION, so the CCU box and every device
129268
+ * adopted from it resolve the same session by `integrationId`. A device
129269
+ * persisted without an `integrationId` cannot be attributed to a CCU and
129270
+ * resolves nothing.
129271
+ */
129272
+ var HmFacadeResolver = class {
129273
+ #facades = /* @__PURE__ */ new Map();
129274
+ #sessions = /* @__PURE__ */ new Map();
129275
+ /** Per-integration state-change fan-out (connect, disconnect, error). */
129276
+ #snapshotSubs = /* @__PURE__ */ new Map();
129277
+ /** Publish or remove the facade for an integration id. `null` removes the entry. */
129278
+ set(integrationId, facade) {
129279
+ if (facade === null) {
129280
+ this.#facades.delete(integrationId);
129281
+ return;
129282
+ }
129283
+ this.#facades.set(integrationId, facade);
129284
+ }
129285
+ /** The live facade for an integration id, or null when unknown / absent / not running. */
129286
+ get(integrationId) {
129287
+ if (integrationId === void 0 || integrationId === null) return null;
129288
+ return this.#facades.get(integrationId) ?? null;
129289
+ }
129290
+ /** Publish or remove the session (state + connection) for an integration id. */
129291
+ setSession(integrationId, session) {
129292
+ if (session === null) {
129293
+ this.#sessions.delete(integrationId);
129294
+ return;
129295
+ }
129296
+ this.#sessions.set(integrationId, session);
129297
+ }
129298
+ /** The session of an integration, or null when it is not registered. */
129299
+ getSession(integrationId) {
129300
+ if (integrationId === void 0 || integrationId === null) return null;
129301
+ return this.#sessions.get(integrationId) ?? null;
129302
+ }
129303
+ /** Subscribe a device to the state changes of one integration. Returns an unsubscribe fn. */
129304
+ onSnapshot(integrationId, cb) {
129305
+ let set = this.#snapshotSubs.get(integrationId);
129306
+ if (!set) {
129307
+ set = /* @__PURE__ */ new Set();
129308
+ this.#snapshotSubs.set(integrationId, set);
129309
+ }
129310
+ set.add(cb);
129311
+ return () => {
129312
+ const current = this.#snapshotSubs.get(integrationId);
129313
+ current?.delete(cb);
129314
+ if (current && current.size === 0) this.#snapshotSubs.delete(integrationId);
129315
+ };
129316
+ }
129317
+ /** Fan one state change out to every subscribed device of an integration. */
129318
+ emitSnapshot(integrationId) {
129319
+ const set = this.#snapshotSubs.get(integrationId);
129320
+ if (!set) return;
129321
+ for (const cb of [...set]) try {
129322
+ cb();
129323
+ } catch {}
129324
+ }
129325
+ /** Remove everything (called on full shutdown). */
129326
+ clear() {
129327
+ this.#facades.clear();
129328
+ this.#sessions.clear();
129329
+ this.#snapshotSubs.clear();
129330
+ }
129331
+ };
129332
+ /** The single in-process resolver shared between the integration and its devices. */
129333
+ var homematicFacades = new HmFacadeResolver();
129334
+ //#endregion
128377
129335
  //#region src/devices/hm-child-device.ts
128378
129336
  /**
128379
129337
  * Persisted config every Homematic accessory CHILD carries. `address` is the
@@ -129238,65 +130196,9 @@ var HmSensorDevice = class extends HmChildDevice {
129238
130196
  }
129239
130197
  };
129240
130198
  //#endregion
129241
- //#region src/devices/hm-key-vocabulary.ts
129242
- var PRESS_MEANING = {
129243
- PRESS_SHORT: {
129244
- label: "Short press",
129245
- kind: "press"
129246
- },
129247
- PRESS_LONG: {
129248
- label: "Long press",
129249
- kind: "long-press"
129250
- },
129251
- PRESS_LONG_START: {
129252
- label: "Long press started",
129253
- kind: "long-press-start"
129254
- },
129255
- PRESS_LONG_RELEASE: {
129256
- label: "Long press released",
129257
- kind: "release"
129258
- },
129259
- PRESS_CONT: {
129260
- label: "Long press held",
129261
- kind: "repeat"
129262
- }
129263
- };
129264
- /** The channels of a device that are buttons, in channel order. */
129265
- function hmKeyChannels(device) {
129266
- return mapHmDeviceChannels(device).filter(({ mapping }) => mapping.capabilities.includes("event-emitter")).map(({ channel }) => channel);
129267
- }
129268
- /** The presses one key channel has; the standard set when it lists none. */
129269
- function pressesOf(channel) {
129270
- const listed = new Set((channel.dataPoints ?? []).map((dataPoint) => dataPoint.parameter).filter((parameter) => HM_KEY_PRESS_SET.has(parameter)));
129271
- if (listed.size === 0) return HM_KEY_PRESS_DATAPOINTS;
129272
- return HM_KEY_PRESS_DATAPOINTS.filter((parameter) => listed.has(parameter));
129273
- }
129274
- function entryOf(parameter, source) {
129275
- const meaning = PRESS_MEANING[parameter];
129276
- if (meaning === void 0) return {
129277
- id: parameter,
129278
- source,
129279
- label: parameter
129280
- };
129281
- return {
129282
- id: parameter,
129283
- source,
129284
- label: meaning.label,
129285
- kind: meaning.kind
129286
- };
129287
- }
129288
- function hmKeyVocabulary(device) {
129289
- return hmKeyChannels(device).flatMap((channel, position) => {
129290
- const index = channelIndexFromAddress(channel.address) ?? String(channel.index);
129291
- const source = {
129292
- id: index,
129293
- label: `Button ${position + 1} (channel ${index})`
129294
- };
129295
- return pressesOf(channel).map((parameter) => entryOf(parameter, source));
129296
- });
129297
- }
129298
- //#endregion
129299
130199
  //#region src/devices/hm-event-emitter-device.ts
130200
+ /** Shown on the Buttons child when none of its key channels has a central link. */
130201
+ var BUTTON_EVENTS_HINT = "The CCU does not send these presses — enable button events on the CCU page";
129300
130202
  /**
129301
130203
  * Event-emitter child config: the persisted native press vocabulary for the
129302
130204
  * device's key channels. Stored at adoption so the cap advertises the right
@@ -129318,6 +130220,10 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129318
130220
  #declared = null;
129319
130221
  /** Fires already reported as outside the vocabulary, as `source:token`. */
129320
130222
  #undeclaredLogged = /* @__PURE__ */ new Set();
130223
+ /** Key channels that have delivered a press since this process started. */
130224
+ #pressSeen = /* @__PURE__ */ new Set();
130225
+ /** True once we know every key channel lacks a central link. */
130226
+ #centralLinkMissing = false;
129321
130227
  #eventSeq = 0;
129322
130228
  #eventCount = 0;
129323
130229
  /** Unsubscribe for the integration's state-change fan-out. */
@@ -129328,7 +130234,29 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129328
130234
  this.persistedEventTypes = persisted && persisted.length > 0 ? persisted : HM_KEY_PRESS_DATAPOINTS;
129329
130235
  this.registerEventEmitterCap();
129330
130236
  this.attachValueChangedListener((event) => this.decodeKeyPress(event));
129331
- if (this.integrationId !== void 0) this.#snapshotUnsub = homematicFacades.onSnapshot(this.integrationId, () => this.refreshDeclaredVocabulary());
130237
+ if (this.integrationId !== void 0) this.#snapshotUnsub = homematicFacades.onSnapshot(this.integrationId, () => {
130238
+ this.refreshDeclaredVocabulary();
130239
+ this.refreshCentralLinks();
130240
+ });
130241
+ this.refreshCentralLinks();
130242
+ }
130243
+ getSettingsUISchema() {
130244
+ if (!this.#centralLinkMissing) return { sections: [] };
130245
+ return { sections: [{
130246
+ id: "button-events",
130247
+ title: "Button events",
130248
+ titleKey: "provider-homematic:device.buttonEvents.title",
130249
+ columns: 1,
130250
+ fields: [{
130251
+ type: "info",
130252
+ key: "buttonEventsHint",
130253
+ label: "Button events",
130254
+ labelKey: "provider-homematic:device.buttonEvents.hint.label",
130255
+ content: BUTTON_EVENTS_HINT,
130256
+ contentKey: "provider-homematic:device.buttonEvents.hint.content",
130257
+ variant: "warning"
130258
+ }]
130259
+ }] };
129332
130260
  }
129333
130261
  /**
129334
130262
  * Rewrite the slice with the buttons once the CCU's channel list carries
@@ -129336,12 +130264,62 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129336
130264
  */
129337
130265
  refreshDeclaredVocabulary() {
129338
130266
  if (this.#declared !== null) return;
129339
- const vocabulary = this.vocabulary();
130267
+ this.vocabulary();
129340
130268
  if (this.#declared === null) return;
130269
+ const published = this.publishedVocabulary();
129341
130270
  const current = this.runtimeState.getCapState("event-emitter");
129342
130271
  this.runtimeState.setCapState("event-emitter", {
129343
- eventTypes: eventTypesOfVocabulary(vocabulary),
129344
- vocabulary: [...vocabulary],
130272
+ eventTypes: eventTypesOfVocabulary(published),
130273
+ vocabulary: [...published],
130274
+ lastEvent: current?.lastEvent ?? null,
130275
+ eventCountSinceStart: current?.eventCountSinceStart ?? 0
130276
+ });
130277
+ }
130278
+ /** The live vocabulary, plus the central-link hint when the CCU sends nothing. */
130279
+ publishedVocabulary() {
130280
+ const vocabulary = this.vocabulary();
130281
+ if (!this.#centralLinkMissing) return vocabulary;
130282
+ return vocabulary.map((entry) => ({
130283
+ ...entry,
130284
+ description: BUTTON_EVENTS_HINT
130285
+ }));
130286
+ }
130287
+ /**
130288
+ * Ask the facade whether each key channel has a central link. A library
130289
+ * that cannot answer (`unsupported`) leaves the hint off: absence of the
130290
+ * method is not evidence the CCU is silent.
130291
+ */
130292
+ async refreshCentralLinks() {
130293
+ const facade = this.integrationId === void 0 ? null : homematicFacades.get(this.integrationId);
130294
+ const device = this.resolveHmDevice();
130295
+ if (facade === null || device === null) return;
130296
+ const keys = hmKeyChannels(device);
130297
+ if (keys.length === 0) return;
130298
+ const port = channelLinkPort(facade);
130299
+ let missing = false;
130300
+ for (const channel of keys) {
130301
+ const read = await port.getChannelLinkState(channel.address);
130302
+ if (read.kind === "unsupported") return;
130303
+ if (read.kind === "error") {
130304
+ this.ctx.logger.warn("Homematic key channel link state could not be read", {
130305
+ tags: { deviceId: this.ctx.id },
130306
+ meta: {
130307
+ address: this.address,
130308
+ channel: channel.address,
130309
+ error: read.message
130310
+ }
130311
+ });
130312
+ return;
130313
+ }
130314
+ if (!read.state.central) missing = true;
130315
+ }
130316
+ if (missing === this.#centralLinkMissing) return;
130317
+ this.#centralLinkMissing = missing;
130318
+ const current = this.runtimeState.getCapState("event-emitter");
130319
+ const published = this.publishedVocabulary();
130320
+ this.runtimeState.setCapState("event-emitter", {
130321
+ eventTypes: eventTypesOfVocabulary(published),
130322
+ vocabulary: [...published],
129345
130323
  lastEvent: current?.lastEvent ?? null,
129346
130324
  eventCountSinceStart: current?.eventCountSinceStart ?? 0
129347
130325
  });
@@ -129353,7 +130331,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129353
130331
  }
129354
130332
  registerEventEmitterCap() {
129355
130333
  this.ctx.registerNativeCap(eventEmitterCapability, { getStatus: async () => this.runtimeState.getCapState("event-emitter") ?? coldEventEmitter(this.vocabulary()) });
129356
- this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.vocabulary()));
130334
+ this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.publishedVocabulary()));
129357
130335
  }
129358
130336
  /**
129359
130337
  * The buttons and their presses, read LIVE from the CCU's channel list.
@@ -129387,6 +130365,11 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129387
130365
  }
129388
130366
  });
129389
130367
  }
130368
+ keyChannelAddresses() {
130369
+ const device = this.resolveHmDevice();
130370
+ if (device === null) return /* @__PURE__ */ new Set();
130371
+ return new Set(hmKeyChannels(device).map((channel) => channel.address));
130372
+ }
129390
130373
  /**
129391
130374
  * Translate a key-channel `PRESS_*` datapoint into an `EventFire`: emit
129392
130375
  * `EventCategory.EventEmitted` on the bus and write the `event-emitter`
@@ -129398,8 +130381,36 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129398
130381
  decodeKeyPress(event) {
129399
130382
  const now = event.ts || Date.now();
129400
130383
  const { parameter, value, channel } = event;
129401
- if (!HM_KEY_PRESS_SET.has(parameter)) return;
129402
- if (typeof value === "boolean" && value === false) return;
130384
+ const isPress = HM_KEY_PRESS_SET.has(parameter);
130385
+ if (!(isPress || this.keyChannelAddresses().has(channel))) return;
130386
+ if (!(isPress && !(typeof value === "boolean" && value === false))) {
130387
+ this.ctx.logger.debug("Homematic key channel value changed but decoded to no press", {
130388
+ tags: { deviceId: this.ctx.id },
130389
+ meta: {
130390
+ channel,
130391
+ parameter,
130392
+ ...isPress ? { press: parameter } : {}
130393
+ }
130394
+ });
130395
+ return;
130396
+ }
130397
+ this.ctx.logger.debug("Homematic key press received", {
130398
+ tags: { deviceId: this.ctx.id },
130399
+ meta: {
130400
+ channel,
130401
+ press: parameter
130402
+ }
130403
+ });
130404
+ if (!this.#pressSeen.has(channel)) {
130405
+ this.#pressSeen.add(channel);
130406
+ this.ctx.logger.info("Homematic key channel delivered its first press since start", {
130407
+ tags: { deviceId: this.ctx.id },
130408
+ meta: {
130409
+ channel,
130410
+ press: parameter
130411
+ }
130412
+ });
130413
+ }
129403
130414
  const channelIndex = channelIndexFromAddress(channel);
129404
130415
  const fire = {
129405
130416
  deviceId: this.id,
@@ -129415,7 +130426,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129415
130426
  deviceId: this.id,
129416
130427
  addonId: this.ctx.deviceMeta.addonId
129417
130428
  }, fire));
129418
- const vocabulary = this.vocabulary();
130429
+ const vocabulary = this.publishedVocabulary();
129419
130430
  this.noteUndeclared(vocabulary, parameter, channelIndex);
129420
130431
  const slice = {
129421
130432
  eventTypes: eventTypesOfVocabulary(vocabulary),
@@ -129719,6 +130730,43 @@ var HmChildDispatcher = class {
129719
130730
  /** The documented boundary-cast export used in the `deviceClasses` restore map. */
129720
130731
  var hmChildDeviceClass = HmChildDispatcher;
129721
130732
  //#endregion
130733
+ //#region src/devices/hm-child-name.ts
130734
+ /**
130735
+ * Display name of one actuator child.
130736
+ *
130737
+ * A single actuator keeps the container's name (the caller passes it). A
130738
+ * multi-actuator child uses the CCU channel name when the facade has one,
130739
+ * otherwise `"<container> ch<index>"`. Never the channel address.
130740
+ */
130741
+ function multiActuatorChildName(input) {
130742
+ if (input.channelName !== null) return input.channelName;
130743
+ const index = input.channelIndex ?? "?";
130744
+ return `${input.containerName} ch${index}`;
130745
+ }
130746
+ /** The name this addon used to give a multi-actuator child: container + raw address. */
130747
+ function legacyActuatorName(containerName, channelAddress) {
130748
+ return `${containerName} ${channelAddress}`;
130749
+ }
130750
+ /**
130751
+ * Whether an already-adopted actuator may take the new auto name.
130752
+ *
130753
+ * An operator rename (`userNamed`, or a legacy row whose name is not one of
130754
+ * the auto forms) is left alone. A name that is still the generated address
130755
+ * form, the `ch<index>` form, or the stable-id placeholder is replaced.
130756
+ * `stampUserNamed` is true only when the row is already flagged user-named:
130757
+ * the device-manager refuses a system rename of those rows, and accessory
130758
+ * registration stamps the flag on every non-placeholder name.
130759
+ */
130760
+ function actuatorNameWrite(input) {
130761
+ if (input.currentName === input.desiredName) return { kind: "keep" };
130762
+ if (!(input.currentName === input.legacyAutoName || input.currentName === input.fallbackAutoName || input.currentName === input.stableId) && (input.userNamed === true || input.userNamed === void 0)) return { kind: "keep" };
130763
+ return {
130764
+ kind: "rename",
130765
+ name: input.desiredName,
130766
+ stampUserNamed: input.userNamed === true
130767
+ };
130768
+ }
130769
+ //#endregion
129722
130770
  //#region src/devices/hm-container-device.ts
129723
130771
  /**
129724
130772
  * Persisted config for a Homematic Container (the parent of one physical CCU
@@ -129751,6 +130799,8 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
129751
130799
  integrationId;
129752
130800
  /** Unsubscribe for the facade `valueChanged` reachability listener. */
129753
130801
  valueChangedUnsub = null;
130802
+ /** Unsubscribe for the session fan-out that re-stamps names once the CCU answers. */
130803
+ reconcileUnsub = null;
129754
130804
  constructor(ctx) {
129755
130805
  const cfg = hmContainerSchema.parse(ctx.persistedConfig ?? {});
129756
130806
  super(ctx, hmContainerSchema, { type: DeviceType.Container });
@@ -129797,7 +130847,16 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
129797
130847
  if (this.online !== next) this.markOnline(next);
129798
130848
  });
129799
130849
  }
130850
+ async onActivate() {
130851
+ await super.onActivate();
130852
+ await this.reconcileDerived();
130853
+ this.reconcileUnsub = homematicFacades.onSnapshot(this.integrationId, () => {
130854
+ this.reconcileDerived();
130855
+ });
130856
+ }
129800
130857
  async removeDevice() {
130858
+ this.reconcileUnsub?.();
130859
+ this.reconcileUnsub = null;
129801
130860
  if (this.valueChangedUnsub) {
129802
130861
  try {
129803
130862
  this.valueChangedUnsub();
@@ -129834,11 +130893,96 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
129834
130893
  const specs = deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((e) => e.device === this.address) ?? []);
129835
130894
  const multipleActuators = specs.filter((s) => s.key.startsWith("act-")).map((s) => s.key).length > 1;
129836
130895
  return specs.map((spec) => {
129837
- if (!spec.key.startsWith("act-")) return this.childSpec(spec);
129838
- const suffix = multipleActuators ? ` ${spec.key.slice(4)}` : "";
129839
- return this.childSpec(spec, `${this.name}${suffix}`);
130896
+ if (!spec.key.startsWith("act-") || !multipleActuators) return this.childSpec(spec, spec.key.startsWith("act-") ? this.name : void 0);
130897
+ return this.childSpec(spec, this.actuatorName(hmDevice, spec));
130898
+ });
130899
+ }
130900
+ /** CCU channel name, else `"<container> ch<index>"`. Never the raw address. */
130901
+ actuatorName(hmDevice, spec) {
130902
+ const channelAddress = spec.key.slice(4);
130903
+ const channel = hmDevice.channels.find((candidate) => candidate.address === channelAddress);
130904
+ const index = channel !== void 0 ? String(channel.index) : channelIndexFromAddress(channelAddress);
130905
+ return multiActuatorChildName({
130906
+ containerName: this.name,
130907
+ channelName: channel === void 0 ? null : readHmName(channel),
130908
+ channelIndex: index
130909
+ });
130910
+ }
130911
+ async reconcileDerived() {
130912
+ const hmDevice = this.resolveHmDevice();
130913
+ if (hmDevice === null) return;
130914
+ try {
130915
+ await this.stampPrimaryPreference(hmDevice);
130916
+ await this.refreshActuatorNames(hmDevice);
130917
+ } catch (err) {
130918
+ this.ctx.logger.warn("HmContainerDevice: could not refresh derived child meta", {
130919
+ tags: { deviceId: this.id },
130920
+ meta: {
130921
+ address: this.address,
130922
+ error: errMsg(err)
130923
+ }
130924
+ });
130925
+ }
130926
+ }
130927
+ async stampPrimaryPreference(hmDevice) {
130928
+ const manager = this.ctx.api?.deviceManager;
130929
+ if (manager === void 0) return;
130930
+ const declared = hmPrimaryChildKeys(deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((entity) => entity.device === this.address) ?? []));
130931
+ const keys = preferenceToStamp(this.ctx.deviceMeta.primaryChildPreference, declared);
130932
+ if (keys === null) return;
130933
+ await manager.setPrimaryChildPreference.mutate({
130934
+ deviceId: this.id,
130935
+ primaryChildPreference: keys
130936
+ });
130937
+ this.ctx.logger.info("Homematic container stamped its primary child", {
130938
+ tags: { deviceId: this.id },
130939
+ meta: {
130940
+ address: this.address,
130941
+ primaryChildPreference: keys
130942
+ }
129840
130943
  });
129841
130944
  }
130945
+ async refreshActuatorNames(hmDevice) {
130946
+ const manager = this.ctx.api?.deviceManager;
130947
+ if (manager === void 0) return;
130948
+ const specs = deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((entity) => entity.device === this.address) ?? []).filter((spec) => spec.key.startsWith("act-"));
130949
+ if (specs.length < 2) return;
130950
+ const children = await manager.getChildren.query({ parentDeviceId: this.id });
130951
+ for (const spec of specs) {
130952
+ const child = children.find((candidate) => candidate.stableId.endsWith(`-${spec.key}`));
130953
+ if (child === void 0) continue;
130954
+ const meta = await manager.loadMeta.query({ deviceId: child.id });
130955
+ if (meta === null) continue;
130956
+ const channelAddress = spec.key.slice(4);
130957
+ const desired = this.actuatorName(hmDevice, spec);
130958
+ const decision = actuatorNameWrite({
130959
+ currentName: meta.name,
130960
+ userNamed: meta.userNamed,
130961
+ desiredName: desired,
130962
+ legacyAutoName: legacyActuatorName(this.name, channelAddress),
130963
+ fallbackAutoName: multiActuatorChildName({
130964
+ containerName: this.name,
130965
+ channelName: null,
130966
+ channelIndex: channelIndexFromAddress(channelAddress)
130967
+ }),
130968
+ stableId: child.stableId
130969
+ });
130970
+ if (decision.kind === "keep") continue;
130971
+ await manager.setName.mutate({
130972
+ deviceId: child.id,
130973
+ name: decision.name,
130974
+ ...decision.stampUserNamed ? {} : { stampUserNamed: false }
130975
+ });
130976
+ this.ctx.logger.info("Homematic actuator child took its channel name", {
130977
+ tags: { deviceId: child.id },
130978
+ meta: {
130979
+ address: this.address,
130980
+ channel: channelAddress,
130981
+ name: decision.name
130982
+ }
130983
+ });
130984
+ }
130985
+ }
129842
130986
  /** Wrap one {@link HmEntitySpec} into an accessory-child spec, stamping the
129843
130987
  * CCU `address` + integration FK onto config and the container link
129844
130988
  * + integration + type/role onto meta. */
@@ -130127,7 +131271,7 @@ function buildCcuGatewayCandidate(input) {
130127
131271
  const adoptedId = input.adopted.get(nativeId) ?? null;
130128
131272
  return {
130129
131273
  childNativeId: nativeId,
130130
- name: input.integrationName,
131274
+ name: gatewayDeviceName("Homematic", "CCU3"),
130131
131275
  type: DeviceType.Gateway,
130132
131276
  status: input.online ? "online" : "offline",
130133
131277
  metadata: {
@@ -130396,7 +131540,7 @@ function buildHmAdoptionProvider(deps) {
130396
131540
  const { deviceId } = await adoptGateway({
130397
131541
  integrationId,
130398
131542
  nativeId,
130399
- name: perCandidate?.[nativeId]?.name ?? registry.getName(integrationId) ?? "Homematic CCU"
131543
+ name: perCandidate?.[nativeId]?.name ?? gatewayDeviceName("Homematic", "CCU3")
130400
131544
  });
130401
131545
  adopted.push({
130402
131546
  childNativeId: nativeId,
@@ -130599,7 +131743,7 @@ function homematicDiscoveryCandidates(proposals) {
130599
131743
  return proposals.map((found) => ({
130600
131744
  stableId: `homematic:${found.id}`,
130601
131745
  type: DeviceType.Gateway,
130602
- suggestedName: found.name,
131746
+ suggestedName: defaultIntegrationName("Homematic"),
130603
131747
  prefilledConfig: { host: found.host },
130604
131748
  setupIntegration: true
130605
131749
  }));
@@ -131501,6 +132645,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131501
132645
  ...buildCcuHeatingHandlers(this.ccuActionDeps()),
131502
132646
  ...buildCcuPairingHandlers(this.ccuActionDeps()),
131503
132647
  ...buildCcuConfigHandlers(this.ccuActionDeps()),
132648
+ ...buildButtonEventHandlers(this.ccuActionDeps()),
131504
132649
  discoverCcu: async () => {
131505
132650
  const { candidates } = await this.ctx.api.deviceManager.discoverProvider.mutate({ addonId: this.ctx.id });
131506
132651
  const hosts = candidates.map((candidate) => ({
@@ -131523,12 +132668,38 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131523
132668
  listPages: () => HOMEMATIC_PAGES
131524
132669
  };
131525
132670
  }
132671
+ /** The child a new container stands for, from the live CCU descriptor. */
132672
+ primaryChildPreference(integrationId, address) {
132673
+ const facade = homematicFacades.get(integrationId);
132674
+ if (facade === null) return [];
132675
+ const device = facade.devices().find((candidate) => candidate.address === address);
132676
+ if (device === void 0) return [];
132677
+ return hmPrimaryChildKeys(deriveHmEntitySpecs(device, facade.customEntities().filter((entity) => entity.device === address)));
132678
+ }
132679
+ /** A connected session's facade, or null while the integration is down. */
132680
+ connectedFacade(integrationId) {
132681
+ return this.clients?.sessions().some((session) => session.id === integrationId && session.status === "connected") === true ? homematicFacades.get(integrationId) : null;
132682
+ }
132683
+ /** CCU addresses adopted as containers from one integration. */
132684
+ async adoptedCcuAddresses(integrationId) {
132685
+ const reg = this.ctx.kernel.deviceRegistry;
132686
+ const devices = this.ctx.kernel.devices;
132687
+ const addresses = /* @__PURE__ */ new Set();
132688
+ if (!reg || !devices) return addresses;
132689
+ for (const device of reg.getAllForAddon(this.addonId)) {
132690
+ if (device.parentDeviceId !== null) continue;
132691
+ const config = await devices.loadConfig(device.id).catch(() => ({}));
132692
+ if (config["integrationId"] !== integrationId) continue;
132693
+ if (typeof config["hmEntityKey"] === "string") continue;
132694
+ const address = config["hmAddress"];
132695
+ if (typeof address === "string" && address.length > 0) addresses.add(address);
132696
+ }
132697
+ return addresses;
132698
+ }
131526
132699
  /** What the CCU management actions reach: connected sessions only, never a half-started facade. */
131527
132700
  ccuActionDeps() {
131528
132701
  return {
131529
- facade: (integrationId) => {
131530
- return this.clients?.sessions().some((session) => session.id === integrationId && session.status === "connected") === true ? homematicFacades.get(integrationId) : null;
131531
- },
132702
+ facade: (integrationId) => this.connectedFacade(integrationId),
131532
132703
  integrations: () => {
131533
132704
  const clients = this.clients;
131534
132705
  if (clients === null) return [];
@@ -131539,7 +132710,12 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131539
132710
  connected: connectedIds.has(integrationId)
131540
132711
  }));
131541
132712
  },
131542
- logger: this.ctx.logger
132713
+ logger: this.ctx.logger,
132714
+ adoptedAddresses: (integrationId) => this.adoptedCcuAddresses(integrationId),
132715
+ channelLinks: (integrationId) => {
132716
+ const facade = this.connectedFacade(integrationId);
132717
+ return facade === null ? null : channelLinkPort(facade);
132718
+ }
131543
132719
  };
131544
132720
  }
131545
132721
  async onShutdown() {
@@ -131777,10 +132953,12 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131777
132953
  name
131778
132954
  };
131779
132955
  const stableId = this.generateStableId(DeviceType.Container, config);
132956
+ const primaryChildPreference = this.primaryChildPreference(integrationId, hmAddress);
131780
132957
  const device = await devices.create(stableId, HmContainerDevice, config, null, {
131781
132958
  type: DeviceType.Container,
131782
132959
  name,
131783
- integrationId
132960
+ integrationId,
132961
+ ...primaryChildPreference.length > 0 ? { primaryChildPreference } : {}
131784
132962
  });
131785
132963
  const children = await devices.getChildren(device.id);
131786
132964
  return {
@@ -131889,4 +133067,4 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131889
133067
  }
131890
133068
  };
131891
133069
  //#endregion
131892
- export { HomematicProviderAddon, buildConnectionFormSchema as a, homematicGatewayDeviceSchema as c, mapHmDeviceChannels as i, toHomematicOptions as l, inferHmDeviceType as n, connectionFromSettings as o, mapHmChannel as r, homematicConfigSchema as s, deriveHmEntitySpecs as t };
133070
+ export { HomematicProviderAddon, homematicGatewayDeviceSchema as a, mapHmChannel as c, homematicConfigSchema as i, mapHmDeviceChannels as l, buildConnectionFormSchema as n, toHomematicOptions as o, connectionFromSettings as r, inferHmDeviceType as s, deriveHmEntitySpecs as t };