@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.js CHANGED
@@ -8,7 +8,7 @@ let crypto$1 = require("crypto");
8
8
  let fs_promises = require("fs/promises");
9
9
  let path = require("path");
10
10
  let node_os = require("node:os");
11
- //#region ../types/dist/event-category-78tcBemo.mjs
11
+ //#region ../types/dist/event-category-Dv-Gcv1f.mjs
12
12
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
13
13
  EventCategory["SystemBoot"] = "system.boot";
14
14
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -449,6 +449,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
449
449
  */
450
450
  EventCategory["DeviceStateChanged"] = "device.state-changed";
451
451
  /**
452
+ * A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
453
+ * transition audit (D1022): confirmed, already in place, unconfirmed or
454
+ * failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
455
+ * (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
456
+ * the Notification Center `device-command` kind. Telemetry (D8): losing one
457
+ * costs a notification, never state; the audit row is the record.
458
+ */
459
+ EventCategory["DeviceCommandSettled"] = "device.command-settled";
460
+ /**
452
461
  * The NATIVE shadow of a cap a composition has claimed fields of moved
453
462
  * (D663). Payload: `{ deviceId, capName, native }` — what the provider
454
463
  * wrote, BEFORE the owned fields are overlaid. Owner-only (D224): it is for
@@ -811,7 +820,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
811
820
  return EventCategory;
812
821
  }({});
813
822
  //#endregion
814
- //#region ../types/dist/composed-stable-id-CPp3votu.mjs
823
+ //#region ../types/dist/composed-stable-id-iddnCQ51.mjs
815
824
  /**
816
825
  import { errMsg } from '@camstack/types'
817
826
  * Extract a human-readable message from an unknown error value.
@@ -1153,6 +1162,11 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1153
1162
  * with the switch's on/off only. Speed or oscillation appear only when the
1154
1163
  * device also has a fan cap (D1033). */
1155
1164
  DeviceRole["SwitchFan"] = "switch-fan";
1165
+ /** A relay driving an on/off-only lamp: drawn as a light (bulb and glow, no
1166
+ * slider), presented to the exports as a light with power only. Not a
1167
+ * `light` type: the provider owns the type, and a light implies brightness
1168
+ * or colour this relay lacks. */
1169
+ DeviceRole["SwitchLight"] = "switch-light";
1156
1170
  /** Air conditioner / split unit: cooling, fan speed, louvres. */
1157
1171
  DeviceRole["ClimateAc"] = "climate-ac";
1158
1172
  /** Room thermostat: a setpoint and a room temperature. The default. */
