@camstack/addon-provider-homematic 1.2.192 → 1.2.194

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"),
@@ -44857,21 +44979,23 @@ function convertLegacyWhen(half) {
44857
44979
  * (instants) and state leaves (durations). It replaces the flat trigger list
44858
44980
  * plus the separate condition tree; the firing rule is in that file and in
44859
44981
  * ADR "one tree".
44860
- * - **Actions** — the `wait` and `cap` steps, plus the `{kind:'code'}`
44982
+ * - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
44861
44983
  * fragment of §3.2.2. See {@link AutomationActionSchema}.
44862
44984
  *
44863
44985
  * A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
44864
44986
  * {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
44865
44987
  */
44866
44988
  /**
44867
- * One action step: `wait`, or a `cap` call.
44989
+ * One action step: `wait`, or a device `command`.
44868
44990
  *
44869
- * A cap step's target is who it acts on (D983: `devices`, a `domain`, or a
44870
- * `{ $var }` resolved from the run's variables); the legacy `deviceId` is still
44871
- * READ, never written. The step runner (`runSteps`) owns the device-scope
44872
- * check, the stop-at-first-failure and the variable substitution, once, for
44873
- * every caller — automations, Actions, and the notification centre, which runs
44874
- * 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).
44875
44999
  */
44876
45000
  /** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
44877
45001
  var WAIT_MAX_SECONDS = 3600;
@@ -44880,39 +45004,22 @@ var AutomationWaitStepSchema = object({
44880
45004
  kind: literal("wait"),
44881
45005
  seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
44882
45006
  });
44883
- /** The legacy `deviceId` of a cap step: still READ, never written (D983). */
44884
- var LegacyStepDeviceSchema = union([
44885
- number$1().int(),
44886
- array(number$1().int()).min(1),
44887
- object({ $var: string().min(1) })
44888
- ]);
44889
45007
  /**
44890
- * The fields of a cap step, before the target rules are applied. Exported for
44891
- * a shape that is "a cap call, narrowed" (a remote-control binding is one
44892
- * device); a step is {@link AutomationCapStepSchema}.
45008
+ * The fields of a command step, before the vocabulary check. A step is
45009
+ * {@link AutomationCommandStepSchema}.
44893
45010
  */
44894
- var AutomationCapStepBaseSchema = object({
44895
- kind: literal("cap"),
44896
- /**
44897
- * The vocabulary action this step performs (`cover.open`). Required when
44898
- * `target` is a `domain` (the domain is "every device offering this
44899
- * action"); filled by {@link normalizeCapStep} for a legacy step whose
44900
- * cap + method match exactly one vocabulary action.
44901
- */
44902
- actionId: string().min(1).optional(),
44903
- /** WHO the step acts on. The only shape that is written. */
44904
- 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),
44905
45017
  /**
44906
- * @deprecated The pre-D983 target: one device, several, or `{ $var }`.
44907
- * Still READ — {@link normalizeCapStep} maps it to `target` — and never
44908
- * 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).
44909
45022
  */
44910
- deviceId: LegacyStepDeviceSchema.optional(),
44911
- cap: string().min(1),
44912
- method: string().min(1),
44913
- /** Values may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
44914
- * SUBSTITUTE and do not evaluate (§3.2.3). Anything beyond substitution is
44915
- * the expression leaf. */
44916
45023
  args: record(string(), unknown()).optional(),
44917
45024
  /**
44918
45025
  * The unit the person picked per arg (display only). `args` always hold the
@@ -44921,18 +45028,20 @@ var AutomationCapStepBaseSchema = object({
44921
45028
  */
44922
45029
  argUnits: record(string(), string().min(1)).optional()
44923
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
+ }
44924
45039
  /**
44925
- * 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
44926
45041
  * call back into an Action — so an Action can never reach itself (no cycles).
44927
45042
  * This is the LEAF shape: no condition of its own.
44928
45043
  */
44929
- var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCapStepBaseSchema.refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44930
- message: "a cap step needs a target",
44931
- path: ["target"]
44932
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44933
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44934
- path: ["actionId"]
44935
- })]);
45044
+ var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
44936
45045
  /**
44937
45046
  * The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
44938
45047
  * on the state mirror when the step is reached; `else` runs when it is false.
@@ -44953,13 +45062,7 @@ var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refi
44953
45062
  * same two step kinds an automation runs, minus a guard that reads the
44954
45063
  * automation's trigger, which such a list does not have.
44955
45064
  */
44956
- var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44957
- message: "a cap step needs a target",
44958
- path: ["target"]
44959
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44960
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44961
- path: ["actionId"]
44962
- }).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) => {
44963
45066
  if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
44964
45067
  code: "custom",
44965
45068
  message: TRIGGERED_BY_NEEDS_AUTOMATION,
@@ -44974,17 +45077,11 @@ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, Automa
44974
45077
  var continueOnErrorShape = {
44975
45078
  /** A failure of this step is traced `failed-continued` and the next step runs. */
44976
45079
  continueOnError: literal(true).optional() };
44977
- /** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
44978
- var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
45080
+ /** An automation's command step: the shared guarded command step, plus `continueOnError`. */
45081
+ var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
44979
45082
  ...stepGuardShape,
44980
45083
  ...continueOnErrorShape
44981
- }).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44982
- message: "a cap step needs a target",
44983
- path: ["target"]
44984
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44985
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44986
- path: ["actionId"]
44987
- }).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);
44988
45085
  /** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
44989
45086
  var AutomationStopStepSchema = object({
44990
45087
  kind: literal("stop"),
@@ -45064,13 +45161,7 @@ function nestTooDeep(issue) {
45064
45161
  }
45065
45162
  var plainStepSchemas = [
45066
45163
  AutomationWaitStepSchema.strict(),
45067
- AutomationCapStepBaseSchema.extend(continueOnErrorShape).strict().refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
45068
- message: "a cap step needs a target",
45069
- path: ["target"]
45070
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
45071
- message: "a domain target needs the vocabulary action it applies to (actionId)",
45072
- path: ["actionId"]
45073
- }),
45164
+ AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
45074
45165
  AutomationStopStepSchema.omit({ if: true }).strict(),
45075
45166
  AutomationSetStepSchema.omit({ if: true }).strict(),
45076
45167
  AutomationRunActionStepSchema.strict()
@@ -45081,7 +45172,7 @@ var plainStepSchemas = [
45081
45172
  */
45082
45173
  var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
45083
45174
  /** A step that can run beside others: it writes no variable and does not end the run. */
45084
- 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");
45085
45176
  /**
45086
45177
  * Several steps at once (#500): all are started together and all are awaited.
45087
45178
  * A failure fails the run once the others finished, as in a sequence; a member
@@ -45161,7 +45252,7 @@ var AutomationBodyStepSchema = discriminatedUnion("kind", [
45161
45252
  var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
45162
45253
  var AutomationActionSchema = discriminatedUnion("kind", [
45163
45254
  GuardedWaitStepSchema,
45164
- AutomationGuardedCapStepSchema,
45255
+ AutomationGuardedCommandStepSchema,
45165
45256
  AutomationStopStepSchema,
45166
45257
  AutomationSetStepSchema,
45167
45258
  chooseSchemaOf(AutomationBodyStepSchema),
@@ -45232,110 +45323,6 @@ function convertLegacyRecipe(legacy) {
45232
45323
  };
45233
45324
  }
45234
45325
  var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
45235
- var DETECTION_DESCRIPTIONS = {
45236
- deviceId: "the camera that saw it",
45237
- className: "what it saw",
45238
- trackId: "the track",
45239
- score: "how sure the detector was",
45240
- label: "the label it matched (a name, a plate), empty when none"
45241
- };
45242
- var STATIONARY_DESCRIPTIONS = {
45243
- deviceId: "the camera that saw it",
45244
- className: "what it saw",
45245
- zones: "the zones it is in",
45246
- phase: "appeared or departed",
45247
- entryId: "the stopped object"
45248
- };
45249
- var BECOMES_DESCRIPTIONS = {
45250
- deviceId: "the device that changed",
45251
- from: "the value before the change, empty when it is not known",
45252
- to: "the value it changed to"
45253
- };
45254
- /**
45255
- * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
45256
- * those names depend on the device, so they are not in this list.
45257
- */
45258
- var FIRED_DESCRIPTIONS = {
45259
- deviceId: "the device that fired",
45260
- eventType: "the event, as the device names it",
45261
- sourceId: "the part of the device that fired (a button), empty when it names none",
45262
- eventKind: "the kind of press (press, long-press …), empty when the device declares none"
45263
- };
45264
- function describe$1(descriptions) {
45265
- return Object.entries(descriptions).map(([name, description]) => ({
45266
- name,
45267
- description
45268
- }));
45269
- }
45270
- describe$1(DETECTION_DESCRIPTIONS);
45271
- describe$1(STATIONARY_DESCRIPTIONS);
45272
- describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45273
- ...v,
45274
- hintKey: "firedDeviceId"
45275
- } : v);
45276
- describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45277
- ...v,
45278
- hintKey: "becomesDeviceId"
45279
- } : v);
45280
- new Set(Object.values(COCO_TO_MACRO.mapping));
45281
- /**
45282
- * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
45283
- * device. Carries the device's EXACT declared event vocabulary verbatim
45284
- * (NO normalization). Two shapes:
45285
- * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
45286
- * declared set (e.g. press_short, press_long, …).
45287
- * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
45288
- * is [] (open) and `lastEvent.data` carries the complex payload.
45289
- * `vocabulary` (D1044) names each event for a person and types it for a
45290
- * rule; `eventTypes` is its list of native tokens, kept for older readers.
45291
- * A fire names the part of the device it came from in `sourceId` when the
45292
- * vocabulary declares sources (a remote's buttons).
45293
- * `seq` is monotonic so two identical events still produce distinct slice writes.
45294
- */
45295
- var EventFireSchema = object({
45296
- deviceId: number$1(),
45297
- eventType: string(),
45298
- sourceId: string().optional(),
45299
- data: record(string(), unknown()).nullable(),
45300
- timestamp: number$1().meta(readingMeta("none")),
45301
- seq: number$1().meta(readingMeta("count"))
45302
- });
45303
- var EventEmitterStatusSchema = object({
45304
- eventTypes: array(string()),
45305
- /**
45306
- * Required of a provider by the type. A status written before the field
45307
- * existed still parses, as an empty vocabulary: read it through
45308
- * `readEventVocabulary`, which then answers with the plain tokens.
45309
- */
45310
- vocabulary: array(EventVocabularyEntrySchema).default([]),
45311
- lastEvent: EventFireSchema.nullable(),
45312
- eventCountSinceStart: number$1().meta(readingMeta("count"))
45313
- });
45314
- var eventEmitterCapability = {
45315
- name: "event-emitter",
45316
- scope: "device",
45317
- deviceNative: true,
45318
- mode: "singleton",
45319
- deviceTypes: [DeviceType.EventEmitter],
45320
- methods: {},
45321
- events: { onEvent: { data: EventFireSchema } },
45322
- status: {
45323
- schema: EventEmitterStatusSchema,
45324
- kind: "push"
45325
- },
45326
- runtimeState: EventEmitterStatusSchema,
45327
- /**
45328
- * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
45329
- *
45330
- * See `RuntimeStateDurability`. Enforced by
45331
- * `scripts/check-runtime-state-durability.ts`.
45332
- */
45333
- durability: "session",
45334
- /**
45335
- * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
45336
- */
45337
- history: "none"
45338
- };
45339
45326
  /**
45340
45327
  * Schedulers (D983) — an entity that performs actions over the day.
45341
45328
  *
@@ -45734,6 +45721,110 @@ var AutomationStateDocSchema = object({
45734
45721
  lastRunStartedAt: number$1().nullable(),
45735
45722
  traces: array(AutomationRunTraceSchema)
45736
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
+ };
45737
45828
  /**
45738
45829
  * Actions — named, runnable things an operator (or an automation) can start,
45739
45830
  * declared as LIST ENTRIES, never as devices.
@@ -45913,6 +46004,177 @@ var UnitWarningSchema = object({
45913
46004
  assumedUnit: string(),
45914
46005
  message: string()
45915
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());
45916
46178
  _enum([
45917
46179
  "automation",
45918
46180
  "action",
@@ -51116,11 +51378,13 @@ var IrCodecError = class extends Error {
51116
51378
  this.code = code;
51117
51379
  }
51118
51380
  };
51381
+ /** Maximum number of mark/space entries one pulse train may carry. */
51382
+ var IR_TIMINGS_MAX = 1024;
51119
51383
  /**
51120
51384
  * A pulse train in signed microseconds: mark (+) first, then space (-), strictly
51121
51385
  * alternating, no zeros, 2..1024 entries.
51122
51386
  */