@@ -6053,7 +6067,7 @@ var ZodIssueCode = {
6053
6067
  var ZodFirstPartyTypeKind;
6054
6068
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6055
6069
  //#endregion
6056
- //#region ../types/dist/sleep-D0roI_CZ.mjs
6070
+ //#region ../types/dist/sleep-BvVGLl30.mjs
6057
6071
  /**
6058
6072
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6059
6073
  * window to float samples (D455).
@@ -6736,6 +6750,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6736
6750
  else skipped.push(id);
6737
6751
  };
6738
6752
  const selected = options.only === void 0 ? null : new Set(options.only);
6753
+ const deferred = /* @__PURE__ */ new Set();
6754
+ const deferredBy = (reason) => {
6755
+ if (selected === null || reason === null) return null;
6756
+ const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
6757
+ if (dep === void 0 || !byId.has(dep)) return null;
6758
+ return !selected.has(dep) || deferred.has(dep) ? dep : null;
6759
+ };
6739
6760
  for (const step of declaration.steps) {
6740
6761
  if (selected !== null && !selected.has(step.id)) continue;
6741
6762
  const bound = byId.get(step.id);
@@ -6747,6 +6768,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6747
6768
  try {
6748
6769
  const gate = await host.startMigration({ id: step.id });
6749
6770
  if (!gate.proceed) {
6771
+ const waitsFor = deferredBy(gate.reason);
6772
+ if (waitsFor !== null) {
6773
+ log.info("migration deferred: its predecessor runs in another phase of this owner", {
6774
+ tags,
6775
+ meta: {
6776
+ waitsFor,
6777
+ reason: gate.reason
6778
+ }
6779
+ });
6780
+ deferred.add(step.id);
6781
+ skipped.push(step.id);
6782
+ continue;
6783
+ }
6750
6784
  log.warn("migration not run", {
6751
6785
  tags,
6752
6786
  meta: {
@@ -10224,6 +10258,13 @@ var DeviceTransitionSchema = object({
10224
10258
  actor: TransitionActorSchema,
10225
10259
  command: TransitionCommandSchema.optional()
10226
10260
  });
10261
+ object({
10262
+ deviceId: number$1().int(),
10263
+ action: string(),
10264
+ outcome: TransitionOutcomeSchema,
10265
+ actor: TransitionActorSchema,
10266
+ at: number$1()
10267
+ });
10227
10268
  var READING_QUANTITIES = [
10228
10269
  "temperature",
10229
10270
  "pressure",
@@ -10767,6 +10808,13 @@ var ACTUATOR_CAP_VOCABULARY = {
10767
10808
  },
10768
10809
  state: { on: { icon: "lightbulb" } }
10769
10810
  },
10811
+ [DeviceRole.SwitchLight]: {
10812
+ actions: {
10813
+ "switch.on": { icon: "lightbulb" },
10814
+ "switch.off": { icon: "lightbulb-off" }
10815
+ },
10816
+ state: { on: { icon: "lightbulb" } }
10817
+ },
10770
10818
  [DeviceRole.Chime]: { actions: {
10771
10819
  "switch.on": {
10772
10820
  label: t("Enable chime", "Attiva il campanello"),
@@ -12247,7 +12295,10 @@ var ACTUATOR_CAP_VOCABULARY = {
12247
12295
  "ir-transmitter": {
12248
12296
  scope: "device",
12249
12297
  noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
12250
- notOperatorFacing: { send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it" }
12298
+ notOperatorFacing: {
12299
+ send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
12300
+ learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
12301
+ }
12251
12302
  },
12252
12303
  control: {
12253
12304
  scope: "device",
@@ -15168,6 +15219,32 @@ var CAP_VOCABULARY_BY_NAME = {
15168
15219
  ...SYSTEM_CAP_VOCABULARY
15169
15220
  };
15170
15221
  /**
15222
+ * Vocabulary actions by id (D983). An action step names a vocabulary action
15223
+ * (`cover.open`), never a raw cap method; this is the one lookup that turns the
15224
+ * id into its cap, method and effect — and a persisted legacy `cap` + `method`
15225
+ * pair back into the action id when exactly one action matches.
15226
+ */
15227
+ function buildIndex() {
15228
+ const byId = /* @__PURE__ */ new Map();
15229
+ for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
15230
+ if (entry.scope !== "device") continue;
15231
+ for (const action of entry.actions ?? []) byId.set(action.id, {
15232
+ cap,
15233
+ action
15234
+ });
15235
+ }
15236
+ return byId;
15237
+ }
15238
+ var index;
15239
+ function actionIndex() {
15240
+ index ??= buildIndex();
15241
+ return index;
15242
+ }
15243
+ /** The vocabulary action with this id, or `undefined`. */
15244
+ function findVocabAction(actionId) {
15245
+ return actionIndex().get(actionId);
15246
+ }
15247
+ /**
15171
15248
  * `addon-pages-source` — collection cap exposing per-provider raw page
15172
15249
  * declarations. Every addon that contributes a UI page registers a
15173
15250
  * provider here. The hub-side singleton aggregator (`addon-pages` cap,
@@ -17475,7 +17552,7 @@ Object.freeze({
17475
17552
  }
17476
17553
  });
17477
17554
  //#endregion
17478
- //#region ../types/dist/implemented-methods-5YMDeE3f.mjs
17555
+ //#region ../types/dist/implemented-methods-CSTk6zYK.mjs
17479
17556
  /**
17480
17557
  * The ffmpeg build every CamStack node downloads, per platform and arch.
17481
17558
  *
@@ -17529,6 +17606,30 @@ function portable(target) {
17529
17606
  }
17530
17607
  portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac64"), `${BASE}${FFMPEG_RELEASE}`;
17531
17608
  /**
17609
+ * A device's KIND is its type plus its role (D1033): the type is the set of
17610
+ * controls it has, the role says which thing it is among the devices that
17611
+ * share those controls. A plug-in heater is a `switch` with role
17612
+ * `switch-heater`; an air conditioner and a radiator valve are both `climate`,
17613
+ * told apart by their `climate-*` role.
17614
+ */
17615
+ /**
17616
+ * Type values a persisted row may still carry after the type was retired, and
17617
+ * the type each one is read as. The row is rewritten by the next registration
17618
+ * of the device (its provider stamps the live type), so this is a read alias,
17619
+ * not a migration.
17620
+ *
17621
+ * `heater` is deliberately absent: the only heaters were composed devices the
17622
+ * operator deletes. Such a row stays an unknown type, which every reader
17623
+ * treats as a generic device.
17624
+ */
17625
+ var RETIRED_DEVICE_TYPES = { thermostat: DeviceType.Climate };
17626
+ /** The live type a stored `type` value stands for (itself unless retired). */
17627
+ function canonicalStoredDeviceType(stored) {
17628
+ return RETIRED_DEVICE_TYPES[stored] ?? stored;
17629
+ }
17630
+ preprocess((value) => typeof value === "string" ? canonicalStoredDeviceType(value) : value, _enum(DeviceType));
17631
+ DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
17632
+ /**
17532
17633
  * THE table "which boolean of this device type counts as HIGH", and the
17533
17634
  * pure evaluator of its EDGE.
17534
17635
  *
@@ -23379,7 +23480,7 @@ var DeviceTokenScopeSchema = object({
23379
23480
  function migrateLegacyTokenScope(raw) {
23380
23481
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
23381
23482
  if (Reflect.get(raw, "type") !== "device") return raw;
23382
- if (Reflect.get(raw, "selector") !== void 0) return raw;
23483
+ if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
23383
23484
  const targets = Reflect.get(raw, "targets");
23384
23485
  if (!Array.isArray(targets)) return raw;
23385
23486
  return {
@@ -23391,6 +23492,27 @@ function migrateLegacyTokenScope(raw) {
23391
23492
  access: Reflect.get(raw, "access")
23392
23493
  };
23393
23494
  }
23495
+ /**
23496
+ * A stored `types` selector may name a type D1033 retired (`thermostat`). The
23497
+ * grant is read back through this same preprocess, so the retired name is
23498
+ * rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
23499
+ * stays a strict enum on the wire.
23500
+ */
23501
+ function canonicalSelectorTypes(raw) {
23502
+ const selector = Reflect.get(raw, "selector");
23503
+ if (selector === null || typeof selector !== "object") return raw;
23504
+ if (Reflect.get(selector, "kind") !== "types") return raw;
23505
+ const types = Reflect.get(selector, "types");
23506
+ if (!Array.isArray(types)) return raw;
23507
+ const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
23508
+ return {
23509
+ ...raw,
23510
+ selector: {
23511
+ ...selector,
23512
+ types: canonical
23513
+ }
23514
+ };
23515
+ }
23394
23516
  var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
23395
23517
  object({
23396
23518
  type: literal("category"),
@@ -44856,21 +44978,23 @@ function convertLegacyWhen(half) {
44856
44978
  * (instants) and state leaves (durations). It replaces the flat trigger list
44857
44979
  * plus the separate condition tree; the firing rule is in that file and in
44858
44980
  * ADR "one tree".
44859
- * - **Actions** — the `wait` and `cap` steps, plus the `{kind:'code'}`
44981
+ * - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
44860
44982
  * fragment of §3.2.2. See {@link AutomationActionSchema}.
44861
44983
  *
44862
44984
  * A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
44863
44985
  * {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
44864
44986
  */
44865
44987
  /**
44866
- * One action step: `wait`, or a `cap` call.
44988
+ * One action step: `wait`, or a device `command`.
44867
44989
  *
44868
- * A cap step's target is who it acts on (D983: `devices`, a `domain`, or a
44869
- * `{ $var }` resolved from the run's variables); the legacy `deviceId` is still
44870
- * READ, never written. The step runner (`runSteps`) owns the device-scope
44871
- * check, the stop-at-first-failure and the variable substitution, once, for
44872
- * every caller — automations, Actions, and the notification centre, which runs
44873
- * only Actions (planning#473).
44990
+ * A command step names a VOCABULARY action (`cover.open`) and who it acts on
44991
+ * (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
44992
+ * variables). It never names a cap method: the step runner turns the action
44993
+ * id into its cap + method through the vocabulary index when the step runs
44994
+ * (`vocabCall`), the one place that mapping happens. The step runner
44995
+ * (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
44996
+ * variable substitution, once, for every caller — automations, Actions, and
44997
+ * the notification centre, which runs only Actions (planning#473).
44874
44998
  */
44875
44999
  /** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
44876
45000
  var WAIT_MAX_SECONDS = 3600;
@@ -44879,39 +45003,22 @@ var AutomationWaitStepSchema = object({
44879
45003
  kind: literal("wait"),
44880
45004
  seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
44881
45005
  });
44882
- /** The legacy `deviceId` of a cap step: still READ, never written (D983). */
44883
- var LegacyStepDeviceSchema = union([
44884
- number$1().int(),
44885
- array(number$1().int()).min(1),
44886
- object({ $var: string().min(1) })
44887
- ]);
44888
45006
  /**
44889
- * The fields of a cap step, before the target rules are applied. Exported for
44890
- * a shape that is "a cap call, narrowed" (a remote-control binding is one
44891
- * device); a step is {@link AutomationCapStepSchema}.
45007
+ * The fields of a command step, before the vocabulary check. A step is
45008
+ * {@link AutomationCommandStepSchema}.
44892
45009
  */
44893
- var AutomationCapStepBaseSchema = object({
44894
- kind: literal("cap"),
44895
- /**
44896
- * The vocabulary action this step performs (`cover.open`). Required when
44897
- * `target` is a `domain` (the domain is "every device offering this
44898
- * action"); filled by {@link normalizeCapStep} for a legacy step whose
44899
- * cap + method match exactly one vocabulary action.
44900
- */
44901
- actionId: string().min(1).optional(),
44902
- /** WHO the step acts on. The only shape that is written. */
44903
- target: ActionTargetSchema.optional(),
45010
+ var AutomationCommandStepBaseSchema = object({
45011
+ kind: literal("command"),
45012
+ /** WHO the step acts on. */
45013
+ target: ActionTargetSchema,
45014
+ /** The vocabulary action this step performs (`cover.open`). */
45015
+ actionId: string().min(1),
44904
45016
  /**
44905
- * @deprecated The pre-D983 target: one device, several, or `{ $var }`.
44906
- * Still READ — {@link normalizeCapStep} maps it to `target` — and never
44907
- * written.
45017
+ * The values of the action's OPEN args (`position`, `presetId`); the args
45018
+ * the vocabulary bakes into the action are added when the step runs. Values
45019
+ * may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
45020
+ * SUBSTITUTE and do not evaluate (§3.2.3).
44908
45021
  */
44909
- deviceId: LegacyStepDeviceSchema.optional(),
44910
- cap: string().min(1),
44911
- method: string().min(1),
44912
- /** Values may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
44913
- * SUBSTITUTE and do not evaluate (§3.2.3). Anything beyond substitution is
44914
- * the expression leaf. */
44915
45022
  args: record(string(), unknown()).optional(),
44916
45023
  /**
44917
45024
  * The unit the person picked per arg (display only). `args` always hold the
@@ -44920,18 +45027,20 @@ var AutomationCapStepBaseSchema = object({
44920
45027
  */
44921
45028
  argUnits: record(string(), string().min(1)).optional()
44922
45029
  });
45030
+ /** The vocabulary check every command step passes: the action exists. */
45031
+ function refineKnownAction(step, ctx) {
45032
+ if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
45033
+ code: "custom",
45034
+ message: `"${step.actionId}" is not a vocabulary action id`,
45035
+ path: ["actionId"]
45036
+ });
45037
+ }
44923
45038
  /**
44924
- * The steps an internal Action may contain: cap and wait, and nothing that can
45039
+ * The steps an internal Action may contain: command and wait, and nothing that can
44925
45040
  * call back into an Action — so an Action can never reach itself (no cycles).
44926
45041
  * This is the LEAF shape: no condition of its own.
44927
45042
  */
44928
- var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCapStepBaseSchema.refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44929
- message: "a cap step needs a target",
44930
- path: ["target"]
44931
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44932
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44933
- path: ["actionId"]
44934
- })]);
45043
+ var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
44935
45044
  /**
44936
45045
  * The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
44937
45046
  * on the state mirror when the step is reached; `else` runs when it is false.
@@ -44952,13 +45061,7 @@ var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refi
44952
45061
  * same two step kinds an automation runs, minus a guard that reads the
44953
45062
  * automation's trigger, which such a list does not have.
44954
45063
  */
44955
- var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCapStepBaseSchema.extend(stepGuardShape).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44956
- message: "a cap step needs a target",
44957
- path: ["target"]
44958
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44959
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44960
- path: ["actionId"]
44961
- }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
45064
+ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCommandStepBaseSchema.extend(stepGuardShape).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
44962
45065
  if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
44963
45066
  code: "custom",
44964
45067
  message: TRIGGERED_BY_NEEDS_AUTOMATION,
@@ -44973,17 +45076,11 @@ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, Automa
44973
45076
  var continueOnErrorShape = {
44974
45077
  /** A failure of this step is traced `failed-continued` and the next step runs. */
44975
45078
  continueOnError: literal(true).optional() };
44976
- /** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
44977
- var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
45079
+ /** An automation's command step: the shared guarded command step, plus `continueOnError`. */
45080
+ var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
44978
45081
  ...stepGuardShape,
44979
45082
  ...continueOnErrorShape
44980
- }).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
44981
- message: "a cap step needs a target",
44982
- path: ["target"]
44983
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
44984
- message: "a domain target needs the vocabulary action it applies to (actionId)",
44985
- path: ["actionId"]
44986
- }).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
45083
+ }).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
44987
45084
  /** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
44988
45085
  var AutomationStopStepSchema = object({
44989
45086
  kind: literal("stop"),
@@ -45063,13 +45160,7 @@ function nestTooDeep(issue) {
45063
45160
  }
45064
45161
  var plainStepSchemas = [
45065
45162
  AutomationWaitStepSchema.strict(),
45066
- AutomationCapStepBaseSchema.extend(continueOnErrorShape).strict().refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
45067
- message: "a cap step needs a target",
45068
- path: ["target"]
45069
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
45070
- message: "a domain target needs the vocabulary action it applies to (actionId)",
45071
- path: ["actionId"]
45072
- }),
45163
+ AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
45073
45164
  AutomationStopStepSchema.omit({ if: true }).strict(),
45074
45165
  AutomationSetStepSchema.omit({ if: true }).strict(),
45075
45166
  AutomationRunActionStepSchema.strict()
@@ -45080,7 +45171,7 @@ var plainStepSchemas = [
45080
45171
  */
45081
45172
  var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
45082
45173
  /** A step that can run beside others: it writes no variable and does not end the run. */
45083
- 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");
45174
+ 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");
45084
45175
  /**
45085
45176
  * Several steps at once (#500): all are started together and all are awaited.
45086
45177
  * A failure fails the run once the others finished, as in a sequence; a member
@@ -45160,7 +45251,7 @@ var AutomationBodyStepSchema = discriminatedUnion("kind", [
45160
45251
  var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
45161
45252
  var AutomationActionSchema = discriminatedUnion("kind", [
45162
45253
  GuardedWaitStepSchema,
45163
- AutomationGuardedCapStepSchema,
45254
+ AutomationGuardedCommandStepSchema,
45164
45255
  AutomationStopStepSchema,
45165
45256
  AutomationSetStepSchema,
45166
45257
  chooseSchemaOf(AutomationBodyStepSchema),
@@ -45231,110 +45322,6 @@ function convertLegacyRecipe(legacy) {
45231
45322
  };
45232
45323
  }
45233
45324
  var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
45234
- var DETECTION_DESCRIPTIONS = {
45235
- deviceId: "the camera that saw it",
45236
- className: "what it saw",
45237
- trackId: "the track",
45238
- score: "how sure the detector was",
45239
- label: "the label it matched (a name, a plate), empty when none"
45240
- };
45241
- var STATIONARY_DESCRIPTIONS = {
45242
- deviceId: "the camera that saw it",
45243
- className: "what it saw",
45244
- zones: "the zones it is in",
45245
- phase: "appeared or departed",
45246
- entryId: "the stopped object"
45247
- };
45248
- var BECOMES_DESCRIPTIONS = {
45249
- deviceId: "the device that changed",
45250
- from: "the value before the change, empty when it is not known",
45251
- to: "the value it changed to"
45252
- };
45253
- /**
45254
- * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
45255
- * those names depend on the device, so they are not in this list.
45256
- */
45257
- var FIRED_DESCRIPTIONS = {
45258
- deviceId: "the device that fired",
45259
- eventType: "the event, as the device names it",
45260
- sourceId: "the part of the device that fired (a button), empty when it names none",
45261
- eventKind: "the kind of press (press, long-press …), empty when the device declares none"
45262
- };
45263
- function describe$1(descriptions) {
45264
- return Object.entries(descriptions).map(([name, description]) => ({
45265
- name,
45266
- description
45267
- }));
45268
- }
45269
- describe$1(DETECTION_DESCRIPTIONS);
45270
- describe$1(STATIONARY_DESCRIPTIONS);
45271
- describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45272
- ...v,
45273
- hintKey: "firedDeviceId"
45274
- } : v);
45275
- describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45276
- ...v,
45277
- hintKey: "becomesDeviceId"
45278
- } : v);
45279
- new Set(Object.values(COCO_TO_MACRO.mapping));
45280
- /**
45281
- * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
45282
- * device. Carries the device's EXACT declared event vocabulary verbatim
45283
- * (NO normalization). Two shapes:
45284
- * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
45285
- * declared set (e.g. press_short, press_long, …).
45286
- * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
45287
- * is [] (open) and `lastEvent.data` carries the complex payload.
45288
- * `vocabulary` (D1044) names each event for a person and types it for a
45289
- * rule; `eventTypes` is its list of native tokens, kept for older readers.
45290
- * A fire names the part of the device it came from in `sourceId` when the
45291
- * vocabulary declares sources (a remote's buttons).
45292
- * `seq` is monotonic so two identical events still produce distinct slice writes.
45293
- */
45294
- var EventFireSchema = object({
45295
- deviceId: number$1(),
45296
- eventType: string(),
45297
- sourceId: string().optional(),
45298
- data: record(string(), unknown()).nullable(),
45299
- timestamp: number$1().meta(readingMeta("none")),
45300
- seq: number$1().meta(readingMeta("count"))
45301
- });
45302
- var EventEmitterStatusSchema = object({
45303
- eventTypes: array(string()),
45304
- /**
45305
- * Required of a provider by the type. A status written before the field
45306
- * existed still parses, as an empty vocabulary: read it through
45307
- * `readEventVocabulary`, which then answers with the plain tokens.
45308
- */
45309
- vocabulary: array(EventVocabularyEntrySchema).default([]),
45310
- lastEvent: EventFireSchema.nullable(),
45311
- eventCountSinceStart: number$1().meta(readingMeta("count"))
45312
- });
45313
- var eventEmitterCapability = {
45314
- name: "event-emitter",
45315
- scope: "device",
45316
- deviceNative: true,
45317
- mode: "singleton",
45318
- deviceTypes: [DeviceType.EventEmitter],
45319
- methods: {},
45320
- events: { onEvent: { data: EventFireSchema } },
45321
- status: {
45322
- schema: EventEmitterStatusSchema,
45323
- kind: "push"
45324
- },
45325
- runtimeState: EventEmitterStatusSchema,
45326
- /**
45327
- * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
45328
- *
45329
- * See `RuntimeStateDurability`. Enforced by
45330
- * `scripts/check-runtime-state-durability.ts`.
45331
- */
45332
- durability: "session",
45333
- /**
45334
- * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
45335
- */
45336
- history: "none"
45337
- };
45338
45325
  /**
45339
45326
  * Schedulers (D983) — an entity that performs actions over the day.
45340
45327
  *
@@ -45733,6 +45720,110 @@ var AutomationStateDocSchema = object({
45733
45720
  lastRunStartedAt: number$1().nullable(),
45734
45721
  traces: array(AutomationRunTraceSchema)
45735
45722
  });
45723
+ var DETECTION_DESCRIPTIONS = {
45724
+ deviceId: "the camera that saw it",
45725
+ className: "what it saw",
45726
+ trackId: "the track",
45727
+ score: "how sure the detector was",
45728
+ label: "the label it matched (a name, a plate), empty when none"
45729
+ };
45730
+ var STATIONARY_DESCRIPTIONS = {
45731
+ deviceId: "the camera that saw it",
45732
+ className: "what it saw",
45733
+ zones: "the zones it is in",
45734
+ phase: "appeared or departed",
45735
+ entryId: "the stopped object"
45736
+ };
45737
+ var BECOMES_DESCRIPTIONS = {
45738
+ deviceId: "the device that changed",
45739
+ from: "the value before the change, empty when it is not known",
45740
+ to: "the value it changed to"
45741
+ };
45742
+ /**
45743
+ * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
45744
+ * those names depend on the device, so they are not in this list.
45745
+ */
45746
+ var FIRED_DESCRIPTIONS = {
45747
+ deviceId: "the device that fired",
45748
+ eventType: "the event, as the device names it",
45749
+ sourceId: "the part of the device that fired (a button), empty when it names none",
45750
+ eventKind: "the kind of press (press, long-press …), empty when the device declares none"
45751
+ };
45752
+ function describe$1(descriptions) {
45753
+ return Object.entries(descriptions).map(([name, description]) => ({
45754
+ name,
45755
+ description
45756
+ }));
45757
+ }
45758
+ describe$1(DETECTION_DESCRIPTIONS);
45759
+ describe$1(STATIONARY_DESCRIPTIONS);
45760
+ describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45761
+ ...v,
45762
+ hintKey: "firedDeviceId"
45763
+ } : v);
45764
+ describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45765
+ ...v,
45766
+ hintKey: "becomesDeviceId"
45767
+ } : v);
45768
+ new Set(Object.values(COCO_TO_MACRO.mapping));
45769
+ /**
45770
+ * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
45771
+ * device. Carries the device's EXACT declared event vocabulary verbatim
45772
+ * (NO normalization). Two shapes:
45773
+ * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
45774
+ * declared set (e.g. press_short, press_long, …).
45775
+ * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
45776
+ * is [] (open) and `lastEvent.data` carries the complex payload.
45777
+ * `vocabulary` (D1044) names each event for a person and types it for a
45778
+ * rule; `eventTypes` is its list of native tokens, kept for older readers.
45779
+ * A fire names the part of the device it came from in `sourceId` when the
45780
+ * vocabulary declares sources (a remote's buttons).
45781
+ * `seq` is monotonic so two identical events still produce distinct slice writes.
45782
+ */
45783
+ var EventFireSchema = object({
45784
+ deviceId: number$1(),
45785
+ eventType: string(),
45786
+ sourceId: string().optional(),
45787
+ data: record(string(), unknown()).nullable(),
45788
+ timestamp: number$1().meta(readingMeta("none")),
45789
+ seq: number$1().meta(readingMeta("count"))
45790
+ });
45791
+ var EventEmitterStatusSchema = object({
45792
+ eventTypes: array(string()),
45793
+ /**
45794
+ * Required of a provider by the type. A status written before the field
45795
+ * existed still parses, as an empty vocabulary: read it through
45796
+ * `readEventVocabulary`, which then answers with the plain tokens.
45797
+ */
45798
+ vocabulary: array(EventVocabularyEntrySchema).default([]),
45799
+ lastEvent: EventFireSchema.nullable(),
45800
+ eventCountSinceStart: number$1().meta(readingMeta("count"))
45801
+ });
45802
+ var eventEmitterCapability = {
45803
+ name: "event-emitter",
45804
+ scope: "device",
45805
+ deviceNative: true,
45806
+ mode: "singleton",
45807
+ deviceTypes: [DeviceType.EventEmitter],
45808
+ methods: {},
45809
+ events: { onEvent: { data: EventFireSchema } },
45810
+ status: {
45811
+ schema: EventEmitterStatusSchema,
45812
+ kind: "push"
45813
+ },
45814
+ runtimeState: EventEmitterStatusSchema,
45815
+ /**
45816
+ * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
45817
+ *
45818
+ * See `RuntimeStateDurability`. Enforced by
45819
+ * `scripts/check-runtime-state-durability.ts`.
45820
+ */
45821
+ durability: "session",
45822
+ /**
45823
+ * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
45824
+ */
45825
+ history: "none"
45826
+ };
45736
45827
  /**
45737
45828
  * Actions — named, runnable things an operator (or an automation) can start,
45738
45829
  * declared as LIST ENTRIES, never as devices.
@@ -45912,6 +46003,177 @@ var UnitWarningSchema = object({
45912
46003
  assumedUnit: string(),
45913
46004
  message: string()
45914
46005
  });
46006
+ /**
46007
+ * `device-export` — collection cap for addons that export camstack
46008
+ * devices to external ecosystems (HomeAssistant via MQTT discovery,
46009
+ * HomeKit/HAP, Alexa Smart Home, …).
46010
+ *
46011
+ * No `ecosystem` enum — the addon id identifies the export target.
46012
+ * Each addon owns its mapping logic in its own settings UI. The cap
46013
+ * exposes only the COMMON surface: link state, supported device
46014
+ * kinds (so the UI can filter the device picker), and per-device
46015
+ * expose/unexpose.
46016
+ *
46017
+ * INSTANCES. One export addon can serve several independent targets (a
46018
+ * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
46019
+ * `instanceId` on a READ is optional: absent = the whole addon (linked if any
46020
+ * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
46021
+ * default instance's); present = that instance; an id the provider does not
46022
+ * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
46023
+ * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
46024
+ * change always names the target it changes. A single-instance provider
46025
+ * accepts an absent id on a read or its own id, and refuses any other.
46026
+ */
46027
+ /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
46028
+ var InstanceIdSchema$1 = string().min(1);
46029
+ var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
46030
+ /** One independent export target of an addon. */
46031
+ var ExportInstanceSchema = object({
46032
+ instanceId: InstanceIdSchema$1,
46033
+ name: string(),
46034
+ enabled: boolean(),
46035
+ kind: string().optional(),
46036
+ /**
46037
+ * What this instance's platform accepts as a device name, in one operator-facing sentence
46038
+ * (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
46039
+ * about the rule.
46040
+ */
46041
+ nameRule: string().optional()
46042
+ });
46043
+ var LinkStateSchema = _enum([
46044
+ "unlinked",
46045
+ "linked",
46046
+ "error"
46047
+ ]);
46048
+ /**
46049
+ * A single label/value row surfaced in the export panel's "Setup"
46050
+ * section. Rendered with a copy-to-clipboard button. `secret: true`
46051
+ * rows are masked by default with a reveal toggle (client ids,
46052
+ * secrets, …).
46053
+ */
46054
+ var ExportSetupFieldSchema = object({
46055
+ label: string(),
46056
+ value: string(),
46057
+ /** Mask the value by default + render a reveal toggle (client id, secrets). */
46058
+ secret: boolean().optional()
46059
+ });
46060
+ /**
46061
+ * Generic, addon-agnostic pairing/account block. Any export addon can
46062
+ * surface a scannable QR, a set of copyable label/value rows, and a
46063
+ * free-form operator note — the `DeviceExportPanel` renders whatever
46064
+ * the provider supplies and skips the section entirely when `setup`
46065
+ * is unset.
46066
+ */
46067
+ var ExportSetupSchema = object({
46068
+ /** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
46069
+ qr: string().optional(),
46070
+ /** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
46071
+ fields: array(ExportSetupFieldSchema).readonly().optional(),
46072
+ /** Free-form operator instructions rendered above the fields. */
46073
+ note: string().optional()
46074
+ });
46075
+ var DeviceExportStatusSchema = object({
46076
+ linkState: LinkStateSchema,
46077
+ exposedDeviceCount: number$1(),
46078
+ error: string().optional(),
46079
+ /**
46080
+ * Optional pairing/account info the panel renders in a generic
46081
+ * "Setup" section. Addon-agnostic — the addon id identifies the
46082
+ * export target, never an `ecosystem` key here.
46083
+ */
46084
+ setup: ExportSetupSchema.optional()
46085
+ });
46086
+ var DeviceKindSchema = string();
46087
+ /**
46088
+ * EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
46089
+ * device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
46090
+ * store (D865), validated by the exporter against its platform's naming rules, and never reaches
46091
+ * the exported id — a rename updates the SAME device on the platform, never a second one.
46092
+ * Blank or `null` = the device's own name. A name the platform would refuse is refused with
46093
+ * `ExportNameRefusedError` (`export-name-refused`), whose message says why.
46094
+ */
46095
+ var ExposedDeviceSchema = object({
46096
+ deviceId: string(),
46097
+ exposedAs: string().optional(),
46098
+ /** The operator's name for this device on this instance; absent = the device's own name. */
46099
+ exposedName: string().optional(),
46100
+ capabilities: array(string()).optional()
46101
+ });
46102
+ var ExposeInputSchema = object({
46103
+ instanceId: InstanceIdSchema$1,
46104
+ deviceId: string(),
46105
+ capabilities: array(string()).optional(),
46106
+ /** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
46107
+ exposedName: string().nullable().optional()
46108
+ });
46109
+ var SetExposedNameInputSchema = object({
46110
+ instanceId: InstanceIdSchema$1,
46111
+ deviceId: string(),
46112
+ /** Blank or null = the device's own name. */
46113
+ name: string().nullable(),
46114
+ /**
46115
+ * Validate only: refuse exactly as a real call would, write nothing. A caller saving several
46116
+ * names at once checks every one first, so one refusal writes none (D1049).
46117
+ */
46118
+ dryRun: boolean().optional()
46119
+ });
46120
+ var UnexposeInputSchema = object({
46121
+ instanceId: InstanceIdSchema$1,
46122
+ deviceId: string()
46123
+ });
46124
+ /**
46125
+ * What an exporter may expose besides devices (D968). An action and a
46126
+ * notification target are LIST ENTRIES, never devices (D954): they enter an
46127
+ * exporter's own selection, not the device registry.
46128
+ */
46129
+ var ExportEntityKindSchema = _enum([
46130
+ "device",
46131
+ "action",
46132
+ "notifier"
46133
+ ]);
46134
+ var ExportEntityRefSchema = discriminatedUnion("kind", [
46135
+ object({
46136
+ kind: literal("device"),
46137
+ deviceId: string()
46138
+ }),
46139
+ object({
46140
+ kind: literal("action"),
46141
+ actionId: string().min(1)
46142
+ }),
46143
+ object({
46144
+ kind: literal("notifier"),
46145
+ targetId: string().min(1)
46146
+ })
46147
+ ]);
46148
+ var ExposedEntitySchema = object({
46149
+ entity: ExportEntityRefSchema,
46150
+ exposedAs: string().optional()
46151
+ });
46152
+ var ExposeEntityInputSchema = object({
46153
+ instanceId: InstanceIdSchema$1,
46154
+ entity: ExportEntityRefSchema
46155
+ });
46156
+ var UnexposeEntityInputSchema = object({
46157
+ instanceId: InstanceIdSchema$1,
46158
+ entity: ExportEntityRefSchema
46159
+ });
46160
+ method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
46161
+ kind: "mutation",
46162
+ auth: "admin"
46163
+ }), method(UnexposeInputSchema, _void(), {
46164
+ kind: "mutation",
46165
+ auth: "admin"
46166
+ }), method(SetExposedNameInputSchema, _void(), {
46167
+ kind: "mutation",
46168
+ auth: "admin"
46169
+ }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
46170
+ kind: "mutation",
46171
+ auth: "admin"
46172
+ }), optionalMethod(UnexposeEntityInputSchema, _void(), {
46173
+ kind: "mutation",
46174
+ auth: "admin"
46175
+ });
46176
+ record(string(), string());
45915
46177
  _enum([
45916
46178
  "automation",
45917
46179
  "action",
@@ -51115,11 +51377,13 @@ var IrCodecError = class extends Error {
51115
51377
  this.code = code;
51116
51378
  }
51117
51379
  };
51380
+ /** Maximum number of mark/space entries one pulse train may carry. */
51381
+ var IR_TIMINGS_MAX = 1024;
51118
51382
  /**
51119
51383
  * A pulse train in signed microseconds: mark (+) first, then space (-), strictly
51120
51384
  * alternating, no zeros, 2..1024 entries.
51121
51385
  */
51122
- var IrTimingsSchema = array(number$1().int()).min(2).max(1024).superRefine((timings, ctx) => {
51386
+ var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
51123
51387
  timings.forEach((value, index) => {
51124
51388
  const expectMark = index % 2 === 0;
51125
51389
  if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
@@ -51166,15 +51430,186 @@ function decodePronto(code) {
51166
51430
  carrierHz: Math.round(1e6 / unitUs)
51167
51431
  };
51168
51432
  }
51169
- /** What a remote command stores: a raw pulse train, or a learned Pronto code. */
51170
- var IrPayloadSchema = discriminatedUnion("kind", [object({
51171
- kind: literal("raw"),
51172
- timings: array(number$1().int()),
51173
- settings: TransmitSettingsSchema.optional()
51174
- }), object({
51175
- kind: literal("pronto"),
51176
- code: string()
51177
- })]);
51433
+ /**
51434
+ * FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
51435
+ * literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
51436
+ * is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
51437
+ * between the low 5 bits and the next byte.
51438
+ */
51439
+ var MAX_DISTANCE = 8192;
51440
+ var MAX_LITERAL_RUN = 32;
51441
+ var MIN_MATCH = 3;
51442
+ var MAX_MATCH = 264;
51443
+ /**
51444
+ * Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
51445
+ * can expand ~130x, so the decoder checks this bound before every write.
51446
+ */
51447
+ var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
51448
+ function fastlzDecompress(input) {
51449
+ const out = [];
51450
+ let ip = 0;
51451
+ const room = (count) => {
51452
+ if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
51453
+ };
51454
+ const next = () => {
51455
+ const byte = input[ip++];
51456
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
51457
+ return byte;
51458
+ };
51459
+ while (ip < input.length) {
51460
+ const ctrl = next();
51461
+ if (ctrl < 32) {
51462
+ room(ctrl + 1);
51463
+ for (let i = 0; i <= ctrl; i++) out.push(next());
51464
+ continue;
51465
+ }
51466
+ let len = (ctrl >> 5) - 1;
51467
+ if (len === 6) len += next();
51468
+ const distance = ((ctrl & 31) << 8) + next() + 1;
51469
+ const start = out.length - distance;
51470
+ if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
51471
+ room(len + 3);
51472
+ for (let i = 0; i < len + 3; i++) {
51473
+ const byte = out[start + i];
51474
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
51475
+ out.push(byte);
51476
+ }
51477
+ }
51478
+ return Uint8Array.from(out);
51479
+ }
51480
+ function fastlzCompress(input) {
51481
+ const out = [];
51482
+ const lastSeen = /* @__PURE__ */ new Map();
51483
+ let literalStart = 0;
51484
+ const flushLiterals = (end) => {
51485
+ for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
51486
+ const to = Math.min(from + MAX_LITERAL_RUN, end);
51487
+ out.push(to - from - 1);
51488
+ for (let i = from; i < to; i++) out.push(input[i] ?? 0);
51489
+ }
51490
+ };
51491
+ let pos = 0;
51492
+ while (pos < input.length) {
51493
+ let matchLen = 0;
51494
+ let matchDistance = 0;
51495
+ if (pos + MIN_MATCH <= input.length) {
51496
+ const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
51497
+ const candidate = lastSeen.get(key);
51498
+ lastSeen.set(key, pos);
51499
+ if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
51500
+ let len = 0;
51501
+ while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
51502
+ if (len >= MIN_MATCH) {
51503
+ matchLen = len;
51504
+ matchDistance = pos - candidate - 1;
51505
+ }
51506
+ }
51507
+ }
51508
+ if (matchLen === 0) {
51509
+ pos++;
51510
+ continue;
51511
+ }
51512
+ flushLiterals(pos);
51513
+ const enc = matchLen - 2;
51514
+ if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
51515
+ else out.push(224 | matchDistance >> 8, enc - 7);
51516
+ out.push(matchDistance & 255);
51517
+ pos += matchLen;
51518
+ literalStart = pos;
51519
+ }
51520
+ flushLiterals(input.length);
51521
+ return Uint8Array.from(out);
51522
+ }
51523
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
51524
+ var MAX_DURATION_US = 65535;
51525
+ function toBase64(bytes) {
51526
+ let out = "";
51527
+ for (let i = 0; i < bytes.length; i += 3) {
51528
+ const a = bytes[i] ?? 0;
51529
+ const b = bytes[i + 1] ?? 0;
51530
+ const c = bytes[i + 2] ?? 0;
51531
+ const word = a << 16 | b << 8 | c;
51532
+ out += ALPHABET[word >> 18 & 63];
51533
+ out += ALPHABET[word >> 12 & 63];
51534
+ out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
51535
+ out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
51536
+ }
51537
+ return out;
51538
+ }
51539
+ function fromBase64(text) {
51540
+ const clean = text.trim().replace(/=+$/, "");
51541
+ if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
51542
+ const out = [];
51543
+ let bits = 0;
51544
+ let acc = 0;
51545
+ for (const ch of clean) {
51546
+ const value = ALPHABET.indexOf(ch);
51547
+ if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
51548
+ acc = acc << 6 | value;
51549
+ bits += 6;
51550
+ if (bits >= 8) {
51551
+ bits -= 8;
51552
+ out.push(acc >> bits & 255);
51553
+ }
51554
+ }
51555
+ return Uint8Array.from(out);
51556
+ }
51557
+ /** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
51558
+ function encodeTuya(timings) {
51559
+ const bytes = new Uint8Array(timings.length * 2);
51560
+ timings.forEach((value, index) => {
51561
+ const duration = Math.abs(value);
51562
+ if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
51563
+ bytes[index * 2] = duration & 255;
51564
+ bytes[index * 2 + 1] = duration >> 8;
51565
+ });
51566
+ return toBase64(fastlzCompress(bytes));
51567
+ }
51568
+ /** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
51569
+ function decodeTuya(code) {
51570
+ const bytes = fastlzDecompress(fromBase64(code));
51571
+ if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
51572
+ const timings = [];
51573
+ for (let i = 0; i < bytes.length; i += 2) {
51574
+ const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
51575
+ timings.push(i / 2 % 2 === 0 ? duration : -duration);
51576
+ }
51577
+ const checked = IrTimingsSchema.safeParse(timings);
51578
+ if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
51579
+ return checked.data;
51580
+ }
51581
+ /** Device-native IR code formats a transmitter can replay verbatim. */
51582
+ var IrNativeFormatSchema = _enum(["tuya"]);
51583
+ /**
51584
+ * Longest native code accepted: base64 of the worst-case compressed stream
51585
+ * (every decoded byte as a literal, plus one control byte per 32), with margin.
51586
+ */
51587
+ var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
51588
+ var IrNativeCodeSchema = object({
51589
+ format: IrNativeFormatSchema,
51590
+ code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
51591
+ });
51592
+ var IR_NATIVE_CODECS = { tuya: {
51593
+ encode: encodeTuya,
51594
+ decode: decodeTuya
51595
+ } };
51596
+ /** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
51597
+ var IrPayloadSchema = discriminatedUnion("kind", [
51598
+ object({
51599
+ kind: literal("raw"),
51600
+ timings: array(number$1().int()),
51601
+ settings: TransmitSettingsSchema.optional()
51602
+ }),
51603
+ object({
51604
+ kind: literal("pronto"),
51605
+ code: string()
51606
+ }),
51607
+ object({
51608
+ kind: literal("native"),
51609
+ format: IrNativeFormatSchema,
51610
+ code: string()
51611
+ })
51612
+ ]);
51178
51613
  /** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
51179
51614
  function toTimings(payload) {
51180
51615
  if (payload.kind === "pronto") {
@@ -51184,6 +51619,10 @@ function toTimings(payload) {
51184
51619
  settings: { carrierHz: decoded.carrierHz }
51185
51620
  };
51186
51621
  }
51622
+ if (payload.kind === "native") return {
51623
+ timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
51624
+ settings: {}
51625
+ };
51187
51626
  const checked = IrTimingsSchema.safeParse(payload.timings);
51188
51627
  if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
51189
51628
  return {
@@ -52055,8 +52494,8 @@ function actuator(input) {
52055
52494
  };
52056
52495
  }
52057
52496
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
52058
- DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
52059
52497
  DeviceType.Camera;
52498
+ DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
52060
52499
  var PowerSourceRefusalReasonSchema = _enum([
52061
52500
  "no-power-source",
52062
52501
  "switch-missing",
@@ -53516,144 +53955,6 @@ method(object({
53516
53955
  kind: "mutation",
53517
53956
  auth: "admin"
53518
53957
  });
53519
- /**
53520
- * `device-export` — collection cap for addons that export camstack
53521
- * devices to external ecosystems (HomeAssistant via MQTT discovery,
53522
- * HomeKit/HAP, Alexa Smart Home, …).
53523
- *
53524
- * No `ecosystem` enum — the addon id identifies the export target.
53525
- * Each addon owns its mapping logic in its own settings UI. The cap
53526
- * exposes only the COMMON surface: link state, supported device
53527
- * kinds (so the UI can filter the device picker), and per-device
53528
- * expose/unexpose.
53529
- *
53530
- * INSTANCES. One export addon can serve several independent targets (a
53531
- * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
53532
- * `instanceId` on a READ is optional: absent = the whole addon (linked if any
53533
- * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
53534
- * default instance's); present = that instance; an id the provider does not
53535
- * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
53536
- * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
53537
- * change always names the target it changes. A single-instance provider
53538
- * accepts an absent id on a read or its own id, and refuses any other.
53539
- */
53540
- /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
53541
- var InstanceIdSchema$1 = string().min(1);
53542
- var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
53543
- /** One independent export target of an addon. */
53544
- var ExportInstanceSchema = object({
53545
- instanceId: InstanceIdSchema$1,
53546
- name: string(),
53547
- enabled: boolean(),
53548
- kind: string().optional()
53549
- });
53550
- var LinkStateSchema = _enum([
53551
- "unlinked",
53552
- "linked",
53553
- "error"
53554
- ]);
53555
- /**
53556
- * A single label/value row surfaced in the export panel's "Setup"
53557
- * section. Rendered with a copy-to-clipboard button. `secret: true`
53558
- * rows are masked by default with a reveal toggle (client ids,
53559
- * secrets, …).
53560
- */
53561
- var ExportSetupFieldSchema = object({
53562
- label: string(),
53563
- value: string(),
53564
- /** Mask the value by default + render a reveal toggle (client id, secrets). */
53565
- secret: boolean().optional()
53566
- });
53567
- /**
53568
- * Generic, addon-agnostic pairing/account block. Any export addon can
53569
- * surface a scannable QR, a set of copyable label/value rows, and a
53570
- * free-form operator note — the `DeviceExportPanel` renders whatever
53571
- * the provider supplies and skips the section entirely when `setup`
53572
- * is unset.
53573
- */
53574
- var ExportSetupSchema = object({
53575
- /** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
53576
- qr: string().optional(),
53577
- /** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
53578
- fields: array(ExportSetupFieldSchema).readonly().optional(),
53579
- /** Free-form operator instructions rendered above the fields. */
53580
- note: string().optional()
53581
- });
53582
- var DeviceExportStatusSchema = object({
53583
- linkState: LinkStateSchema,
53584
- exposedDeviceCount: number$1(),
53585
- error: string().optional(),
53586
- /**
53587
- * Optional pairing/account info the panel renders in a generic
53588
- * "Setup" section. Addon-agnostic — the addon id identifies the
53589
- * export target, never an `ecosystem` key here.
53590
- */
53591
- setup: ExportSetupSchema.optional()
53592
- });
53593
- var DeviceKindSchema = string();
53594
- var ExposedDeviceSchema = object({
53595
- deviceId: string(),
53596
- exposedAs: string().optional(),
53597
- capabilities: array(string()).optional()
53598
- });
53599
- var ExposeInputSchema = object({
53600
- instanceId: InstanceIdSchema$1,
53601
- deviceId: string(),
53602
- capabilities: array(string()).optional()
53603
- });
53604
- var UnexposeInputSchema = object({
53605
- instanceId: InstanceIdSchema$1,
53606
- deviceId: string()
53607
- });
53608
- /**
53609
- * What an exporter may expose besides devices (D968). An action and a
53610
- * notification target are LIST ENTRIES, never devices (D954): they enter an
53611
- * exporter's own selection, not the device registry.
53612
- */
53613
- var ExportEntityKindSchema = _enum([
53614
- "device",
53615
- "action",
53616
- "notifier"
53617
- ]);
53618
- var ExportEntityRefSchema = discriminatedUnion("kind", [
53619
- object({
53620
- kind: literal("device"),
53621
- deviceId: string()
53622
- }),
53623
- object({
53624
- kind: literal("action"),
53625
- actionId: string().min(1)
53626
- }),
53627
- object({
53628
- kind: literal("notifier"),
53629
- targetId: string().min(1)
53630
- })
53631
- ]);
53632
- var ExposedEntitySchema = object({
53633
- entity: ExportEntityRefSchema,
53634
- exposedAs: string().optional()
53635
- });
53636
- var ExposeEntityInputSchema = object({
53637
- instanceId: InstanceIdSchema$1,
53638
- entity: ExportEntityRefSchema
53639
- });
53640
- var UnexposeEntityInputSchema = object({
53641
- instanceId: InstanceIdSchema$1,
53642
- entity: ExportEntityRefSchema
53643
- });
53644
- method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
53645
- kind: "mutation",
53646
- auth: "admin"
53647
- }), method(UnexposeInputSchema, _void(), {
53648
- kind: "mutation",
53649
- auth: "admin"
53650
- }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
53651
- kind: "mutation",
53652
- auth: "admin"
53653
- }), optionalMethod(UnexposeEntityInputSchema, _void(), {
53654
- kind: "mutation",
53655
- auth: "admin"
53656
- });
53657
53958
  var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
53658
53959
  var DeviceTemplateSchema = string().min(1).max(4096);
53659
53960
  /** One value a caller hands the renderer for `thisDevice`. */
@@ -58508,6 +58809,193 @@ var StateLookSchema = object({
58508
58809
  background: _enum(HERO_BACKGROUNDS),
58509
58810
  animation: HeroAnimationSchema
58510
58811
  });
58812
+ /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
58813
+ var HeroTextSchema = object({
58814
+ en: string(),
58815
+ it: string()
58816
+ });
58817
+ /**
58818
+ * What a device that has not reported says in place of its value: an empty "—",
58819
+ * never a word like "Unknown" and never a 0 (D393). The card stays its normal
58820
+ * self; only the value is empty.
58821
+ */
58822
+ var NOT_REPORTED = {
58823
+ en: "—",
58824
+ it: "—"
58825
+ };
58826
+ /**
58827
+ * The ONE measurement a simple sensor shows (card wave, phase 1).
58828
+ *
58829
+ * A sensor that measures a single quantity (a temperature, a humidity, a power,
58830
+ * a contact, a text state) is drawn as that reading, once, big, inside a scene
58831
+ * whose motion says what the number means: heat rising when hot, flakes when
58832
+ * cold, a wire flowing at the speed of the power, a ring while a window is
58833
+ * open. Everything the card draws is decided here; a client only paints it.
58834
+ */
58835
+ var HERO_MEASUREMENT_QUANTITIES = [
58836
+ "temperature",
58837
+ "humidity",
58838
+ "power",
58839
+ "contact",
58840
+ "text"
58841
+ ];
58842
+ /** How a temperature reads to a person; drives the heat or the cold scene. */
58843
+ var HERO_MEASUREMENT_BANDS = [
58844
+ "hot",
58845
+ "mild",
58846
+ "cold"
58847
+ ];
58848
+ /** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
58849
+ var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
58850
+ var HeroMeasurementReadingSchema = object({
58851
+ value: number$1(),
58852
+ quantity: ReadingQuantitySchema
58853
+ });
58854
+ var HeroMeasurementSchema = object({
58855
+ quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
58856
+ reading: HeroMeasurementReadingSchema.nullable(),
58857
+ icon: IconKeySchema.nullable(),
58858
+ value: HeroTextSchema,
58859
+ unit: string().nullable(),
58860
+ band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
58861
+ level: number$1().min(0).max(1).nullable(),
58862
+ word: HeroTextSchema,
58863
+ tone: _enum(HERO_TONES),
58864
+ since: number$1().nullable(),
58865
+ sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
58866
+ historyKey: string().nullable()
58867
+ });
58868
+ var same$2 = (text) => t(text, text);
58869
+ var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
58870
+ var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
58871
+ function temperatureBand(celsius) {
58872
+ if (celsius < 12) return "cold";
58873
+ if (celsius > 28) return "hot";
58874
+ return "mild";
58875
+ }
58876
+ var BAND_WORD = {
58877
+ hot: t("Hot", "Caldo"),
58878
+ mild: t("Normal", "Normale"),
58879
+ cold: t("Cold", "Freddo")
58880
+ };
58881
+ var BAND_TONE = {
58882
+ hot: "warning",
58883
+ mild: "muted",
58884
+ cold: "info"
58885
+ };
58886
+ function temperatureMeasurement(celsius, since) {
58887
+ const band = temperatureBand(celsius);
58888
+ return {
58889
+ quantity: "temperature",
58890
+ reading: {
58891
+ value: celsius,
58892
+ quantity: "temperature"
58893
+ },
58894
+ icon: "thermometer",
58895
+ value: same$2(trimmed(celsius, 1)),
58896
+ unit: "°C",
58897
+ band,
58898
+ level: null,
58899
+ word: BAND_WORD[band],
58900
+ tone: BAND_TONE[band],
58901
+ since,
58902
+ sinceKind: "updated",
58903
+ historyKey: "cap:temperature-sensor.temperature"
58904
+ };
58905
+ }
58906
+ function humidityMeasurement(percent, since) {
58907
+ const dry = percent < 30;
58908
+ const humid = percent > 70;
58909
+ return {
58910
+ quantity: "humidity",
58911
+ reading: {
58912
+ value: percent,
58913
+ quantity: "humidity"
58914
+ },
58915
+ icon: "droplets",
58916
+ value: same$2(String(Math.round(percent))),
58917
+ unit: "%",
58918
+ band: null,
58919
+ level: clamp01$1(percent / 100),
58920
+ word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
58921
+ tone: dry || humid ? "warning" : "info",
58922
+ since,
58923
+ sinceKind: "updated",
58924
+ historyKey: "cap:humidity-sensor.humidity"
58925
+ };
58926
+ }
58927
+ function textMeasurement(text, since) {
58928
+ return {
58929
+ quantity: "text",
58930
+ reading: null,
58931
+ icon: null,
58932
+ value: same$2(text),
58933
+ unit: null,
58934
+ band: null,
58935
+ level: null,
58936
+ word: t("Changed", "Cambiato"),
58937
+ tone: "muted",
58938
+ since,
58939
+ sinceKind: "updated",
58940
+ historyKey: null
58941
+ };
58942
+ }
58943
+ /** What each quantity draws beside its value, reported or not. */
58944
+ var QUANTITY_FACE = {
58945
+ temperature: {
58946
+ icon: "thermometer",
58947
+ unit: "°C",
58948
+ sinceKind: "updated",
58949
+ historyKey: "cap:temperature-sensor.temperature"
58950
+ },
58951
+ humidity: {
58952
+ icon: "droplets",
58953
+ unit: "%",
58954
+ sinceKind: "updated",
58955
+ historyKey: "cap:humidity-sensor.humidity"
58956
+ },
58957
+ power: {
58958
+ icon: "zap",
58959
+ unit: "W",
58960
+ sinceKind: "updated",
58961
+ historyKey: "cap:power-meter.power"
58962
+ },
58963
+ contact: {
58964
+ icon: null,
58965
+ unit: null,
58966
+ sinceKind: "changed",
58967
+ historyKey: null
58968
+ },
58969
+ text: {
58970
+ icon: null,
58971
+ unit: null,
58972
+ sinceKind: "updated",
58973
+ historyKey: null
58974
+ }
58975
+ };
58976
+ /**
58977
+ * The measurement of a sensor that has not reported yet: its normal card with
58978
+ * an empty "—" value and its unit — never a placeholder, never a 0 (D393). The
58979
+ * reading is `null` (nothing to format), the scene does not move, and nothing
58980
+ * claims a moment.
58981
+ */
58982
+ function emptyMeasurement(quantity) {
58983
+ const face = QUANTITY_FACE[quantity];
58984
+ return {
58985
+ quantity,
58986
+ reading: null,
58987
+ icon: face.icon,
58988
+ value: NOT_REPORTED,
58989
+ unit: face.unit,
58990
+ band: null,
58991
+ level: null,
58992
+ word: NOT_REPORTED,
58993
+ tone: "muted",
58994
+ since: null,
58995
+ sinceKind: face.sinceKind,
58996
+ historyKey: face.historyKey
58997
+ };
58998
+ }
58511
58999
  /** The scene as the model carries it. `null` = the device did not say (never a guess). */
58512
59000
  var HeroSceneSchema = object({
58513
59001
  id: _enum([
@@ -58558,12 +59046,7 @@ var HeroSceneSchema = object({
58558
59046
  level: number$1().min(0).max(1).nullable()
58559
59047
  });
58560
59048
  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;
58561
- 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;
58562
- /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
58563
- var HeroTextSchema = object({
58564
- en: string(),
58565
- it: string()
58566
- });
59049
+ 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;
58567
59050
  var HeroRowIdSchema = _enum([
58568
59051
  "progress",
58569
59052
  "run-for",
@@ -58669,6 +59152,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
58669
59152
  optionLabels: record(string(), HeroTextSchema).optional(),
58670
59153
  call: HeroCallSchema,
58671
59154
  valueArg: string()
59155
+ }),
59156
+ object({
59157
+ kind: literal("number"),
59158
+ id: string(),
59159
+ label: HeroTextSchema,
59160
+ value: number$1().nullable(),
59161
+ /** `null` = any number; the device rounds what it does not accept. */
59162
+ step: number$1().nullable(),
59163
+ unit: string(),
59164
+ call: HeroCallSchema,
59165
+ valueArg: string()
59166
+ }),
59167
+ object({
59168
+ kind: literal("text"),
59169
+ id: string(),
59170
+ label: HeroTextSchema,
59171
+ value: string().nullable(),
59172
+ call: HeroCallSchema,
59173
+ valueArg: string()
58672
59174
  })
58673
59175
  ]);
58674
59176
  /** Declared by its interface: a `z.infer` of one more icon union pushes the cap's inferred type past what the compiler can print. */
@@ -58870,6 +59372,11 @@ var HeroModelSchema = object({
58870
59372
  timedRun: HeroTimedRunSlotSchema.nullable(),
58871
59373
  powerSupply: HeroPowerSupplySlotSchema.nullable(),
58872
59374
  rows: array(HeroRowSchema),
59375
+ /**
59376
+ * The ONE measurement of a simple sensor, drawn once inside the scene in place of
59377
+ * the caption, tiles and value chips. Absent = the card draws as before.
59378
+ */
59379
+ measurement: HeroMeasurementSchema.optional(),
58873
59380
  /** Ids of parts that actuate the device, hidden from a session that may not act on it. */
58874
59381
  gated: array(string()),
58875
59382
  provenance: array(HeroProvenanceSchema)
@@ -58941,8 +59448,23 @@ var HeroRowModelSchema = object({
58941
59448
  * the call. Absent or empty = `primary` alone.
58942
59449
  */
58943
59450
  extras: array(HeroControlSchema).max(2).optional(),
58944
- trailing: HeroFactSchema.nullable()
59451
+ trailing: HeroFactSchema.nullable(),
59452
+ /**
59453
+ * The simple sensor's one reading (the hero's `measurement`): the row draws its value
59454
+ * at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
59455
+ * older server or a device that is not a simple sensor: draw `trailing`.
59456
+ */
59457
+ measurement: HeroMeasurementSchema.optional()
58945
59458
  });
59459
+ new Set([
59460
+ "temperature",
59461
+ "humidity",
59462
+ "pressure",
59463
+ "illuminance",
59464
+ "reading",
59465
+ "air-quality",
59466
+ "valve"
59467
+ ]);
58946
59468
  DeviceType.Climate;
58947
59469
  DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
58948
59470
  /**
@@ -60031,13 +60553,32 @@ var IrSendResultSchema = object({
60031
60553
  var IrTransmitterInfoSchema = object({
60032
60554
  media: array(IrMediumSchema),
60033
60555
  settable: array(TransmitSettingKeySchema),
60034
- maxTimings: number$1().int().positive()
60556
+ maxTimings: number$1().int().positive(),
60557
+ /** The transmitter can learn a code (`learn`). */
60558
+ learn: boolean().default(false),
60559
+ /** Native code formats the transmitter replays verbatim (`send.native`). */
60560
+ formats: array(IrNativeFormatSchema).default([])
60561
+ });
60562
+ var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
60563
+ var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
60564
+ var IrLearnResultSchema = object({
60565
+ /** The code in the device's own format, when it reports one. */
60566
+ native: IrNativeCodeSchema.nullable(),
60567
+ timings: IrTimingsSchema,
60568
+ carrierHz: number$1().int().positive().nullable()
60035
60569
  });
60036
60570
  DeviceType.Generic, method(object({
60037
60571
  deviceId: number$1().int().nonnegative(),
60038
- timings: IrTimingsSchema,
60572
+ timings: IrTimingsSchema.optional(),
60573
+ native: IrNativeCodeSchema.optional(),
60039
60574
  settings: TransmitSettingsSchema.optional()
60040
- }), IrSendResultSchema, {
60575
+ }).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
60576
+ kind: "mutation",
60577
+ auth: "protected"
60578
+ }), method(object({
60579
+ deviceId: number$1().int().nonnegative(),
60580
+ timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
60581
+ }), IrLearnResultSchema, {
60041
60582
  kind: "mutation",
60042
60583
  auth: "protected"
60043
60584
  }), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