51123
- 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) => {
51124
51388
  timings.forEach((value, index) => {
51125
51389
  const expectMark = index % 2 === 0;
51126
51390
  if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
@@ -51167,15 +51431,186 @@ function decodePronto(code) {
51167
51431
  carrierHz: Math.round(1e6 / unitUs)
51168
51432
  };
51169
51433
  }
51170
- /** What a remote command stores: a raw pulse train, or a learned Pronto code. */
51171
- var IrPayloadSchema = discriminatedUnion("kind", [object({
51172
- kind: literal("raw"),
51173
- timings: array(number$1().int()),
51174
- settings: TransmitSettingsSchema.optional()
51175
- }), object({
51176
- kind: literal("pronto"),
51177
- code: string()
51178
- })]);
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
+ ]);
51179
51614
  /** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
51180
51615
  function toTimings(payload) {
51181
51616
  if (payload.kind === "pronto") {
@@ -51185,6 +51620,10 @@ function toTimings(payload) {
51185
51620
  settings: { carrierHz: decoded.carrierHz }
51186
51621
  };
51187
51622
  }
51623
+ if (payload.kind === "native") return {
51624
+ timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
51625
+ settings: {}
51626
+ };
51188
51627
  const checked = IrTimingsSchema.safeParse(payload.timings);
51189
51628
  if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
51190
51629
  return {
@@ -52056,8 +52495,8 @@ function actuator(input) {
52056
52495
  };
52057
52496
  }
52058
52497
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
52059
- DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
52060
52498
  DeviceType.Camera;
52499
+ DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
52061
52500
  var PowerSourceRefusalReasonSchema = _enum([
52062
52501
  "no-power-source",
52063
52502
  "switch-missing",
@@ -53517,144 +53956,6 @@ method(object({
53517
53956
  kind: "mutation",
53518
53957
  auth: "admin"
53519
53958
  });
53520
- /**
53521
- * `device-export` — collection cap for addons that export camstack
53522
- * devices to external ecosystems (HomeAssistant via MQTT discovery,
53523
- * HomeKit/HAP, Alexa Smart Home, …).
53524
- *
53525
- * No `ecosystem` enum — the addon id identifies the export target.
53526
- * Each addon owns its mapping logic in its own settings UI. The cap
53527
- * exposes only the COMMON surface: link state, supported device
53528
- * kinds (so the UI can filter the device picker), and per-device
53529
- * expose/unexpose.
53530
- *
53531
- * INSTANCES. One export addon can serve several independent targets (a
53532
- * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
53533
- * `instanceId` on a READ is optional: absent = the whole addon (linked if any
53534
- * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
53535
- * default instance's); present = that instance; an id the provider does not
53536
- * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
53537
- * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
53538
- * change always names the target it changes. A single-instance provider
53539
- * accepts an absent id on a read or its own id, and refuses any other.
53540
- */
53541
- /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
53542
- var InstanceIdSchema$1 = string().min(1);
53543
- var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
53544
- /** One independent export target of an addon. */
53545
- var ExportInstanceSchema = object({
53546
- instanceId: InstanceIdSchema$1,
53547
- name: string(),
53548
- enabled: boolean(),
53549
- kind: string().optional()
53550
- });
53551
- var LinkStateSchema = _enum([
53552
- "unlinked",
53553
- "linked",
53554
- "error"
53555
- ]);
53556
- /**
53557
- * A single label/value row surfaced in the export panel's "Setup"
53558
- * section. Rendered with a copy-to-clipboard button. `secret: true`
53559
- * rows are masked by default with a reveal toggle (client ids,
53560
- * secrets, …).
53561
- */
53562
- var ExportSetupFieldSchema = object({
53563
- label: string(),
53564
- value: string(),
53565
- /** Mask the value by default + render a reveal toggle (client id, secrets). */
53566
- secret: boolean().optional()
53567
- });
53568
- /**
53569
- * Generic, addon-agnostic pairing/account block. Any export addon can
53570
- * surface a scannable QR, a set of copyable label/value rows, and a
53571
- * free-form operator note — the `DeviceExportPanel` renders whatever
53572
- * the provider supplies and skips the section entirely when `setup`
53573
- * is unset.
53574
- */
53575
- var ExportSetupSchema = object({
53576
- /** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
53577
- qr: string().optional(),
53578
- /** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
53579
- fields: array(ExportSetupFieldSchema).readonly().optional(),
53580
- /** Free-form operator instructions rendered above the fields. */
53581
- note: string().optional()
53582
- });
53583
- var DeviceExportStatusSchema = object({
53584
- linkState: LinkStateSchema,
53585
- exposedDeviceCount: number$1(),
53586
- error: string().optional(),
53587
- /**
53588
- * Optional pairing/account info the panel renders in a generic
53589
- * "Setup" section. Addon-agnostic — the addon id identifies the
53590
- * export target, never an `ecosystem` key here.
53591
- */
53592
- setup: ExportSetupSchema.optional()
53593
- });
53594
- var DeviceKindSchema = string();
53595
- var ExposedDeviceSchema = object({
53596
- deviceId: string(),
53597
- exposedAs: string().optional(),
53598
- capabilities: array(string()).optional()
53599
- });
53600
- var ExposeInputSchema = object({
53601
- instanceId: InstanceIdSchema$1,
53602
- deviceId: string(),
53603
- capabilities: array(string()).optional()
53604
- });
53605
- var UnexposeInputSchema = object({
53606
- instanceId: InstanceIdSchema$1,
53607
- deviceId: string()
53608
- });
53609
- /**
53610
- * What an exporter may expose besides devices (D968). An action and a
53611
- * notification target are LIST ENTRIES, never devices (D954): they enter an
53612
- * exporter's own selection, not the device registry.
53613
- */
53614
- var ExportEntityKindSchema = _enum([
53615
- "device",
53616
- "action",
53617
- "notifier"
53618
- ]);
53619
- var ExportEntityRefSchema = discriminatedUnion("kind", [
53620
- object({
53621
- kind: literal("device"),
53622
- deviceId: string()
53623
- }),
53624
- object({
53625
- kind: literal("action"),
53626
- actionId: string().min(1)
53627
- }),
53628
- object({
53629
- kind: literal("notifier"),
53630
- targetId: string().min(1)
53631
- })
53632
- ]);
53633
- var ExposedEntitySchema = object({
53634
- entity: ExportEntityRefSchema,
53635
- exposedAs: string().optional()
53636
- });
53637
- var ExposeEntityInputSchema = object({
53638
- instanceId: InstanceIdSchema$1,
53639
- entity: ExportEntityRefSchema
53640
- });
53641
- var UnexposeEntityInputSchema = object({
53642
- instanceId: InstanceIdSchema$1,
53643
- entity: ExportEntityRefSchema
53644
- });
53645
- method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
53646
- kind: "mutation",
53647
- auth: "admin"
53648
- }), method(UnexposeInputSchema, _void(), {
53649
- kind: "mutation",
53650
- auth: "admin"
53651
- }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
53652
- kind: "mutation",
53653
- auth: "admin"
53654
- }), optionalMethod(UnexposeEntityInputSchema, _void(), {
53655
- kind: "mutation",
53656
- auth: "admin"
53657
- });
53658
53959
  var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
53659
53960
  var DeviceTemplateSchema = string().min(1).max(4096);
53660
53961
  /** One value a caller hands the renderer for `thisDevice`. */