@@ -69823,6 +70364,7 @@ var NcSystemEventKindSchema = _enum([
69823
70364
  "recording-degraded",
69824
70365
  "device-attention-required",
69825
70366
  "device-attention-resolved",
70367
+ "device-command",
69826
70368
  "storage-location-low",
69827
70369
  "storage-location-critical",
69828
70370
  "storage-location-ok",
@@ -69885,11 +70427,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
69885
70427
  "alarm-sensor-bypass",
69886
70428
  "alarm-disarmed"
69887
70429
  ];
69888
- /**
69889
- * One coherent system-event condition. `kinds` is the required opt-in safety
69890
- * gate; the remaining lists are optional narrowing filters relevant to the
69891
- * selected kinds.
69892
- */
69893
70430
  var NcSystemEventConditionSchema = object({
69894
70431
  kinds: array(NcSystemEventKindSchema).min(1),
69895
70432
  deviceIds: array(number$1().int()).min(1).optional(),
@@ -69921,6 +70458,28 @@ var NcSystemEventConditionSchema = object({
69921
70458
  nodeIds: array(string().min(1)).min(1).optional(),
69922
70459
  packageNames: array(string().min(1)).min(1).optional(),
69923
70460
  /**
70461
+ * `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
70462
+ * this rule speaks about - the same dictionary the automation action blocks
70463
+ * pick from. The hub refuses an id the action index does not know.
70464
+ */
70465
+ commandActions: array(string().min(1)).min(1).optional(),
70466
+ /** `device-command` only: how the command settled. A device's own change is not a command. */
70467
+ commandOutcomes: array(_enum([
70468
+ "confirmed",
70469
+ "already",
70470
+ "unconfirmed",
70471
+ "failed"
70472
+ ])).min(1).optional(),
70473
+ /** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
70474
+ commandActorKinds: array(_enum([
70475
+ "user",
70476
+ "addon",
70477
+ "action",
70478
+ "scheduler",
70479
+ "composition",
70480
+ "node"
70481
+ ])).min(1).optional(),
70482
+ /**
69924
70483
  * At or below this remaining-life %, a consumable is LOW for THIS rule
69925
70484
  * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
69926
70485
  * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
@@ -70901,6 +71460,13 @@ var NcRuleInputSchema = object({
70901
71460
  */
70902
71461
  groupingSec: number$1().int().min(5).max(60).optional(),
70903
71462
  /**
71463
+ * Hold deliveries of this rule to one target and, when two or more arrive
71464
+ * before the window ends, send them as one summary. Absent = the kind's
71465
+ * default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
71466
+ * other kind. `0` sends each delivery as it does today.
71467
+ */
71468
+ groupWithinSec: number$1().int().min(0).max(300).optional(),
71469
+ /**
70904
71470
  * ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
70905
71471
  * carries "Correct" / "Wrong" buttons (and, where the channel has room, a
70906
71472
  * "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
@@ -71337,7 +71903,12 @@ var NcHistoryEntrySchema = object({
71337
71903
  * Assistant export) must render as "no image right now", never as a
71338
71904
  * broken link.
71339
71905
  */
71340
- artifactIds: array(string().min(1)).optional()
71906
+ artifactIds: array(string().min(1)).optional(),
71907
+ /**
71908
+ * When this row was folded into a group-window summary, the outbox id of
71909
+ * that one notification. Absent on a row that was sent as itself.
71910
+ */
71911
+ groupedInto: string().min(1).optional()
71341
71912
  });
71342
71913
  /**
71343
71914
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -77410,10 +77981,15 @@ getStatus: method(object({ deviceId: number$1() }), RecordingSignalStatusSchema)
77410
77981
  */
77411
77982
  history: "none"
77412
77983
  };
77413
- var RemoteBindingSchema = object({ action: AutomationCapStepBaseSchema.omit({
77414
- target: true,
77415
- actionId: true
77416
- }).extend({ deviceId: number$1().int().nonnegative() }) });
77984
+ var RemoteBindingSchema = object({ action: object({
77985
+ kind: literal("cap"),
77986
+ deviceId: number$1().int().nonnegative(),
77987
+ cap: string().min(1),
77988
+ method: string().min(1),
77989
+ args: record(string(), unknown()).optional(),
77990
+ /** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
77991
+ argUnits: record(string(), string().min(1)).optional()
77992
+ }) });
77417
77993
  var RemoteCustomButtonSchema = object({
77418
77994
  /** The slug after `custom:` in the role. */
77419
77995
  key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
@@ -78403,7 +78979,7 @@ var sceneMonitorCapability = {
78403
78979
  * instead of failing silently weeks later.
78404
78980
  *
78405
78981
  * Reachable from three surfaces on this one mutation: the scene card, a
78406
- * notification button (an `onTrigger` sequence with a `kind:'cap'` step —
78982
+ * notification button (an `onTrigger` sequence with a `kind:'command'` step —
78407
78983
  * no new Notification-Center code at all), and tRPC for scripts.
78408
78984
  */
78409
78985
  resetScene: method(object({
@@ -85382,8 +85958,6 @@ var BaseDeviceProvider = class extends BaseAddon {
85382
85958
  }
85383
85959
  };
85384
85960
  DeviceType.HeatPump;
85385
- DeviceType.Climate;
85386
- DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
85387
85961
  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;
85388
85962
  new Set(Object.values(DeviceType));
85389
85963
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
@@ -85396,6 +85970,13 @@ function contribution(cap, schema, build) {
85396
85970
  }
85397
85971
  };
85398
85972
  }
85973
+ /** The fragment, carrying the cap's single measurement when it has one. */
85974
+ function measured(fragment, measurement) {
85975
+ return measurement === void 0 ? fragment : {
85976
+ ...fragment,
85977
+ measurement
85978
+ };
85979
+ }
85399
85980
  function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
85400
85981
  return {
85401
85982
  id,
@@ -85515,7 +86096,7 @@ var lockContribution = contribution("lock-control", LockControlStatusSchema, (sl
85515
86096
  const state = slice?.state ?? null;
85516
86097
  const words = state === null ? null : LOCK_WORDS[state];
85517
86098
  const since = slice === void 0 ? null : elapsedText(slice.lastChangedAt, ctx.now);
85518
- const title = words?.title ?? t("Unknown", "Sconosciuto");
86099
+ const title = words?.title ?? NOT_REPORTED;
85519
86100
  return {
85520
86101
  reading: reading("lock-control", words?.state ?? "unknown", false, words?.title),
85521
86102
  rows: [row$1("lock", state === "locked" || state === "locking" ? "lock" : "lock-open", joinText([title, since]), lockControls(state, ctx.features.includes(DeviceFeature.LockOpen)))],
@@ -85607,7 +86188,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85607
86188
  const modes = slice === void 0 ? ALARM_MODES : slice.availableModes;
85608
86189
  return {
85609
86190
  reading: reading("alarm-panel", words?.state ?? "unknown", false, words?.title),
85610
- 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))],
86191
+ 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))],
85611
86192
  ...since === null || words === null ? {} : { facts: [fact("since", "clock", since, state === "triggered" ? "danger" : "muted")] },
85612
86193
  ...words === null ? {} : { tiles: {
85613
86194
  left: [{
@@ -85638,7 +86219,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85638
86219
  return {
85639
86220
  reading: reading("automation-control", state, false, title),
85640
86221
  rows: [row$1("automation", "workflow", joinText([
85641
- title ?? t("Unknown", "Sconosciuto"),
86222
+ title ?? NOT_REPORTED,
85642
86223
  last === null ? null : t(`Ran ${last.en}`, `Eseguita ${last.it}`),
85643
86224
  slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
85644
86225
  ]), [asAction(run), toggle])],
@@ -85654,7 +86235,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85654
86235
  return {
85655
86236
  reading: reading("script-runner", state, false, title),
85656
86237
  rows: [row$1("script", "scroll-text", joinText([
85657
- title ?? t("Unknown", "Sconosciuto"),
86238
+ title ?? NOT_REPORTED,
85658
86239
  last === null ? null : t(`Ran ${last.en}`, `Eseguito ${last.it}`),
85659
86240
  slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
85660
86241
  ]), [asAction(control)])],
@@ -85663,7 +86244,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85663
86244
  }),
85664
86245
  "do-not-disturb": contribution("do-not-disturb", DoNotDisturbStatusSchema, (slice) => {
85665
86246
  const on = slice?.enabled ?? null;
85666
- 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"), [{
86247
+ 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"), [{
85667
86248
  kind: "toggle",
85668
86249
  id: "do-not-disturb.toggle",
85669
86250
  label: t("Do not disturb", "Non disturbare"),
@@ -85681,7 +86262,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
85681
86262
  * is absent from the facts, never a zero (D393).
85682
86263
  */
85683
86264
  var has$3 = (ctx, f) => ctx.features.includes(f);
85684
- var unknownText = t("Unknown", "Sconosciuto");
86265
+ var unknownText = NOT_REPORTED;
85685
86266
  var pct$2 = (n) => t(`${Math.round(n)}%`, `${Math.round(n)}%`);
85686
86267
  var unit = (n) => Math.min(1, Math.max(0, n / 100));
85687
86268
  /** Battery as a fact, unless the device is also bound to the `battery` cap (it already says so). */
@@ -86670,10 +87251,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
86670
87251
  };
86671
87252
  });
86672
87253
  var CONTROL_LABEL = t("Value", "Valore");
86673
- /** A number with known bounds is a slider, a choice a picker; text and dates stay read-only. */
87254
+ /**
87255
+ * A number with known bounds is a slider, one without a number field, a choice a picker,
87256
+ * free text a text field; a date stays read-only.
87257
+ */
86674
87258
  function controlRows(slice) {
86675
87259
  if (slice.kind === "numeric" && typeof slice.value === "number") {
86676
- if (slice.min === void 0 || slice.max === void 0) return [];
87260
+ if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
87261
+ kind: "number",
87262
+ id: "control.value",
87263
+ label: CONTROL_LABEL,
87264
+ value: slice.value,
87265
+ step: slice.step ?? null,
87266
+ unit: "",
87267
+ call: {
87268
+ cap: "control",
87269
+ method: "setValue",
87270
+ args: { control: { kind: "numeric" } }
87271
+ },
87272
+ valueArg: "control.value"
87273
+ }])];
86677
87274
  return [row$1("control", "sliders-horizontal", null, [{
86678
87275
  kind: "slider",
86679
87276
  id: "control.value",
@@ -86704,6 +87301,18 @@ function controlRows(slice) {
86704
87301
  },
86705
87302
  valueArg: "control.value"
86706
87303
  }])];
87304
+ if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
87305
+ kind: "text",
87306
+ id: "control.value",
87307
+ label: CONTROL_LABEL,
87308
+ value: typeof slice.value === "string" ? slice.value : null,
87309
+ call: {
87310
+ cap: "control",
87311
+ method: "setValue",
87312
+ args: { control: { kind: "text" } }
87313
+ },
87314
+ valueArg: "control.value"
87315
+ }])];
86707
87316
  return [];
86708
87317
  }
86709
87318
  var SENSORS_FAMILY_CONTRIBUTIONS = {
@@ -87059,15 +87668,15 @@ function sensorFragment(value, id, icon, en, it, text) {
87059
87668
  tiles: { right: [tile$1(en, it, text)] }
87060
87669
  };
87061
87670
  }
87062
- var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
87063
- var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`));
87671
+ 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)));
87672
+ 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)));
87064
87673
  var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
87065
87674
  var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
87066
87675
  var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
87067
87676
  var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
87068
- if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
87677
+ if (slice === void 0 || slice.value === "") return measured({ reading: reading("sensor", "unknown") }, emptyMeasurement("text"));
87069
87678
  if (slice.timestamp === true) return { reading: reading("sensor", "on") };
87070
- return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
87679
+ return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
87071
87680
  });
87072
87681
  /** Index bands: the headline of an air-quality sensor is a word, not a number. */
87073
87682
  function airQualityWord(aqi) {
@@ -87189,7 +87798,7 @@ function circuitControl(circuit) {
87189
87798
  return picker(`heat-pump.${circuit.id}.mode`, t("Mode", "Modalità"), circuit.operationMode, method, args);
87190
87799
  }
87191
87800
  /** A circuit with no reading is still a row: it shows that nothing is known, not nothing. */
87192
- var UNKNOWN_STATUS = same("—");
87801
+ var UNKNOWN_STATUS = NOT_REPORTED;
87193
87802
  function circuitRow(circuit) {
87194
87803
  const control = circuitControl(circuit);
87195
87804
  const status = thermalStatusText(circuit.targetTemp, circuit.currentTemp) ?? UNKNOWN_STATUS;
@@ -87413,9 +88022,8 @@ function look(icon, tone, background, animation) {
87413
88022
  animation
87414
88023
  };
87415
88024
  }
87416
- /** A state a device is in whatever it is: unreachable, or silent. Identical for every look. */
88025
+ /** Unreachable: identical for every look. */
87417
88026
  var OFFLINE = look("wifi-off", "muted", "plain", "none");
87418
- var UNKNOWN = look("circle-question-mark", "muted", "plain", "none");
87419
88027
  var ALERT = look("triangle-alert", "danger", "alert-wash", "pulse");
87420
88028
  function lookOf(spec) {
87421
88029
  const at = (s) => look(spec.icon, s[0], s[1], s[2]);
@@ -87427,7 +88035,7 @@ function lookOf(spec) {
87427
88035
  standby: at(spec.standby),
87428
88036
  alert: spec.alert ?? ALERT,
87429
88037
  offline: OFFLINE,
87430
- unknown: UNKNOWN
88038
+ unknown: look(spec.icon, "muted", "plain", "none")
87431
88039
  };
87432
88040
  }
87433
88041
  var MUTED = [
@@ -88036,7 +88644,7 @@ lookOf({
88036
88644
  });
88037
88645
  DeviceType.Climate;
88038
88646
  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;
88039
- 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;
88647
+ 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;
88040
88648
  Object.freeze({
88041
88649
  "accessories.getStatus": {
88042
88650
  capName: "accessories",
@@ -89963,6 +90571,13 @@ Object.freeze({
89963
90571
  access: "view",
89964
90572
  role: "admin"
89965
90573
  },
90574
+ "deviceExport.setExposedName": {
90575
+ capName: "device-export",
90576
+ capScope: "system",
90577
+ addonId: null,
90578
+ access: "create",
90579
+ role: "admin"
90580
+ },
89966
90581
  "deviceExport.unexposeDevice": {
89967
90582
  capName: "device-export",
89968
90583
  capScope: "system",
@@ -91902,6 +92517,13 @@ Object.freeze({
91902
92517
  access: "view",
91903
92518
  role: "viewer"
91904
92519
  },
92520
+ "irTransmitter.learn": {
92521
+ capName: "ir-transmitter",
92522
+ capScope: "device",
92523
+ addonId: null,
92524
+ access: "create",
92525
+ role: "viewer"
92526
+ },
91905
92527
  "irTransmitter.send": {
91906
92528
  capName: "ir-transmitter",
91907
92529
  capScope: "device",
@@ -98420,48 +99042,6 @@ Object.freeze({
98420
99042
  role: "admin"
98421
99043
  }
98422
99044
  });
98423
- /**
98424
- * "Do" actions an operator can pick for a device — presentation-free.
98425
- *
98426
- * The wire shape stays `{ cap, method, args }`. Since D920 this module no
98427
- * longer HOLDS a catalogue: {@link DEVICE_DO_ACTIONS} is a projection of the
98428
- * cap vocabulary (`cap-vocabulary/`), the one cap-keyed map of every action
98429
- * and trigger — so a picker built on this module and one built on
98430
- * `actionsForDevice` (the vocabulary resolver) can never disagree about what
98431
- * a device can do. Ids, baked args and the matching of saved steps are the
98432
- * vocabulary's; labels here are its English labels.
98433
- *
98434
- * Shared by the admin NC Sequences / rule Do editor and Automations; the
98435
- * viewer can reuse the same catalogue once its step editor catches up.
98436
- */
98437
- function openArgKind(offer) {
98438
- if (offer.kind === "number") return "number";
98439
- if (offer.kind === "dynamic" && offer.valueKind === "number") return "number";
98440
- if (offer.kind === "enum" && offer.values.every((v) => typeof v.value === "number")) return "number";
98441
- return "string";
98442
- }
98443
- function projectOpenArg(arg) {
98444
- return {
98445
- key: arg.key,
98446
- label: arg.label.en,
98447
- kind: openArgKind(arg.offer),
98448
- offer: arg.offer,
98449
- ...arg.optional === true ? { optional: true } : {}
98450
- };
98451
- }
98452
- function projectAction(cap, action) {
98453
- const open = action.openArgs ?? [];
98454
- return {
98455
- id: action.id,
98456
- label: action.label.en,
98457
- cap,
98458
- method: action.method,
98459
- args: action.args ?? {},
98460
- ...open.length > 0 ? { openArgs: open.map(projectOpenArg) } : {}
98461
- };
98462
- }
98463
- Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
98464
- 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;
98465
99045
  DeviceFeature.BatteryOperated;
98466
99046
  function bound(cap, methods = [], authority = "reported") {
98467
99047
  return {
@@ -98520,6 +99100,10 @@ function offered(received) {
98520
99100
  };
98521
99101
  }
98522
99102
  offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
99103
+ 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;
99104
+ 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;
99105
+ new Set(Object.values(DeviceType));
99106
+ new Set(Object.values(DeviceRole));
98523
99107
  var PowerSwitchRefusedError = class extends Error {
98524
99108
  reason;
98525
99109
  constructor(reason, message) {
@@ -99896,6 +100480,11 @@ Object.freeze({
99896
100480
  form: "single",
99897
100481
  optional: false
99898
100482
  }],
100483
+ "irTransmitter.learn": [{
100484
+ name: "deviceId",
100485
+ form: "single",
100486
+ optional: false
100487
+ }],
99899
100488
  "irTransmitter.send": [{
99900
100489
  name: "deviceId",
99901
100490
  form: "single",
@@ -101835,7 +102424,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
101835
102424
  "deviceTypes",
101836
102425
  "nodeIds",
101837
102426
  "packageNames",
101838
- "consumableLowPercent"
102427
+ "consumableLowPercent",
102428
+ "commandActions",
102429
+ "commandOutcomes",
102430
+ "commandActorKinds"
101839
102431
  ];
101840
102432
  new Map(Object.entries({
101841
102433
  "device-online": "device-events",
@@ -101858,6 +102450,7 @@ new Map(Object.entries({
101858
102450
  "recording-degraded": "device-events",
101859
102451
  "device-attention-required": "device-events",
101860
102452
  "device-attention-resolved": "device-events",
102453
+ "device-command": "device-events",
101861
102454
  "node-online": "system",
101862
102455
  "node-offline": "system",
101863
102456
  "node-restarting": "system",
@@ -101958,6 +102551,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
101958
102551
  label: "Needs attention",
101959
102552
  kinds: ["device-attention-required", "device-attention-resolved"]
101960
102553
  },
102554
+ {
102555
+ id: "device-command",
102556
+ family: "device-events",
102557
+ label: "Commands given to devices",
102558
+ kinds: ["device-command"]
102559
+ },
101961
102560
  {
101962
102561
  id: "nodes",
101963
102562
  family: "system",
@@ -102035,6 +102634,15 @@ function systemEventKindsOfFamily(family) {
102035
102634
  return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
102036
102635
  }
102037
102636
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
102637
+ new Set([
102638
+ "alarm.trigger",
102639
+ "alarm.disarm",
102640
+ "alarm.arm.home",
102641
+ "alarm.arm.away",
102642
+ "alarm.arm.night",
102643
+ "alarm.arm.vacation",
102644
+ "alarm.arm.custom_bypass"
102645
+ ]);
102038
102646
  /**
102039
102647
  * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
102040
102648
  * persists (D640 "a sensor rule fires on the raise, the clear, or both").
@@ -102230,6 +102838,7 @@ var DEVICE_EVENTS = [
102230
102838
  "recording-healthy",
102231
102839
  "recording-degraded",
102232
102840
  ...DEVICE_ATTENTION,
102841
+ "device-command",
102233
102842
  ...ALARM
102234
102843
  ];
102235
102844
  /** Every kind a summary may speak about — the two summarisable families. */
@@ -102383,6 +102992,9 @@ var STATE_SUMMARY_VARS = [
102383
102992
  [...RULE_BODY_ONLY],
102384
102993
  [...RULE_TEXT],
102385
102994
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
102995
+ [...RULE_TEXT],
102996
+ [...RULE_TEXT],
102997
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
102386
102998
  ([...RULE_TEXT], [...COMBINED_ALARM]),
102387
102999
  ([...RULE_TEXT], [...COMBINED_ALARM]),
102388
103000
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
@@ -103451,6 +104063,284 @@ var HomematicReconciler = class {
103451
104063
  }
103452
104064
  };
103453
104065
  //#endregion
104066
+ //#region src/homematic-mapping.ts
104067
+ /**
104068
+ * Map a single Homematic channel to its CamStack triplet. The channel
104069
+ * `TYPE` is the discriminator. Only the controllable / primary channel
104070
+ * types map; status-only `*_TRANSMITTER` mirrors and the various key /
104071
+ * remote / week-profile channels return `null` (their datapoints are
104072
+ * still decoded into the owning cap's slice via the device's
104073
+ * `valueChanged` handler, keyed by parameter name).
104074
+ */
104075
+ function mapHmChannel(channelType) {
104076
+ if (!channelType) return null;
104077
+ switch (channelType.toUpperCase()) {
104078
+ case "SWITCH_VIRTUAL_RECEIVER": return {
104079
+ deviceType: DeviceType.Switch,
104080
+ role: null,
104081
+ capabilities: ["switch"]
104082
+ };
104083
+ case "SHUTTER_VIRTUAL_RECEIVER": return {
104084
+ deviceType: DeviceType.Cover,
104085
+ role: null,
104086
+ capabilities: ["cover"]
104087
+ };
104088
+ case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
104089
+ deviceType: DeviceType.Climate,
104090
+ role: null,
104091
+ capabilities: [
104092
+ "climate-control",
104093
+ "temperature-sensor",
104094
+ "humidity-sensor"
104095
+ ]
104096
+ };
104097
+ case "MOTIONDETECTOR_TRANSCEIVER": return {
104098
+ deviceType: DeviceType.Sensor,
104099
+ role: DeviceRole.MotionSensor,
104100
+ capabilities: ["motion", "ambient-light-sensor"]
104101
+ };
104102
+ case "DOOR_LOCK_STATE_TRANSMITTER": return {
104103
+ deviceType: DeviceType.Lock,
104104
+ role: null,
104105
+ capabilities: ["lock-control"]
104106
+ };
104107
+ case "ENERGIE_METER_TRANSMITTER": return {
104108
+ deviceType: DeviceType.Sensor,
104109
+ role: DeviceRole.PowerSensor,
104110
+ capabilities: ["power-meter"]
104111
+ };
104112
+ case "KEY_TRANSCEIVER":
104113
+ case "KEY_TRANSMITTER":
104114
+ case "VIRTUAL_KEY":
104115
+ case "KEY": return {
104116
+ deviceType: DeviceType.EventEmitter,
104117
+ role: null,
104118
+ capabilities: ["event-emitter"]
104119
+ };
104120
+ default: return null;
104121
+ }
104122
+ }
104123
+ /**
104124
+ * Best-effort parent DeviceType for a whole Homematic device, derived
104125
+ * from the union of its channel mappings. Actuators win over sensors so
104126
+ * a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
104127
+ * Sensor, and a thermostat with a humidity sensor reports as a
104128
+ * Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
104129
+ * ranked above Sensor so its battery / maintenance sensor channels don't
104130
+ * win the parent type. Returns `DeviceType.Generic` when no channel maps.
104131
+ */
104132
+ var PARENT_TYPE_PRIORITY = [
104133
+ DeviceType.Climate,
104134
+ DeviceType.Lock,
104135
+ DeviceType.Cover,
104136
+ DeviceType.Light,
104137
+ DeviceType.Switch,
104138
+ DeviceType.EventEmitter,
104139
+ DeviceType.Sensor
104140
+ ];
104141
+ function inferHmDeviceType(device) {
104142
+ const present = /* @__PURE__ */ new Set();
104143
+ for (const channel of device.channels) {
104144
+ const mapping = mapHmChannel(channel.type);
104145
+ if (mapping) present.add(mapping.deviceType);
104146
+ }
104147
+ for (const dt of PARENT_TYPE_PRIORITY) if (present.has(dt)) return dt;
104148
+ return DeviceType.Generic;
104149
+ }
104150
+ function mapHmDeviceChannels(device) {
104151
+ const out = [];
104152
+ for (const channel of device.channels) {
104153
+ const mapping = mapHmChannel(channel.type);
104154
+ if (mapping) out.push({
104155
+ channel,
104156
+ mapping
104157
+ });
104158
+ }
104159
+ return out;
104160
+ }
104161
+ //#endregion
104162
+ //#region src/devices/hm-cold-start.ts
104163
+ /**
104164
+ * Shared cold-start defaults + the key-channel press vocabulary helpers,
104165
+ * extracted from the (legacy) flat `homematic-device.ts` so the Container +
104166
+ * accessory-child classes reuse the SAME seeds and decoders without
104167
+ * duplicating them. Pure: no `BaseDevice` / facade dependency.
104168
+ */
104169
+ /**
104170
+ * Cold-start defaults so reads never miss a slice before the first push.
104171
+ * `lastChangedAt: 0` marks each as a PLACEHOLDER — the value is a guess, and
104172
+ * consumers read it as unknown. A replayed CCU value is stamped
104173
+ * `HM_SEEDED_CHANGED_AT` instead (`hm-change-stamp.ts`).
104174
+ */
104175
+ var COLD_SWITCH = {
104176
+ on: false,
104177
+ lastChangedAt: 0
104178
+ };
104179
+ var COLD_COVER = {
104180
+ state: "closed",
104181
+ position: null,
104182
+ tiltPosition: null,
104183
+ lastChangedAt: 0
104184
+ };
104185
+ var COLD_LOCK = {
104186
+ state: "unlocked",
104187
+ lastChangedAt: 0
104188
+ };
104189
+ var COLD_MOTION = {
104190
+ detected: false,
104191
+ lastDetectedAt: null,
104192
+ autoClearAfterMs: null
104193
+ };
104194
+ /**
104195
+ * The motion seed a constructor writes OVER the slice hydrated from the
104196
+ * persisted runtime state. The level is a placeholder (`false`) until the
104197
+ * CCU says otherwise, but a stored rise is a fact: `lastDetectedAt: null`
104198
+ * means "never detected" (`motion.cap.ts`), and a restart must not turn
104199
+ * "fired an hour ago" into that.
104200
+ */
104201
+ function coldMotionKeepingRise(stored) {
104202
+ const rise = stored?.lastDetectedAt;
104203
+ return {
104204
+ ...COLD_MOTION,
104205
+ lastDetectedAt: typeof rise === "number" && Number.isFinite(rise) && rise > 0 ? rise : null
104206
+ };
104207
+ }
104208
+ var COLD_CLIMATE = {
104209
+ mode: "auto",
104210
+ availableModes: [...[
104211
+ "off",
104212
+ "heat",
104213
+ "auto"
104214
+ ]],
104215
+ fanMode: "",
104216
+ availableFanModes: [],
104217
+ preset: "",
104218
+ availablePresets: ["boost"],
104219
+ target: null,
104220
+ targetHigh: null,
104221
+ targetLow: null,
104222
+ targetHumidity: null,
104223
+ currentTemp: null,
104224
+ currentHumidity: null,
104225
+ swingVertical: null,
104226
+ swingHorizontal: null,
104227
+ lastFetchedAt: 0
104228
+ };
104229
+ /**
104230
+ * The standard HmIP key-channel datapoint vocabulary, used VERBATIM (NO
104231
+ * normalization) as the `event-emitter` event types — the native uppercase
104232
+ * tokens a `KEY_TRANSCEIVER` / `KEY_TRANSMITTER` / `VIRTUAL_KEY` / `KEY`
104233
+ * channel emits on the facade `valueChanged` stream.
104234
+ */
104235
+ var HM_KEY_PRESS_DATAPOINTS = [
104236
+ "PRESS_SHORT",
104237
+ "PRESS_LONG",
104238
+ "PRESS_LONG_START",
104239
+ "PRESS_LONG_RELEASE",
104240
+ "PRESS_CONT"
104241
+ ];
104242
+ /** Set form for O(1) fire-detection membership tests. */
104243
+ var HM_KEY_PRESS_SET = new Set(HM_KEY_PRESS_DATAPOINTS);
104244
+ /** Cold-start event-emitter slice; vocabulary supplied per-device. */
104245
+ function coldEventEmitter(vocabulary) {
104246
+ return {
104247
+ eventTypes: eventTypesOfVocabulary(vocabulary),
104248
+ vocabulary: [...vocabulary],
104249
+ lastEvent: null,
104250
+ eventCountSinceStart: 0
104251
+ };
104252
+ }
104253
+ /**
104254
+ * Collect the union of native `PRESS_*` datapoints a device's key channels
104255
+ * support, VERBATIM. Falls back to the standard HmIP key vocabulary when no
104256
+ * datapoints were enumerated, so the cap always advertises a non-empty set.
104257
+ */
104258
+ function keyEventVocabulary(keyChannels) {
104259
+ const found = /* @__PURE__ */ new Set();
104260
+ for (const channel of keyChannels) for (const dp of channel.dataPoints ?? []) if (HM_KEY_PRESS_SET.has(dp.parameter)) found.add(dp.parameter);
104261
+ if (found.size === 0) return HM_KEY_PRESS_DATAPOINTS;
104262
+ return HM_KEY_PRESS_DATAPOINTS.filter((dp) => found.has(dp));
104263
+ }
104264
+ /**
104265
+ * The CamStack cap names that are ACTUATORS — driven by the library's typed
104266
+ * custom entities (correct channel), NOT by the raw mapped channels. The
104267
+ * raw-channel sensor/event loop skips these so they are not double-registered.
104268
+ */
104269
+ var ACTUATOR_CAP_NAMES = new Set([
104270
+ "switch",
104271
+ "cover",
104272
+ "light",
104273
+ "lock-control",
104274
+ "climate-control"
104275
+ ]);
104276
+ /** Parse the numeric channel index suffix (`:N`) from a channel address.
104277
+ * Null when absent. Kept as a string for the event payload, mirroring the
104278
+ * CCU's `device:index` addressing. */
104279
+ function channelIndexFromAddress(channelAddress) {
104280
+ const idx = channelAddress.lastIndexOf(":");
104281
+ if (idx === -1) return null;
104282
+ const suffix = channelAddress.slice(idx + 1);
104283
+ return suffix.length > 0 ? suffix : null;
104284
+ }
104285
+ //#endregion
104286
+ //#region src/devices/hm-key-vocabulary.ts
104287
+ var PRESS_MEANING = {
104288
+ PRESS_SHORT: {
104289
+ label: "Short press",
104290
+ kind: "press"
104291
+ },
104292
+ PRESS_LONG: {
104293
+ label: "Long press",
104294
+ kind: "long-press"
104295
+ },
104296
+ PRESS_LONG_START: {
104297
+ label: "Long press started",
104298
+ kind: "long-press-start"
104299
+ },
104300
+ PRESS_LONG_RELEASE: {
104301
+ label: "Long press released",
104302
+ kind: "release"
104303
+ },
104304
+ PRESS_CONT: {
104305
+ label: "Long press held",
104306
+ kind: "repeat"
104307
+ }
104308
+ };
104309
+ /** The channels of a device that are buttons, in channel order. */
104310
+ function hmKeyChannels(device) {
104311
+ return mapHmDeviceChannels(device).filter(({ mapping }) => mapping.capabilities.includes("event-emitter")).map(({ channel }) => channel);
104312
+ }
104313
+ /** The presses one key channel has; the standard set when it lists none. */
104314
+ function pressesOf(channel) {
104315
+ const listed = new Set((channel.dataPoints ?? []).map((dataPoint) => dataPoint.parameter).filter((parameter) => HM_KEY_PRESS_SET.has(parameter)));
104316
+ if (listed.size === 0) return HM_KEY_PRESS_DATAPOINTS;
104317
+ return HM_KEY_PRESS_DATAPOINTS.filter((parameter) => listed.has(parameter));
104318
+ }
104319
+ function entryOf(parameter, source) {
104320
+ const meaning = PRESS_MEANING[parameter];
104321
+ if (meaning === void 0) return {
104322
+ id: parameter,
104323
+ source,
104324
+ label: parameter
104325
+ };
104326
+ return {
104327
+ id: parameter,
104328
+ source,
104329
+ label: meaning.label,
104330
+ kind: meaning.kind
104331
+ };
104332
+ }
104333
+ function hmKeyVocabulary(device) {
104334
+ return hmKeyChannels(device).flatMap((channel, position) => {
104335
+ const index = channelIndexFromAddress(channel.address) ?? String(channel.index);
104336
+ const source = {
104337
+ id: index,
104338
+ label: `Button ${position + 1} (channel ${index})`
104339
+ };
104340
+ return pressesOf(channel).map((parameter) => entryOf(parameter, source));
104341
+ });
104342
+ }
104343
+ //#endregion
103454
104344
  //#region src/ccu/ccu-facade.ts
103455
104345
  function errorText(err) {
103456
104346
  return err instanceof Error ? err.message : String(err);
@@ -103466,6 +104356,144 @@ function requireConfirmed(confirmed) {
103466
104356
  if (confirmed !== true) throw new Error("A CCU write needs the operator confirmation (confirmed: true)");
103467
104357
  }
103468
104358
  //#endregion
104359
+ //#region src/ccu/hm-channel-links.ts
104360
+ /**
104361
+ * The slice of nodehomematic the button-event actions need. Specs hand in a
104362
+ * fake. The installed 0.5.1 build has none of these methods: the adapter
104363
+ * feature-checks and answers `unsupported` instead of calling them.
104364
+ *
104365
+ * What 0.6 must provide, on the facade object:
104366
+ * - `getChannelLinkState(address) → { central: boolean; links: { sender, receiver, name }[] }`
104367
+ * - `createCentralLink(address)` idempotent
104368
+ * - `removeCentralLink(address)` idempotent, throwing a typed error on failure
104369
+ * - `name: string | null` on devices and channels (read separately, not here)
104370
+ */
104371
+ var ChannelLinkSchema = object({
104372
+ sender: string(),
104373
+ receiver: string(),
104374
+ name: string()
104375
+ });
104376
+ var ChannelLinkStateSchema = object({
104377
+ central: boolean(),
104378
+ links: array(ChannelLinkSchema)
104379
+ });
104380
+ var GET_CHANNEL_LINK_STATE = "getChannelLinkState";
104381
+ var CREATE_CENTRAL_LINK = "createCentralLink";
104382
+ var REMOVE_CENTRAL_LINK = "removeCentralLink";
104383
+ /** A method the installed library actually has, bound to its facade. */
104384
+ function lookup$1(target, name) {
104385
+ const value = Reflect.get(target, name);
104386
+ if (typeof value !== "function") return null;
104387
+ const fn = (...args) => Reflect.apply(value, target, [...args]);
104388
+ return fn;
104389
+ }
104390
+ function errorMessage$1(err) {
104391
+ return err instanceof Error ? err.message : String(err);
104392
+ }
104393
+ async function write(target, name, address) {
104394
+ const fn = lookup$1(target, name);
104395
+ if (fn === null) return { kind: "unsupported" };
104396
+ try {
104397
+ await fn(address);
104398
+ return { kind: "ok" };
104399
+ } catch (err) {
104400
+ return {
104401
+ kind: "error",
104402
+ message: errorMessage$1(err)
104403
+ };
104404
+ }
104405
+ }
104406
+ /** Adapt a live facade. Missing methods are `unsupported`, never a cast. */
104407
+ function channelLinkPort(target) {
104408
+ return {
104409
+ async getChannelLinkState(address) {
104410
+ const fn = lookup$1(target, GET_CHANNEL_LINK_STATE);
104411
+ if (fn === null) return { kind: "unsupported" };
104412
+ try {
104413
+ const parsed = ChannelLinkStateSchema.safeParse(await fn(address));
104414
+ if (!parsed.success) return {
104415
+ kind: "error",
104416
+ message: "Channel link state did not match the expected shape"
104417
+ };
104418
+ return {
104419
+ kind: "ok",
104420
+ state: parsed.data
104421
+ };
104422
+ } catch (err) {
104423
+ return {
104424
+ kind: "error",
104425
+ message: errorMessage$1(err)
104426
+ };
104427
+ }
104428
+ },
104429
+ createCentralLink: (address) => write(target, CREATE_CENTRAL_LINK, address),
104430
+ removeCentralLink: (address) => write(target, REMOVE_CENTRAL_LINK, address)
104431
+ };
104432
+ }
104433
+ /**
104434
+ * A CCU name on a device or channel (`name: string | null` in nodehomematic
104435
+ * 0.6). 0.5.1 omits the field: that is "no name", not a failure.
104436
+ */
104437
+ function readHmName(value) {
104438
+ if (!("name" in value)) return null;
104439
+ const raw = Reflect.get(value, "name");
104440
+ if (typeof raw !== "string") return null;
104441
+ const trimmed = raw.trim();
104442
+ return trimmed.length > 0 ? trimmed : null;
104443
+ }
104444
+ //#endregion
104445
+ //#region src/ccu/ccu-button-events.ts
104446
+ var UNSUPPORTED = "This CCU library cannot read or change central links yet";
104447
+ function centralOf(read) {
104448
+ if (read.kind === "unsupported") return "unsupported";
104449
+ if (read.kind === "error") return "unknown";
104450
+ return read.state.central ? "on" : "off";
104451
+ }
104452
+ async function keyChannelRow(port, channel) {
104453
+ const read = await port.getChannelLinkState(channel.address);
104454
+ return {
104455
+ address: channel.address,
104456
+ index: channelIndexFromAddress(channel.address) ?? String(channel.index),
104457
+ name: readHmName(channel),
104458
+ central: centralOf(read)
104459
+ };
104460
+ }
104461
+ /** Key-channel central-link rows for adopted devices. Direct links are not touched. */
104462
+ async function keyChannelsForDevice(deps, integrationId, device, adopted) {
104463
+ if (!adopted.has(device.address)) return [];
104464
+ const keys = hmKeyChannels(device);
104465
+ if (keys.length === 0) return [];
104466
+ const port = deps.channelLinks(integrationId);
104467
+ if (port === null) return [];
104468
+ return Promise.all(keys.map((channel) => keyChannelRow(port, channel)));
104469
+ }
104470
+ function withKeyChannels(row, keyChannels) {
104471
+ return {
104472
+ ...row,
104473
+ keyChannels: [...keyChannels]
104474
+ };
104475
+ }
104476
+ /** Enable or disable the central link of one key channel. Other links stay. */
104477
+ function buildButtonEventHandlers(deps) {
104478
+ return { setButtonEvents: async (input) => {
104479
+ requireConfirmed(input.confirmed);
104480
+ requireFacade(deps, input.integrationId);
104481
+ const port = deps.channelLinks(input.integrationId);
104482
+ if (port === null) throw new Error(UNSUPPORTED);
104483
+ const result = input.enabled ? await port.createCentralLink(input.address) : await port.removeCentralLink(input.address);
104484
+ if (result.kind === "unsupported") throw new Error(UNSUPPORTED);
104485
+ if (result.kind === "error") {
104486
+ deps.logger.warn("Homematic central link change failed", { meta: {
104487
+ integrationId: input.integrationId,
104488
+ address: input.address,
104489
+ error: result.message
104490
+ } });
104491
+ throw new Error(result.message);
104492
+ }
104493
+ return { ok: true };
104494
+ } };
104495
+ }
104496
+ //#endregion
103469
104497
  //#region src/ccu/ccu-device-rows.ts
103470
104498
  /** `RSSI_*` reports this when the device has no signal reading. */
103471
104499
  var RSSI_UNKNOWN = 65535;
@@ -103512,7 +104540,8 @@ function toCcuDeviceRow(device) {
103512
104540
  lowBattery: asBool$1(readParam(maintenance, ["LOW_BAT", "LOWBAT"])),
103513
104541
  unreach: asBool$1(readParam(maintenance, ["UNREACH", "STICKY_UNREACH"])),
103514
104542
  configPending: asBool$1(readParam(maintenance, ["CONFIG_PENDING"])),
103515
- sabotage: asBool$1(readParam(maintenance, ["SABOTAGE", "ERROR_SABOTAGE"]))
104543
+ sabotage: asBool$1(readParam(maintenance, ["SABOTAGE", "ERROR_SABOTAGE"])),
104544
+ keyChannels: []
103516
104545
  };
103517
104546
  }
103518
104547
  //#endregion
@@ -103520,7 +104549,12 @@ function toCcuDeviceRow(device) {
103520
104549
  /** The CCU device list: every device the CCU knows, with its radio and maintenance health. */
103521
104550
  function buildCcuDevicesHandlers(deps) {
103522
104551
  return { listCcuDevices: async (input) => {
103523
- return { devices: requireFacade(deps, input.integrationId).devices().map(toCcuDeviceRow) };
104552
+ const facade = requireFacade(deps, input.integrationId);
104553
+ const adopted = await deps.adoptedAddresses(input.integrationId);
104554
+ return { devices: await Promise.all(facade.devices().map(async (device) => {
104555
+ const links = await keyChannelsForDevice(deps, input.integrationId, device, adopted);
104556
+ return withKeyChannels(toCcuDeviceRow(device), links);
104557
+ })) };
103524
104558
  } };
103525
104559
  }
103526
104560
  //#endregion
@@ -103665,6 +104699,24 @@ var AcknowledgeInputSchema = IntegrationRefSchema.extend({
103665
104699
  confirmed: ConfirmedSchema
103666
104700
  });
103667
104701
  var OkResultSchema = object({ ok: literal(true) });
104702
+ var SetButtonEventsInputSchema = IntegrationRefSchema.extend({
104703
+ /** Key-channel address, e.g. `00315F298E5093:1`. */
104704
+ address: string().min(1),
104705
+ enabled: boolean(),
104706
+ confirmed: ConfirmedSchema
104707
+ });
104708
+ /** One key channel's central-link state. `unknown` is a read that failed. */
104709
+ var KeyChannelLinkSchema = object({
104710
+ address: string(),
104711
+ index: string(),
104712
+ name: string().nullable(),
104713
+ central: _enum([
104714
+ "on",
104715
+ "off",
104716
+ "unsupported",
104717
+ "unknown"
104718
+ ])
104719
+ });
103668
104720
  var CcuDevicesResultSchema = object({ devices: array(object({
103669
104721
  address: string(),
103670
104722
  type: string(),
@@ -103685,7 +104737,12 @@ var CcuDevicesResultSchema = object({ devices: array(object({
103685
104737
  lowBattery: boolean().nullable(),
103686
104738
  unreach: boolean().nullable(),
103687
104739
  configPending: boolean().nullable(),
103688
- sabotage: boolean().nullable()
104740
+ sabotage: boolean().nullable(),
104741
+ /**
104742
+ * Key channels of an ADOPTED device, and whether the CCU sends their presses
104743
+ * (a central link). Empty for a device that is not adopted or has no keys.
104744
+ */
104745
+ keyChannels: array(KeyChannelLinkSchema).default([])
103689
104746
  })) });
103690
104747
  /** The group types the CCU can create (nodehomematic `HmGroupCreate.type`). */
103691
104748
  var HEATING_GROUP_TYPES = ["hmip.heating.group", "HomeMatic.heating"];
@@ -127391,6 +128448,10 @@ var homematicActions = defineCustomActions({
127391
128448
  acknowledgeServiceMessage: customAction(AcknowledgeInputSchema, OkResultSchema, {
127392
128449
  kind: "mutation",
127393
128450
  auth: "admin"
128451
+ }),
128452
+ setButtonEvents: customAction(SetButtonEventsInputSchema, OkResultSchema, {
128453
+ kind: "mutation",
128454
+ auth: "admin"
127394
128455
  })
127395
128456
  });
127396
128457
  //#endregion
@@ -127438,7 +128499,7 @@ function inferCallbackHost(ccuHost) {
127438
128499
  var homematicConfigSchema = object({
127439
128500
  host: string().min(1).describe("CCU3 / RaspberryMatic host name or IP address"),
127440
128501
  enableHmipRf: boolean().default(true).describe("Enable Homematic IP (HmIP-RF)"),
127441
- enableBidcosRf: boolean().default(false).describe("Enable Homematic (BidCos-RF)"),
128502
+ enableBidcosRf: boolean().default(false).describe("Enable Homematic (BidCos-RF). HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on"),
127442
128503
  enableGroups: boolean().default(true).describe("Enable groups (heating groups / VirtualDevices)"),
127443
128504
  enableBidcosWired: boolean().default(false).describe("Enable BidCos-Wired (HM-Wired)"),
127444
128505
  username: string().default("Admin").describe("WebUI username (optional — enables names / rooms / sysvars)"),
@@ -127584,6 +128645,8 @@ function buildConnectionFormSchema() {
127584
128645
  key: "enableBidcosRf",
127585
128646
  label: "Enable Homematic (BidCos-RF)",
127586
128647
  labelKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.label",
128648
+ description: "HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on.",
128649
+ descriptionKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.description",
127587
128650
  default: false
127588
128651
  },
127589
128652
  {
@@ -127853,81 +128916,6 @@ var HOMEMATIC_ROWS_TO_RECORD_MIGRATION = {
127853
128916
  })
127854
128917
  };
127855
128918
  //#endregion
127856
- //#region src/homematic-facade-resolver.ts
127857
- /**
127858
- * Per-integration registry that device classes use to reach the live
127859
- * `Homematic` facade (and the session state) of their CCU.
127860
- *
127861
- * The kernel constructs device classes through the `deviceClasses` map with
127862
- * only a `DeviceContext` — it cannot thread the facade in as a constructor
127863
- * arg. The connection lives on the INTEGRATION, so the CCU box and every device
127864
- * adopted from it resolve the same session by `integrationId`. A device
127865
- * persisted without an `integrationId` cannot be attributed to a CCU and
127866
- * resolves nothing.
127867
- */
127868
- var HmFacadeResolver = class {
127869
- #facades = /* @__PURE__ */ new Map();
127870
- #sessions = /* @__PURE__ */ new Map();
127871
- /** Per-integration state-change fan-out (connect, disconnect, error). */
127872
- #snapshotSubs = /* @__PURE__ */ new Map();
127873
- /** Publish or remove the facade for an integration id. `null` removes the entry. */
127874
- set(integrationId, facade) {
127875
- if (facade === null) {
127876
- this.#facades.delete(integrationId);
127877
- return;
127878
- }
127879
- this.#facades.set(integrationId, facade);
127880
- }
127881
- /** The live facade for an integration id, or null when unknown / absent / not running. */
127882
- get(integrationId) {
127883
- if (integrationId === void 0 || integrationId === null) return null;
127884
- return this.#facades.get(integrationId) ?? null;
127885
- }
127886
- /** Publish or remove the session (state + connection) for an integration id. */
127887
- setSession(integrationId, session) {
127888
- if (session === null) {
127889
- this.#sessions.delete(integrationId);
127890
- return;
127891
- }
127892
- this.#sessions.set(integrationId, session);
127893
- }
127894
- /** The session of an integration, or null when it is not registered. */
127895
- getSession(integrationId) {
127896
- if (integrationId === void 0 || integrationId === null) return null;
127897
- return this.#sessions.get(integrationId) ?? null;
127898
- }
127899
- /** Subscribe a device to the state changes of one integration. Returns an unsubscribe fn. */
127900
- onSnapshot(integrationId, cb) {
127901
- let set = this.#snapshotSubs.get(integrationId);
127902
- if (!set) {
127903
- set = /* @__PURE__ */ new Set();
127904
- this.#snapshotSubs.set(integrationId, set);
127905
- }
127906
- set.add(cb);
127907
- return () => {
127908
- const current = this.#snapshotSubs.get(integrationId);
127909
- current?.delete(cb);
127910
- if (current && current.size === 0) this.#snapshotSubs.delete(integrationId);
127911
- };
127912
- }
127913
- /** Fan one state change out to every subscribed device of an integration. */
127914
- emitSnapshot(integrationId) {
127915
- const set = this.#snapshotSubs.get(integrationId);
127916
- if (!set) return;
127917
- for (const cb of [...set]) try {
127918
- cb();
127919
- } catch {}
127920
- }
127921
- /** Remove everything (called on full shutdown). */
127922
- clear() {
127923
- this.#facades.clear();
127924
- this.#sessions.clear();
127925
- this.#snapshotSubs.clear();
127926
- }
127927
- };
127928
- /** The single in-process resolver shared between the integration and its devices. */
127929
- var homematicFacades = new HmFacadeResolver();
127930
- //#endregion
127931
128919
  //#region src/homematic-diagnostics-mapping.ts
127932
128920
  var MAINTENANCE_CHANNEL_TYPE$1 = "MAINTENANCE";
127933
128921
  /** Reachability parameters that drive the Container's `online`, not a child. */
@@ -128058,226 +129046,6 @@ function readReachability(device) {
128058
129046
  return null;
128059
129047
  }
128060
129048
  //#endregion
128061
- //#region src/homematic-mapping.ts
128062
- /**
128063
- * Map a single Homematic channel to its CamStack triplet. The channel
128064
- * `TYPE` is the discriminator. Only the controllable / primary channel
128065
- * types map; status-only `*_TRANSMITTER` mirrors and the various key /
128066
- * remote / week-profile channels return `null` (their datapoints are
128067
- * still decoded into the owning cap's slice via the device's
128068
- * `valueChanged` handler, keyed by parameter name).
128069
- */
128070
- function mapHmChannel(channelType) {
128071
- if (!channelType) return null;
128072
- switch (channelType.toUpperCase()) {
128073
- case "SWITCH_VIRTUAL_RECEIVER": return {
128074
- deviceType: DeviceType.Switch,
128075
- role: null,
128076
- capabilities: ["switch"]
128077
- };
128078
- case "SHUTTER_VIRTUAL_RECEIVER": return {
128079
- deviceType: DeviceType.Cover,
128080
- role: null,
128081
- capabilities: ["cover"]
128082
- };
128083
- case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
128084
- deviceType: DeviceType.Climate,
128085
- role: null,
128086
- capabilities: [
128087
- "climate-control",
128088
- "temperature-sensor",
128089
- "humidity-sensor"
128090
- ]
128091
- };
128092
- case "MOTIONDETECTOR_TRANSCEIVER": return {
128093
- deviceType: DeviceType.Sensor,
128094
- role: DeviceRole.MotionSensor,
128095
- capabilities: ["motion", "ambient-light-sensor"]
128096
- };
128097
- case "DOOR_LOCK_STATE_TRANSMITTER": return {
128098
- deviceType: DeviceType.Lock,
128099
- role: null,
128100
- capabilities: ["lock-control"]
128101
- };
128102
- case "ENERGIE_METER_TRANSMITTER": return {
128103
- deviceType: DeviceType.Sensor,
128104
- role: DeviceRole.PowerSensor,
128105
- capabilities: ["power-meter"]
128106
- };
128107
- case "KEY_TRANSCEIVER":
128108
- case "KEY_TRANSMITTER":
128109
- case "VIRTUAL_KEY":
128110
- case "KEY": return {
128111
- deviceType: DeviceType.EventEmitter,
128112
- role: null,
128113
- capabilities: ["event-emitter"]
128114
- };
128115
- default: return null;
128116
- }
128117
- }
128118
- /**
128119
- * Best-effort parent DeviceType for a whole Homematic device, derived
128120
- * from the union of its channel mappings. Actuators win over sensors so
128121
- * a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
128122
- * Sensor, and a thermostat with a humidity sensor reports as a
128123
- * Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
128124
- * ranked above Sensor so its battery / maintenance sensor channels don't
128125
- * win the parent type. Returns `DeviceType.Generic` when no channel maps.
128126
- */
128127
- var PARENT_TYPE_PRIORITY = [
128128
- DeviceType.Climate,
128129
- DeviceType.Lock,
128130
- DeviceType.Cover,
128131
- DeviceType.Light,
128132
- DeviceType.Switch,
128133
- DeviceType.EventEmitter,
128134
- DeviceType.Sensor
128135
- ];
128136
- function inferHmDeviceType(device) {
128137
- const present = /* @__PURE__ */ new Set();
128138
- for (const channel of device.channels) {
128139
- const mapping = mapHmChannel(channel.type);
128140
- if (mapping) present.add(mapping.deviceType);
128141
- }
128142
- for (const dt of PARENT_TYPE_PRIORITY) if (present.has(dt)) return dt;
128143
- return DeviceType.Generic;
128144
- }
128145
- function mapHmDeviceChannels(device) {
128146
- const out = [];
128147
- for (const channel of device.channels) {
128148
- const mapping = mapHmChannel(channel.type);
128149
- if (mapping) out.push({
128150
- channel,
128151
- mapping
128152
- });
128153
- }
128154
- return out;
128155
- }
128156
- //#endregion
128157
- //#region src/devices/hm-cold-start.ts
128158
- /**
128159
- * Shared cold-start defaults + the key-channel press vocabulary helpers,
128160
- * extracted from the (legacy) flat `homematic-device.ts` so the Container +
128161
- * accessory-child classes reuse the SAME seeds and decoders without
128162
- * duplicating them. Pure: no `BaseDevice` / facade dependency.
128163
- */
128164
- /**
128165
- * Cold-start defaults so reads never miss a slice before the first push.
128166
- * `lastChangedAt: 0` marks each as a PLACEHOLDER — the value is a guess, and
128167
- * consumers read it as unknown. A replayed CCU value is stamped
128168
- * `HM_SEEDED_CHANGED_AT` instead (`hm-change-stamp.ts`).
128169
- */
128170
- var COLD_SWITCH = {
128171
- on: false,
128172
- lastChangedAt: 0
128173
- };
128174
- var COLD_COVER = {
128175
- state: "closed",
128176
- position: null,
128177
- tiltPosition: null,
128178
- lastChangedAt: 0
128179
- };
128180
- var COLD_LOCK = {
128181
- state: "unlocked",
128182
- lastChangedAt: 0
128183
- };
128184
- var COLD_MOTION = {
128185
- detected: false,
128186
- lastDetectedAt: null,
128187
- autoClearAfterMs: null
128188
- };
128189
- /**
128190
- * The motion seed a constructor writes OVER the slice hydrated from the
128191
- * persisted runtime state. The level is a placeholder (`false`) until the
128192
- * CCU says otherwise, but a stored rise is a fact: `lastDetectedAt: null`
128193
- * means "never detected" (`motion.cap.ts`), and a restart must not turn
128194
- * "fired an hour ago" into that.
128195
- */
128196
- function coldMotionKeepingRise(stored) {
128197
- const rise = stored?.lastDetectedAt;
128198
- return {
128199
- ...COLD_MOTION,
128200
- lastDetectedAt: typeof rise === "number" && Number.isFinite(rise) && rise > 0 ? rise : null
128201
- };
128202
- }
128203
- var COLD_CLIMATE = {
128204
- mode: "auto",
128205
- availableModes: [...[
128206
- "off",
128207
- "heat",
128208
- "auto"
128209
- ]],
128210
- fanMode: "",
128211
- availableFanModes: [],
128212
- preset: "",
128213
- availablePresets: ["boost"],
128214
- target: null,
128215
- targetHigh: null,
128216
- targetLow: null,
128217
- targetHumidity: null,
128218
- currentTemp: null,
128219
- currentHumidity: null,
128220
- swingVertical: null,
128221
- swingHorizontal: null,
128222
- lastFetchedAt: 0
128223
- };
128224
- /**
128225
- * The standard HmIP key-channel datapoint vocabulary, used VERBATIM (NO
128226
- * normalization) as the `event-emitter` event types — the native uppercase
128227
- * tokens a `KEY_TRANSCEIVER` / `KEY_TRANSMITTER` / `VIRTUAL_KEY` / `KEY`
128228
- * channel emits on the facade `valueChanged` stream.
128229
- */
128230
- var HM_KEY_PRESS_DATAPOINTS = [
128231
- "PRESS_SHORT",
128232
- "PRESS_LONG",
128233
- "PRESS_LONG_START",
128234
- "PRESS_LONG_RELEASE",
128235
- "PRESS_CONT"
128236
- ];
128237
- /** Set form for O(1) fire-detection membership tests. */
128238
- var HM_KEY_PRESS_SET = new Set(HM_KEY_PRESS_DATAPOINTS);
128239
- /** Cold-start event-emitter slice; vocabulary supplied per-device. */
128240
- function coldEventEmitter(vocabulary) {
128241
- return {
128242
- eventTypes: eventTypesOfVocabulary(vocabulary),
128243
- vocabulary: [...vocabulary],
128244
- lastEvent: null,
128245
- eventCountSinceStart: 0
128246
- };
128247
- }
128248
- /**
128249
- * Collect the union of native `PRESS_*` datapoints a device's key channels
128250
- * support, VERBATIM. Falls back to the standard HmIP key vocabulary when no
128251
- * datapoints were enumerated, so the cap always advertises a non-empty set.
128252
- */
128253
- function keyEventVocabulary(keyChannels) {
128254
- const found = /* @__PURE__ */ new Set();
128255
- for (const channel of keyChannels) for (const dp of channel.dataPoints ?? []) if (HM_KEY_PRESS_SET.has(dp.parameter)) found.add(dp.parameter);
128256
- if (found.size === 0) return HM_KEY_PRESS_DATAPOINTS;
128257
- return HM_KEY_PRESS_DATAPOINTS.filter((dp) => found.has(dp));
128258
- }
128259
- /**
128260
- * The CamStack cap names that are ACTUATORS — driven by the library's typed
128261
- * custom entities (correct channel), NOT by the raw mapped channels. The
128262
- * raw-channel sensor/event loop skips these so they are not double-registered.
128263
- */
128264
- var ACTUATOR_CAP_NAMES = new Set([
128265
- "switch",
128266
- "cover",
128267
- "light",
128268
- "lock-control",
128269
- "climate-control"
128270
- ]);
128271
- /** Parse the numeric channel index suffix (`:N`) from a channel address.
128272
- * Null when absent. Kept as a string for the event payload, mirroring the
128273
- * CCU's `device:index` addressing. */
128274
- function channelIndexFromAddress(channelAddress) {
128275
- const idx = channelAddress.lastIndexOf(":");
128276
- if (idx === -1) return null;
128277
- const suffix = channelAddress.slice(idx + 1);
128278
- return suffix.length > 0 ? suffix : null;
128279
- }
128280
- //#endregion
128281
129049
  //#region src/devices/hm-entity-spec.ts
128282
129050
  var MAINTENANCE_CHANNEL_TYPE = "MAINTENANCE";
128283
129051
  /**
@@ -128456,6 +129224,113 @@ function deriveHmEntitySpecs(device, customEntities) {
128456
129224
  ];
128457
129225
  }
128458
129226
  //#endregion
129227
+ //#region src/devices/hm-primary-child.ts
129228
+ var ACT_PREFIX = "act-";
129229
+ function channelIndex(key) {
129230
+ const suffix = channelIndexFromAddress(key.slice(4));
129231
+ if (suffix === null) return Number.MAX_SAFE_INTEGER;
129232
+ const parsed = Number(suffix);
129233
+ return Number.isFinite(parsed) ? parsed : Number.MAX_SAFE_INTEGER;
129234
+ }
129235
+ /**
129236
+ * Which child a Homematic container stands for.
129237
+ *
129238
+ * A device with relay channels stands for the first relay (lowest channel
129239
+ * index), so a two-relay switch is not left to the namesake tie-break. A
129240
+ * key-only device (no actuator) stands for its event-emitter. Anything else
129241
+ * declares nothing and the shared heuristic decides.
129242
+ */
129243
+ function hmPrimaryChildKeys(specs) {
129244
+ const first = specs.filter((spec) => spec.key.startsWith(ACT_PREFIX) && spec.config["kind"] === "switch").toSorted((a, b) => channelIndex(a.key) - channelIndex(b.key))[0];
129245
+ if (first !== void 0) return [first.key];
129246
+ if (specs.some((spec) => spec.key.startsWith(ACT_PREFIX))) return [];
129247
+ return specs.some((spec) => spec.key === "events") ? ["events"] : [];
129248
+ }
129249
+ /**
129250
+ * The preference to write, or null when the container already has one or
129251
+ * there is nothing to declare. An operator pick is a different column.
129252
+ */
129253
+ function preferenceToStamp(stored, declared) {
129254
+ if (stored !== void 0 && stored.length > 0) return null;
129255
+ if (declared.length === 0) return null;
129256
+ return declared;
129257
+ }
129258
+ //#endregion
129259
+ //#region src/homematic-facade-resolver.ts
129260
+ /**
129261
+ * Per-integration registry that device classes use to reach the live
129262
+ * `Homematic` facade (and the session state) of their CCU.
129263
+ *
129264
+ * The kernel constructs device classes through the `deviceClasses` map with
129265
+ * only a `DeviceContext` — it cannot thread the facade in as a constructor
129266
+ * arg. The connection lives on the INTEGRATION, so the CCU box and every device
129267
+ * adopted from it resolve the same session by `integrationId`. A device
129268
+ * persisted without an `integrationId` cannot be attributed to a CCU and
129269
+ * resolves nothing.
129270
+ */
129271
+ var HmFacadeResolver = class {
129272
+ #facades = /* @__PURE__ */ new Map();
129273
+ #sessions = /* @__PURE__ */ new Map();
129274
+ /** Per-integration state-change fan-out (connect, disconnect, error). */
129275
+ #snapshotSubs = /* @__PURE__ */ new Map();
129276
+ /** Publish or remove the facade for an integration id. `null` removes the entry. */
129277
+ set(integrationId, facade) {
129278
+ if (facade === null) {
129279
+ this.#facades.delete(integrationId);
129280
+ return;
129281
+ }
129282
+ this.#facades.set(integrationId, facade);
129283
+ }
129284
+ /** The live facade for an integration id, or null when unknown / absent / not running. */
129285
+ get(integrationId) {
129286
+ if (integrationId === void 0 || integrationId === null) return null;
129287
+ return this.#facades.get(integrationId) ?? null;
129288
+ }
129289
+ /** Publish or remove the session (state + connection) for an integration id. */
129290
+ setSession(integrationId, session) {
129291
+ if (session === null) {
129292
+ this.#sessions.delete(integrationId);
129293
+ return;
129294
+ }
129295
+ this.#sessions.set(integrationId, session);
129296
+ }
129297
+ /** The session of an integration, or null when it is not registered. */
129298
+ getSession(integrationId) {
129299
+ if (integrationId === void 0 || integrationId === null) return null;
129300
+ return this.#sessions.get(integrationId) ?? null;
129301
+ }
129302
+ /** Subscribe a device to the state changes of one integration. Returns an unsubscribe fn. */
129303
+ onSnapshot(integrationId, cb) {
129304
+ let set = this.#snapshotSubs.get(integrationId);
129305
+ if (!set) {
129306
+ set = /* @__PURE__ */ new Set();
129307
+ this.#snapshotSubs.set(integrationId, set);
129308
+ }
129309
+ set.add(cb);
129310
+ return () => {
129311
+ const current = this.#snapshotSubs.get(integrationId);
129312
+ current?.delete(cb);
129313
+ if (current && current.size === 0) this.#snapshotSubs.delete(integrationId);
129314
+ };
129315
+ }
129316
+ /** Fan one state change out to every subscribed device of an integration. */
129317
+ emitSnapshot(integrationId) {
129318
+ const set = this.#snapshotSubs.get(integrationId);
129319
+ if (!set) return;
129320
+ for (const cb of [...set]) try {
129321
+ cb();
129322
+ } catch {}
129323
+ }
129324
+ /** Remove everything (called on full shutdown). */
129325
+ clear() {
129326
+ this.#facades.clear();
129327
+ this.#sessions.clear();
129328
+ this.#snapshotSubs.clear();
129329
+ }
129330
+ };
129331
+ /** The single in-process resolver shared between the integration and its devices. */
129332
+ var homematicFacades = new HmFacadeResolver();
129333
+ //#endregion
128459
129334
  //#region src/devices/hm-child-device.ts
128460
129335
  /**
128461
129336
  * Persisted config every Homematic accessory CHILD carries. `address` is the
@@ -128729,28 +129604,37 @@ var HmChildDevice = class extends BaseDevice {
128729
129604
  this.seedTriggerUnsubs = [];
128730
129605
  }
128731
129606
  };
128732
- //#endregion
128733
- //#region src/homematic-decode.ts
128734
- /** HmIP `CONTROL_MODE` ENUM index → library climate mode. Numeric-arm
128735
- * fallback only (see {@link fromHmControlMode}) — the wire index, used
128736
- * when the value list did not resolve. */
128737
- var HM_CONTROL_MODE_BY_INDEX = {
129607
+ function isHmOffSetpoint(target) {
129608
+ return target !== null && target <= 4.5;
129609
+ }
129610
+ /**
129611
+ * HmIP `SET_POINT_MODE` index → library climate mode.
129612
+ *
129613
+ * Observed 2026-11-13 via `getParamsetDescription` on `INT0000001:1`: the
129614
+ * datapoint is `TYPE INTEGER`, `MIN 0`, `MAX 3`, with no value list. The
129615
+ * live CCU therefore delivers the index, not a name.
129616
+ * 0 auto, 1 manual heat, 2 party (a timed override — still auto).
129617
+ * 3 is absent: unknown, so {@link fromHmSetPointMode} returns null and the
129618
+ * caller keeps the previous mode.
129619
+ * `CONTROL_MODE` is write-only on HmIP heating groups and always reads `0`;
129620
+ * mode is read from here.
129621
+ */
129622
+ var HM_SET_POINT_MODE_BY_INDEX = {
128738
129623
  0: "auto",
128739
129624
  1: "heat",
128740
- 2: "heat",
128741
- 3: "heat"
129625
+ 2: "auto"
128742
129626
  };
128743
129627
  /**
128744
- * HmIP `CONTROL_MODE` ENUM member (the CONVERTED value the library hands
128745
- * over — `nodehomematic` resolves the value list, same as `LOCK_STATE` /
128746
- * `ACTIVITY_STATE`, see {@link readLockState} / {@link readTravel}) →
128747
- * library climate mode. Matched BY NAME, case-insensitively.
129628
+ * Name form, accepted only when a string arrives (a value list that did
129629
+ * resolve). Matched case-insensitively. `PARTY` is the timed override and
129630
+ * stays auto, matching index 2.
128748
129631
  */
128749
- var HM_CONTROL_MODE_BY_NAME = {
129632
+ var HM_SET_POINT_MODE_BY_NAME = {
129633
+ AUTO: "auto",
128750
129634
  "AUTO-MODE": "auto",
129635
+ MANU: "heat",
128751
129636
  "MANU-MODE": "heat",
128752
- "PARTY-MODE": "heat",
128753
- "BOOST-MODE": "heat"
129637
+ PARTY: "auto"
128754
129638
  };
128755
129639
  /** Map a CamStack `HvacMode` to the library's narrower climate mode. */
128756
129640
  function toHmClimateMode(mode) {
@@ -128762,22 +129646,20 @@ function toHmClimateMode(mode) {
128762
129646
  }
128763
129647
  }
128764
129648
  /**
128765
- * Map a library climate mode back to the CamStack `HvacMode`.
129649
+ * Map a Homematic `SET_POINT_MODE` value to the CamStack `HvacMode`.
128766
129650
  *
128767
- * Like {@link readLockState} / {@link readTravel}, the library delivers a
128768
- * CONVERTED ENUM string on the live CCU (`'AUTO-MODE'` etc) — testing
128769
- * `typeof value === 'number'` alone meant a resolved `CONTROL_MODE` never
128770
- * decoded at all. The numeric arm survives for a datapoint whose value
128771
- * list did not resolve.
129651
+ * The live CCU sends the integer index (see {@link HM_SET_POINT_MODE_BY_INDEX}).
129652
+ * A string is accepted only when one arrives (`AUTO` / `AUTO-MODE`,
129653
+ * `MANU` / `MANU-MODE`). Index 3 and any other unknown value return null.
128772
129654
  */
128773
- function fromHmControlMode(value) {
129655
+ function fromHmSetPointMode(value) {
128774
129656
  if (typeof value === "string") {
128775
- const mode = HM_CONTROL_MODE_BY_NAME[value.toUpperCase()];
129657
+ const mode = HM_SET_POINT_MODE_BY_NAME[value.toUpperCase()];
128776
129658
  if (mode === void 0) return null;
128777
129659
  return mode === "auto" ? "auto" : "heat";
128778
129660
  }
128779
129661
  if (typeof value !== "number") return null;
128780
- const mode = HM_CONTROL_MODE_BY_INDEX[value];
129662
+ const mode = HM_SET_POINT_MODE_BY_INDEX[value];
128781
129663
  if (mode === void 0) return null;
128782
129664
  return mode === "auto" ? "auto" : "heat";
128783
129665
  }
@@ -128923,12 +129805,19 @@ function decodeLock(parameter, value, now) {
128923
129805
  /**
128924
129806
  * Decode a climate datapoint into a ClimateControlStatus patch.
128925
129807
  * Parameters: SET_POINT_TEMPERATURE (target °C), ACTUAL_TEMPERATURE
128926
- * (current °C), HUMIDITY (%), CONTROL_MODE (ENUM), BOOST_MODE (bool).
129808
+ * (current °C), HUMIDITY (%), SET_POINT_MODE (ENUM, readable mode),
129809
+ * BOOST_MODE (bool). `CONTROL_MODE` is write-only on HmIP and ignored here.
128927
129810
  */
129811
+ function modeWithHmOffTarget(previous, target) {
129812
+ if (isHmOffSetpoint(target)) return previous.mode === "auto" ? "auto" : "off";
129813
+ if (previous.mode === "off") return previous.lastActiveMode ?? "heat";
129814
+ return previous.mode;
129815
+ }
128928
129816
  function decodeClimate(previous, parameter, value, now) {
128929
129817
  if (parameter === "SET_POINT_TEMPERATURE" && typeof value === "number") return {
128930
129818
  ...previous,
128931
129819
  target: value,
129820
+ mode: modeWithHmOffTarget(previous, value),
128932
129821
  lastFetchedAt: now
128933
129822
  };
128934
129823
  if (parameter === "ACTUAL_TEMPERATURE" && typeof value === "number") return {
@@ -128941,12 +129830,13 @@ function decodeClimate(previous, parameter, value, now) {
128941
129830
  currentHumidity: value,
128942
129831
  lastFetchedAt: now
128943
129832
  };
128944
- if (parameter === "CONTROL_MODE") {
128945
- const mode = fromHmControlMode(value);
129833
+ if (parameter === "SET_POINT_MODE") {
129834
+ const mode = fromHmSetPointMode(value);
128946
129835
  if (mode === null) return null;
129836
+ const resolved = mode === "heat" && isHmOffSetpoint(previous.target) ? "off" : mode;
128947
129837
  return {
128948
129838
  ...previous,
128949
- mode,
129839
+ mode: resolved,
128950
129840
  lastFetchedAt: now
128951
129841
  };
128952
129842
  }
@@ -129007,6 +129897,8 @@ var HmActuatorDevice = class extends HmChildDevice {
129007
129897
  kind;
129008
129898
  /** The actuator cap name actually registered (drives decode routing). */
129009
129899
  registeredCap = null;
129900
+ /** Last setpoint above {@link HM_OFF_SETPOINT_C}; HmIP OFF leaves target at 4.5. */
129901
+ climateRestoreTargetC = null;
129010
129902
  constructor(ctx) {
129011
129903
  super(ctx, hmActuatorSchema);
129012
129904
  this.kind = this.config.values.kind;
@@ -129087,9 +129979,18 @@ var HmActuatorDevice = class extends HmChildDevice {
129087
129979
  const provider = {
129088
129980
  getStatus: async () => this.runtimeState.getCapState("climate-control") ?? COLD_CLIMATE,
129089
129981
  setMode: async ({ mode }) => {
129090
- await this.requireFacade().climateSetMode(this.address, channel, toHmClimateMode(mode));
129982
+ const facade = this.requireFacade();
129983
+ const prev = this.runtimeState.getCapState("climate-control") ?? COLD_CLIMATE;
129984
+ const hmMode = toHmClimateMode(mode);
129985
+ if (hmMode === "off" && prev.target !== null && prev.target > 4.5) this.climateRestoreTargetC = prev.target;
129986
+ await facade.climateSetMode(this.address, channel, hmMode);
129987
+ if (mode === "heat" && (prev.mode === "off" || isHmOffSetpoint(prev.target))) {
129988
+ const restore = this.climateRestoreTargetC ?? 21;
129989
+ await facade.climateSetTemperature(this.address, channel, restore);
129990
+ }
129091
129991
  },
129092
129992
  setTarget: async ({ target }) => {
129993
+ if (target > 4.5) this.climateRestoreTargetC = target;
129093
129994
  await this.requireFacade().climateSetTemperature(this.address, channel, target);
129094
129995
  },
129095
129996
  setPreset: async ({ preset }) => {
@@ -129123,7 +130024,17 @@ var HmActuatorDevice = class extends HmChildDevice {
129123
130024
  if (cap === "lock-control") return this.applyLock(parameter, value, now, origin);
129124
130025
  if (cap === "climate-control") {
129125
130026
  const next = decodeClimate(this.runtimeState.getCapState("climate-control") ?? COLD_CLIMATE, parameter, value, now);
129126
- if (next) this.runtimeState.setCapState("climate-control", next);
130027
+ if (next === null && parameter === "SET_POINT_MODE") this.ctx.logger.debug("Homematic climate: SET_POINT_MODE unknown — mode unchanged", {
130028
+ tags: { deviceId: this.id },
130029
+ meta: {
130030
+ value,
130031
+ valueType: typeof value
130032
+ }
130033
+ });
130034
+ if (next) {
130035
+ if (next.target !== null && next.target > 4.5) this.climateRestoreTargetC = next.target;
130036
+ this.runtimeState.setCapState("climate-control", next);
130037
+ }
129127
130038
  }
129128
130039
  }
129129
130040
  applyCover(parameter, value, now, origin) {
@@ -129320,65 +130231,9 @@ var HmSensorDevice = class extends HmChildDevice {
129320
130231
  }
129321
130232
  };
129322
130233
  //#endregion
129323
- //#region src/devices/hm-key-vocabulary.ts
129324
- var PRESS_MEANING = {
129325
- PRESS_SHORT: {
129326
- label: "Short press",
129327
- kind: "press"
129328
- },
129329
- PRESS_LONG: {
129330
- label: "Long press",
129331
- kind: "long-press"
129332
- },
129333
- PRESS_LONG_START: {
129334
- label: "Long press started",
129335
- kind: "long-press-start"
129336
- },
129337
- PRESS_LONG_RELEASE: {
129338
- label: "Long press released",
129339
- kind: "release"
129340
- },
129341
- PRESS_CONT: {
129342
- label: "Long press held",
129343
- kind: "repeat"
129344
- }
129345
- };
129346
- /** The channels of a device that are buttons, in channel order. */
129347
- function hmKeyChannels(device) {
129348
- return mapHmDeviceChannels(device).filter(({ mapping }) => mapping.capabilities.includes("event-emitter")).map(({ channel }) => channel);
129349
- }
129350
- /** The presses one key channel has; the standard set when it lists none. */
129351
- function pressesOf(channel) {
129352
- const listed = new Set((channel.dataPoints ?? []).map((dataPoint) => dataPoint.parameter).filter((parameter) => HM_KEY_PRESS_SET.has(parameter)));
129353
- if (listed.size === 0) return HM_KEY_PRESS_DATAPOINTS;
129354
- return HM_KEY_PRESS_DATAPOINTS.filter((parameter) => listed.has(parameter));
129355
- }
129356
- function entryOf(parameter, source) {
129357
- const meaning = PRESS_MEANING[parameter];
129358
- if (meaning === void 0) return {
129359
- id: parameter,
129360
- source,
129361
- label: parameter
129362
- };
129363
- return {
129364
- id: parameter,
129365
- source,
129366
- label: meaning.label,
129367
- kind: meaning.kind
129368
- };
129369
- }
129370
- function hmKeyVocabulary(device) {
129371
- return hmKeyChannels(device).flatMap((channel, position) => {
129372
- const index = channelIndexFromAddress(channel.address) ?? String(channel.index);
129373
- const source = {
129374
- id: index,
129375
- label: `Button ${position + 1} (channel ${index})`
129376
- };
129377
- return pressesOf(channel).map((parameter) => entryOf(parameter, source));
129378
- });
129379
- }
129380
- //#endregion
129381
130234
  //#region src/devices/hm-event-emitter-device.ts
130235
+ /** Shown on the Buttons child when none of its key channels has a central link. */
130236
+ var BUTTON_EVENTS_HINT = "The CCU does not send these presses — enable button events on the CCU page";
129382
130237
  /**
129383
130238
  * Event-emitter child config: the persisted native press vocabulary for the
129384
130239
  * device's key channels. Stored at adoption so the cap advertises the right
@@ -129400,6 +130255,10 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129400
130255
  #declared = null;
129401
130256
  /** Fires already reported as outside the vocabulary, as `source:token`. */
129402
130257
  #undeclaredLogged = /* @__PURE__ */ new Set();
130258
+ /** Key channels that have delivered a press since this process started. */
130259
+ #pressSeen = /* @__PURE__ */ new Set();
130260
+ /** True once we know every key channel lacks a central link. */
130261
+ #centralLinkMissing = false;
129403
130262
  #eventSeq = 0;
129404
130263
  #eventCount = 0;
129405
130264
  /** Unsubscribe for the integration's state-change fan-out. */
@@ -129410,7 +130269,29 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129410
130269
  this.persistedEventTypes = persisted && persisted.length > 0 ? persisted : HM_KEY_PRESS_DATAPOINTS;
129411
130270
  this.registerEventEmitterCap();
129412
130271
  this.attachValueChangedListener((event) => this.decodeKeyPress(event));
129413
- if (this.integrationId !== void 0) this.#snapshotUnsub = homematicFacades.onSnapshot(this.integrationId, () => this.refreshDeclaredVocabulary());
130272
+ if (this.integrationId !== void 0) this.#snapshotUnsub = homematicFacades.onSnapshot(this.integrationId, () => {
130273
+ this.refreshDeclaredVocabulary();
130274
+ this.refreshCentralLinks();
130275
+ });
130276
+ this.refreshCentralLinks();
130277
+ }
130278
+ getSettingsUISchema() {
130279
+ if (!this.#centralLinkMissing) return { sections: [] };
130280
+ return { sections: [{
130281
+ id: "button-events",
130282
+ title: "Button events",
130283
+ titleKey: "provider-homematic:device.buttonEvents.title",
130284
+ columns: 1,
130285
+ fields: [{
130286
+ type: "info",
130287
+ key: "buttonEventsHint",
130288
+ label: "Button events",
130289
+ labelKey: "provider-homematic:device.buttonEvents.hint.label",
130290
+ content: BUTTON_EVENTS_HINT,
130291
+ contentKey: "provider-homematic:device.buttonEvents.hint.content",
130292
+ variant: "warning"
130293
+ }]
130294
+ }] };
129414
130295
  }
129415
130296
  /**
129416
130297
  * Rewrite the slice with the buttons once the CCU's channel list carries
@@ -129418,12 +130299,62 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129418
130299
  */
129419
130300
  refreshDeclaredVocabulary() {
129420
130301
  if (this.#declared !== null) return;
129421
- const vocabulary = this.vocabulary();
130302
+ this.vocabulary();
129422
130303
  if (this.#declared === null) return;
130304
+ const published = this.publishedVocabulary();
129423
130305
  const current = this.runtimeState.getCapState("event-emitter");
129424
130306
  this.runtimeState.setCapState("event-emitter", {
129425
- eventTypes: eventTypesOfVocabulary(vocabulary),
129426
- vocabulary: [...vocabulary],
130307
+ eventTypes: eventTypesOfVocabulary(published),
130308
+ vocabulary: [...published],
130309
+ lastEvent: current?.lastEvent ?? null,
130310
+ eventCountSinceStart: current?.eventCountSinceStart ?? 0
130311
+ });
130312
+ }
130313
+ /** The live vocabulary, plus the central-link hint when the CCU sends nothing. */
130314
+ publishedVocabulary() {
130315
+ const vocabulary = this.vocabulary();
130316
+ if (!this.#centralLinkMissing) return vocabulary;
130317
+ return vocabulary.map((entry) => ({
130318
+ ...entry,
130319
+ description: BUTTON_EVENTS_HINT
130320
+ }));
130321
+ }
130322
+ /**
130323
+ * Ask the facade whether each key channel has a central link. A library
130324
+ * that cannot answer (`unsupported`) leaves the hint off: absence of the
130325
+ * method is not evidence the CCU is silent.
130326
+ */
130327
+ async refreshCentralLinks() {
130328
+ const facade = this.integrationId === void 0 ? null : homematicFacades.get(this.integrationId);
130329
+ const device = this.resolveHmDevice();
130330
+ if (facade === null || device === null) return;
130331
+ const keys = hmKeyChannels(device);
130332
+ if (keys.length === 0) return;
130333
+ const port = channelLinkPort(facade);
130334
+ let missing = false;
130335
+ for (const channel of keys) {
130336
+ const read = await port.getChannelLinkState(channel.address);
130337
+ if (read.kind === "unsupported") return;
130338
+ if (read.kind === "error") {
130339
+ this.ctx.logger.warn("Homematic key channel link state could not be read", {
130340
+ tags: { deviceId: this.ctx.id },
130341
+ meta: {
130342
+ address: this.address,
130343
+ channel: channel.address,
130344
+ error: read.message
130345
+ }
130346
+ });
130347
+ return;
130348
+ }
130349
+ if (!read.state.central) missing = true;
130350
+ }
130351
+ if (missing === this.#centralLinkMissing) return;
130352
+ this.#centralLinkMissing = missing;
130353
+ const current = this.runtimeState.getCapState("event-emitter");
130354
+ const published = this.publishedVocabulary();
130355
+ this.runtimeState.setCapState("event-emitter", {
130356
+ eventTypes: eventTypesOfVocabulary(published),
130357
+ vocabulary: [...published],
129427
130358
  lastEvent: current?.lastEvent ?? null,
129428
130359
  eventCountSinceStart: current?.eventCountSinceStart ?? 0
129429
130360
  });
@@ -129435,7 +130366,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129435
130366
  }
129436
130367
  registerEventEmitterCap() {
129437
130368
  this.ctx.registerNativeCap(eventEmitterCapability, { getStatus: async () => this.runtimeState.getCapState("event-emitter") ?? coldEventEmitter(this.vocabulary()) });
129438
- this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.vocabulary()));
130369
+ this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.publishedVocabulary()));
129439
130370
  }
129440
130371
  /**
129441
130372
  * The buttons and their presses, read LIVE from the CCU's channel list.
@@ -129469,6 +130400,11 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129469
130400
  }
129470
130401
  });
129471
130402
  }
130403
+ keyChannelAddresses() {
130404
+ const device = this.resolveHmDevice();
130405
+ if (device === null) return /* @__PURE__ */ new Set();
130406
+ return new Set(hmKeyChannels(device).map((channel) => channel.address));
130407
+ }
129472
130408
  /**
129473
130409
  * Translate a key-channel `PRESS_*` datapoint into an `EventFire`: emit
129474
130410
  * `EventCategory.EventEmitted` on the bus and write the `event-emitter`
@@ -129480,8 +130416,36 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129480
130416
  decodeKeyPress(event) {
129481
130417
  const now = event.ts || Date.now();
129482
130418
  const { parameter, value, channel } = event;
129483
- if (!HM_KEY_PRESS_SET.has(parameter)) return;
129484
- if (typeof value === "boolean" && value === false) return;
130419
+ const isPress = HM_KEY_PRESS_SET.has(parameter);
130420
+ if (!(isPress || this.keyChannelAddresses().has(channel))) return;
130421
+ if (!(isPress && !(typeof value === "boolean" && value === false))) {
130422
+ this.ctx.logger.debug("Homematic key channel value changed but decoded to no press", {
130423
+ tags: { deviceId: this.ctx.id },
130424
+ meta: {
130425
+ channel,
130426
+ parameter,
130427
+ ...isPress ? { press: parameter } : {}
130428
+ }
130429
+ });
130430
+ return;
130431
+ }
130432
+ this.ctx.logger.debug("Homematic key press received", {
130433
+ tags: { deviceId: this.ctx.id },
130434
+ meta: {
130435
+ channel,
130436
+ press: parameter
130437
+ }
130438
+ });
130439
+ if (!this.#pressSeen.has(channel)) {
130440
+ this.#pressSeen.add(channel);
130441
+ this.ctx.logger.info("Homematic key channel delivered its first press since start", {
130442
+ tags: { deviceId: this.ctx.id },
130443
+ meta: {
130444
+ channel,
130445
+ press: parameter
130446
+ }
130447
+ });
130448
+ }
129485
130449
  const channelIndex = channelIndexFromAddress(channel);
129486
130450
  const fire = {
129487
130451
  deviceId: this.id,
@@ -129497,7 +130461,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
129497
130461
  deviceId: this.id,
129498
130462
  addonId: this.ctx.deviceMeta.addonId
129499
130463
  }, fire));
129500
- const vocabulary = this.vocabulary();
130464
+ const vocabulary = this.publishedVocabulary();
129501
130465
  this.noteUndeclared(vocabulary, parameter, channelIndex);
129502
130466
  const slice = {
129503
130467
  eventTypes: eventTypesOfVocabulary(vocabulary),
@@ -129801,6 +130765,43 @@ var HmChildDispatcher = class {
129801
130765
  /** The documented boundary-cast export used in the `deviceClasses` restore map. */
129802
130766
  var hmChildDeviceClass = HmChildDispatcher;
129803
130767
  //#endregion
130768
+ //#region src/devices/hm-child-name.ts
130769
+ /**
130770
+ * Display name of one actuator child.
130771
+ *
130772
+ * A single actuator keeps the container's name (the caller passes it). A
130773
+ * multi-actuator child uses the CCU channel name when the facade has one,
130774
+ * otherwise `"<container> ch<index>"`. Never the channel address.
130775
+ */
130776
+ function multiActuatorChildName(input) {
130777
+ if (input.channelName !== null) return input.channelName;
130778
+ const index = input.channelIndex ?? "?";
130779
+ return `${input.containerName} ch${index}`;
130780
+ }
130781
+ /** The name this addon used to give a multi-actuator child: container + raw address. */
130782
+ function legacyActuatorName(containerName, channelAddress) {
130783
+ return `${containerName} ${channelAddress}`;
130784
+ }
130785
+ /**
130786
+ * Whether an already-adopted actuator may take the new auto name.
130787
+ *
130788
+ * An operator rename (`userNamed`, or a legacy row whose name is not one of
130789
+ * the auto forms) is left alone. A name that is still the generated address
130790
+ * form, the `ch<index>` form, or the stable-id placeholder is replaced.
130791
+ * `stampUserNamed` is true only when the row is already flagged user-named:
130792
+ * the device-manager refuses a system rename of those rows, and accessory
130793
+ * registration stamps the flag on every non-placeholder name.
130794
+ */
130795
+ function actuatorNameWrite(input) {
130796
+ if (input.currentName === input.desiredName) return { kind: "keep" };
130797
+ if (!(input.currentName === input.legacyAutoName || input.currentName === input.fallbackAutoName || input.currentName === input.stableId) && (input.userNamed === true || input.userNamed === void 0)) return { kind: "keep" };
130798
+ return {
130799
+ kind: "rename",
130800
+ name: input.desiredName,
130801
+ stampUserNamed: input.userNamed === true
130802
+ };
130803
+ }
130804
+ //#endregion
129804
130805
  //#region src/devices/hm-container-device.ts
129805
130806
  /**
129806
130807
  * Persisted config for a Homematic Container (the parent of one physical CCU
@@ -129833,6 +130834,8 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
129833
130834
  integrationId;
129834
130835
  /** Unsubscribe for the facade `valueChanged` reachability listener. */
129835
130836
  valueChangedUnsub = null;
130837
+ /** Unsubscribe for the session fan-out that re-stamps names once the CCU answers. */
130838
+ reconcileUnsub = null;
129836
130839
  constructor(ctx) {
129837
130840
  const cfg = hmContainerSchema.parse(ctx.persistedConfig ?? {});
129838
130841
  super(ctx, hmContainerSchema, { type: DeviceType.Container });
@@ -129879,7 +130882,16 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
129879
130882
  if (this.online !== next) this.markOnline(next);
129880
130883
  });
129881
130884
  }
130885
+ async onActivate() {
130886
+ await super.onActivate();
130887
+ await this.reconcileDerived();
130888
+ this.reconcileUnsub = homematicFacades.onSnapshot(this.integrationId, () => {
130889
+ this.reconcileDerived();
130890
+ });
130891
+ }
129882
130892
  async removeDevice() {
130893
+ this.reconcileUnsub?.();
130894
+ this.reconcileUnsub = null;
129883
130895
  if (this.valueChangedUnsub) {
129884
130896
  try {
129885
130897
  this.valueChangedUnsub();
@@ -129916,11 +130928,96 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
129916
130928
  const specs = deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((e) => e.device === this.address) ?? []);
129917
130929
  const multipleActuators = specs.filter((s) => s.key.startsWith("act-")).map((s) => s.key).length > 1;
129918
130930
  return specs.map((spec) => {
129919
- if (!spec.key.startsWith("act-")) return this.childSpec(spec);
129920
- const suffix = multipleActuators ? ` ${spec.key.slice(4)}` : "";
129921
- return this.childSpec(spec, `${this.name}${suffix}`);
130931
+ if (!spec.key.startsWith("act-") || !multipleActuators) return this.childSpec(spec, spec.key.startsWith("act-") ? this.name : void 0);
130932
+ return this.childSpec(spec, this.actuatorName(hmDevice, spec));
130933
+ });
130934
+ }
130935
+ /** CCU channel name, else `"<container> ch<index>"`. Never the raw address. */
130936
+ actuatorName(hmDevice, spec) {
130937
+ const channelAddress = spec.key.slice(4);
130938
+ const channel = hmDevice.channels.find((candidate) => candidate.address === channelAddress);
130939
+ const index = channel !== void 0 ? String(channel.index) : channelIndexFromAddress(channelAddress);
130940
+ return multiActuatorChildName({
130941
+ containerName: this.name,
130942
+ channelName: channel === void 0 ? null : readHmName(channel),
130943
+ channelIndex: index
129922
130944
  });
129923
130945
  }
130946
+ async reconcileDerived() {
130947
+ const hmDevice = this.resolveHmDevice();
130948
+ if (hmDevice === null) return;
130949
+ try {
130950
+ await this.stampPrimaryPreference(hmDevice);
130951
+ await this.refreshActuatorNames(hmDevice);
130952
+ } catch (err) {
130953
+ this.ctx.logger.warn("HmContainerDevice: could not refresh derived child meta", {
130954
+ tags: { deviceId: this.id },
130955
+ meta: {
130956
+ address: this.address,
130957
+ error: errMsg(err)
130958
+ }
130959
+ });
130960
+ }
130961
+ }
130962
+ async stampPrimaryPreference(hmDevice) {
130963
+ const manager = this.ctx.api?.deviceManager;
130964
+ if (manager === void 0) return;
130965
+ const declared = hmPrimaryChildKeys(deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((entity) => entity.device === this.address) ?? []));
130966
+ const keys = preferenceToStamp(this.ctx.deviceMeta.primaryChildPreference, declared);
130967
+ if (keys === null) return;
130968
+ await manager.setPrimaryChildPreference.mutate({
130969
+ deviceId: this.id,
130970
+ primaryChildPreference: keys
130971
+ });
130972
+ this.ctx.logger.info("Homematic container stamped its primary child", {
130973
+ tags: { deviceId: this.id },
130974
+ meta: {
130975
+ address: this.address,
130976
+ primaryChildPreference: keys
130977
+ }
130978
+ });
130979
+ }
130980
+ async refreshActuatorNames(hmDevice) {
130981
+ const manager = this.ctx.api?.deviceManager;
130982
+ if (manager === void 0) return;
130983
+ const specs = deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((entity) => entity.device === this.address) ?? []).filter((spec) => spec.key.startsWith("act-"));
130984
+ if (specs.length < 2) return;
130985
+ const children = await manager.getChildren.query({ parentDeviceId: this.id });
130986
+ for (const spec of specs) {
130987
+ const child = children.find((candidate) => candidate.stableId.endsWith(`-${spec.key}`));
130988
+ if (child === void 0) continue;
130989
+ const meta = await manager.loadMeta.query({ deviceId: child.id });
130990
+ if (meta === null) continue;
130991
+ const channelAddress = spec.key.slice(4);
130992
+ const desired = this.actuatorName(hmDevice, spec);
130993
+ const decision = actuatorNameWrite({
130994
+ currentName: meta.name,
130995
+ userNamed: meta.userNamed,
130996
+ desiredName: desired,
130997
+ legacyAutoName: legacyActuatorName(this.name, channelAddress),
130998
+ fallbackAutoName: multiActuatorChildName({
130999
+ containerName: this.name,
131000
+ channelName: null,
131001
+ channelIndex: channelIndexFromAddress(channelAddress)
131002
+ }),
131003
+ stableId: child.stableId
131004
+ });
131005
+ if (decision.kind === "keep") continue;
131006
+ await manager.setName.mutate({
131007
+ deviceId: child.id,
131008
+ name: decision.name,
131009
+ ...decision.stampUserNamed ? {} : { stampUserNamed: false }
131010
+ });
131011
+ this.ctx.logger.info("Homematic actuator child took its channel name", {
131012
+ tags: { deviceId: child.id },
131013
+ meta: {
131014
+ address: this.address,
131015
+ channel: channelAddress,
131016
+ name: decision.name
131017
+ }
131018
+ });
131019
+ }
131020
+ }
129924
131021
  /** Wrap one {@link HmEntitySpec} into an accessory-child spec, stamping the
129925
131022
  * CCU `address` + integration FK onto config and the container link
129926
131023
  * + integration + type/role onto meta. */
@@ -131583,6 +132680,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131583
132680
  ...buildCcuHeatingHandlers(this.ccuActionDeps()),
131584
132681
  ...buildCcuPairingHandlers(this.ccuActionDeps()),
131585
132682
  ...buildCcuConfigHandlers(this.ccuActionDeps()),
132683
+ ...buildButtonEventHandlers(this.ccuActionDeps()),
131586
132684
  discoverCcu: async () => {
131587
132685
  const { candidates } = await this.ctx.api.deviceManager.discoverProvider.mutate({ addonId: this.ctx.id });
131588
132686
  const hosts = candidates.map((candidate) => ({
@@ -131605,12 +132703,38 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131605
132703
  listPages: () => HOMEMATIC_PAGES
131606
132704
  };
131607
132705
  }
132706
+ /** The child a new container stands for, from the live CCU descriptor. */
132707
+ primaryChildPreference(integrationId, address) {
132708
+ const facade = homematicFacades.get(integrationId);
132709
+ if (facade === null) return [];
132710
+ const device = facade.devices().find((candidate) => candidate.address === address);
132711
+ if (device === void 0) return [];
132712
+ return hmPrimaryChildKeys(deriveHmEntitySpecs(device, facade.customEntities().filter((entity) => entity.device === address)));
132713
+ }
132714
+ /** A connected session's facade, or null while the integration is down. */
132715
+ connectedFacade(integrationId) {
132716
+ return this.clients?.sessions().some((session) => session.id === integrationId && session.status === "connected") === true ? homematicFacades.get(integrationId) : null;
132717
+ }
132718
+ /** CCU addresses adopted as containers from one integration. */
132719
+ async adoptedCcuAddresses(integrationId) {
132720
+ const reg = this.ctx.kernel.deviceRegistry;
132721
+ const devices = this.ctx.kernel.devices;
132722
+ const addresses = /* @__PURE__ */ new Set();
132723
+ if (!reg || !devices) return addresses;
132724
+ for (const device of reg.getAllForAddon(this.addonId)) {
132725
+ if (device.parentDeviceId !== null) continue;
132726
+ const config = await devices.loadConfig(device.id).catch(() => ({}));
132727
+ if (config["integrationId"] !== integrationId) continue;
132728
+ if (typeof config["hmEntityKey"] === "string") continue;
132729
+ const address = config["hmAddress"];
132730
+ if (typeof address === "string" && address.length > 0) addresses.add(address);
132731
+ }
132732
+ return addresses;
132733
+ }
131608
132734
  /** What the CCU management actions reach: connected sessions only, never a half-started facade. */
131609
132735
  ccuActionDeps() {
131610
132736
  return {
131611
- facade: (integrationId) => {
131612
- return this.clients?.sessions().some((session) => session.id === integrationId && session.status === "connected") === true ? homematicFacades.get(integrationId) : null;
131613
- },
132737
+ facade: (integrationId) => this.connectedFacade(integrationId),
131614
132738
  integrations: () => {
131615
132739
  const clients = this.clients;
131616
132740
  if (clients === null) return [];
@@ -131621,7 +132745,12 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131621
132745
  connected: connectedIds.has(integrationId)
131622
132746
  }));
131623
132747
  },
131624
- logger: this.ctx.logger
132748
+ logger: this.ctx.logger,
132749
+ adoptedAddresses: (integrationId) => this.adoptedCcuAddresses(integrationId),
132750
+ channelLinks: (integrationId) => {
132751
+ const facade = this.connectedFacade(integrationId);
132752
+ return facade === null ? null : channelLinkPort(facade);
132753
+ }
131625
132754
  };
131626
132755
  }
131627
132756
  async onShutdown() {
@@ -131859,10 +132988,12 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
131859
132988
  name
131860
132989
  };
131861
132990
  const stableId = this.generateStableId(DeviceType.Container, config);
132991
+ const primaryChildPreference = this.primaryChildPreference(integrationId, hmAddress);
131862
132992
  const device = await devices.create(stableId, HmContainerDevice, config, null, {
131863
132993
  type: DeviceType.Container,
131864
132994
  name,
131865
- integrationId
132995
+ integrationId,
132996
+ ...primaryChildPreference.length > 0 ? { primaryChildPreference } : {}
131866
132997
  });
131867
132998
  const children = await devices.getChildren(device.id);
131868
132999
  return {