@@ -58509,6 +58810,193 @@ var StateLookSchema = object({
58509
58810
  background: _enum(HERO_BACKGROUNDS),
58510
58811
  animation: HeroAnimationSchema
58511
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
+ }
58512
59000
  /** The scene as the model carries it. `null` = the device did not say (never a guess). */
58513
59001
  var HeroSceneSchema = object({
58514
59002
  id: _enum([
@@ -58559,12 +59047,7 @@ var HeroSceneSchema = object({
58559
59047
  level: number$1().min(0).max(1).nullable()
58560
59048
  });
58561
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;
58562
- 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;
58563
- /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
58564
- var HeroTextSchema = object({
58565
- en: string(),
58566
- it: string()
58567
- });
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;
58568
59051
  var HeroRowIdSchema = _enum([
58569
59052
  "progress",
58570
59053
  "run-for",
@@ -58670,6 +59153,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
58670
59153
  optionLabels: record(string(), HeroTextSchema).optional(),
58671
59154
  call: HeroCallSchema,
58672
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()
58673
59175
  })
58674
59176
  ]);
58675
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. */
@@ -58871,6 +59373,11 @@ var HeroModelSchema = object({
58871
59373
  timedRun: HeroTimedRunSlotSchema.nullable(),
58872
59374
  powerSupply: HeroPowerSupplySlotSchema.nullable(),
58873
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(),
58874
59381
  /** Ids of parts that actuate the device, hidden from a session that may not act on it. */
58875
59382
  gated: array(string()),
58876
59383
  provenance: array(HeroProvenanceSchema)
@@ -58942,8 +59449,23 @@ var HeroRowModelSchema = object({
58942
59449
  * the call. Absent or empty = `primary` alone.
58943
59450
  */
58944
59451
  extras: array(HeroControlSchema).max(2).optional(),
58945
- 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()
58946
59459
  });
59460
+ new Set([
59461
+ "temperature",
59462
+ "humidity",
59463
+ "pressure",
59464
+ "illuminance",
59465
+ "reading",
59466
+ "air-quality",
59467
+ "valve"
59468
+ ]);
58947
59469
  DeviceType.Climate;
58948
59470
  DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
58949
59471
  /**
@@ -60032,13 +60554,32 @@ var IrSendResultSchema = object({
60032
60554
  var IrTransmitterInfoSchema = object({
60033
60555
  media: array(IrMediumSchema),
60034
60556
  settable: array(TransmitSettingKeySchema),
60035
- 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()
60036
60570
  });
60037
60571
  DeviceType.Generic, method(object({
60038
60572
  deviceId: number$1().int().nonnegative(),
60039
- timings: IrTimingsSchema,
60573
+ timings: IrTimingsSchema.optional(),
60574
+ native: IrNativeCodeSchema.optional(),
60040
60575
  settings: TransmitSettingsSchema.optional()
60041
- }), 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, {
60042
60583
  kind: "mutation",
60043
60584
  auth: "protected"
60044
60585
  }), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
@@ -69824,6 +70365,7 @@ var NcSystemEventKindSchema = _enum([
69824
70365
  "recording-degraded",
69825
70366
  "device-attention-required",
69826
70367
  "device-attention-resolved",
70368
+ "device-command",
69827
70369
  "storage-location-low",
69828
70370
  "storage-location-critical",
69829
70371
  "storage-location-ok",
@@ -69886,11 +70428,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
69886
70428
  "alarm-sensor-bypass",
69887
70429
  "alarm-disarmed"
69888
70430
  ];
69889
- /**
69890
- * One coherent system-event condition. `kinds` is the required opt-in safety
69891
- * gate; the remaining lists are optional narrowing filters relevant to the
69892
- * selected kinds.
69893
- */
69894
70431
  var NcSystemEventConditionSchema = object({
69895
70432
  kinds: array(NcSystemEventKindSchema).min(1),
69896
70433
  deviceIds: array(number$1().int()).min(1).optional(),
@@ -69922,6 +70459,28 @@ var NcSystemEventConditionSchema = object({
69922
70459
  nodeIds: array(string().min(1)).min(1).optional(),
69923
70460
  packageNames: array(string().min(1)).min(1).optional(),
69924
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
+ /**
69925
70484
  * At or below this remaining-life %, a consumable is LOW for THIS rule
69926
70485
  * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
69927
70486
  * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
@@ -70902,6 +71461,13 @@ var NcRuleInputSchema = object({
70902
71461
  */
70903
71462
  groupingSec: number$1().int().min(5).max(60).optional(),
70904
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
+ /**
70905
71471
  * ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
70906
71472
  * carries "Correct" / "Wrong" buttons (and, where the channel has room, a
70907
71473
  * "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
@@ -71338,7 +71904,12 @@ var NcHistoryEntrySchema = object({
71338
71904
  * Assistant export) must render as "no image right now", never as a
71339
71905
  * broken link.
71340
71906
  */
71341
- 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()
71342
71913
  });
71343
71914
  /**
71344
71915
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -77411,10 +77982,15 @@ getStatus: method(object({ deviceId: number$1() }), RecordingSignalStatusSchema)
77411
77982
  */
77412
77983
  history: "none"
77413
77984
  };
77414
- var RemoteBindingSchema = object({ action: AutomationCapStepBaseSchema.omit({
77415
- target: true,
77416
- actionId: true
77417
- }).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
+ }) });
77418
77994
  var RemoteCustomButtonSchema = object({
77419
77995
  /** The slug after `custom:` in the role. */
77420
77996
  key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
@@ -78404,7 +78980,7 @@ var sceneMonitorCapability = {
78404
78980
  * instead of failing silently weeks later.
78405
78981
  *
78406
78982
  * Reachable from three surfaces on this one mutation: the scene card, a
78407
- * notification button (an `onTrigger` sequence with a `kind:'cap'` step —
78983
+ * notification button (an `onTrigger` sequence with a `kind:'command'` step —
78408
78984
  * no new Notification-Center code at all), and tRPC for scripts.
78409
78985
  */
78410
78986
  resetScene: method(object({
@@ -85383,8 +85959,6 @@ var BaseDeviceProvider = class extends BaseAddon {
85383
85959
  }
85384
85960
  };
85385
85961
  DeviceType.HeatPump;
85386
- DeviceType.Climate;
85387
- DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
85388
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;
85389
85963
  new Set(Object.values(DeviceType));
85390
85964
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
@@ -85397,6 +85971,13 @@ function contribution(cap, schema, build) {
85397
85971
  }
85398
85972
  };
85399
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
+ }
85400
85981
  function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
85401
85982
  return {
85402
85983
  id,
@@ -85516,7 +86097,7 @@ var lockContribution = contribution("lock-control", LockControlStatusSchema, (sl
85516
86097
  const state = slice?.state ?? null;
85517
86098
  const words = state === null ? null : LOCK_WORDS[state];
85518
86099
  const since = slice === void 0 ? null : elapsedText(slice.lastChangedAt, ctx.now);
85519
- const title = words?.title ?? t("Unknown", "Sconosciuto");
86100
+ const title = words?.title ?? NOT_REPORTED;
85520
86101
  return {
85521
86102
  reading: reading("lock-control", words?.state ?? "unknown", false, words?.title),
85522
86103
  rows: [row$1("lock", state === "locked" || state === "locking" ? "lock" : "lock-open", joinText([title, since]), lockControls(state, ctx.features.includes(DeviceFeature.LockOpen)))],
@@ -85608,7 +86189,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85608
86189
  const modes = slice === void 0 ? ALARM_MODES : slice.availableModes;
85609
86190
  return {
85610
86191
  reading: reading("alarm-panel", words?.state ?? "unknown", false, words?.title),
85611
- 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))],
85612
86193
  ...since === null || words === null ? {} : { facts: [fact("since", "clock", since, state === "triggered" ? "danger" : "muted")] },
85613
86194
  ...words === null ? {} : { tiles: {
85614
86195
  left: [{
@@ -85639,7 +86220,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85639
86220
  return {
85640
86221
  reading: reading("automation-control", state, false, title),
85641
86222
  rows: [row$1("automation", "workflow", joinText([
85642
- title ?? t("Unknown", "Sconosciuto"),
86223
+ title ?? NOT_REPORTED,
85643
86224
  last === null ? null : t(`Ran ${last.en}`, `Eseguita ${last.it}`),
85644
86225
  slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
85645
86226
  ]), [asAction(run), toggle])],
@@ -85655,7 +86236,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85655
86236
  return {
85656
86237
  reading: reading("script-runner", state, false, title),
85657
86238
  rows: [row$1("script", "scroll-text", joinText([
85658
- title ?? t("Unknown", "Sconosciuto"),
86239
+ title ?? NOT_REPORTED,
85659
86240
  last === null ? null : t(`Ran ${last.en}`, `Eseguito ${last.it}`),
85660
86241
  slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
85661
86242
  ]), [asAction(control)])],
@@ -85664,7 +86245,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85664
86245
  }),
85665
86246
  "do-not-disturb": contribution("do-not-disturb", DoNotDisturbStatusSchema, (slice) => {
85666
86247
  const on = slice?.enabled ?? null;
85667
- 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"), [{
85668
86249
  kind: "toggle",
85669
86250
  id: "do-not-disturb.toggle",
85670
86251
  label: t("Do not disturb", "Non disturbare"),
@@ -85682,7 +86263,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85682
86263
  * is absent from the facts, never a zero (D393).
85683
86264
  */
85684
86265
  var has$3 = (ctx, f) => ctx.features.includes(f);
85685
- var unknownText = t("Unknown", "Sconosciuto");
86266
+ var unknownText = NOT_REPORTED;
85686
86267
  var pct$2 = (n) => t(`${Math.round(n)}%`, `${Math.round(n)}%`);
85687
86268
  var unit = (n) => Math.min(1, Math.max(0, n / 100));
85688
86269
  /** Battery as a fact, unless the device is also bound to the `battery` cap (it already says so). */
@@ -86671,10 +87252,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
86671
87252
  };
86672
87253
  });
86673
87254
  var CONTROL_LABEL = t("Value", "Valore");
86674
- /** 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
+ */
86675
87259
  function controlRows(slice) {
86676
87260
  if (slice.kind === "numeric" && typeof slice.value === "number") {
86677
- 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
+ }])];
86678
87275
  return [row$1("control", "sliders-horizontal", null, [{
86679
87276
  kind: "slider",
86680
87277
  id: "control.value",
@@ -86705,6 +87302,18 @@ function controlRows(slice) {
86705
87302
  },
86706
87303
  valueArg: "control.value"
86707
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
+ }])];
86708
87317
  return [];
86709
87318
  }
86710
87319
  var SENSORS_FAMILY_CONTRIBUTIONS = {
@@ -87060,15 +87669,15 @@ function sensorFragment(value, id, icon, en, it, text) {
87060
87669
  tiles: { right: [tile$1(en, it, text)] }
87061
87670
  };
87062
87671
  }
87063
- var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
87064
- 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)));
87065
87674
  var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
87066
87675
  var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
87067
87676
  var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
87068
87677
  var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
87069
- 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"));
87070
87679
  if (slice.timestamp === true) return { reading: reading("sensor", "on") };
87071
- 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));
87072
87681
  });
87073
87682
  /** Index bands: the headline of an air-quality sensor is a word, not a number. */
87074
87683
  function airQualityWord(aqi) {
@@ -87190,7 +87799,7 @@ function circuitControl(circuit) {
87190
87799
  return picker(`heat-pump.${circuit.id}.mode`, t("Mode", "Modalità"), circuit.operationMode, method, args);
87191
87800
  }
87192
87801
  /** A circuit with no reading is still a row: it shows that nothing is known, not nothing. */
87193
- var UNKNOWN_STATUS = same("—");
87802
+ var UNKNOWN_STATUS = NOT_REPORTED;
87194
87803
  function circuitRow(circuit) {
87195
87804
  const control = circuitControl(circuit);
87196
87805
  const status = thermalStatusText(circuit.targetTemp, circuit.currentTemp) ?? UNKNOWN_STATUS;
@@ -87414,9 +88023,8 @@ function look(icon, tone, background, animation) {
87414
88023
  animation
87415
88024
  };
87416
88025
  }
87417
- /** A state a device is in whatever it is: unreachable, or silent. Identical for every look. */
88026
+ /** Unreachable: identical for every look. */
87418
88027
  var OFFLINE = look("wifi-off", "muted", "plain", "none");
87419
- var UNKNOWN = look("circle-question-mark", "muted", "plain", "none");
87420
88028
  var ALERT = look("triangle-alert", "danger", "alert-wash", "pulse");
87421
88029
  function lookOf(spec) {
87422
88030
  const at = (s) => look(spec.icon, s[0], s[1], s[2]);
@@ -87428,7 +88036,7 @@ function lookOf(spec) {
87428
88036
  standby: at(spec.standby),
87429
88037
  alert: spec.alert ?? ALERT,
87430
88038
  offline: OFFLINE,
87431
- unknown: UNKNOWN
88039
+ unknown: look(spec.icon, "muted", "plain", "none")
87432
88040
  };
87433
88041
  }
87434
88042
  var MUTED = [
@@ -88037,7 +88645,7 @@ lookOf({
88037
88645
  });
88038
88646
  DeviceType.Climate;
88039
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;
88040
- 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;
88041
88649
  Object.freeze({
88042
88650
  "accessories.getStatus": {
88043
88651
  capName: "accessories",
@@ -89964,6 +90572,13 @@ Object.freeze({
89964
90572
  access: "view",
89965
90573
  role: "admin"
89966
90574
  },
90575
+ "deviceExport.setExposedName": {
90576
+ capName: "device-export",
90577
+ capScope: "system",
90578
+ addonId: null,
90579
+ access: "create",
90580
+ role: "admin"
90581
+ },
89967
90582
  "deviceExport.unexposeDevice": {
89968
90583
  capName: "device-export",
89969
90584
  capScope: "system",
@@ -91903,6 +92518,13 @@ Object.freeze({
91903
92518
  access: "view",
91904
92519
  role: "viewer"
91905
92520
  },
92521
+ "irTransmitter.learn": {
92522
+ capName: "ir-transmitter",
92523
+ capScope: "device",
92524
+ addonId: null,
92525
+ access: "create",
92526
+ role: "viewer"
92527
+ },
91906
92528
  "irTransmitter.send": {
91907
92529
  capName: "ir-transmitter",
91908
92530
  capScope: "device",
@@ -98421,48 +99043,6 @@ Object.freeze({
98421
99043
  role: "admin"
98422
99044
  }
98423
99045
  });
98424
- /**
98425
- * "Do" actions an operator can pick for a device — presentation-free.
98426
- *
98427
- * The wire shape stays `{ cap, method, args }`. Since D920 this module no
98428
- * longer HOLDS a catalogue: {@link DEVICE_DO_ACTIONS} is a projection of the
98429
- * cap vocabulary (`cap-vocabulary/`), the one cap-keyed map of every action
98430
- * and trigger — so a picker built on this module and one built on
98431
- * `actionsForDevice` (the vocabulary resolver) can never disagree about what
98432
- * a device can do. Ids, baked args and the matching of saved steps are the
98433
- * vocabulary's; labels here are its English labels.
98434
- *
98435
- * Shared by the admin NC Sequences / rule Do editor and Automations; the
98436
- * viewer can reuse the same catalogue once its step editor catches up.
98437
- */
98438
- function openArgKind(offer) {
98439
- if (offer.kind === "number") return "number";
98440
- if (offer.kind === "dynamic" && offer.valueKind === "number") return "number";
98441
- if (offer.kind === "enum" && offer.values.every((v) => typeof v.value === "number")) return "number";
98442
- return "string";
98443
- }
98444
- function projectOpenArg(arg) {
98445
- return {
98446
- key: arg.key,
98447
- label: arg.label.en,
98448
- kind: openArgKind(arg.offer),
98449
- offer: arg.offer,
98450
- ...arg.optional === true ? { optional: true } : {}
98451
- };
98452
- }
98453
- function projectAction(cap, action) {
98454
- const open = action.openArgs ?? [];
98455
- return {
98456
- id: action.id,
98457
- label: action.label.en,
98458
- cap,
98459
- method: action.method,
98460
- args: action.args ?? {},
98461
- ...open.length > 0 ? { openArgs: open.map(projectOpenArg) } : {}
98462
- };
98463
- }
98464
- Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
98465
- 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;
98466
99046
  DeviceFeature.BatteryOperated;
98467
99047
  function bound(cap, methods = [], authority = "reported") {
98468
99048
  return {
@@ -98521,6 +99101,10 @@ function offered(received) {
98521
99101
  };
98522
99102
  }
98523
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));
98524
99108
  var PowerSwitchRefusedError = class extends Error {
98525
99109
  reason;
98526
99110
  constructor(reason, message) {
@@ -99897,6 +100481,11 @@ Object.freeze({
99897
100481
  form: "single",
99898
100482
  optional: false
99899
100483
  }],
100484
+ "irTransmitter.learn": [{
100485
+ name: "deviceId",
100486
+ form: "single",
100487
+ optional: false
100488
+ }],
99900
100489
  "irTransmitter.send": [{
99901
100490
  name: "deviceId",
99902
100491
  form: "single",
@@ -101836,7 +102425,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
101836
102425
  "deviceTypes",
101837
102426
  "nodeIds",
101838
102427
  "packageNames",
101839
- "consumableLowPercent"
102428
+ "consumableLowPercent",
102429
+ "commandActions",
102430
+ "commandOutcomes",
102431
+ "commandActorKinds"
101840
102432
  ];
101841
102433
  new Map(Object.entries({
101842
102434
  "device-online": "device-events",
@@ -101859,6 +102451,7 @@ new Map(Object.entries({
101859
102451
  "recording-degraded": "device-events",
101860
102452
  "device-attention-required": "device-events",
101861
102453
  "device-attention-resolved": "device-events",
102454
+ "device-command": "device-events",
101862
102455
  "node-online": "system",
101863
102456
  "node-offline": "system",
101864
102457
  "node-restarting": "system",
@@ -101959,6 +102552,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
101959
102552
  label: "Needs attention",
101960
102553
  kinds: ["device-attention-required", "device-attention-resolved"]
101961
102554
  },
102555
+ {
102556
+ id: "device-command",
102557
+ family: "device-events",
102558
+ label: "Commands given to devices",
102559
+ kinds: ["device-command"]
102560
+ },
101962
102561
  {
101963
102562
  id: "nodes",
101964
102563
  family: "system",
@@ -102036,6 +102635,15 @@ function systemEventKindsOfFamily(family) {
102036
102635
  return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
102037
102636
  }
102038
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
+ ]);
102039
102647
  /**
102040
102648
  * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
102041
102649
  * persists (D640 "a sensor rule fires on the raise, the clear, or both").
@@ -102231,6 +102839,7 @@ var DEVICE_EVENTS = [
102231
102839
  "recording-healthy",
102232
102840
  "recording-degraded",
102233
102841
  ...DEVICE_ATTENTION,
102842
+ "device-command",
102234
102843
  ...ALARM
102235
102844
  ];
102236
102845
  /** Every kind a summary may speak about — the two summarisable families. */
@@ -102384,6 +102993,9 @@ var STATE_SUMMARY_VARS = [
102384
102993
  [...RULE_BODY_ONLY],
102385
102994
  [...RULE_TEXT],
102386
102995
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
102996
+ [...RULE_TEXT],
102997
+ [...RULE_TEXT],
102998
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
102387
102999
  ([...RULE_TEXT], [...COMBINED_ALARM]),
102388
103000
  ([...RULE_TEXT], [...COMBINED_ALARM]),
102389
103001
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
@@ -103452,6 +104064,284 @@ var HomematicReconciler = class {
103452
104064
  }
103453
104065
  };
103454
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
103455
104345
  //#region src/ccu/ccu-facade.ts
103456
104346
  function errorText(err) {
103457
104347
  return err instanceof Error ? err.message : String(err);
@@ -103467,6 +104357,144 @@ function requireConfirmed(confirmed) {
103467
104357
  if (confirmed !== true) throw new Error("A CCU write needs the operator confirmation (confirmed: true)");
103468
104358
  }
103469
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
103470
104498
  //#region src/ccu/ccu-device-rows.ts
103471
104499
  /** `RSSI_*` reports this when the device has no signal reading. */
103472
104500
  var RSSI_UNKNOWN = 65535;
@@ -103513,7 +104541,8 @@ function toCcuDeviceRow(device) {
103513
104541
  lowBattery: asBool$1(readParam(maintenance, ["LOW_BAT", "LOWBAT"])),
103514
104542
  unreach: asBool$1(readParam(maintenance, ["UNREACH", "STICKY_UNREACH"])),
103515
104543
  configPending: asBool$1(readParam(maintenance, ["CONFIG_PENDING"])),
103516
- sabotage: asBool$1(readParam(maintenance, ["SABOTAGE", "ERROR_SABOTAGE"]))
104544
+ sabotage: asBool$1(readParam(maintenance, ["SABOTAGE", "ERROR_SABOTAGE"])),
104545
+ keyChannels: []
103517
104546
  };
103518
104547
  }
103519
104548
  //#endregion
@@ -103521,7 +104550,12 @@ function toCcuDeviceRow(device) {
103521
104550
  /** The CCU device list: every device the CCU knows, with its radio and maintenance health. */
103522
104551
  function buildCcuDevicesHandlers(deps) {
103523
104552
  return { listCcuDevices: async (input) => {
103524
- 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
+ })) };
103525
104559
  } };
103526
104560
  }
103527
104561
  //#endregion
@@ -103666,6 +104700,24 @@ var AcknowledgeInputSchema = IntegrationRefSchema.extend({
103666
104700
  confirmed: ConfirmedSchema
103667
104701
  });
103668
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
+ });
103669
104721
  var CcuDevicesResultSchema = object({ devices: array(object({
103670
104722
  address: string(),
103671
104723
  type: string(),
@@ -103686,7 +104738,12 @@ var CcuDevicesResultSchema = object({ devices: array(object({
103686
104738
  lowBattery: boolean().nullable(),
103687
104739
  unreach: boolean().nullable(),
103688
104740
  configPending: boolean().nullable(),
103689
- 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([])
103690
104747
  })) });
103691
104748
  /** The group types the CCU can create (nodehomematic `HmGroupCreate.type`). */
103692
104749
  var HEATING_GROUP_TYPES = ["hmip.heating.group", "HomeMatic.heating"];
@@ -127392,6 +128449,10 @@ var homematicActions = defineCustomActions({
127392
128449
  acknowledgeServiceMessage: customAction(AcknowledgeInputSchema, OkResultSchema, {
127393
128450
  kind: "mutation",
127394
128451
  auth: "admin"
128452
+ }),
128453
+ setButtonEvents: customAction(SetButtonEventsInputSchema, OkResultSchema, {
128454
+ kind: "mutation",
128455
+ auth: "admin"
127395
128456
  })
127396
128457
  });
127397
128458
  //#endregion
@@ -127439,7 +128500,7 @@ function inferCallbackHost(ccuHost) {
127439
128500
  var homematicConfigSchema = object({
127440
128501
  host: string().min(1).describe("CCU3 / RaspberryMatic host name or IP address"),
127441
128502
  enableHmipRf: boolean().default(true).describe("Enable Homematic IP (HmIP-RF)"),
127442
- 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"),
127443
128504
  enableGroups: boolean().default(true).describe("Enable groups (heating groups / VirtualDevices)"),
127444
128505
  enableBidcosWired: boolean().default(false).describe("Enable BidCos-Wired (HM-Wired)"),
127445
128506
  username: string().default("Admin").describe("WebUI username (optional — enables names / rooms / sysvars)"),
@@ -127585,6 +128646,8 @@ function buildConnectionFormSchema() {
127585
128646
  key: "enableBidcosRf",
127586
128647
  label: "Enable Homematic (BidCos-RF)",
127587
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",
127588
128651
  default: false
127589
128652
  },
127590
128653
  {
@@ -127854,81 +128917,6 @@ var HOMEMATIC_ROWS_TO_RECORD_MIGRATION = {
127854
128917
  })
127855
128918
  };
127856
128919
  //#endregion
127857
- //#region src/homematic-facade-resolver.ts
127858
- /**
127859
- * Per-integration registry that device classes use to reach the live
127860
- * `Homematic` facade (and the session state) of their CCU.
127861
- *
127862
- * The kernel constructs device classes through the `deviceClasses` map with
127863
- * only a `DeviceContext` — it cannot thread the facade in as a constructor
127864
- * arg. The connection lives on the INTEGRATION, so the CCU box and every device
127865
- * adopted from it resolve the same session by `integrationId`. A device
127866
- * persisted without an `integrationId` cannot be attributed to a CCU and
127867
- * resolves nothing.
127868
- */
127869
- var HmFacadeResolver = class {
127870
- #facades = /* @__PURE__ */ new Map();
127871
- #sessions = /* @__PURE__ */ new Map();
127872
- /** Per-integration state-change fan-out (connect, disconnect, error). */
127873
- #snapshotSubs = /* @__PURE__ */ new Map();
127874
- /** Publish or remove the facade for an integration id. `null` removes the entry. */
127875
- set(integrationId, facade) {
127876
- if (facade === null) {
127877
- this.#facades.delete(integrationId);
127878
- return;
127879
- }
127880
- this.#facades.set(integrationId, facade);
127881
- }
127882
- /** The live facade for an integration id, or null when unknown / absent / not running. */
127883
- get(integrationId) {
127884
- if (integrationId === void 0 || integrationId === null) return null;
127885
- return this.#facades.get(integrationId) ?? null;
127886
- }
127887
- /** Publish or remove the session (state + connection) for an integration id. */
127888
- setSession(integrationId, session) {
127889
- if (session === null) {
127890
- this.#sessions.delete(integrationId);
127891
- return;
127892
- }
127893
- this.#sessions.set(integrationId, session);
127894
- }
127895
- /** The session of an integration, or null when it is not registered. */
127896
- getSession(integrationId) {
127897
- if (integrationId === void 0 || integrationId === null) return null;
127898
- return this.#sessions.get(integrationId) ?? null;
127899
- }
127900
- /** Subscribe a device to the state changes of one integration. Returns an unsubscribe fn. */
127901
- onSnapshot(integrationId, cb) {
127902
- let set = this.#snapshotSubs.get(integrationId);
127903
- if (!set) {
127904
- set = /* @__PURE__ */ new Set();
127905
- this.#snapshotSubs.set(integrationId, set);
127906
- }
127907
- set.add(cb);
127908
- return () => {
127909
- const current = this.#snapshotSubs.get(integrationId);
127910
- current?.delete(cb);
127911
- if (current && current.size === 0) this.#snapshotSubs.delete(integrationId);
127912
- };
127913
- }
127914
- /** Fan one state change out to every subscribed device of an integration. */
127915
- emitSnapshot(integrationId) {
127916
- const set = this.#snapshotSubs.get(integrationId);
127917
- if (!set) return;
127918
- for (const cb of [...set]) try {
127919
- cb();
127920
- } catch {}
127921
- }
127922
- /** Remove everything (called on full shutdown). */
127923
- clear() {
127924
- this.#facades.clear();
127925
- this.#sessions.clear();
127926
- this.#snapshotSubs.clear();
127927
- }
127928
- };
127929
- /** The single in-process resolver shared between the integration and its devices. */
127930
- var homematicFacades = new HmFacadeResolver();
127931
- //#endregion
127932
128920
  //#region src/homematic-diagnostics-mapping.ts
127933
128921
  var MAINTENANCE_CHANNEL_TYPE$1 = "MAINTENANCE";
127934
128922
  /** Reachability parameters that drive the Container's `online`, not a child. */
@@ -128059,226 +129047,6 @@ function readReachability(device) {
128059
129047
  return null;
128060
129048
  }
128061
129049
  //#endregion
128062
- //#region src/homematic-mapping.ts
128063
- /**
128064
- * Map a single Homematic channel to its CamStack triplet. The channel
128065
- * `TYPE` is the discriminator. Only the controllable / primary channel
128066
- * types map; status-only `*_TRANSMITTER` mirrors and the various key /
128067
- * remote / week-profile channels return `null` (their datapoints are
128068
- * still decoded into the owning cap's slice via the device's
128069
- * `valueChanged` handler, keyed by parameter name).
128070
- */
128071
- function mapHmChannel(channelType) {
128072
- if (!channelType) return null;
128073
- switch (channelType.toUpperCase()) {
128074
- case "SWITCH_VIRTUAL_RECEIVER": return {
128075
- deviceType: DeviceType.Switch,
128076
- role: null,
128077
- capabilities: ["switch"]
128078
- };
128079
- case "SHUTTER_VIRTUAL_RECEIVER": return {
128080
- deviceType: DeviceType.Cover,
128081
- role: null,
128082
- capabilities: ["cover"]
128083
- };
128084
- case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
128085
- deviceType: DeviceType.Climate,
128086
- role: null,
128087
- capabilities: [
128088
- "climate-control",
128089
- "temperature-sensor",
128090
- "humidity-sensor"
128091
- ]
128092
- };
128093
- case "MOTIONDETECTOR_TRANSCEIVER": return {
128094
- deviceType: DeviceType.Sensor,
128095
- role: DeviceRole.MotionSensor,
128096
- capabilities: ["motion", "ambient-light-sensor"]
128097
- };
128098
- case "DOOR_LOCK_STATE_TRANSMITTER": return {
128099
- deviceType: DeviceType.Lock,
128100
- role: null,
128101
- capabilities: ["lock-control"]
128102
- };
128103
- case "ENERGIE_METER_TRANSMITTER": return {
128104
- deviceType: DeviceType.Sensor,
128105
- role: DeviceRole.PowerSensor,
128106
- capabilities: ["power-meter"]
128107
- };
128108
- case "KEY_TRANSCEIVER":
128109
- case "KEY_TRANSMITTER":
128110
- case "VIRTUAL_KEY":
128111
- case "KEY": return {
128112
- deviceType: DeviceType.EventEmitter,
128113
- role: null,
128114
- capabilities: ["event-emitter"]
128115
- };
128116
- default: return null;
128117
- }
128118
- }
128119
- /**
128120
- * Best-effort parent DeviceType for a whole Homematic device, derived
128121
- * from the union of its channel mappings. Actuators win over sensors so
128122
- * a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
128123
- * Sensor, and a thermostat with a humidity sensor reports as a
128124
- * Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
128125
- * ranked above Sensor so its battery / maintenance sensor channels don't
128126
- * win the parent type. Returns `DeviceType.Generic` when no channel maps.
128127
- */
128128
- var PARENT_TYPE_PRIORITY = [
128129
- DeviceType.Climate,
128130
- DeviceType.Lock,
128131
- DeviceType.Cover,
128132
- DeviceType.Light,
128133
- DeviceType.Switch,
128134
- DeviceType.EventEmitter,
128135
- DeviceType.Sensor
128136
- ];
128137
- function inferHmDeviceType(device) {
128138
- const present = /* @__PURE__ */ new Set();
128139
- for (const channel of device.channels) {
128140
- const mapping = mapHmChannel(channel.type);
128141
- if (mapping) present.add(mapping.deviceType);
128142
- }
128143
- for (const dt of PARENT_TYPE_PRIORITY) if (present.has(dt)) return dt;
128144
- return DeviceType.Generic;
128145
- }
128146
- function mapHmDeviceChannels(device) {
128147
- const out = [];
128148
- for (const channel of device.channels) {
128149
- const mapping = mapHmChannel(channel.type);
128150
- if (mapping) out.push({
128151
- channel,
128152
- mapping
128153
- });
128154
- }
128155
- return out;
128156
- }
128157
- //#endregion
128158
- //#region src/devices/hm-cold-start.ts
128159
- /**
128160
- * Shared cold-start defaults + the key-channel press vocabulary helpers,
128161
- * extracted from the (legacy) flat `homematic-device.ts` so the Container +
128162
- * accessory-child classes reuse the SAME seeds and decoders without
128163
- * duplicating them. Pure: no `BaseDevice` / facade dependency.
128164
- */
128165
- /**
128166
- * Cold-start defaults so reads never miss a slice before the first push.
128167
- * `lastChangedAt: 0` marks each as a PLACEHOLDER — the value is a guess, and
128168
- * consumers read it as unknown. A replayed CCU value is stamped
128169
- * `HM_SEEDED_CHANGED_AT` instead (`hm-change-stamp.ts`).
128170
- */
128171
- var COLD_SWITCH = {
128172
- on: false,
128173
- lastChangedAt: 0
128174
- };
128175
- var COLD_COVER = {
128176
- state: "closed",
128177
- position: null,
128178
- tiltPosition: null,
128179
- lastChangedAt: 0
128180
- };
128181
- var COLD_LOCK = {
128182
- state: "unlocked",
128183
- lastChangedAt: 0
128184
- };
128185
- var COLD_MOTION = {
128186
- detected: false,
128187
- lastDetectedAt: null,
128188
- autoClearAfterMs: null
128189
- };
128190
- /**
128191
- * The motion seed a constructor writes OVER the slice hydrated from the
128192
- * persisted runtime state. The level is a placeholder (`false`) until the
128193
- * CCU says otherwise, but a stored rise is a fact: `lastDetectedAt: null`
128194
- * means "never detected" (`motion.cap.ts`), and a restart must not turn
128195
- * "fired an hour ago" into that.
128196
- */
128197
- function coldMotionKeepingRise(stored) {
128198
- const rise = stored?.lastDetectedAt;
128199
- return {
128200
- ...COLD_MOTION,
128201
- lastDetectedAt: typeof rise === "number" && Number.isFinite(rise) && rise > 0 ? rise : null
128202
- };
128203
- }
128204
- var COLD_CLIMATE = {
128205
- mode: "auto",
128206
- availableModes: [...[
128207
- "off",
128208
- "heat",
128209
- "auto"
128210
- ]],
128211
- fanMode: "",
128212
- availableFanModes: [],
128213
- preset: "",
128214
- availablePresets: ["boost"],
128215
- target: null,
128216
- targetHigh: null,
128217
- targetLow: null,
128218
- targetHumidity: null,
128219
- currentTemp: null,
128220
- currentHumidity: null,
128221
- swingVertical: null,
128222
- swingHorizontal: null,
128223
- lastFetchedAt: 0
128224
- };
128225
- /**
128226
- * The standard HmIP key-channel datapoint vocabulary, used VERBATIM (NO
128227
- * normalization) as the `event-emitter` event types — the native uppercase
128228
- * tokens a `KEY_TRANSCEIVER` / `KEY_TRANSMITTER` / `VIRTUAL_KEY` / `KEY`
128229
- * channel emits on the facade `valueChanged` stream.
128230
- */
128231
- var HM_KEY_PRESS_DATAPOINTS = [
128232
- "PRESS_SHORT",
128233
- "PRESS_LONG",
128234
- "PRESS_LONG_START",
128235
- "PRESS_LONG_RELEASE",
128236
- "PRESS_CONT"
128237
- ];
128238
- /** Set form for O(1) fire-detection membership tests. */
128239
- var HM_KEY_PRESS_SET = new Set(HM_KEY_PRESS_DATAPOINTS);
128240
- /** Cold-start event-emitter slice; vocabulary supplied per-device. */
128241
- function coldEventEmitter(vocabulary) {
128242
- return {
128243
- eventTypes: eventTypesOfVocabulary(vocabulary),
128244
- vocabulary: [...vocabulary],
128245
- lastEvent: null,
128246
- eventCountSinceStart: 0
128247
- };
128248
- }
128249
- /**
128250
- * Collect the union of native `PRESS_*` datapoints a device's key channels
128251
- * support, VERBATIM. Falls back to the standard HmIP key vocabulary when no
128252
- * datapoints were enumerated, so the cap always advertises a non-empty set.
128253
- */
128254
- function keyEventVocabulary(keyChannels) {
128255
- const found = /* @__PURE__ */ new Set();
128256
- for (const channel of keyChannels) for (const dp of channel.dataPoints ?? []) if (HM_KEY_PRESS_SET.has(dp.parameter)) found.add(dp.parameter);
128257
- if (found.size === 0) return HM_KEY_PRESS_DATAPOINTS;
128258
- return HM_KEY_PRESS_DATAPOINTS.filter((dp) => found.has(dp));
128259
- }
128260
- /**
128261
- * The CamStack cap names that are ACTUATORS — driven by the library's typed
128262
- * custom entities (correct channel), NOT by the raw mapped channels. The
128263
- * raw-channel sensor/event loop skips these so they are not double-registered.
128264
- */
128265
- var ACTUATOR_CAP_NAMES = new Set([
128266
- "switch",
128267
- "cover",
128268
- "light",
128269
- "lock-control",
128270
- "climate-control"
128271
- ]);
128272
- /** Parse the numeric channel index suffix (`:N`) from a channel address.
128273
- * Null when absent. Kept as a string for the event payload, mirroring the
128274
- * CCU's `device:index` addressing. */
128275
- function channelIndexFromAddress(channelAddress) {
128276
- const idx = channelAddress.lastIndexOf(":");
128277
- if (idx === -1) return null;
128278
- const suffix = channelAddress.slice(idx + 1);
128279
- return suffix.length > 0 ? suffix : null;
128280
- }
128281
- //#endregion
128282
129050
  //#region src/devices/hm-entity-spec.ts
128283
129051
  var MAINTENANCE_CHANNEL_TYPE = "MAINTENANCE";
128284
129052
  /**
@@ -128457,6 +129225,113 @@ function deriveHmEntitySpecs(device, customEntities) {
128457
129225
  ];
128458
129226
  }
128459
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
128460
129335
  //#region src/devices/hm-child-device.ts
128461
129336
  /**
128462
129337
  * Persisted config every Homematic accessory CHILD carries. `address` is the
@@ -128730,28 +129605,37 @@ var HmChildDevice = class extends BaseDevice {
128730
129605
  this.seedTriggerUnsubs = [];
128731
129606
  }
128732
129607
  };
128733
- //#endregion
128734
- //#region src/homematic-decode.ts
128735
- /** HmIP `CONTROL_MODE` ENUM index → library climate mode. Numeric-arm
128736
- * fallback only (see {@link fromHmControlMode}) — the wire index, used
128737
- * when the value list did not resolve. */
128738
- var HM_CONTROL_MODE_BY_INDEX = {
129608
+ function isHmOffSetpoint(target) {
129609
+ return target !== null && target <= 4.5;
129610
+ }
129611
+ /**
129612
+ * HmIP `SET_POINT_MODE` index → library climate mode.
129613
+ *
129614
+ * Observed 2026-11-13 via `getParamsetDescription` on `INT0000001:1`: the
129615
+ * datapoint is `TYPE INTEGER`, `MIN 0`, `MAX 3`, with no value list. The
129616
+ * live CCU therefore delivers the index, not a name.
129617
+ * 0 auto, 1 manual heat, 2 party (a timed override — still auto).
129618
+ * 3 is absent: unknown, so {@link fromHmSetPointMode} returns null and the
129619
+ * caller keeps the previous mode.
129620
+ * `CONTROL_MODE` is write-only on HmIP heating groups and always reads `0`;
129621
+ * mode is read from here.
129622
+ */
129623
+ var HM_SET_POINT_MODE_BY_INDEX = {
128739
129624
  0: "auto",
128740
129625
  1: "heat",
128741
- 2: "heat",
128742
- 3: "heat"
129626
+ 2: "auto"
128743
129627
  };
128744
129628
  /**
128745
- * HmIP `CONTROL_MODE` ENUM member (the CONVERTED value the library hands
128746
- * over — `nodehomematic` resolves the value list, same as `LOCK_STATE` /
128747
- * `ACTIVITY_STATE`, see {@link readLockState} / {@link readTravel}) →
128748
- * library climate mode. Matched BY NAME, case-insensitively.
129629
+ * Name form, accepted only when a string arrives (a value list that did
129630
+ * resolve). Matched case-insensitively. `PARTY` is the timed override and
129631
+ * stays auto, matching index 2.
128749
129632
  */
128750
- var HM_CONTROL_MODE_BY_NAME = {
129633
+ var HM_SET_POINT_MODE_BY_NAME = {
129634
+ AUTO: "auto",
128751
129635
  "AUTO-MODE": "auto",
129636
+ MANU: "heat",
128752
129637
  "MANU-MODE": "heat",
128753
- "PARTY-MODE": "heat",
128754
- "BOOST-MODE": "heat"
129638
+ PARTY: "auto"
128755
129639
  };
128756
129640
  /** Map a CamStack `HvacMode` to the library's narrower climate mode. */
128757
129641
  function toHmClimateMode(mode) {
@@ -128763,22 +129647,20 @@ function toHmClimateMode(mode) {
128763
129647
  }
128764
129648
  }
128765
129649
  /**
128766
- * Map a library climate mode back to the CamStack `HvacMode`.
129650
+ * Map a Homematic `SET_POINT_MODE` value to the CamStack `HvacMode`.
128767
129651
  *
128768
- * Like {@link readLockState} / {@link readTravel}, the library delivers a
128769
- * CONVERTED ENUM string on the live CCU (`'AUTO-MODE'` etc) — testing
128770
- * `typeof value === 'number'` alone meant a resolved `CONTROL_MODE` never
128771
- * decoded at all. The numeric arm survives for a datapoint whose value
128772
- * list did not resolve.
129652
+ * The live CCU sends the integer index (see {@link HM_SET_POINT_MODE_BY_INDEX}).
129653
+ * A string is accepted only when one arrives (`AUTO` / `AUTO-MODE`,
129654
+ * `MANU` / `MANU-MODE`). Index 3 and any other unknown value return null.
128773
129655
  */
128774
- function fromHmControlMode(value) {
129656
+ function fromHmSetPointMode(value) {
128775
129657
  if (typeof value === "string") {
128776
- const mode = HM_CONTROL_MODE_BY_NAME[value.toUpperCase()];
129658
+ const mode = HM_SET_POINT_MODE_BY_NAME[value.toUpperCase()];
128777
129659
  if (mode === void 0) return null;
128778
129660
  return mode === "auto" ? "auto" : "heat";
128779
129661
  }
128780
129662
  if (typeof value !== "number") return null;
128781
- const mode = HM_CONTROL_MODE_BY_INDEX[value];
129663
+ const mode = HM_SET_POINT_MODE_BY_INDEX[value];
128782
129664
  if (mode === void 0) return null;
128783
129665
  return mode === "auto" ? "auto" : "heat";
128784
129666
  }
@@ -128924,12 +129806,19 @@ function decodeLock(parameter, value, now) {
128924
129806
  /**
128925
129807
  * Decode a climate datapoint into a ClimateControlStatus patch.
128926
129808
  * Parameters: SET_POINT_TEMPERATURE (target °C), ACTUAL_TEMPERATURE
128927
- * (current °C), HUMIDITY (%), CONTROL_MODE (ENUM), BOOST_MODE (bool).
129809
+ * (current °C), HUMIDITY (%), SET_POINT_MODE (ENUM, readable mode),
129810
+ * BOOST_MODE (bool). `CONTROL_MODE` is write-only on HmIP and ignored here.
128928
129811
  */
129812
+ function modeWithHmOffTarget(previous, target) {
129813
+ if (isHmOffSetpoint(target)) return previous.mode === "auto" ? "auto" : "off";
129814
+ if (previous.mode === "off") return previous.lastActiveMode ?? "heat";
129815
+ return previous.mode;
129816
+ }
128929
129817
  function decodeClimate(previous, parameter, value, now) {
128930
129818
  if (parameter === "SET_POINT_TEMPERATURE" && typeof value === "number") return {
128931
129819
  ...previous,
128932
129820
  target: value,
129821
+ mode: modeWithHmOffTarget(previous, value),
128933
129822
  lastFetchedAt: now
128934
129823
  };
128935
129824
  if (parameter === "ACTUAL_TEMPERATURE" && typeof value === "number") return {
@@ -128942,12 +129831,13 @@ function decodeClimate(previous, parameter, value, now) {
128942
129831
  currentHumidity: value,
128943
129832
  lastFetchedAt: now
128944
129833
  };
128945
- if (parameter === "CONTROL_MODE") {
128946
- const mode = fromHmControlMode(value);
129834
+ if (parameter === "SET_POINT_MODE") {
129835
+ const mode = fromHmSetPointMode(value);
128947
129836
  if (mode === null) return null;
129837
+ const resolved = mode === "heat" && isHmOffSetpoint(previous.target) ? "off" : mode;
128948
129838
  return {
128949
129839
  ...previous,
128950
- mode,
129840
+ mode: resolved,
128951
129841
  lastFetchedAt: now
128952
129842
  };
128953
129843
  }
@@ -129008,6 +129898,8 @@ var HmActuatorDevice = class extends HmChildDevice {
129008
129898
  kind;
129009
129899
  /** The actuator cap name actually registered (drives decode routing). */
129010
129900
  registeredCap = null;
129901
+ /** Last setpoint above {@link HM_OFF_SETPOINT_C}; HmIP OFF leaves target at 4.5. */
129902
+ climateRestoreTargetC = null;
129011
129903
  constructor(ctx) {
129012
129904
  super(ctx, hmActuatorSchema);
129013
129905
  this.kind = this.config.values.kind;
@@ -129088,9 +129980,18 @@ var HmActuatorDevice = class extends HmChildDevice {
129088
129980
  const provider = {
129089
129981
  getStatus: async () => this.runtimeState.getCapState("climate-control") ?? COLD_CLIMATE,
129090
129982
  setMode: async ({ mode }) => {
129091
- await this.requireFacade().climateSetMode(this.address, channel, toHmClimateMode(mode));
129983
+ const facade = this.requireFacade();
129984
+ const prev = this.runtimeState.getCapState("climate-control") ?? COLD_CLIMATE;
129985
+ const hmMode = toHmClimateMode(mode);
129986
+ if (hmMode === "off" && prev.target !== null && prev.target > 4.5) this.climateRestoreTargetC = prev.target;
129987
+ await facade.climateSetMode(this.address, channel, hmMode);
129988
+ if (mode === "heat" && (prev.mode === "off" || isHmOffSetpoint(prev.target))) {
129989
+ const restore = this.climateRestoreTargetC ?? 21;
129990
+ await facade.climateSetTemperature(this.address, channel, restore);
129991
+ }
129092
129992
  },
129093
129993
  setTarget: async ({ target }) => {
129994
+ if (target > 4.5) this.climateRestoreTargetC = target;
129094
129995
  await this.requireFacade().climateSetTemperature(this.address, channel, target);
129095
129996
  },
129096
129997
  setPreset: async ({ preset }) => {
@@ -129124,7 +130025,17 @@ var HmActuatorDevice = class extends HmChildDevice {
129124
130025
  if (cap === "lock-control") return this.applyLock(parameter, value, now, origin);
129125
130026
  if (cap === "climate-control") {
129126
130027
  const next = decodeClimate(this.runtimeState.getCapState("climate-control") ?? COLD_CLIMATE, parameter, value, now);
129127
- if (next) this.runtimeState.setCapState("climate-control", next);
130028
+ if (next === null && parameter === "SET_POINT_MODE") this.ctx.logger.debug("Homematic climate: SET_POINT_MODE unknown — mode unchanged", {
130029
+ tags: { deviceId: this.id },
130030
+ meta: {
130031
+ value,
130032
+ valueType: typeof value
130033
+ }
130034
+ });
130035
+ if (next) {
130036
+ if (next.target !== null && next.target > 4.5) this.climateRestoreTargetC = next.target;
130037
+ this.runtimeState.setCapState("climate-control", next);
130038
+ }
129128
130039
  }
129129
130040
  }
129130
130041
  applyCover(parameter, value, now, origin) {
@@ -129321,65 +130232,9 @@ var HmSensorDevice = class extends HmChildDevice {
129321
130232
  }
129322
130233
  };
129323
130234
  //#endregion
129324
- //#region src/devices/hm-key-vocabulary.ts
129325
- var PRESS_MEANING = {
129326
- PRESS_SHORT: {
129327
- label: "Short press",
129328
- kind: "press"
129329
- },
129330
- PRESS_LONG: {
129331
- label: "Long press",
129332
- kind: "long-press"
129333
- },
129334
- PRESS_LONG_START: {
129335
- label: "Long press started",
129336
- kind: "long-press-start"
129337
- },
129338
- PRESS_LONG_RELEASE: {
129339
- label: "Long press released",
129340
- kind: "release"
129341
- },
129342
- PRESS_CONT: {
129343
- label: "Long press held",
129344
- kind: "repeat"
129345
- }
129346
- };
129347
- /** The channels of a device that are buttons, in channel order. */
129348
- function hmKeyChannels(device) {
129349
- return mapHmDeviceChannels(device).filter(({ mapping }) => mapping.capabilities.includes("event-emitter")).map(({ channel }) => channel);
129350
- }
129351
- /** The presses one key channel has; the standard set when it lists none. */
129352
- function pressesOf(channel) {
129353
- const listed = new Set((channel.dataPoints ?? []).map((dataPoint) => dataPoint.parameter).filter((parameter) => HM_KEY_PRESS_SET.has(parameter)));
129354
- if (listed.size === 0) return HM_KEY_PRESS_DATAPOINTS;
129355
- return HM_KEY_PRESS_DATAPOINTS.filter((parameter) => listed.has(parameter));
129356
- }
129357
- function entryOf(parameter, source) {
129358
- const meaning = PRESS_MEANING[parameter];
129359
- if (meaning === void 0) return {
129360
- id: parameter,
129361
- source,
129362
- label: parameter
129363
- };
129364
- return {
129365
- id: parameter,
129366
- source,
129367
- label: meaning.label,
129368
- kind: meaning.kind
129369
- };
129370
- }
129371
- function hmKeyVocabulary(device) {
129372
- return hmKeyChannels(device).flatMap((channel, position) => {
129373
- const index = channelIndexFromAddress(channel.address) ?? String(channel.index);
129374
- const source = {
129375
- id: index,
129376
- label: `Button ${position + 1} (channel ${index})`
129377
- };
129378
- return pressesOf(channel).map((parameter) => entryOf(parameter, source));
129379
- });
129380
- }
129381
- //#endregion
129382
130235
  //#region src/devices/hm-event-emitter-device.ts
130236
+ /** Shown on the Buttons child when none of its key channels has a central link. */
130237
+ var BUTTON_EVENTS_HINT = "The CCU does not send these presses — enable button events on the CCU page";
129383
130238
  /**
129384
130239
  * Event-emitter child config: the persisted native press vocabulary for the
129385
130240
  * device's key channels. Stored at adoption so the cap advertises the right
@@ -129401,6 +130256,10 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129401
130256
  #declared = null;
129402
130257
  /** Fires already reported as outside the vocabulary, as `source:token`. */
129403
130258
  #undeclaredLogged = /* @__PURE__ */ new Set();
130259
+ /** Key channels that have delivered a press since this process started. */
130260
+ #pressSeen = /* @__PURE__ */ new Set();
130261
+ /** True once we know every key channel lacks a central link. */
130262
+ #centralLinkMissing = false;
129404
130263
  #eventSeq = 0;
129405
130264
  #eventCount = 0;
129406
130265
  /** Unsubscribe for the integration's state-change fan-out. */
@@ -129411,7 +130270,29 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129411
130270
  this.persistedEventTypes = persisted && persisted.length > 0 ? persisted : HM_KEY_PRESS_DATAPOINTS;
129412
130271
  this.registerEventEmitterCap();
129413
130272
  this.attachValueChangedListener((event) => this.decodeKeyPress(event));
129414
- if (this.integrationId !== void 0) this.#snapshotUnsub = homematicFacades.onSnapshot(this.integrationId, () => this.refreshDeclaredVocabulary());
130273
+ if (this.integrationId !== void 0) this.#snapshotUnsub = homematicFacades.onSnapshot(this.integrationId, () => {
130274
+ this.refreshDeclaredVocabulary();
130275
+ this.refreshCentralLinks();
130276
+ });
130277
+ this.refreshCentralLinks();
130278
+ }
130279
+ getSettingsUISchema() {
130280
+ if (!this.#centralLinkMissing) return { sections: [] };
130281
+ return { sections: [{
130282
+ id: "button-events",
130283
+ title: "Button events",
130284
+ titleKey: "provider-homematic:device.buttonEvents.title",
130285
+ columns: 1,
130286
+ fields: [{
130287
+ type: "info",
130288
+ key: "buttonEventsHint",
130289
+ label: "Button events",
130290
+ labelKey: "provider-homematic:device.buttonEvents.hint.label",
130291
+ content: BUTTON_EVENTS_HINT,
130292
+ contentKey: "provider-homematic:device.buttonEvents.hint.content",
130293
+ variant: "warning"
130294
+ }]
130295
+ }] };
129415
130296
  }
129416
130297
  /**
129417
130298
  * Rewrite the slice with the buttons once the CCU's channel list carries
@@ -129419,12 +130300,62 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129419
130300
  */
129420
130301
  refreshDeclaredVocabulary() {
129421
130302
  if (this.#declared !== null) return;
129422
- const vocabulary = this.vocabulary();
130303
+ this.vocabulary();
129423
130304
  if (this.#declared === null) return;
130305
+ const published = this.publishedVocabulary();
129424
130306
  const current = this.runtimeState.getCapState("event-emitter");
129425
130307
  this.runtimeState.setCapState("event-emitter", {
129426
- eventTypes: eventTypesOfVocabulary(vocabulary),
129427
- vocabulary: [...vocabulary],
130308
+ eventTypes: eventTypesOfVocabulary(published),
130309
+ vocabulary: [...published],
130310
+ lastEvent: current?.lastEvent ?? null,
130311
+ eventCountSinceStart: current?.eventCountSinceStart ?? 0
130312
+ });
130313
+ }
130314
+ /** The live vocabulary, plus the central-link hint when the CCU sends nothing. */
130315
+ publishedVocabulary() {
130316
+ const vocabulary = this.vocabulary();
130317
+ if (!this.#centralLinkMissing) return vocabulary;
130318
+ return vocabulary.map((entry) => ({
130319
+ ...entry,
130320
+ description: BUTTON_EVENTS_HINT
130321
+ }));
130322
+ }
130323
+ /**
130324
+ * Ask the facade whether each key channel has a central link. A library
130325
+ * that cannot answer (`unsupported`) leaves the hint off: absence of the
130326
+ * method is not evidence the CCU is silent.
130327
+ */
130328
+ async refreshCentralLinks() {
130329
+ const facade = this.integrationId === void 0 ? null : homematicFacades.get(this.integrationId);
130330
+ const device = this.resolveHmDevice();
130331
+ if (facade === null || device === null) return;
130332
+ const keys = hmKeyChannels(device);
130333
+ if (keys.length === 0) return;
130334
+ const port = channelLinkPort(facade);
130335
+ let missing = false;
130336
+ for (const channel of keys) {
130337
+ const read = await port.getChannelLinkState(channel.address);
130338
+ if (read.kind === "unsupported") return;
130339
+ if (read.kind === "error") {
130340
+ this.ctx.logger.warn("Homematic key channel link state could not be read", {
130341
+ tags: { deviceId: this.ctx.id },
130342
+ meta: {
130343
+ address: this.address,
130344
+ channel: channel.address,
130345
+ error: read.message
130346
+ }
130347
+ });
130348
+ return;
130349
+ }
130350
+ if (!read.state.central) missing = true;
130351
+ }
130352
+ if (missing === this.#centralLinkMissing) return;
130353
+ this.#centralLinkMissing = missing;
130354
+ const current = this.runtimeState.getCapState("event-emitter");
130355
+ const published = this.publishedVocabulary();
130356
+ this.runtimeState.setCapState("event-emitter", {
130357
+ eventTypes: eventTypesOfVocabulary(published),
130358
+ vocabulary: [...published],
129428
130359
  lastEvent: current?.lastEvent ?? null,
129429
130360
  eventCountSinceStart: current?.eventCountSinceStart ?? 0
129430
130361
  });
@@ -129436,7 +130367,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129436
130367
  }
129437
130368
  registerEventEmitterCap() {
129438
130369
  this.ctx.registerNativeCap(eventEmitterCapability, { getStatus: async () => this.runtimeState.getCapState("event-emitter") ?? coldEventEmitter(this.vocabulary()) });
129439
- this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.vocabulary()));
130370
+ this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.publishedVocabulary()));
129440
130371
  }
129441
130372
  /**
129442
130373
  * The buttons and their presses, read LIVE from the CCU's channel list.
@@ -129470,6 +130401,11 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129470
130401
  }
129471
130402
  });
129472
130403
  }
130404
+ keyChannelAddresses() {
130405
+ const device = this.resolveHmDevice();
130406
+ if (device === null) return /* @__PURE__ */ new Set();
130407
+ return new Set(hmKeyChannels(device).map((channel) => channel.address));
130408
+ }
129473
130409
  /**
129474
130410
  * Translate a key-channel `PRESS_*` datapoint into an `EventFire`: emit
129475
130411
  * `EventCategory.EventEmitted` on the bus and write the `event-emitter`
@@ -129481,8 +130417,36 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129481
130417
  decodeKeyPress(event) {
129482
130418
  const now = event.ts || Date.now();
129483
130419
  const { parameter, value, channel } = event;
129484
- if (!HM_KEY_PRESS_SET.has(parameter)) return;
129485
- if (typeof value === "boolean" && value === false) return;
130420
+ const isPress = HM_KEY_PRESS_SET.has(parameter);
130421
+ if (!(isPress || this.keyChannelAddresses().has(channel))) return;
130422
+ if (!(isPress && !(typeof value === "boolean" && value === false))) {
130423
+ this.ctx.logger.debug("Homematic key channel value changed but decoded to no press", {
130424
+ tags: { deviceId: this.ctx.id },
130425
+ meta: {
130426
+ channel,
130427
+ parameter,
130428
+ ...isPress ? { press: parameter } : {}
130429
+ }
130430
+ });
130431
+ return;
130432
+ }
130433
+ this.ctx.logger.debug("Homematic key press received", {
130434
+ tags: { deviceId: this.ctx.id },
130435
+ meta: {
130436
+ channel,
130437
+ press: parameter
130438
+ }
130439
+ });
130440
+ if (!this.#pressSeen.has(channel)) {
130441
+ this.#pressSeen.add(channel);
130442
+ this.ctx.logger.info("Homematic key channel delivered its first press since start", {
130443
+ tags: { deviceId: this.ctx.id },
130444
+ meta: {
130445
+ channel,
130446
+ press: parameter
130447
+ }
130448
+ });
130449
+ }
129486
130450
  const channelIndex = channelIndexFromAddress(channel);
129487
130451
  const fire = {
129488
130452
  deviceId: this.id,
@@ -129498,7 +130462,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129498
130462
  deviceId: this.id,
129499
130463
  addonId: this.ctx.deviceMeta.addonId
129500
130464
  }, fire));
129501
- const vocabulary = this.vocabulary();
130465
+ const vocabulary = this.publishedVocabulary();
129502
130466
  this.noteUndeclared(vocabulary, parameter, channelIndex);
129503
130467
  const slice = {
129504
130468
  eventTypes: eventTypesOfVocabulary(vocabulary),
@@ -129802,6 +130766,43 @@ var HmChildDispatcher = class {
129802
130766
  /** The documented boundary-cast export used in the `deviceClasses` restore map. */
129803
130767
  var hmChildDeviceClass = HmChildDispatcher;
129804
130768
  //#endregion
130769
+ //#region src/devices/hm-child-name.ts
130770
+ /**
130771
+ * Display name of one actuator child.
130772
+ *
130773
+ * A single actuator keeps the container's name (the caller passes it). A
130774
+ * multi-actuator child uses the CCU channel name when the facade has one,
130775
+ * otherwise `"<container> ch<index>"`. Never the channel address.
130776
+ */
130777
+ function multiActuatorChildName(input) {
130778
+ if (input.channelName !== null) return input.channelName;
130779
+ const index = input.channelIndex ?? "?";
130780
+ return `${input.containerName} ch${index}`;
130781
+ }
130782
+ /** The name this addon used to give a multi-actuator child: container + raw address. */
130783
+ function legacyActuatorName(containerName, channelAddress) {
130784
+ return `${containerName} ${channelAddress}`;
130785
+ }
130786
+ /**
130787
+ * Whether an already-adopted actuator may take the new auto name.
130788
+ *
130789
+ * An operator rename (`userNamed`, or a legacy row whose name is not one of
130790
+ * the auto forms) is left alone. A name that is still the generated address
130791
+ * form, the `ch<index>` form, or the stable-id placeholder is replaced.
130792
+ * `stampUserNamed` is true only when the row is already flagged user-named:
130793
+ * the device-manager refuses a system rename of those rows, and accessory
130794
+ * registration stamps the flag on every non-placeholder name.
130795
+ */
130796
+ function actuatorNameWrite(input) {
130797
+ if (input.currentName === input.desiredName) return { kind: "keep" };
130798
+ if (!(input.currentName === input.legacyAutoName || input.currentName === input.fallbackAutoName || input.currentName === input.stableId) && (input.userNamed === true || input.userNamed === void 0)) return { kind: "keep" };
130799
+ return {
130800
+ kind: "rename",
130801
+ name: input.desiredName,
130802
+ stampUserNamed: input.userNamed === true
130803
+ };
130804
+ }
130805
+ //#endregion
129805
130806
  //#region src/devices/hm-container-device.ts
129806
130807
  /**
129807
130808
  * Persisted config for a Homematic Container (the parent of one physical CCU
@@ -129834,6 +130835,8 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
129834
130835
  integrationId;
129835
130836
  /** Unsubscribe for the facade `valueChanged` reachability listener. */
129836
130837
  valueChangedUnsub = null;
130838
+ /** Unsubscribe for the session fan-out that re-stamps names once the CCU answers. */
130839
+ reconcileUnsub = null;
129837
130840
  constructor(ctx) {
129838
130841
  const cfg = hmContainerSchema.parse(ctx.persistedConfig ?? {});
129839
130842
  super(ctx, hmContainerSchema, { type: DeviceType.Container });
@@ -129880,7 +130883,16 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
129880
130883
  if (this.online !== next) this.markOnline(next);
129881
130884
  });
129882
130885
  }
130886
+ async onActivate() {
130887
+ await super.onActivate();
130888
+ await this.reconcileDerived();
130889
+ this.reconcileUnsub = homematicFacades.onSnapshot(this.integrationId, () => {
130890
+ this.reconcileDerived();
130891
+ });
130892
+ }
129883
130893
  async removeDevice() {
130894
+ this.reconcileUnsub?.();
130895
+ this.reconcileUnsub = null;
129884
130896
  if (this.valueChangedUnsub) {
129885
130897
  try {
129886
130898
  this.valueChangedUnsub();
@@ -129917,11 +130929,96 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
129917
130929
  const specs = deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((e) => e.device === this.address) ?? []);
129918
130930
  const multipleActuators = specs.filter((s) => s.key.startsWith("act-")).map((s) => s.key).length > 1;
129919
130931
  return specs.map((spec) => {
129920
- if (!spec.key.startsWith("act-")) return this.childSpec(spec);
129921
- const suffix = multipleActuators ? ` ${spec.key.slice(4)}` : "";
129922
- return this.childSpec(spec, `${this.name}${suffix}`);
130932
+ if (!spec.key.startsWith("act-") || !multipleActuators) return this.childSpec(spec, spec.key.startsWith("act-") ? this.name : void 0);
130933
+ return this.childSpec(spec, this.actuatorName(hmDevice, spec));
130934
+ });
130935
+ }
130936
+ /** CCU channel name, else `"<container> ch<index>"`. Never the raw address. */
130937
+ actuatorName(hmDevice, spec) {
130938
+ const channelAddress = spec.key.slice(4);
130939
+ const channel = hmDevice.channels.find((candidate) => candidate.address === channelAddress);
130940
+ const index = channel !== void 0 ? String(channel.index) : channelIndexFromAddress(channelAddress);
130941
+ return multiActuatorChildName({
130942
+ containerName: this.name,
130943
+ channelName: channel === void 0 ? null : readHmName(channel),
130944
+ channelIndex: index
129923
130945
  });
129924
130946
  }
130947
+ async reconcileDerived() {
130948
+ const hmDevice = this.resolveHmDevice();
130949
+ if (hmDevice === null) return;
130950
+ try {
130951
+ await this.stampPrimaryPreference(hmDevice);
130952
+ await this.refreshActuatorNames(hmDevice);
130953
+ } catch (err) {
130954
+ this.ctx.logger.warn("HmContainerDevice: could not refresh derived child meta", {
130955
+ tags: { deviceId: this.id },
130956
+ meta: {
130957
+ address: this.address,
130958
+ error: errMsg(err)
130959
+ }
130960
+ });
130961
+ }
130962
+ }
130963
+ async stampPrimaryPreference(hmDevice) {
130964
+ const manager = this.ctx.api?.deviceManager;
130965
+ if (manager === void 0) return;
130966
+ const declared = hmPrimaryChildKeys(deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((entity) => entity.device === this.address) ?? []));
130967
+ const keys = preferenceToStamp(this.ctx.deviceMeta.primaryChildPreference, declared);
130968
+ if (keys === null) return;
130969
+ await manager.setPrimaryChildPreference.mutate({
130970
+ deviceId: this.id,
130971
+ primaryChildPreference: keys
130972
+ });
130973
+ this.ctx.logger.info("Homematic container stamped its primary child", {
130974
+ tags: { deviceId: this.id },
130975
+ meta: {
130976
+ address: this.address,
130977
+ primaryChildPreference: keys
130978
+ }
130979
+ });
130980
+ }
130981
+ async refreshActuatorNames(hmDevice) {
130982
+ const manager = this.ctx.api?.deviceManager;
130983
+ if (manager === void 0) return;
130984
+ const specs = deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((entity) => entity.device === this.address) ?? []).filter((spec) => spec.key.startsWith("act-"));
130985
+ if (specs.length < 2) return;
130986
+ const children = await manager.getChildren.query({ parentDeviceId: this.id });
130987
+ for (const spec of specs) {
130988
+ const child = children.find((candidate) => candidate.stableId.endsWith(`-${spec.key}`));
130989
+ if (child === void 0) continue;
130990
+ const meta = await manager.loadMeta.query({ deviceId: child.id });
130991
+ if (meta === null) continue;
130992
+ const channelAddress = spec.key.slice(4);
130993
+ const desired = this.actuatorName(hmDevice, spec);
130994
+ const decision = actuatorNameWrite({
130995
+ currentName: meta.name,
130996
+ userNamed: meta.userNamed,
130997
+ desiredName: desired,
130998
+ legacyAutoName: legacyActuatorName(this.name, channelAddress),
130999
+ fallbackAutoName: multiActuatorChildName({
131000
+ containerName: this.name,
131001
+ channelName: null,
131002
+ channelIndex: channelIndexFromAddress(channelAddress)
131003
+ }),
131004
+ stableId: child.stableId
131005
+ });
131006
+ if (decision.kind === "keep") continue;
131007
+ await manager.setName.mutate({
131008
+ deviceId: child.id,
131009
+ name: decision.name,
131010
+ ...decision.stampUserNamed ? {} : { stampUserNamed: false }
131011
+ });
131012
+ this.ctx.logger.info("Homematic actuator child took its channel name", {
131013
+ tags: { deviceId: child.id },
131014
+ meta: {
131015
+ address: this.address,
131016
+ channel: channelAddress,
131017
+ name: decision.name
131018
+ }
131019
+ });
131020
+ }
131021
+ }
129925
131022
  /** Wrap one {@link HmEntitySpec} into an accessory-child spec, stamping the
129926
131023
  * CCU `address` + integration FK onto config and the container link
129927
131024
  * + integration + type/role onto meta. */
@@ -131584,6 +132681,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131584
132681
  ...buildCcuHeatingHandlers(this.ccuActionDeps()),
131585
132682
  ...buildCcuPairingHandlers(this.ccuActionDeps()),
131586
132683
  ...buildCcuConfigHandlers(this.ccuActionDeps()),
132684
+ ...buildButtonEventHandlers(this.ccuActionDeps()),
131587
132685
  discoverCcu: async () => {
131588
132686
  const { candidates } = await this.ctx.api.deviceManager.discoverProvider.mutate({ addonId: this.ctx.id });
131589
132687
  const hosts = candidates.map((candidate) => ({
@@ -131606,12 +132704,38 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131606
132704
  listPages: () => HOMEMATIC_PAGES
131607
132705
  };
131608
132706
  }
132707
+ /** The child a new container stands for, from the live CCU descriptor. */
132708
+ primaryChildPreference(integrationId, address) {
132709
+ const facade = homematicFacades.get(integrationId);
132710
+ if (facade === null) return [];
132711
+ const device = facade.devices().find((candidate) => candidate.address === address);
132712
+ if (device === void 0) return [];
132713
+ return hmPrimaryChildKeys(deriveHmEntitySpecs(device, facade.customEntities().filter((entity) => entity.device === address)));
132714
+ }
132715
+ /** A connected session's facade, or null while the integration is down. */
132716
+ connectedFacade(integrationId) {
132717
+ return this.clients?.sessions().some((session) => session.id === integrationId && session.status === "connected") === true ? homematicFacades.get(integrationId) : null;
132718
+ }
132719
+ /** CCU addresses adopted as containers from one integration. */
132720
+ async adoptedCcuAddresses(integrationId) {
132721
+ const reg = this.ctx.kernel.deviceRegistry;
132722
+ const devices = this.ctx.kernel.devices;
132723
+ const addresses = /* @__PURE__ */ new Set();
132724
+ if (!reg || !devices) return addresses;
132725
+ for (const device of reg.getAllForAddon(this.addonId)) {
132726
+ if (device.parentDeviceId !== null) continue;
132727
+ const config = await devices.loadConfig(device.id).catch(() => ({}));
132728
+ if (config["integrationId"] !== integrationId) continue;
132729
+ if (typeof config["hmEntityKey"] === "string") continue;
132730
+ const address = config["hmAddress"];
132731
+ if (typeof address === "string" && address.length > 0) addresses.add(address);
132732
+ }
132733
+ return addresses;
132734
+ }
131609
132735
  /** What the CCU management actions reach: connected sessions only, never a half-started facade. */
131610
132736
  ccuActionDeps() {
131611
132737
  return {
131612
- facade: (integrationId) => {
131613
- return this.clients?.sessions().some((session) => session.id === integrationId && session.status === "connected") === true ? homematicFacades.get(integrationId) : null;
131614
- },
132738
+ facade: (integrationId) => this.connectedFacade(integrationId),
131615
132739
  integrations: () => {
131616
132740
  const clients = this.clients;
131617
132741
  if (clients === null) return [];
@@ -131622,7 +132746,12 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131622
132746
  connected: connectedIds.has(integrationId)
131623
132747
  }));
131624
132748
  },
131625
- logger: this.ctx.logger
132749
+ logger: this.ctx.logger,
132750
+ adoptedAddresses: (integrationId) => this.adoptedCcuAddresses(integrationId),
132751
+ channelLinks: (integrationId) => {
132752
+ const facade = this.connectedFacade(integrationId);
132753
+ return facade === null ? null : channelLinkPort(facade);
132754
+ }
131626
132755
  };
131627
132756
  }
131628
132757
  async onShutdown() {
@@ -131860,10 +132989,12 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131860
132989
  name
131861
132990
  };
131862
132991
  const stableId = this.generateStableId(DeviceType.Container, config);
132992
+ const primaryChildPreference = this.primaryChildPreference(integrationId, hmAddress);
131863
132993
  const device = await devices.create(stableId, HmContainerDevice, config, null, {
131864
132994
  type: DeviceType.Container,
131865
132995
  name,
131866
- integrationId
132996
+ integrationId,
132997
+ ...primaryChildPreference.length > 0 ? { primaryChildPreference } : {}
131867
132998
  });
131868
132999
  const children = await devices.getChildren(device.id);
131869
133000
  return {
@@ -131972,4 +133103,4 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131972
133103
  }
131973
133104
  };
131974
133105
  //#endregion
131975
- 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 };
133106
+ 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 };