@camstack/addon-provider-homematic 1.2.197 → 1.2.198

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.
Files changed (20) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/.bundle-modules.json +10 -4
  3. package/dist/_stub.js +2132 -1567
  4. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-C4Fww_oV.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-Dn1q938b.mjs} +4 -4
  5. package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-JVtI9IQh.mjs +26 -0
  6. package/dist/addon-provider-homematic.css +1 -1
  7. package/dist/addon.js +1899 -1506
  8. package/dist/addon.mjs +1900 -1507
  9. package/dist/{hostInit-DTPxs8RG.mjs → hostInit-Bn44sNXl.mjs} +3 -3
  10. package/dist/index.mjs +1 -1
  11. package/dist/remoteEntry.js +1 -1
  12. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-DSDGvcoJ.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-Lmec5QIi.mjs} +1 -1
  13. package/dist/widgets/_stub.js +208 -57
  14. package/dist/widgets/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-p7WFaZQH.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-CRu7ZKE2.mjs} +2 -2
  15. package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BEMWyRfG.mjs +26 -0
  16. package/dist/widgets/{hostInit-CtVv-2Cj.mjs → hostInit-oD-DrYN6.mjs} +2 -2
  17. package/dist/widgets/remoteEntry.js +1 -1
  18. package/package.json +3 -3
  19. package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-D0unHZPY.mjs +0 -26
  20. package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-C7ks8wIZ.mjs +0 -26
package/dist/addon.js CHANGED
@@ -6071,7 +6071,7 @@ var ZodIssueCode = {
6071
6071
  var ZodFirstPartyTypeKind;
6072
6072
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6073
6073
  //#endregion
6074
- //#region ../types/dist/sleep-BCWQQG52.mjs
6074
+ //#region ../types/dist/sleep-D7hCDd7y.mjs
6075
6075
  /**
6076
6076
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6077
6077
  * window to float samples (D455).
@@ -10322,6 +10322,8 @@ var READING_QUANTITIES = [
10322
10322
  "information",
10323
10323
  "sound-level",
10324
10324
  "signal-level",
10325
+ "signal-ratio",
10326
+ "frequency",
10325
10327
  "colour-temperature",
10326
10328
  "angle",
10327
10329
  "bitrate",
@@ -10365,6 +10367,8 @@ var QUANTITY_BASE = {
10365
10367
  information: "B",
10366
10368
  "sound-level": "dBFS",
10367
10369
  "signal-level": "dBm",
10370
+ "signal-ratio": "dB",
10371
+ frequency: "Hz",
10368
10372
  "colour-temperature": "mired",
10369
10373
  angle: "°",
10370
10374
  bitrate: "kbps",
@@ -20340,6 +20344,10 @@ Object.freeze({
20340
20344
  {
20341
20345
  "path": "storage.dischargedTodayKwh",
20342
20346
  "valueType": "number"
20347
+ },
20348
+ {
20349
+ "path": "storage.healthPct",
20350
+ "valueType": "number"
20343
20351
  }
20344
20352
  ],
20345
20353
  "enum-sensor": [{
@@ -20720,6 +20728,10 @@ Object.freeze({
20720
20728
  "path": "isMuted",
20721
20729
  "valueType": "boolean"
20722
20730
  },
20731
+ {
20732
+ "path": "muteReadback",
20733
+ "valueType": "boolean"
20734
+ },
20723
20735
  {
20724
20736
  "path": "source",
20725
20737
  "valueType": "string"
@@ -22840,7 +22852,7 @@ var NodeColorIdSchema = _enum([
22840
22852
  "node-h"
22841
22853
  ]);
22842
22854
  //#endregion
22843
- //#region ../types/dist/convert-BAzH15HU.mjs
22855
+ //#region ../types/dist/convert-BwMfbk5b.mjs
22844
22856
  /**
22845
22857
  * Frozen unit → spec table. `•` in the doc marks each dimension's canonical
22846
22858
  * unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
@@ -23173,6 +23185,21 @@ var UNIT_TABLE = {
23173
23185
  factor: 1,
23174
23186
  offset: 0
23175
23187
  },
23188
+ dB: {
23189
+ dimension: "signal-ratio",
23190
+ factor: 1,
23191
+ offset: 0
23192
+ },
23193
+ Hz: {
23194
+ dimension: "frequency",
23195
+ factor: 1,
23196
+ offset: 0
23197
+ },
23198
+ kHz: {
23199
+ dimension: "frequency",
23200
+ factor: 1e3,
23201
+ offset: 0
23202
+ },
23176
23203
  mired: {
23177
23204
  dimension: "colour-temperature",
23178
23205
  factor: 1,
@@ -57048,6 +57075,12 @@ var MediaPlayerStatusSchema = object({
57048
57075
  /** Mute toggle distinct from volume=0. Null when no mute surface.
57049
57076
  * Pair with `DeviceFeature.MediaPlayerMute`. */
57050
57077
  isMuted: boolean().nullable(),
57078
+ /**
57079
+ * True only when the provider READS the mute state back from the device.
57080
+ * Absent or false: mute is a momentary key. A non-null `isMuted` is not a
57081
+ * reading on its own — an infrared send can leave a value without this flag.
57082
+ */
57083
+ muteReadback: boolean().optional(),
57051
57084
  /** Active source / input. Empty when no source surface. */
57052
57085
  source: string(),
57053
57086
  /** Selectable sources. Empty when no source surface.
@@ -63110,7 +63143,9 @@ var EnergyStorageSchema = object({
63110
63143
  /** Lifetime discharged, kWh. */
63111
63144
  dischargedKwh: number$1().nullable().meta(readingMeta("energy")),
63112
63145
  chargedTodayKwh: number$1().nullable().meta(readingMeta("energy")),
63113
- dischargedTodayKwh: number$1().nullable().meta(readingMeta("energy"))
63146
+ dischargedTodayKwh: number$1().nullable().meta(readingMeta("energy")),
63147
+ /** State of health, 0..100. Null when the system did not report it. */
63148
+ healthPct: number$1().nullable().meta(readingMeta("percentage"))
63114
63149
  });
63115
63150
  var EnergySystemStatusSchema = object({
63116
63151
  solar: EnergySolarSchema.nullable(),
@@ -63222,6 +63257,12 @@ var energySystemCapability = {
63222
63257
  kind: "counter",
63223
63258
  unit: "kWh",
63224
63259
  displayName: "Storage discharged"
63260
+ },
63261
+ "storage.healthPct": {
63262
+ kind: "gauge",
63263
+ unit: "%",
63264
+ deadband: 1,
63265
+ displayName: "Storage health"
63225
63266
  }
63226
63267
  } },
63227
63268
  volatileStateFields: ["lastFetchedAt"],
@@ -66116,7 +66157,7 @@ var HeroModelSchema = object({
66116
66157
  *
66117
66158
  * - `extras` are the further inline controls of the types that carry more than one
66118
66159
  * ({@link ROW_EXTRAS_BY_TYPE}): climate setpoint, a robot's return to base,
66119
- * a player's volume and remote. Each is a control the model already has, named by id,
66160
+ * a player's volume and remote, an automation's enabled switch. Each is a control the model already has, named by id,
66120
66161
  * in that order and at most {@link ROW_EXTRAS_MAX}; one the model lacks, or lists in
66121
66162
  * `gated`, is absent, and the one `primary` already is never repeats. Empty = the
66122
66163
  * row of an older server: `primary` alone.
@@ -66176,7 +66217,7 @@ new Set([
66176
66217
  "valve"
66177
66218
  ]);
66178
66219
  DeviceType.Climate;
66179
- DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
66220
+ DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.Automation;
66180
66221
  /**
66181
66222
  * hero-layout — what a device's hero says (D1023). Read-only: the FIXED
66182
66223
  * layouts live in `@camstack/types` and nothing here stores or edits one.
@@ -96672,7 +96713,11 @@ var temperatureContribution = contribution("temperature-sensor", TemperatureSens
96672
96713
  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)));
96673
96714
  var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
96674
96715
  var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
96675
- var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
96716
+ var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice, ctx) => {
96717
+ const unit = ctx.quantity == null ? void 0 : baseUnitOf(ctx.quantity);
96718
+ const text = String(Number((slice?.value ?? 0).toFixed(2)));
96719
+ return sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", unit === void 0 ? text : `${text} ${unit}`);
96720
+ });
96676
96721
  var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
96677
96722
  if (slice === void 0 || slice.value === "") return measured({ reading: reading$1("sensor", "unknown") }, emptyMeasurement("text"));
96678
96723
  if (slice.timestamp === true) return { reading: reading$1("sensor", "on") };
@@ -112786,6 +112831,8 @@ var DIMENSION_QUANTITY = {
112786
112831
  angle: "angle",
112787
112832
  "sound-level": "sound-level",
112788
112833
  "signal-level": "signal-level",
112834
+ "signal-ratio": "signal-ratio",
112835
+ frequency: "frequency",
112789
112836
  "colour-temperature": "colour-temperature",
112790
112837
  bitrate: "bitrate",
112791
112838
  rate: "rate"
@@ -113025,193 +113072,6 @@ object({
113025
113072
  commands: record$1(string(), unknown())
113026
113073
  });
113027
113074
  //#endregion
113028
- //#region src/homematic-reconciler.ts
113029
- /**
113030
- * Keeps one live client per enabled integration. Devices are removed ONLY on an explicit
113031
- * lifecycle event naming the integration (D49): a list that failed, an empty list or an
113032
- * unreadable connection changes nothing about devices and is logged, never read as "gone".
113033
- */
113034
- var HomematicReconciler = class {
113035
- #deps;
113036
- #sweep;
113037
- #rerun = null;
113038
- constructor(deps) {
113039
- this.#deps = deps;
113040
- this.#sweep = new OrphanIntegrationSweep({
113041
- logger: deps.logger,
113042
- ...deps.sweepOptions
113043
- });
113044
- }
113045
- /** Upsert a client per usable enabled integration; drop the CLIENT (never devices) of one the list answered is gone. */
113046
- async reconcile() {
113047
- const { logger, clients } = this.#deps;
113048
- let all;
113049
- try {
113050
- all = await this.#deps.listIntegrations();
113051
- } catch (err) {
113052
- logger.warn("Homematic integration reconcile skipped — the integration list did not answer", { meta: { error: errMsg(err) } });
113053
- return;
113054
- }
113055
- const enabled = all.filter((i) => i.addonId === this.#deps.addonId && i.enabled);
113056
- for (const integration of enabled) try {
113057
- if (!await this.#deps.applySettings(integration)) logger.warn("Homematic integration has no usable connection — left as it is", { meta: { integrationId: integration.id } });
113058
- } catch (err) {
113059
- logger.warn("Homematic reconcile failed for integration — left as it is", { meta: {
113060
- integrationId: integration.id,
113061
- error: errMsg(err)
113062
- } });
113063
- }
113064
- const enabledIds = new Set(enabled.map((i) => i.id));
113065
- for (const id of clients.list()) if (!enabledIds.has(id)) await clients.remove(id);
113066
- await this.#sweepOrphans(all.map((i) => i.id));
113067
- }
113068
- /** Stop the scheduled second read (addon stop). */
113069
- dispose() {
113070
- if (this.#rerun !== null) clearTimeout(this.#rerun);
113071
- this.#rerun = null;
113072
- }
113073
- /**
113074
- * An integration deleted while this addon was down emits nothing it sees: its id owns devices
113075
- * yet is absent from the ANSWERED list. Removal needs a second answered read later, so one
113076
- * re-run is scheduled when a suspect appears (bounded: one timer, no retry loop).
113077
- */
113078
- async #sweepOrphans(listedIds) {
113079
- const { ownerIntegrationIds, removeDevices, logger } = this.#deps;
113080
- if (ownerIntegrationIds === void 0) return;
113081
- try {
113082
- const ownerIds = await ownerIntegrationIds();
113083
- if ((await this.#sweep.sweep({
113084
- ownerIds,
113085
- listedIds,
113086
- removeDevices
113087
- })).newSuspects > 0 && this.#rerun === null) {
113088
- this.#rerun = setTimeout(() => {
113089
- this.#rerun = null;
113090
- this.reconcile();
113091
- }, this.#sweep.minIntervalMs + 1e3);
113092
- this.#rerun.unref();
113093
- }
113094
- } catch (err) {
113095
- logger.warn("Orphan integration sweep failed — devices left as they are", { meta: { error: errMsg(err) } });
113096
- }
113097
- }
113098
- /** An explicit lifecycle event: only `deleted` / `disabled` of a named integration remove devices. */
113099
- async onLifecycle(kind, integrationId) {
113100
- await this.reconcile();
113101
- if (kind === "enabled" || integrationId === null) return;
113102
- try {
113103
- const removed = await this.#deps.removeDevices(integrationId);
113104
- this.#deps.logger.info("Homematic integration devices removed", { meta: {
113105
- integrationId,
113106
- kind,
113107
- removed
113108
- } });
113109
- } catch (err) {
113110
- this.#deps.logger.warn("Homematic integration device removal failed", { meta: {
113111
- integrationId,
113112
- kind,
113113
- error: errMsg(err)
113114
- } });
113115
- }
113116
- }
113117
- };
113118
- //#endregion
113119
- //#region src/homematic-mapping.ts
113120
- /**
113121
- * Map a single Homematic channel to its CamStack triplet. The channel
113122
- * `TYPE` is the discriminator. Only the controllable / primary channel
113123
- * types map; status-only `*_TRANSMITTER` mirrors and the various key /
113124
- * remote / week-profile channels return `null` (their datapoints are
113125
- * still decoded into the owning cap's slice via the device's
113126
- * `valueChanged` handler, keyed by parameter name).
113127
- */
113128
- function mapHmChannel(channelType) {
113129
- if (!channelType) return null;
113130
- switch (channelType.toUpperCase()) {
113131
- case "SWITCH_VIRTUAL_RECEIVER": return {
113132
- deviceType: DeviceType.Switch,
113133
- role: null,
113134
- capabilities: ["switch"]
113135
- };
113136
- case "SHUTTER_VIRTUAL_RECEIVER": return {
113137
- deviceType: DeviceType.Cover,
113138
- role: null,
113139
- capabilities: ["cover"]
113140
- };
113141
- case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
113142
- deviceType: DeviceType.Climate,
113143
- role: null,
113144
- capabilities: [
113145
- "climate-control",
113146
- "temperature-sensor",
113147
- "humidity-sensor"
113148
- ]
113149
- };
113150
- case "MOTIONDETECTOR_TRANSCEIVER": return {
113151
- deviceType: DeviceType.Sensor,
113152
- role: DeviceRole.MotionSensor,
113153
- capabilities: ["motion", "ambient-light-sensor"]
113154
- };
113155
- case "DOOR_LOCK_STATE_TRANSMITTER": return {
113156
- deviceType: DeviceType.Lock,
113157
- role: null,
113158
- capabilities: ["lock-control"]
113159
- };
113160
- case "ENERGIE_METER_TRANSMITTER": return {
113161
- deviceType: DeviceType.Sensor,
113162
- role: DeviceRole.PowerSensor,
113163
- capabilities: ["power-meter"]
113164
- };
113165
- case "KEY_TRANSCEIVER":
113166
- case "KEY_TRANSMITTER":
113167
- case "VIRTUAL_KEY":
113168
- case "KEY": return {
113169
- deviceType: DeviceType.EventEmitter,
113170
- role: null,
113171
- capabilities: ["event-emitter"]
113172
- };
113173
- default: return null;
113174
- }
113175
- }
113176
- /**
113177
- * Best-effort parent DeviceType for a whole Homematic device, derived
113178
- * from the union of its channel mappings. Actuators win over sensors so
113179
- * a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
113180
- * Sensor, and a thermostat with a humidity sensor reports as a
113181
- * Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
113182
- * ranked above Sensor so its battery / maintenance sensor channels don't
113183
- * win the parent type. Returns `DeviceType.Generic` when no channel maps.
113184
- */
113185
- var PARENT_TYPE_PRIORITY = [
113186
- DeviceType.Climate,
113187
- DeviceType.Lock,
113188
- DeviceType.Cover,
113189
- DeviceType.Light,
113190
- DeviceType.Switch,
113191
- DeviceType.EventEmitter,
113192
- DeviceType.Sensor
113193
- ];
113194
- function inferHmDeviceType(device) {
113195
- const present = /* @__PURE__ */ new Set();
113196
- for (const channel of device.channels) {
113197
- const mapping = mapHmChannel(channel.type);
113198
- if (mapping) present.add(mapping.deviceType);
113199
- }
113200
- for (const dt of PARENT_TYPE_PRIORITY) if (present.has(dt)) return dt;
113201
- return DeviceType.Generic;
113202
- }
113203
- function mapHmDeviceChannels(device) {
113204
- const out = [];
113205
- for (const channel of device.channels) {
113206
- const mapping = mapHmChannel(channel.type);
113207
- if (mapping) out.push({
113208
- channel,
113209
- mapping
113210
- });
113211
- }
113212
- return out;
113213
- }
113214
- //#endregion
113215
113075
  //#region src/devices/hm-cold-start.ts
113216
113076
  /**
113217
113077
  * Shared cold-start defaults + the key-channel press vocabulary helpers,
@@ -113336,6 +113196,102 @@ function channelIndexFromAddress(channelAddress) {
113336
113196
  return suffix.length > 0 ? suffix : null;
113337
113197
  }
113338
113198
  //#endregion
113199
+ //#region src/homematic-mapping.ts
113200
+ /**
113201
+ * Map a single Homematic channel to its CamStack triplet. The channel
113202
+ * `TYPE` is the discriminator. Only the controllable / primary channel
113203
+ * types map; status-only `*_TRANSMITTER` mirrors and the various key /
113204
+ * remote / week-profile channels return `null` (their datapoints are
113205
+ * still decoded into the owning cap's slice via the device's
113206
+ * `valueChanged` handler, keyed by parameter name).
113207
+ */
113208
+ function mapHmChannel(channelType) {
113209
+ if (!channelType) return null;
113210
+ switch (channelType.toUpperCase()) {
113211
+ case "SWITCH_VIRTUAL_RECEIVER": return {
113212
+ deviceType: DeviceType.Switch,
113213
+ role: null,
113214
+ capabilities: ["switch"]
113215
+ };
113216
+ case "SHUTTER_VIRTUAL_RECEIVER": return {
113217
+ deviceType: DeviceType.Cover,
113218
+ role: null,
113219
+ capabilities: ["cover"]
113220
+ };
113221
+ case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
113222
+ deviceType: DeviceType.Climate,
113223
+ role: null,
113224
+ capabilities: [
113225
+ "climate-control",
113226
+ "temperature-sensor",
113227
+ "humidity-sensor"
113228
+ ]
113229
+ };
113230
+ case "MOTIONDETECTOR_TRANSCEIVER": return {
113231
+ deviceType: DeviceType.Sensor,
113232
+ role: DeviceRole.MotionSensor,
113233
+ capabilities: ["motion", "ambient-light-sensor"]
113234
+ };
113235
+ case "DOOR_LOCK_STATE_TRANSMITTER": return {
113236
+ deviceType: DeviceType.Lock,
113237
+ role: null,
113238
+ capabilities: ["lock-control"]
113239
+ };
113240
+ case "ENERGIE_METER_TRANSMITTER": return {
113241
+ deviceType: DeviceType.Sensor,
113242
+ role: DeviceRole.PowerSensor,
113243
+ capabilities: ["power-meter"]
113244
+ };
113245
+ case "KEY_TRANSCEIVER":
113246
+ case "KEY_TRANSMITTER":
113247
+ case "VIRTUAL_KEY":
113248
+ case "KEY": return {
113249
+ deviceType: DeviceType.EventEmitter,
113250
+ role: null,
113251
+ capabilities: ["event-emitter"]
113252
+ };
113253
+ default: return null;
113254
+ }
113255
+ }
113256
+ /**
113257
+ * Best-effort parent DeviceType for a whole Homematic device, derived
113258
+ * from the union of its channel mappings. Actuators win over sensors so
113259
+ * a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
113260
+ * Sensor, and a thermostat with a humidity sensor reports as a
113261
+ * Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
113262
+ * ranked above Sensor so its battery / maintenance sensor channels don't
113263
+ * win the parent type. Returns `DeviceType.Generic` when no channel maps.
113264
+ */
113265
+ var PARENT_TYPE_PRIORITY = [
113266
+ DeviceType.Climate,
113267
+ DeviceType.Lock,
113268
+ DeviceType.Cover,
113269
+ DeviceType.Light,
113270
+ DeviceType.Switch,
113271
+ DeviceType.EventEmitter,
113272
+ DeviceType.Sensor
113273
+ ];
113274
+ function inferHmDeviceType(device) {
113275
+ const present = /* @__PURE__ */ new Set();
113276
+ for (const channel of device.channels) {
113277
+ const mapping = mapHmChannel(channel.type);
113278
+ if (mapping) present.add(mapping.deviceType);
113279
+ }
113280
+ for (const dt of PARENT_TYPE_PRIORITY) if (present.has(dt)) return dt;
113281
+ return DeviceType.Generic;
113282
+ }
113283
+ function mapHmDeviceChannels(device) {
113284
+ const out = [];
113285
+ for (const channel of device.channels) {
113286
+ const mapping = mapHmChannel(channel.type);
113287
+ if (mapping) out.push({
113288
+ channel,
113289
+ mapping
113290
+ });
113291
+ }
113292
+ return out;
113293
+ }
113294
+ //#endregion
113339
113295
  //#region src/devices/hm-key-vocabulary.ts
113340
113296
  var PRESS_MEANING = {
113341
113297
  PRESS_SHORT: {
@@ -113465,9 +113421,15 @@ function directLinksOfKey(keyAddress, links, names) {
113465
113421
  function isHmipDevice(device) {
113466
113422
  return /^hmip/i.test(device.type);
113467
113423
  }
113424
+ var KEY_EVENT_PROGRAM_PREFIX = "CamStack: ";
113425
+ var KEY_EVENT_PROGRAM_SUFFIX = " events";
113468
113426
  /** The one CCU program that carries a device's key events. It is found by this name; nothing else is stored. */
113469
113427
  function keyEventProgramName(device) {
113470
- return `CamStack: ${hmName(device.name) ?? device.address} events`;
113428
+ return `${KEY_EVENT_PROGRAM_PREFIX}${hmName(device.name) ?? device.address}${KEY_EVENT_PROGRAM_SUFFIX}`;
113429
+ }
113430
+ /** True when the name is one CamStack assigned to a key-event program. */
113431
+ function isCamStackKeyEventProgramName(name) {
113432
+ return name.startsWith(KEY_EVENT_PROGRAM_PREFIX) && name.endsWith(KEY_EVENT_PROGRAM_SUFFIX) && name.length > 17;
113471
113433
  }
113472
113434
  function deviceAddressOf$2(channelAddress) {
113473
113435
  const colon = channelAddress.lastIndexOf(":");
@@ -113613,6 +113575,169 @@ async function syncKeyEventProgram(deps, facade, device, channelAddress, enabled
113613
113575
  });
113614
113576
  }
113615
113577
  //#endregion
113578
+ //#region src/ccu/ccu-config-actions.ts
113579
+ /** The MASTER paramset editor: read a device's per-channel parameters, write a changed set to one channel. */
113580
+ function buildCcuConfigHandlers(deps) {
113581
+ return {
113582
+ getCcuDeviceConfig: async (input) => {
113583
+ const facade = requireFacade(deps, input.integrationId);
113584
+ const device = facade.devices().find((candidate) => candidate.address === input.address);
113585
+ if (device === void 0) throw new Error(`Device ${input.address} is not known to the CCU`);
113586
+ const channels = [];
113587
+ for (const channel of device.channels) {
113588
+ const specs = facade.getConfigParams(channel.address);
113589
+ if (specs.length === 0) continue;
113590
+ let values = {};
113591
+ let error = null;
113592
+ try {
113593
+ values = await facade.getConfig(channel.address);
113594
+ } catch (err) {
113595
+ error = errorText(err);
113596
+ deps.logger.warn("Homematic: channel configuration unreadable", { meta: {
113597
+ integrationId: input.integrationId,
113598
+ channel: channel.address,
113599
+ error
113600
+ } });
113601
+ }
113602
+ channels.push({
113603
+ channel: channel.address,
113604
+ channelType: channel.type ?? null,
113605
+ error,
113606
+ params: specs.map((spec) => ({
113607
+ parameter: spec.parameter,
113608
+ type: spec.type,
113609
+ min: spec.min ?? null,
113610
+ max: spec.max ?? null,
113611
+ unit: spec.unit ?? null,
113612
+ valueList: spec.valueList === void 0 ? null : [...spec.valueList],
113613
+ writable: spec.writable,
113614
+ value: values[spec.parameter] ?? null
113615
+ }))
113616
+ });
113617
+ }
113618
+ return { channels };
113619
+ },
113620
+ setCcuChannelConfig: async (input) => {
113621
+ requireConfirmed(input.confirmed);
113622
+ const facade = requireFacade(deps, input.integrationId);
113623
+ const names = Object.keys(input.values);
113624
+ if (names.length === 0) throw new Error("Nothing to change: no parameter was edited");
113625
+ const writable = new Set(facade.getConfigParams(input.channel).filter((spec) => spec.writable).map((spec) => spec.parameter));
113626
+ const refused = names.filter((name) => !writable.has(name));
113627
+ if (refused.length > 0) throw new Error(`Not a writable parameter of ${input.channel}: ${refused.join(", ")}`);
113628
+ await facade.setConfig(input.channel, { ...input.values });
113629
+ deps.logger.info("Homematic: channel configuration written", { meta: {
113630
+ integrationId: input.integrationId,
113631
+ channel: input.channel,
113632
+ parameters: names
113633
+ } });
113634
+ return { ok: true };
113635
+ }
113636
+ };
113637
+ }
113638
+ //#endregion
113639
+ //#region src/ccu/ccu-device-state-actions.ts
113640
+ function requireDevice(devices, address) {
113641
+ const device = devices.find((candidate) => candidate.address === address);
113642
+ if (device === void 0) throw new Error(`Device ${address} is not known to the CCU`);
113643
+ return device;
113644
+ }
113645
+ /** The first reading of `names` on any channel (the maintenance channel carries them). */
113646
+ function reading(device, names) {
113647
+ for (const channel of device.channels) {
113648
+ const point = channel.dataPoints.find((candidate) => names.includes(candidate.parameter));
113649
+ if (point !== void 0) return point.value;
113650
+ }
113651
+ }
113652
+ function numberReading(device, names) {
113653
+ const value = reading(device, names);
113654
+ return typeof value === "number" ? value : null;
113655
+ }
113656
+ function boolReading(device, names) {
113657
+ const value = reading(device, names);
113658
+ return typeof value === "boolean" ? value : null;
113659
+ }
113660
+ function diagnosticsOf(device) {
113661
+ const duty = reading(device, ["DUTY_CYCLE", "DUTYCYCLE"]);
113662
+ return {
113663
+ rssiDevice: numberReading(device, ["RSSI_DEVICE"]),
113664
+ rssiPeer: numberReading(device, ["RSSI_PEER"]),
113665
+ unreach: boolReading(device, ["UNREACH"]),
113666
+ lowBattery: boolReading(device, ["LOW_BAT", "LOWBAT"]),
113667
+ dutyCycle: typeof duty === "boolean" || typeof duty === "number" ? duty : null,
113668
+ configPending: boolReading(device, ["CONFIG_PENDING"])
113669
+ };
113670
+ }
113671
+ function toValueParam(point) {
113672
+ return {
113673
+ parameter: point.parameter,
113674
+ type: point.type,
113675
+ min: point.min ?? null,
113676
+ max: point.max ?? null,
113677
+ unit: point.unit ?? null,
113678
+ valueList: point.valueList === void 0 ? null : [...point.valueList],
113679
+ writable: point.writable,
113680
+ readable: point.readable,
113681
+ value: point.value
113682
+ };
113683
+ }
113684
+ function toChannelValues(channel) {
113685
+ return {
113686
+ address: channel.address,
113687
+ index: channel.index,
113688
+ type: channel.type ?? null,
113689
+ name: hmName(channel.name),
113690
+ values: channel.dataPoints.map(toValueParam)
113691
+ };
113692
+ }
113693
+ /**
113694
+ * The device page panel: one CCU device's VALUES and maintenance readings,
113695
+ * and a manual write of one writable value (a switch, a level, a key press).
113696
+ */
113697
+ function buildCcuDeviceStateHandlers(deps) {
113698
+ return {
113699
+ getCcuDeviceState: async (input) => {
113700
+ const device = requireDevice(requireFacade(deps, input.integrationId).devices(), input.address);
113701
+ return {
113702
+ address: device.address,
113703
+ name: hmName(device.name),
113704
+ type: device.type,
113705
+ firmware: {
113706
+ installed: device.firmware ?? null,
113707
+ available: device.availableFirmware ?? null,
113708
+ updatable: device.updatable ?? null,
113709
+ state: device.firmwareUpdateState ?? null
113710
+ },
113711
+ diagnostics: diagnosticsOf(device),
113712
+ channels: device.channels.map(toChannelValues)
113713
+ };
113714
+ },
113715
+ setCcuValue: async (input) => {
113716
+ requireConfirmed(input.confirmed);
113717
+ const facade = requireFacade(deps, input.integrationId);
113718
+ const device = facade.devices().find((candidate) => candidate.channels.some((ch) => ch.address === input.channel));
113719
+ if (device === void 0) throw new Error(`Channel ${input.channel} is not known to the CCU`);
113720
+ const point = device.channels.find((channel) => channel.address === input.channel)?.dataPoints.find((candidate) => candidate.parameter === input.parameter);
113721
+ if (point === void 0 || !point.writable) throw new Error(`${input.parameter} is not a writable value of ${input.channel}`);
113722
+ await facade.setValue({
113723
+ device: device.address,
113724
+ channel: input.channel,
113725
+ parameter: input.parameter
113726
+ }, input.value);
113727
+ deps.logger.info("Homematic: value written", {
113728
+ ...input.deviceId === void 0 ? {} : { tags: { deviceId: input.deviceId } },
113729
+ meta: {
113730
+ integrationId: input.integrationId,
113731
+ channel: input.channel,
113732
+ parameter: input.parameter,
113733
+ value: input.value
113734
+ }
113735
+ });
113736
+ return { ok: true };
113737
+ }
113738
+ };
113739
+ }
113740
+ //#endregion
113616
113741
  //#region src/ccu/ccu-device-rows.ts
113617
113742
  /** `RSSI_*` reports this when the device has no signal reading. */
113618
113743
  var RSSI_UNKNOWN = 65535;
@@ -113687,67 +113812,6 @@ function buildCcuDevicesHandlers(deps) {
113687
113812
  } };
113688
113813
  }
113689
113814
  //#endregion
113690
- //#region src/ccu/ccu-config-actions.ts
113691
- /** The MASTER paramset editor: read a device's per-channel parameters, write a changed set to one channel. */
113692
- function buildCcuConfigHandlers(deps) {
113693
- return {
113694
- getCcuDeviceConfig: async (input) => {
113695
- const facade = requireFacade(deps, input.integrationId);
113696
- const device = facade.devices().find((candidate) => candidate.address === input.address);
113697
- if (device === void 0) throw new Error(`Device ${input.address} is not known to the CCU`);
113698
- const channels = [];
113699
- for (const channel of device.channels) {
113700
- const specs = facade.getConfigParams(channel.address);
113701
- if (specs.length === 0) continue;
113702
- let values = {};
113703
- let error = null;
113704
- try {
113705
- values = await facade.getConfig(channel.address);
113706
- } catch (err) {
113707
- error = errorText(err);
113708
- deps.logger.warn("Homematic: channel configuration unreadable", { meta: {
113709
- integrationId: input.integrationId,
113710
- channel: channel.address,
113711
- error
113712
- } });
113713
- }
113714
- channels.push({
113715
- channel: channel.address,
113716
- channelType: channel.type ?? null,
113717
- error,
113718
- params: specs.map((spec) => ({
113719
- parameter: spec.parameter,
113720
- type: spec.type,
113721
- min: spec.min ?? null,
113722
- max: spec.max ?? null,
113723
- unit: spec.unit ?? null,
113724
- valueList: spec.valueList === void 0 ? null : [...spec.valueList],
113725
- writable: spec.writable,
113726
- value: values[spec.parameter] ?? null
113727
- }))
113728
- });
113729
- }
113730
- return { channels };
113731
- },
113732
- setCcuChannelConfig: async (input) => {
113733
- requireConfirmed(input.confirmed);
113734
- const facade = requireFacade(deps, input.integrationId);
113735
- const names = Object.keys(input.values);
113736
- if (names.length === 0) throw new Error("Nothing to change: no parameter was edited");
113737
- const writable = new Set(facade.getConfigParams(input.channel).filter((spec) => spec.writable).map((spec) => spec.parameter));
113738
- const refused = names.filter((name) => !writable.has(name));
113739
- if (refused.length > 0) throw new Error(`Not a writable parameter of ${input.channel}: ${refused.join(", ")}`);
113740
- await facade.setConfig(input.channel, { ...input.values });
113741
- deps.logger.info("Homematic: channel configuration written", { meta: {
113742
- integrationId: input.integrationId,
113743
- channel: input.channel,
113744
- parameters: names
113745
- } });
113746
- return { ok: true };
113747
- }
113748
- };
113749
- }
113750
- //#endregion
113751
113815
  //#region src/ccu/ccu-schemas.ts
113752
113816
  /**
113753
113817
  * Wire shapes of the CCU management custom actions. Shared by the addon (handler
@@ -114064,6 +114128,48 @@ var CcuLinksResultSchema = object({
114064
114128
  receivers: array(LinkEndpointSchema),
114065
114129
  failures: array(LinkReadFailureSchema)
114066
114130
  });
114131
+ /** A channel a program's conditions use, named from CamStack when the device is adopted. */
114132
+ var ProgramChannelSchema = object({
114133
+ address: string(),
114134
+ channelName: string().nullable(),
114135
+ /** CamStack device name when the channel's device is adopted, otherwise the CCU name. */
114136
+ deviceName: string().nullable(),
114137
+ deviceId: number$1().int().nullable()
114138
+ });
114139
+ var CcuProgramSchema = object({
114140
+ id: string(),
114141
+ name: string(),
114142
+ active: boolean(),
114143
+ internal: boolean(),
114144
+ /** Epoch milliseconds. `null` when the CCU has no last run, or the run is epoch 0. */
114145
+ lastRunMs: number$1().nullable(),
114146
+ /** The name is the key-event program CamStack creates (`CamStack: … events`). */
114147
+ createdByCamstack: boolean(),
114148
+ channels: array(ProgramChannelSchema)
114149
+ });
114150
+ /** A HmIP key channel a new key-event program may listen to. */
114151
+ var ProgramKeySchema = object({
114152
+ address: string(),
114153
+ name: string().nullable(),
114154
+ deviceAddress: string(),
114155
+ deviceName: string().nullable(),
114156
+ deviceType: string()
114157
+ });
114158
+ var CcuProgramsResultSchema = object({
114159
+ programs: array(CcuProgramSchema),
114160
+ keys: array(ProgramKeySchema)
114161
+ });
114162
+ var ProgramIdInputSchema = IntegrationRefSchema.extend({
114163
+ programId: string().min(1),
114164
+ confirmed: ConfirmedSchema
114165
+ });
114166
+ var SetProgramActiveInputSchema = ProgramIdInputSchema.extend({ active: boolean() });
114167
+ /** Create or rewrite the one key-event program of a HmIP button device. */
114168
+ var EnsureKeyEventProgramInputSchema = IntegrationRefSchema.extend({
114169
+ deviceAddress: string().min(1),
114170
+ channelAddresses: array(string().min(1)).min(1),
114171
+ confirmed: ConfirmedSchema
114172
+ });
114067
114173
  var LinkRefInputSchema = IntegrationRefSchema.extend({
114068
114174
  sender: string().min(1),
114069
114175
  receiver: string().min(1),
@@ -114438,289 +114544,77 @@ function buildCcuLinkHandlers(deps) {
114438
114544
  };
114439
114545
  }
114440
114546
  //#endregion
114441
- //#region src/ccu/ccu-rename-actions.ts
114442
- function requireName$1(name) {
114443
- const trimmed = name.trim();
114444
- if (trimmed === "") throw new Error("A CCU name cannot be blank");
114445
- return trimmed;
114446
- }
114447
- /** Renaming a device (optionally with its channels) or one channel on the CCU. */
114448
- function buildCcuRenameHandlers(deps) {
114547
+ //#region src/ccu/ccu-overview-actions.ts
114548
+ /** The CCU overview tab: which CCUs exist, what each says about itself, and its service messages. */
114549
+ function buildCcuOverviewHandlers(deps) {
114449
114550
  return {
114450
- renameCcuDevice: async (input) => {
114451
- requireConfirmed(input.confirmed);
114452
- const name = requireName$1(input.name);
114453
- const renamed = await requireFacade(deps, input.integrationId).renameDevice(input.address, name, { renameChannels: input.renameChannels });
114454
- deps.logger.info("Homematic: device renamed on the CCU", { meta: {
114551
+ listCcus: async (_input) => [...deps.integrations()],
114552
+ ccuOverview: async (input) => {
114553
+ const facade = requireFacade(deps, input.integrationId);
114554
+ const [info, interfaces] = await Promise.allSettled([facade.ccuInfo(), facade.listInterfaces()]);
114555
+ if (info.status === "rejected") deps.logger.warn("Homematic: CCU info unavailable", { meta: {
114455
114556
  integrationId: input.integrationId,
114456
- address: input.address,
114457
- name: renamed.device.name,
114458
- channels: renamed.channels.length
114557
+ error: errorText(info.reason)
114459
114558
  } });
114460
- deps.ccuChanged(input.integrationId);
114461
- return {
114462
- device: {
114463
- address: renamed.device.address,
114464
- name: renamed.device.name
114465
- },
114466
- channels: renamed.channels.map((channel) => ({
114467
- address: channel.address,
114468
- name: channel.name
114469
- }))
114470
- };
114471
- },
114472
- renameCcuChannel: async (input) => {
114473
- requireConfirmed(input.confirmed);
114474
- const name = requireName$1(input.name);
114475
- const renamed = await requireFacade(deps, input.integrationId).renameChannel(input.address, name);
114476
- deps.logger.info("Homematic: channel renamed on the CCU", { meta: {
114559
+ if (interfaces.status === "rejected") deps.logger.warn("Homematic: interface list unavailable", { meta: {
114477
114560
  integrationId: input.integrationId,
114478
- address: input.address,
114479
- name: renamed.name
114561
+ error: errorText(interfaces.reason)
114480
114562
  } });
114481
- deps.ccuChanged(input.integrationId);
114482
- return {
114483
- address: renamed.address,
114484
- name: renamed.name
114485
- };
114486
- }
114487
- };
114488
- }
114489
- //#endregion
114490
- //#region src/ccu/ccu-rooms-actions.ts
114491
- function requireName(name) {
114492
- const trimmed = name.trim();
114493
- if (trimmed === "") throw new Error("A room needs a name");
114494
- return trimmed;
114495
- }
114496
- /** Every channel a room may hold: all but the maintenance channel (index 0). */
114497
- function roomCandidates(devices) {
114498
- return devices.flatMap((device) => device.channels.filter((channel) => channel.index !== 0).map((channel) => ({
114499
- address: channel.address,
114500
- name: hmName(channel.name),
114501
- deviceName: hmName(device.name),
114502
- deviceType: device.type
114503
- })));
114504
- }
114505
- /** The Settings tab's rooms: list, create, rename, delete, and which channels each holds. */
114506
- function buildCcuRoomHandlers(deps) {
114507
- const logWrite = (what, integrationId, extra) => {
114508
- deps.logger.info(`Homematic: room ${what}`, { meta: {
114509
- integrationId,
114510
- ...extra
114511
- } });
114512
- };
114513
- const toRoom = (room, devices) => {
114514
- const names = channelNameLookup(devices);
114515
- return {
114516
- id: room.id,
114517
- name: room.name,
114518
- channels: room.channels.map((address) => {
114519
- const found = names(address);
114520
- return {
114521
- address,
114522
- name: found.channelName,
114523
- deviceName: found.deviceName,
114524
- deviceType: found.deviceType
114525
- };
114526
- })
114527
- };
114528
- };
114529
- return {
114530
- listCcuRooms: async (input) => {
114531
- const facade = requireFacade(deps, input.integrationId);
114532
- const devices = facade.devices();
114533
114563
  return {
114534
- rooms: (await facade.listRooms()).map((room) => toRoom(room, devices)),
114535
- channels: roomCandidates(devices)
114564
+ info: info.status === "fulfilled" ? info.value : null,
114565
+ infoError: info.status === "rejected" ? errorText(info.reason) : null,
114566
+ interfaces: interfaces.status === "fulfilled" ? interfaces.value.map((iface) => ({
114567
+ ...iface,
114568
+ gateways: [...iface.gateways]
114569
+ })) : [],
114570
+ interfacesError: interfaces.status === "rejected" ? errorText(interfaces.reason) : null
114536
114571
  };
114537
114572
  },
114538
- createCcuRoom: async (input) => {
114539
- requireConfirmed(input.confirmed);
114540
- const name = requireName(input.name);
114541
- const facade = requireFacade(deps, input.integrationId);
114542
- const created = await facade.createRoom(name);
114543
- logWrite("created", input.integrationId, {
114544
- roomId: created.id,
114545
- name: created.name
114546
- });
114547
- deps.ccuChanged(input.integrationId);
114548
- return toRoom(created, facade.devices());
114549
- },
114550
- renameCcuRoom: async (input) => {
114551
- requireConfirmed(input.confirmed);
114552
- const name = requireName(input.name);
114553
- await requireFacade(deps, input.integrationId).renameRoom(input.id, name);
114554
- logWrite("renamed", input.integrationId, {
114555
- roomId: input.id,
114556
- name
114557
- });
114558
- deps.ccuChanged(input.integrationId);
114559
- return { ok: true };
114560
- },
114561
- deleteCcuRoom: async (input) => {
114562
- requireConfirmed(input.confirmed);
114563
- await requireFacade(deps, input.integrationId).deleteRoom(input.id);
114564
- logWrite("deleted", input.integrationId, { roomId: input.id });
114565
- deps.ccuChanged(input.integrationId);
114566
- return { ok: true };
114567
- },
114568
- setCcuRoomChannels: async (input) => {
114569
- requireConfirmed(input.confirmed);
114573
+ listServiceMessages: async (input) => {
114570
114574
  const facade = requireFacade(deps, input.integrationId);
114571
- const room = (await facade.listRooms()).find((candidate) => candidate.id === input.id);
114572
- if (room === void 0) throw new Error(`The CCU has no room ${input.id}`);
114573
- const wanted = new Set(input.channels);
114574
- const current = new Set(room.channels);
114575
- const added = input.channels.filter((address) => !current.has(address));
114576
- const removed = room.channels.filter((address) => !wanted.has(address));
114577
- for (const address of added) await facade.addChannelToRoom(input.id, address);
114578
- for (const address of removed) await facade.removeChannelFromRoom(input.id, address);
114579
- logWrite("members changed", input.integrationId, {
114580
- roomId: input.id,
114581
- added: added.length,
114582
- removed: removed.length
114583
- });
114584
- if (added.length > 0 || removed.length > 0) deps.ccuChanged(input.integrationId);
114585
- return {
114586
- added,
114587
- removed
114588
- };
114589
- }
114590
- };
114591
- }
114592
- //#endregion
114593
- //#region src/ccu/ccu-device-state-actions.ts
114594
- function requireDevice(devices, address) {
114595
- const device = devices.find((candidate) => candidate.address === address);
114596
- if (device === void 0) throw new Error(`Device ${address} is not known to the CCU`);
114597
- return device;
114598
- }
114599
- /** The first reading of `names` on any channel (the maintenance channel carries them). */
114600
- function reading(device, names) {
114601
- for (const channel of device.channels) {
114602
- const point = channel.dataPoints.find((candidate) => names.includes(candidate.parameter));
114603
- if (point !== void 0) return point.value;
114604
- }
114605
- }
114606
- function numberReading(device, names) {
114607
- const value = reading(device, names);
114608
- return typeof value === "number" ? value : null;
114609
- }
114610
- function boolReading(device, names) {
114611
- const value = reading(device, names);
114612
- return typeof value === "boolean" ? value : null;
114613
- }
114614
- function diagnosticsOf(device) {
114615
- const duty = reading(device, ["DUTY_CYCLE", "DUTYCYCLE"]);
114616
- return {
114617
- rssiDevice: numberReading(device, ["RSSI_DEVICE"]),
114618
- rssiPeer: numberReading(device, ["RSSI_PEER"]),
114619
- unreach: boolReading(device, ["UNREACH"]),
114620
- lowBattery: boolReading(device, ["LOW_BAT", "LOWBAT"]),
114621
- dutyCycle: typeof duty === "boolean" || typeof duty === "number" ? duty : null,
114622
- configPending: boolReading(device, ["CONFIG_PENDING"])
114623
- };
114624
- }
114625
- function toValueParam(point) {
114626
- return {
114627
- parameter: point.parameter,
114628
- type: point.type,
114629
- min: point.min ?? null,
114630
- max: point.max ?? null,
114631
- unit: point.unit ?? null,
114632
- valueList: point.valueList === void 0 ? null : [...point.valueList],
114633
- writable: point.writable,
114634
- readable: point.readable,
114635
- value: point.value
114636
- };
114637
- }
114638
- function toChannelValues(channel) {
114639
- return {
114640
- address: channel.address,
114641
- index: channel.index,
114642
- type: channel.type ?? null,
114643
- name: hmName(channel.name),
114644
- values: channel.dataPoints.map(toValueParam)
114645
- };
114646
- }
114647
- /**
114648
- * The device page panel: one CCU device's VALUES and maintenance readings,
114649
- * and a manual write of one writable value (a switch, a level, a key press).
114650
- */
114651
- function buildCcuDeviceStateHandlers(deps) {
114652
- return {
114653
- getCcuDeviceState: async (input) => {
114654
- const device = requireDevice(requireFacade(deps, input.integrationId).devices(), input.address);
114655
- return {
114656
- address: device.address,
114657
- name: hmName(device.name),
114658
- type: device.type,
114659
- firmware: {
114660
- installed: device.firmware ?? null,
114661
- available: device.availableFirmware ?? null,
114662
- updatable: device.updatable ?? null,
114663
- state: device.firmwareUpdateState ?? null
114664
- },
114665
- diagnostics: diagnosticsOf(device),
114666
- channels: device.channels.map(toChannelValues)
114667
- };
114575
+ try {
114576
+ return {
114577
+ messages: [...await facade.serviceMessages()],
114578
+ error: null
114579
+ };
114580
+ } catch (err) {
114581
+ deps.logger.warn("Homematic: service messages unavailable", { meta: {
114582
+ integrationId: input.integrationId,
114583
+ error: errorText(err)
114584
+ } });
114585
+ return {
114586
+ messages: [],
114587
+ error: errorText(err)
114588
+ };
114589
+ }
114668
114590
  },
114669
- setCcuValue: async (input) => {
114591
+ acknowledgeServiceMessage: async (input) => {
114670
114592
  requireConfirmed(input.confirmed);
114671
- const facade = requireFacade(deps, input.integrationId);
114672
- const device = facade.devices().find((candidate) => candidate.channels.some((ch) => ch.address === input.channel));
114673
- if (device === void 0) throw new Error(`Channel ${input.channel} is not known to the CCU`);
114674
- const point = device.channels.find((channel) => channel.address === input.channel)?.dataPoints.find((candidate) => candidate.parameter === input.parameter);
114675
- if (point === void 0 || !point.writable) throw new Error(`${input.parameter} is not a writable value of ${input.channel}`);
114676
- await facade.setValue({
114677
- device: device.address,
114678
- channel: input.channel,
114679
- parameter: input.parameter
114680
- }, input.value);
114681
- deps.logger.info("Homematic: value written", {
114682
- ...input.deviceId === void 0 ? {} : { tags: { deviceId: input.deviceId } },
114683
- meta: {
114684
- integrationId: input.integrationId,
114685
- channel: input.channel,
114686
- parameter: input.parameter,
114687
- value: input.value
114688
- }
114689
- });
114593
+ await requireFacade(deps, input.integrationId).acknowledgeServiceMessage(input.id);
114594
+ deps.logger.info("Homematic: service message acknowledged", { meta: {
114595
+ integrationId: input.integrationId,
114596
+ messageId: input.id
114597
+ } });
114690
114598
  return { ok: true };
114691
114599
  }
114692
114600
  };
114693
114601
  }
114694
114602
  //#endregion
114695
- //#region src/widget-catalog.ts
114603
+ //#region src/ccu/ccu-page.ts
114696
114604
  /**
114697
- * The addon's widgets for `addon-widgets-source.listWidgets`. The bundle is
114698
- * built by `vite.widgets.config.ts` into `dist/widgets/` (beside the page
114699
- * bundle, which owns `dist/remoteEntry.js`).
114605
+ * The CCU management page, surfaced through the `addon-pages-source` cap.
114606
+ * Mirrors the manifest `camstack.addons[].pages[]` entry — admin-ui's
114607
+ * `AddonPageLoader` loads `addon_provider_homematic_page/page` from
114608
+ * `/api/addon-pages/provider-homematic/remoteEntry.js`.
114700
114609
  */
114701
- var homematicWidgets = [{
114702
- tab: "device-tab",
114703
- label: "Homematic device",
114704
- preAuth: false,
114705
- kind: "remote",
114706
- remote: {
114707
- remoteName: "addon_provider_homematic_widgets",
114708
- exposedModule: "./widgets",
114709
- componentKey: "device-panel"
114710
- },
114711
- stableId: "device-panel",
114712
- description: "CCU values, diagnostics, manual actuation and MASTER configuration of one device.",
114610
+ var HOMEMATIC_PAGES = [{
114611
+ id: "homematic-ccu",
114612
+ label: "Homematic CCU",
114713
114613
  icon: "plug",
114714
- bundle: "widgets/remoteEntry.js",
114715
- hosts: ["device-tab"],
114716
- requires: {
114717
- deviceContext: true,
114718
- integrationContext: false
114719
- },
114720
- defaultSize: "xl",
114721
- allowedSizes: ["lg", "xl"],
114722
- defaultColumns: 12,
114723
- defaultRows: 4
114614
+ path: "/addon/homematic-ccu",
114615
+ remoteName: "addon_provider_homematic_page",
114616
+ bundle: "remoteEntry.js",
114617
+ section: "administration"
114724
114618
  }];
114725
114619
  //#endregion
114726
114620
  //#region ../../node_modules/nodehomematic/node_modules/undici/lib/core/symbols.js
@@ -139120,75 +139014,365 @@ function buildCcuPairingHandlers(deps) {
139120
139014
  };
139121
139015
  }
139122
139016
  //#endregion
139123
- //#region src/ccu/ccu-page.ts
139124
- /**
139125
- * The CCU management page, surfaced through the `addon-pages-source` cap.
139126
- * Mirrors the manifest `camstack.addons[].pages[]` entry — admin-ui's
139127
- * `AddonPageLoader` loads `addon_provider_homematic_page/page` from
139128
- * `/api/addon-pages/provider-homematic/remoteEntry.js`.
139129
- */
139130
- var HOMEMATIC_PAGES = [{
139131
- id: "homematic-ccu",
139132
- label: "Homematic CCU",
139133
- icon: "plug",
139134
- path: "/addon/homematic-ccu",
139135
- remoteName: "addon_provider_homematic_page",
139136
- bundle: "remoteEntry.js",
139137
- section: "administration"
139138
- }];
139017
+ //#region src/ccu/ccu-programs-actions.ts
139018
+ var REFUSAL_TEXT = {
139019
+ "not-connected": "The CCU is not connected",
139020
+ "not-confirmed": "A CCU write needs the operator confirmation (confirmed: true)",
139021
+ "unknown-program": "The CCU has no such program",
139022
+ internal: "An internal CCU program cannot be deleted here",
139023
+ "not-hmip-key": "A key-event program needs a HmIP button device",
139024
+ "unknown-channel": "That channel is not a key of this device",
139025
+ "no-channels": "A key-event program needs at least one key"
139026
+ };
139027
+ var ProgramRefusalError = class extends Error {
139028
+ reason;
139029
+ constructor(reason, detail) {
139030
+ super(detail ?? REFUSAL_TEXT[reason]);
139031
+ this.name = "ProgramRefusalError";
139032
+ this.reason = reason;
139033
+ }
139034
+ };
139035
+ /** Last run as epoch ms. Missing, blank, and epoch 0 are `null` — never shown as a run. */
139036
+ function parseLastRun(raw) {
139037
+ if (raw === void 0) return null;
139038
+ const trimmed = raw.trim();
139039
+ if (trimmed === "" || trimmed === "0") return null;
139040
+ const numeric = /^-?\d+(\.\d+)?$/.test(trimmed) ? Number(trimmed) : NaN;
139041
+ const ms = Number.isFinite(numeric) ? Math.abs(numeric) < 0xe8d4a51000 ? numeric * 1e3 : numeric : Date.parse(trimmed.includes("T") ? trimmed : trimmed.replace(" ", "T"));
139042
+ if (!Number.isFinite(ms) || ms < 1e3) return null;
139043
+ return ms;
139044
+ }
139045
+ function refuse(reason, detail) {
139046
+ throw new ProgramRefusalError(reason, detail);
139047
+ }
139048
+ function requireWrite(confirmed) {
139049
+ if (confirmed !== true) refuse("not-confirmed");
139050
+ }
139051
+ function connectedFacade(deps, integrationId) {
139052
+ const facade = deps.facade(integrationId);
139053
+ if (facade === null) refuse("not-connected");
139054
+ return facade;
139055
+ }
139056
+ function programById(facade, programId) {
139057
+ const found = facade.programs().find((program) => program.id === programId);
139058
+ if (found === void 0) refuse("unknown-program");
139059
+ return found;
139060
+ }
139061
+ function channelRow(address, names, adopted, adoptedNames) {
139062
+ const deviceAddress = deviceAddressOf$3(address);
139063
+ const ccu = names(address);
139064
+ const camstack = adoptedNames.get(deviceAddress)?.trim();
139065
+ return {
139066
+ address,
139067
+ channelName: ccu.channelName,
139068
+ deviceName: camstack !== void 0 && camstack !== "" ? camstack : ccu.deviceName,
139069
+ deviceId: adopted.get(deviceAddress) ?? null
139070
+ };
139071
+ }
139072
+ function keyRows(devices, adopted, adoptedNames) {
139073
+ const names = channelNameLookup(devices);
139074
+ return devices.filter(isHmipDevice).flatMap((device) => hmKeyChannels(device).map((channel) => {
139075
+ const resolved = channelRow(channel.address, names, adopted, adoptedNames);
139076
+ return {
139077
+ address: channel.address,
139078
+ name: hmName(channel.name),
139079
+ deviceAddress: device.address,
139080
+ deviceName: resolved.deviceName,
139081
+ deviceType: device.type
139082
+ };
139083
+ }));
139084
+ }
139085
+ async function conditionsOf(deps, integrationId, facade, program, devices, adopted, adoptedNames) {
139086
+ if (!isCamStackKeyEventProgramName(program.name)) return [];
139087
+ try {
139088
+ const found = await facade.getKeyEventProgram(program.name);
139089
+ const names = channelNameLookup(devices);
139090
+ return (found?.channelAddresses ?? []).map((address) => channelRow(address, names, adopted, adoptedNames));
139091
+ } catch (err) {
139092
+ const owner = devices.find((device) => keyEventProgramName(device) === program.name);
139093
+ const deviceId = owner === void 0 ? void 0 : adopted.get(owner.address);
139094
+ deps.logger.warn("Homematic key event program could not be read", {
139095
+ ...deviceId !== void 0 ? { tags: { deviceId } } : {},
139096
+ meta: {
139097
+ integrationId,
139098
+ programId: program.id,
139099
+ error: errorText(err)
139100
+ }
139101
+ });
139102
+ return [];
139103
+ }
139104
+ }
139105
+ function toRow(program, channels) {
139106
+ return {
139107
+ id: program.id,
139108
+ name: program.name,
139109
+ active: program.isActive,
139110
+ internal: program.isInternal,
139111
+ lastRunMs: parseLastRun(program.lastExecuteTime),
139112
+ createdByCamstack: isCamStackKeyEventProgramName(program.name),
139113
+ channels: [...channels]
139114
+ };
139115
+ }
139116
+ function deviceIdsOf(channels) {
139117
+ return [...new Set(channels.flatMap((channel) => channel.deviceId === null ? [] : [channel.deviceId]))];
139118
+ }
139119
+ function logProgram(deps, message, deviceIds, meta) {
139120
+ if (deviceIds.length === 0) {
139121
+ deps.logger.info(message, { meta });
139122
+ return;
139123
+ }
139124
+ for (const deviceId of deviceIds) deps.logger.info(message, {
139125
+ tags: { deviceId },
139126
+ meta
139127
+ });
139128
+ }
139129
+ async function refreshPrograms(deps, facade, integrationId) {
139130
+ try {
139131
+ await facade.refreshHub();
139132
+ } catch (err) {
139133
+ deps.logger.warn("Homematic: program list could not be refreshed", { meta: {
139134
+ integrationId,
139135
+ error: errorText(err)
139136
+ } });
139137
+ }
139138
+ deps.ccuChanged(integrationId);
139139
+ }
139140
+ /** The Programs tab: list every CCU program, and the key-event program CamStack can write. */
139141
+ function buildCcuProgramHandlers(deps) {
139142
+ return {
139143
+ listCcuPrograms: async (input) => {
139144
+ const facade = connectedFacade(deps, input.integrationId);
139145
+ const devices = facade.devices();
139146
+ const [adopted, adoptedNames] = await Promise.all([deps.adoptedAddresses(input.integrationId), deps.adoptedNames(input.integrationId)]);
139147
+ const programs = [];
139148
+ for (const program of facade.programs()) {
139149
+ const channels = await conditionsOf(deps, input.integrationId, facade, program, devices, adopted, adoptedNames);
139150
+ programs.push(toRow(program, channels));
139151
+ }
139152
+ return {
139153
+ programs,
139154
+ keys: keyRows(devices, adopted, adoptedNames)
139155
+ };
139156
+ },
139157
+ runCcuProgram: async (input) => {
139158
+ requireWrite(input.confirmed);
139159
+ const facade = connectedFacade(deps, input.integrationId);
139160
+ const program = programById(facade, input.programId);
139161
+ await facade.runProgram(program.id);
139162
+ const adopted = await deps.adoptedAddresses(input.integrationId);
139163
+ const names = await deps.adoptedNames(input.integrationId);
139164
+ logProgram(deps, "Homematic: program run", deviceIdsOf(await conditionsOf(deps, input.integrationId, facade, program, facade.devices(), adopted, names)), {
139165
+ integrationId: input.integrationId,
139166
+ programId: program.id,
139167
+ name: program.name
139168
+ });
139169
+ await refreshPrograms(deps, facade, input.integrationId);
139170
+ return { ok: true };
139171
+ },
139172
+ setCcuProgramActive: async (input) => {
139173
+ requireWrite(input.confirmed);
139174
+ const facade = connectedFacade(deps, input.integrationId);
139175
+ const program = programById(facade, input.programId);
139176
+ await facade.setProgramActive(program.id, input.active);
139177
+ logProgram(deps, `Homematic: program ${input.active ? "enabled" : "disabled"}`, [], {
139178
+ integrationId: input.integrationId,
139179
+ programId: program.id,
139180
+ name: program.name
139181
+ });
139182
+ await refreshPrograms(deps, facade, input.integrationId);
139183
+ return { ok: true };
139184
+ },
139185
+ deleteCcuProgram: async (input) => {
139186
+ requireWrite(input.confirmed);
139187
+ const facade = connectedFacade(deps, input.integrationId);
139188
+ const program = programById(facade, input.programId);
139189
+ if (program.isInternal) refuse("internal");
139190
+ const { removed } = await facade.removeKeyEventProgram(program.name);
139191
+ if (!removed) refuse("unknown-program");
139192
+ logProgram(deps, "Homematic: program deleted", [], {
139193
+ integrationId: input.integrationId,
139194
+ programId: program.id,
139195
+ name: program.name
139196
+ });
139197
+ await refreshPrograms(deps, facade, input.integrationId);
139198
+ return { ok: true };
139199
+ },
139200
+ ensureCcuKeyEventProgram: async (input) => {
139201
+ requireWrite(input.confirmed);
139202
+ const facade = connectedFacade(deps, input.integrationId);
139203
+ const device = facade.devices().find((candidate) => candidate.address === input.deviceAddress);
139204
+ if (device === void 0 || !isHmipDevice(device)) refuse("not-hmip-key");
139205
+ const keys = new Set(hmKeyChannels(device).map((channel) => channel.address));
139206
+ const wanted = [...new Set(input.channelAddresses)];
139207
+ if (wanted.length === 0) refuse("no-channels");
139208
+ const foreign = wanted.find((address) => !keys.has(address));
139209
+ if (foreign !== void 0) refuse("unknown-channel", `Channel ${foreign} is not a key of this device`);
139210
+ const name = keyEventProgramName(device);
139211
+ const { programId } = await facade.ensureKeyEventProgram({
139212
+ name,
139213
+ channelAddresses: wanted
139214
+ });
139215
+ const deviceId = (await deps.adoptedAddresses(input.integrationId)).get(device.address);
139216
+ logProgram(deps, "Homematic: key event program ensured", deviceId === void 0 ? [] : [deviceId], {
139217
+ integrationId: input.integrationId,
139218
+ programId,
139219
+ name,
139220
+ channels: wanted
139221
+ });
139222
+ await refreshPrograms(deps, facade, input.integrationId);
139223
+ return { ok: true };
139224
+ }
139225
+ };
139226
+ }
139139
139227
  //#endregion
139140
- //#region src/ccu/ccu-overview-actions.ts
139141
- /** The CCU overview tab: which CCUs exist, what each says about itself, and its service messages. */
139142
- function buildCcuOverviewHandlers(deps) {
139228
+ //#region src/ccu/ccu-rename-actions.ts
139229
+ function requireName$1(name) {
139230
+ const trimmed = name.trim();
139231
+ if (trimmed === "") throw new Error("A CCU name cannot be blank");
139232
+ return trimmed;
139233
+ }
139234
+ /** Renaming a device (optionally with its channels) or one channel on the CCU. */
139235
+ function buildCcuRenameHandlers(deps) {
139143
139236
  return {
139144
- listCcus: async (_input) => [...deps.integrations()],
139145
- ccuOverview: async (input) => {
139146
- const facade = requireFacade(deps, input.integrationId);
139147
- const [info, interfaces] = await Promise.allSettled([facade.ccuInfo(), facade.listInterfaces()]);
139148
- if (info.status === "rejected") deps.logger.warn("Homematic: CCU info unavailable", { meta: {
139237
+ renameCcuDevice: async (input) => {
139238
+ requireConfirmed(input.confirmed);
139239
+ const name = requireName$1(input.name);
139240
+ const renamed = await requireFacade(deps, input.integrationId).renameDevice(input.address, name, { renameChannels: input.renameChannels });
139241
+ deps.logger.info("Homematic: device renamed on the CCU", { meta: {
139149
139242
  integrationId: input.integrationId,
139150
- error: errorText(info.reason)
139243
+ address: input.address,
139244
+ name: renamed.device.name,
139245
+ channels: renamed.channels.length
139151
139246
  } });
139152
- if (interfaces.status === "rejected") deps.logger.warn("Homematic: interface list unavailable", { meta: {
139247
+ deps.ccuChanged(input.integrationId);
139248
+ return {
139249
+ device: {
139250
+ address: renamed.device.address,
139251
+ name: renamed.device.name
139252
+ },
139253
+ channels: renamed.channels.map((channel) => ({
139254
+ address: channel.address,
139255
+ name: channel.name
139256
+ }))
139257
+ };
139258
+ },
139259
+ renameCcuChannel: async (input) => {
139260
+ requireConfirmed(input.confirmed);
139261
+ const name = requireName$1(input.name);
139262
+ const renamed = await requireFacade(deps, input.integrationId).renameChannel(input.address, name);
139263
+ deps.logger.info("Homematic: channel renamed on the CCU", { meta: {
139153
139264
  integrationId: input.integrationId,
139154
- error: errorText(interfaces.reason)
139265
+ address: input.address,
139266
+ name: renamed.name
139155
139267
  } });
139268
+ deps.ccuChanged(input.integrationId);
139156
139269
  return {
139157
- info: info.status === "fulfilled" ? info.value : null,
139158
- infoError: info.status === "rejected" ? errorText(info.reason) : null,
139159
- interfaces: interfaces.status === "fulfilled" ? interfaces.value.map((iface) => ({
139160
- ...iface,
139161
- gateways: [...iface.gateways]
139162
- })) : [],
139163
- interfacesError: interfaces.status === "rejected" ? errorText(interfaces.reason) : null
139270
+ address: renamed.address,
139271
+ name: renamed.name
139164
139272
  };
139165
- },
139166
- listServiceMessages: async (input) => {
139167
- const facade = requireFacade(deps, input.integrationId);
139168
- try {
139169
- return {
139170
- messages: [...await facade.serviceMessages()],
139171
- error: null
139172
- };
139173
- } catch (err) {
139174
- deps.logger.warn("Homematic: service messages unavailable", { meta: {
139175
- integrationId: input.integrationId,
139176
- error: errorText(err)
139177
- } });
139273
+ }
139274
+ };
139275
+ }
139276
+ //#endregion
139277
+ //#region src/ccu/ccu-rooms-actions.ts
139278
+ function requireName(name) {
139279
+ const trimmed = name.trim();
139280
+ if (trimmed === "") throw new Error("A room needs a name");
139281
+ return trimmed;
139282
+ }
139283
+ /** Every channel a room may hold: all but the maintenance channel (index 0). */
139284
+ function roomCandidates(devices) {
139285
+ return devices.flatMap((device) => device.channels.filter((channel) => channel.index !== 0).map((channel) => ({
139286
+ address: channel.address,
139287
+ name: hmName(channel.name),
139288
+ deviceName: hmName(device.name),
139289
+ deviceType: device.type
139290
+ })));
139291
+ }
139292
+ /** The Settings tab's rooms: list, create, rename, delete, and which channels each holds. */
139293
+ function buildCcuRoomHandlers(deps) {
139294
+ const logWrite = (what, integrationId, extra) => {
139295
+ deps.logger.info(`Homematic: room ${what}`, { meta: {
139296
+ integrationId,
139297
+ ...extra
139298
+ } });
139299
+ };
139300
+ const toRoom = (room, devices) => {
139301
+ const names = channelNameLookup(devices);
139302
+ return {
139303
+ id: room.id,
139304
+ name: room.name,
139305
+ channels: room.channels.map((address) => {
139306
+ const found = names(address);
139178
139307
  return {
139179
- messages: [],
139180
- error: errorText(err)
139308
+ address,
139309
+ name: found.channelName,
139310
+ deviceName: found.deviceName,
139311
+ deviceType: found.deviceType
139181
139312
  };
139182
- }
139313
+ })
139314
+ };
139315
+ };
139316
+ return {
139317
+ listCcuRooms: async (input) => {
139318
+ const facade = requireFacade(deps, input.integrationId);
139319
+ const devices = facade.devices();
139320
+ return {
139321
+ rooms: (await facade.listRooms()).map((room) => toRoom(room, devices)),
139322
+ channels: roomCandidates(devices)
139323
+ };
139183
139324
  },
139184
- acknowledgeServiceMessage: async (input) => {
139325
+ createCcuRoom: async (input) => {
139185
139326
  requireConfirmed(input.confirmed);
139186
- await requireFacade(deps, input.integrationId).acknowledgeServiceMessage(input.id);
139187
- deps.logger.info("Homematic: service message acknowledged", { meta: {
139188
- integrationId: input.integrationId,
139189
- messageId: input.id
139190
- } });
139327
+ const name = requireName(input.name);
139328
+ const facade = requireFacade(deps, input.integrationId);
139329
+ const created = await facade.createRoom(name);
139330
+ logWrite("created", input.integrationId, {
139331
+ roomId: created.id,
139332
+ name: created.name
139333
+ });
139334
+ deps.ccuChanged(input.integrationId);
139335
+ return toRoom(created, facade.devices());
139336
+ },
139337
+ renameCcuRoom: async (input) => {
139338
+ requireConfirmed(input.confirmed);
139339
+ const name = requireName(input.name);
139340
+ await requireFacade(deps, input.integrationId).renameRoom(input.id, name);
139341
+ logWrite("renamed", input.integrationId, {
139342
+ roomId: input.id,
139343
+ name
139344
+ });
139345
+ deps.ccuChanged(input.integrationId);
139346
+ return { ok: true };
139347
+ },
139348
+ deleteCcuRoom: async (input) => {
139349
+ requireConfirmed(input.confirmed);
139350
+ await requireFacade(deps, input.integrationId).deleteRoom(input.id);
139351
+ logWrite("deleted", input.integrationId, { roomId: input.id });
139352
+ deps.ccuChanged(input.integrationId);
139191
139353
  return { ok: true };
139354
+ },
139355
+ setCcuRoomChannels: async (input) => {
139356
+ requireConfirmed(input.confirmed);
139357
+ const facade = requireFacade(deps, input.integrationId);
139358
+ const room = (await facade.listRooms()).find((candidate) => candidate.id === input.id);
139359
+ if (room === void 0) throw new Error(`The CCU has no room ${input.id}`);
139360
+ const wanted = new Set(input.channels);
139361
+ const current = new Set(room.channels);
139362
+ const added = input.channels.filter((address) => !current.has(address));
139363
+ const removed = room.channels.filter((address) => !wanted.has(address));
139364
+ for (const address of added) await facade.addChannelToRoom(input.id, address);
139365
+ for (const address of removed) await facade.removeChannelFromRoom(input.id, address);
139366
+ logWrite("members changed", input.integrationId, {
139367
+ roomId: input.id,
139368
+ added: added.length,
139369
+ removed: removed.length
139370
+ });
139371
+ if (added.length > 0 || removed.length > 0) deps.ccuChanged(input.integrationId);
139372
+ return {
139373
+ added,
139374
+ removed
139375
+ };
139192
139376
  }
139193
139377
  };
139194
139378
  }
@@ -139288,6 +139472,26 @@ var homematicActions = defineCustomActions({
139288
139472
  kind: "mutation",
139289
139473
  auth: "admin"
139290
139474
  }),
139475
+ listCcuPrograms: customAction(IntegrationRefSchema, CcuProgramsResultSchema, {
139476
+ kind: "query",
139477
+ auth: "admin"
139478
+ }),
139479
+ runCcuProgram: customAction(ProgramIdInputSchema, OkResultSchema, {
139480
+ kind: "mutation",
139481
+ auth: "admin"
139482
+ }),
139483
+ setCcuProgramActive: customAction(SetProgramActiveInputSchema, OkResultSchema, {
139484
+ kind: "mutation",
139485
+ auth: "admin"
139486
+ }),
139487
+ deleteCcuProgram: customAction(ProgramIdInputSchema, OkResultSchema, {
139488
+ kind: "mutation",
139489
+ auth: "admin"
139490
+ }),
139491
+ ensureCcuKeyEventProgram: customAction(EnsureKeyEventProgramInputSchema, OkResultSchema, {
139492
+ kind: "mutation",
139493
+ auth: "admin"
139494
+ }),
139291
139495
  renameCcuDevice: customAction(RenameDeviceInputSchema, DeviceRenameResultSchema, {
139292
139496
  kind: "mutation",
139293
139497
  auth: "admin"
@@ -139326,807 +139530,6 @@ var homematicActions = defineCustomActions({
139326
139530
  })
139327
139531
  });
139328
139532
  //#endregion
139329
- //#region src/callback-host.ts
139330
- /**
139331
- * Pick the hub LAN IPv4 a CCU at `ccuHost` can call back to. Prefers an
139332
- * address on the same /24 as the CCU; otherwise the first non-internal IPv4.
139333
- * Returns null when nothing suitable is found. Pure over the supplied addrs.
139334
- */
139335
- function pickCallbackHost(ccuHost, addrs) {
139336
- const ipv4 = addrs.filter((a) => (a.family === "IPv4" || a.family === "4") && !a.internal);
139337
- const first = ipv4[0];
139338
- if (first === void 0) return null;
139339
- const prefix = ccuHost.split(".").slice(0, 3).join(".");
139340
- return ((prefix.split(".").length === 3 ? ipv4.find((a) => a.address.startsWith(prefix + ".")) : void 0) ?? first).address;
139341
- }
139342
- /** Resolve the hub callback host from the live OS interfaces. */
139343
- function inferCallbackHost(ccuHost) {
139344
- const addrs = [];
139345
- for (const list of Object.values((0, node_os.networkInterfaces)())) for (const a of list ?? []) addrs.push({
139346
- family: String(a.family),
139347
- address: a.address,
139348
- internal: a.internal
139349
- });
139350
- return pickCallbackHost(ccuHost, addrs);
139351
- }
139352
- //#endregion
139353
- //#region src/config.ts
139354
- /**
139355
- * Operator-supplied CCU connection settings. Mirrors `HomematicOptions`
139356
- * from the wrapped `nodehomematic` library, but with the addon's own
139357
- * defaults + validation at the system boundary.
139358
- *
139359
- * The CCU exposes one or more XML-RPC interfaces; the operator selects
139360
- * which ones to bind (HmIP-RF for HomematicIP, BidCos-RF for classic
139361
- * Homematic, …). `callbackHost`/`callbackPort` are where the CCU calls
139362
- * BACK into this addon's local XML-RPC server to push value events —
139363
- * `callbackHost` must be an address the CCU can reach (usually the hub's
139364
- * LAN IP), NOT `127.0.0.1`.
139365
- *
139366
- * Credentials are optional: they unlock the JSON-RPC hub layer (names,
139367
- * rooms, system variables, programs). Without them the addon still works
139368
- * over plain XML-RPC, just with raw addresses instead of friendly names.
139369
- */
139370
- var homematicConfigSchema = object({
139371
- host: string().min(1).describe("CCU3 / RaspberryMatic host name or IP address"),
139372
- enableHmipRf: boolean().default(true).describe("Enable Homematic IP (HmIP-RF)"),
139373
- enableBidcosRf: boolean().default(false).describe("Enable Homematic (BidCos-RF). HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on"),
139374
- enableGroups: boolean().default(true).describe("Enable groups (heating groups / VirtualDevices)"),
139375
- enableBidcosWired: boolean().default(false).describe("Enable BidCos-Wired (HM-Wired)"),
139376
- username: string().default("Admin").describe("WebUI username (optional — enables names / rooms / sysvars)"),
139377
- password: string().default("").describe("WebUI password (optional)").meta({ secret: true }),
139378
- callbackHost: string().default("").describe("Address the CCU calls back to for event push (this hub LAN IP)"),
139379
- callbackPort: preprocess((v) => v === "" || v === null ? void 0 : v, number$1().int().min(1).max(65535).default(2128)).describe("Local XML-RPC callback server port"),
139380
- tls: boolean().default(false).describe("Use TLS for the CCU transport")
139381
- });
139382
- /**
139383
- * The XML-RPC interface names the operator's toggles select, in the library's
139384
- * order. Only the four interfaces supported by nodehomematic are included.
139385
- */
139386
- function enabledInterfaces(config) {
139387
- const interfaces = [];
139388
- if (config.enableHmipRf) interfaces.push("HmIP-RF");
139389
- if (config.enableBidcosRf) interfaces.push("BidCos-RF");
139390
- if (config.enableGroups) interfaces.push("VirtualDevices");
139391
- if (config.enableBidcosWired) interfaces.push("BidCos-Wired");
139392
- return interfaces;
139393
- }
139394
- /**
139395
- * Build the `HomematicOptions` the wrapped library constructor expects
139396
- * from the validated addon config. Pure: same config in → same options
139397
- * out. Credentials are forwarded when a username is set (the password may be
139398
- * empty on a CCU without WebUI authentication); without one the library skips
139399
- * the JSON-RPC hub layer cleanly.
139400
- */
139401
- function toHomematicOptions(config) {
139402
- const hasCredentials = config.username.length > 0;
139403
- const callbackHost = config.callbackHost.length > 0 ? config.callbackHost : inferCallbackHost(config.host) ?? "";
139404
- const interfaces = enabledInterfaces(config);
139405
- return {
139406
- host: config.host,
139407
- interfaces,
139408
- callback: {
139409
- host: callbackHost,
139410
- port: config.callbackPort
139411
- },
139412
- tls: config.tls,
139413
- ...hasCredentials ? { credentials: {
139414
- username: config.username,
139415
- password: config.password
139416
- } } : {}
139417
- };
139418
- }
139419
- /**
139420
- * Parse an integration's stored settings, or null while the host is missing or
139421
- * a field is invalid. Strings are trimmed; the password arrives resolved from
139422
- * the keychain.
139423
- */
139424
- function connectionFromSettings(settings) {
139425
- const raw = typeof settings === "object" && settings !== null ? settings : {};
139426
- const parsed = homematicConfigSchema.safeParse(Object.fromEntries(Object.entries(raw).map(([k, v]) => [k, typeof v === "string" ? v.trim() : v])));
139427
- return parsed.success ? parsed.data : null;
139428
- }
139429
- /**
139430
- * Structural equality over the fields that affect the live CCU connection. Two
139431
- * configs are "the same connection" when every field that would force a facade
139432
- * stop+start matches. A `null` argument is never equal to anything.
139433
- */
139434
- function sameConnection(a, b) {
139435
- if (a === null || b === null) return false;
139436
- return a.host === b.host && a.enableHmipRf === b.enableHmipRf && a.enableBidcosRf === b.enableBidcosRf && a.enableGroups === b.enableGroups && a.enableBidcosWired === b.enableBidcosWired && a.callbackHost === b.callbackHost && a.callbackPort === b.callbackPort && a.username === b.username && a.password === b.password && a.tls === b.tls;
139437
- }
139438
- /**
139439
- * What every Homematic device carries so the integration's cascade and offline
139440
- * helpers find it: the provenance marker and the integration (CCU session) it
139441
- * belongs to.
139442
- */
139443
- var homematicGatewayDeviceSchema = object({
139444
- integrationId: string().min(1).describe("Integration (CCU session) the device belongs to"),
139445
- system: literal("homematic"),
139446
- /** The adoption candidate id the device was adopted from. */
139447
- nativeId: string().min(1)
139448
- });
139449
- /** Why the form asks for credentials; shown first (translated through its `labelKey`). */
139450
- var CREDENTIALS_NOTICE = "Device and room names come from the CCU WebUI. Enter a WebUI user (Admin by default). If the WebUI has no login, leave the password empty. Without a user, devices are listed by their address.";
139451
- /**
139452
- * The integration form: a discovered-CCU picker (filled by the LAN scan), the
139453
- * host, the interfaces, the event callback, the WebUI credentials (the password
139454
- * is a `password` field, so it lands in the keychain) and TLS.
139455
- */
139456
- function buildConnectionFormSchema() {
139457
- return { sections: [
139458
- {
139459
- id: "connection",
139460
- title: "CCU connection",
139461
- titleKey: "provider-homematic:connection.s_connection.title",
139462
- columns: 1,
139463
- fields: [
139464
- {
139465
- type: "info",
139466
- key: "credentialsNotice",
139467
- label: CREDENTIALS_NOTICE,
139468
- labelKey: "provider-homematic:connection.s_connection.credentialsNotice.label",
139469
- content: ""
139470
- },
139471
- {
139472
- type: "addon-action-select",
139473
- addonId: "provider-homematic",
139474
- key: "__homematic-discovered",
139475
- writesKey: "host",
139476
- omitFromSettings: true,
139477
- label: "CCU",
139478
- labelKey: "provider-homematic:connection.s_connection.__homematic-discovered.label",
139479
- action: "discoverCcu",
139480
- mapOption: {
139481
- value: "host",
139482
- label: "name"
139483
- },
139484
- hideWhenFewerThan: 2,
139485
- emptyResultsMessage: "No CCU found on the network."
139486
- },
139487
- {
139488
- type: "text",
139489
- key: "host",
139490
- label: "Host / IP",
139491
- labelKey: "provider-homematic:connection.s_connection.host.label",
139492
- description: "Filled when one CCU is found. Type the address if it is not.",
139493
- descriptionKey: "provider-homematic:connection.s_connection.host.description",
139494
- required: true,
139495
- placeholder: "192.168.10.50"
139496
- }
139497
- ]
139498
- },
139499
- {
139500
- id: "interfaces",
139501
- title: "Interfaces",
139502
- titleKey: "provider-homematic:connection.s_interfaces.title",
139503
- description: "CCU-Jack and CUxD are not supported.",
139504
- descriptionKey: "provider-homematic:connection.s_interfaces.description",
139505
- columns: 1,
139506
- fields: [
139507
- {
139508
- type: "boolean",
139509
- key: "enableHmipRf",
139510
- label: "Enable Homematic IP",
139511
- labelKey: "provider-homematic:connection.s_interfaces.enableHmipRf.label",
139512
- default: true
139513
- },
139514
- {
139515
- type: "boolean",
139516
- key: "enableBidcosRf",
139517
- label: "Enable Homematic (BidCos-RF)",
139518
- labelKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.label",
139519
- description: "HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on.",
139520
- descriptionKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.description",
139521
- default: false
139522
- },
139523
- {
139524
- type: "boolean",
139525
- key: "enableGroups",
139526
- label: "Enable groups (heating groups)",
139527
- labelKey: "provider-homematic:connection.s_interfaces.enableGroups.label",
139528
- default: true
139529
- },
139530
- {
139531
- type: "boolean",
139532
- key: "enableBidcosWired",
139533
- label: "Enable BidCos-Wired (HM-Wired)",
139534
- labelKey: "provider-homematic:connection.s_interfaces.enableBidcosWired.label",
139535
- default: false
139536
- }
139537
- ]
139538
- },
139539
- {
139540
- id: "callback",
139541
- title: "Event callback",
139542
- titleKey: "provider-homematic:connection.s_callback.title",
139543
- description: "Optional; must be reachable from the CCU (not 127.0.0.1). Blank auto-infers the hub LAN address.",
139544
- descriptionKey: "provider-homematic:connection.s_callback.description",
139545
- columns: 2,
139546
- fields: [{
139547
- type: "text",
139548
- key: "callbackHost",
139549
- label: "Callback host (optional — auto-inferred when blank)",
139550
- labelKey: "provider-homematic:connection.s_callback.callbackHost.label",
139551
- placeholder: "auto (this hub LAN IP)"
139552
- }, {
139553
- type: "number",
139554
- key: "callbackPort",
139555
- label: "Callback port",
139556
- labelKey: "provider-homematic:connection.s_callback.callbackPort.label",
139557
- min: 1,
139558
- max: 65535,
139559
- default: 2128
139560
- }]
139561
- },
139562
- {
139563
- id: "credentials",
139564
- title: "WebUI credentials",
139565
- titleKey: "provider-homematic:connection.s_credentials.title",
139566
- description: "Optional. Unlocks friendly names, rooms, system variables and programs.",
139567
- descriptionKey: "provider-homematic:connection.s_credentials.description",
139568
- columns: 2,
139569
- fields: [{
139570
- type: "text",
139571
- key: "username",
139572
- label: "Username",
139573
- labelKey: "provider-homematic:connection.s_credentials.username.label",
139574
- default: "Admin"
139575
- }, {
139576
- type: "password",
139577
- key: "password",
139578
- label: "Password",
139579
- labelKey: "provider-homematic:connection.s_credentials.password.label",
139580
- showToggle: true
139581
- }]
139582
- },
139583
- {
139584
- id: "advanced",
139585
- title: "Advanced",
139586
- titleKey: "provider-homematic:connection.s_advanced.title",
139587
- columns: 1,
139588
- fields: [{
139589
- type: "boolean",
139590
- key: "tls",
139591
- label: "Use TLS",
139592
- labelKey: "provider-homematic:connection.s_advanced.tls.label"
139593
- }]
139594
- }
139595
- ] };
139596
- }
139597
- var homematicConnectionsEntryKind = defineEntryKind("connections", {
139598
- title: "Homematic CCUs",
139599
- schema: entryBody({
139600
- host: string().nullish(),
139601
- enableHmipRf: boolean().nullish(),
139602
- enableBidcosRf: boolean().nullish(),
139603
- enableGroups: boolean().nullish(),
139604
- enableBidcosWired: boolean().nullish(),
139605
- username: string().nullish(),
139606
- password: string().optional().meta({ secret: true }),
139607
- callbackHost: string().nullish(),
139608
- callbackPort: number$1().int().min(1).max(65535).nullish(),
139609
- tls: boolean().nullish()
139610
- }),
139611
- writeTrigger: "an operator adds, edits or removes a Homematic CCU"
139612
- });
139613
- /** Every kind this addon declares, keyed by its name. */
139614
- var homematicRecordKinds = { connections: homematicConnectionsEntryKind };
139615
- /** The record body as the flat settings the connection schema parses: no name, no unset keys. */
139616
- function connectionSettingsOf(body) {
139617
- const out = {};
139618
- for (const [key, value] of Object.entries(body)) {
139619
- if (key === "name" || value === null || value === void 0) continue;
139620
- out[key] = value;
139621
- }
139622
- return out;
139623
- }
139624
- function settingsReadOf(resolved) {
139625
- return resolved === null ? {
139626
- values: {},
139627
- secretsLocked: false
139628
- } : {
139629
- values: connectionSettingsOf(resolved.body),
139630
- secretsLocked: resolved.secrets === "unavailable"
139631
- };
139632
- }
139633
- function buildHomematicInstances(records, deps) {
139634
- const handle = records.kind(homematicConnectionsEntryKind);
139635
- return new RecordIntegrationInstances(records, homematicConnectionsEntryKind, {
139636
- description: {
139637
- role: "devices",
139638
- discovery: {
139639
- mode: "lan",
139640
- scopedToInstance: false
139641
- },
139642
- instanceMode: "multiple",
139643
- kind: "connection",
139644
- canTest: true,
139645
- kinds: [{
139646
- id: "connection",
139647
- label: "Homematic",
139648
- functionCap: "device-provider",
139649
- role: "devices"
139650
- }]
139651
- },
139652
- formSchema: () => buildConnectionFormSchema(),
139653
- initialBody: (name) => ({ name }),
139654
- configured: (body) => (body.host ?? "").trim().length > 0,
139655
- onChanged: () => deps.onChanged(),
139656
- test: async ({ id, values }) => {
139657
- const stored = id === null ? null : (await handle.getResolved(id))?.data ?? null;
139658
- const typed = values["password"];
139659
- const password = typeof typed === "string" && typed !== "" && typed !== "__camstack_redacted__" ? typed : stored?.password ?? "";
139660
- const outcome = await deps.tester.testSettings({ settings: {
139661
- ...stored === null ? {} : connectionSettingsOf(stored),
139662
- ...values,
139663
- password
139664
- } });
139665
- if (outcome.outcome === "validated") return {
139666
- success: true,
139667
- status: "validated",
139668
- ...outcome.latencyMs !== void 0 ? { latencyMs: outcome.latencyMs } : {},
139669
- ...outcome.detail !== void 0 ? { detail: outcome.detail } : {}
139670
- };
139671
- return {
139672
- success: false,
139673
- status: outcome.outcome,
139674
- error: outcome.error
139675
- };
139676
- }
139677
- });
139678
- }
139679
- /** The ONE reader of a CCU's connection: the integration's record, never the legacy rows. */
139680
- async function readCcuConnection(instances, integrationId) {
139681
- const read = settingsReadOf(await instances.readResolved(integrationId));
139682
- return {
139683
- connection: connectionFromSettings(read.values),
139684
- secretsLocked: read.secretsLocked
139685
- };
139686
- }
139687
- /** The hosts of the CCUs already set up, for discovery to leave out; an unreadable one is skipped. */
139688
- async function knownCcuHostsOf(deps) {
139689
- const hosts = [];
139690
- for (const id of deps.integrationIds) try {
139691
- const { connection } = await readCcuConnection(deps.instances, id);
139692
- if (connection !== null) hosts.push(connection.host);
139693
- } catch (err) {
139694
- deps.onUnreadable(id, err);
139695
- }
139696
- return hosts;
139697
- }
139698
- //#endregion
139699
- //#region src/migrations/integration-rows-to-record.ts
139700
- /**
139701
- * Every Homematic integration moves from legacy `integration_settings` rows into its own
139702
- * `connections` record under the registry id (planning#416, D1007): the CCU connection the live
139703
- * session dials, the WebUI password a keychain secret declared by the kind. Each integration's
139704
- * record is built from ITS OWN rows, never from another's. Only the integration configuration
139705
- * moves: adopted devices, their stable ids and their history are not touched.
139706
- *
139707
- * Keys nothing reads any more are named in a warning, by key, and dropped with the rows once the
139708
- * record has been read back; a value of the wrong type is left out and named by key as well.
139709
- */
139710
- var HOMEMATIC_ROWS_TO_RECORD_ID = "provider-homematic/2026-11-05-integration-rows-to-record";
139711
- var TEXT_KEYS = [
139712
- "host",
139713
- "username",
139714
- "callbackHost"
139715
- ];
139716
- var FLAG_KEYS = [
139717
- "enableHmipRf",
139718
- "enableBidcosRf",
139719
- "enableGroups",
139720
- "enableBidcosWired",
139721
- "tls"
139722
- ];
139723
- function portOf(value) {
139724
- const n = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
139725
- return typeof n === "number" && Number.isInteger(n) && n >= 1 && n <= 65535 ? n : null;
139726
- }
139727
- /** The record body of one integration, from its resolved legacy rows. Never logs a value. */
139728
- function homematicBodyFromRows(values, log, integration) {
139729
- const body = { name: integration.name };
139730
- const unusable = [];
139731
- const known = new Set([
139732
- "password",
139733
- "callbackPort",
139734
- ...TEXT_KEYS,
139735
- ...FLAG_KEYS
139736
- ]);
139737
- for (const key of TEXT_KEYS) {
139738
- if (!(key in values)) continue;
139739
- const raw = values[key];
139740
- if (typeof raw === "string") {
139741
- if (raw.trim() !== "") body[key] = raw.trim();
139742
- } else unusable.push(key);
139743
- }
139744
- for (const key of FLAG_KEYS) {
139745
- if (!(key in values)) continue;
139746
- const raw = values[key];
139747
- if (typeof raw === "boolean") body[key] = raw;
139748
- else unusable.push(key);
139749
- }
139750
- if ("callbackPort" in values) {
139751
- const raw = values["callbackPort"];
139752
- if (raw !== "" && raw !== null) {
139753
- const port = portOf(raw);
139754
- if (port === null) unusable.push("callbackPort");
139755
- else body["callbackPort"] = port;
139756
- }
139757
- }
139758
- if ("password" in values) {
139759
- const password = values["password"];
139760
- if (typeof password === "string") {
139761
- if (password.length > 0) body["password"] = password;
139762
- } else unusable.push("password");
139763
- }
139764
- const unknown = Object.keys(values).filter((key) => !known.has(key));
139765
- if (unknown.length > 0) log.warn(`integration '${integration.id}': legacy settings nothing reads any more are dropped: ${unknown.join(", ")}`);
139766
- if (unusable.length > 0) log.warn(`integration '${integration.id}': legacy settings with an unusable value are left out: ${unusable.join(", ")}`);
139767
- return homematicConnectionsEntryKind.schema.parse(body);
139768
- }
139769
- var HOMEMATIC_ROWS_TO_RECORD_MIGRATION = {
139770
- meta: {
139771
- id: HOMEMATIC_ROWS_TO_RECORD_ID,
139772
- owner: "provider-homematic",
139773
- level: "addon-state",
139774
- seq: 1,
139775
- dependsOn: [],
139776
- store: "settings",
139777
- scope: "cluster",
139778
- onFailure: "block-owner",
139779
- bodyKind: "procedure",
139780
- description: "Move every Homematic CCU integration into its own connection record keyed by its registry id, the WebUI password as a keychain secret, then clear its legacy integration settings rows; adopted devices are not touched",
139781
- fixtureMark: "a legacy setting key the migration does not know"
139782
- },
139783
- procedure: (ports) => moveIntegrationRowsToRecords(ports, {
139784
- addonId: "provider-homematic",
139785
- secretPaths: homematicConnectionsEntryKind.declaration.secretPaths,
139786
- bodyFrom: homematicBodyFromRows
139787
- })
139788
- };
139789
- //#endregion
139790
- //#region src/homematic-diagnostics-mapping.ts
139791
- var MAINTENANCE_CHANNEL_TYPE$1 = "MAINTENANCE";
139792
- /** Reachability parameters that drive the Container's `online`, not a child. */
139793
- var REACHABILITY_PARAMS$1 = ["UNREACH", "STICKY_UNREACH"];
139794
- function findMaintenanceChannel(device) {
139795
- return device.channels.find((channel) => channel.type?.toUpperCase() === MAINTENANCE_CHANNEL_TYPE$1);
139796
- }
139797
- function findParam(channel, parameter) {
139798
- return channel.dataPoints.find((dp) => dp.parameter.toUpperCase() === parameter);
139799
- }
139800
- /** A datapoint is "boolean" when its declared CCU type is BOOL/ACTION. */
139801
- function isBooleanDataPoint(dp) {
139802
- const type = dp.type.toUpperCase();
139803
- return type === "BOOL" || type === "ACTION";
139804
- }
139805
- /**
139806
- * Map a device's MAINTENANCE channel to its diagnostic derived entities.
139807
- * Emits one entity per recognised datapoint; returns `[]` when there is no
139808
- * MAINTENANCE channel or no recognised datapoints. Entities are emitted even
139809
- * when the datapoint `value` is still `null` — the value arrives via push.
139810
- */
139811
- function mapMaintenanceChannel(device) {
139812
- const channel = findMaintenanceChannel(device);
139813
- if (!channel) return [];
139814
- const entities = [];
139815
- if (findParam(channel, "LOW_BAT")) {
139816
- const voltage = findParam(channel, "OPERATING_VOLTAGE");
139817
- if (voltage) entities.push({
139818
- key: "maint-voltage",
139819
- deviceType: DeviceType.Sensor,
139820
- role: DeviceRole.VoltageSensor,
139821
- capabilities: ["numeric-sensor"],
139822
- name: "Operating voltage",
139823
- unit: voltage.unit ?? "V",
139824
- sourceParams: ["OPERATING_VOLTAGE"]
139825
- });
139826
- else entities.push({
139827
- key: "maint-battery-low",
139828
- deviceType: DeviceType.Sensor,
139829
- role: DeviceRole.BatterySensor,
139830
- capabilities: ["binary"],
139831
- name: "Battery low",
139832
- sourceParams: ["LOW_BAT"]
139833
- });
139834
- }
139835
- const rssiDevice = findParam(channel, "RSSI_DEVICE");
139836
- if (rssiDevice) entities.push({
139837
- key: "maint-rssi-device",
139838
- deviceType: DeviceType.Sensor,
139839
- role: DeviceRole.NumericSensor,
139840
- capabilities: ["numeric-sensor"],
139841
- name: "Signal (device)",
139842
- unit: rssiDevice.unit ?? "dBm",
139843
- sourceParams: ["RSSI_DEVICE"]
139844
- });
139845
- const rssiPeer = findParam(channel, "RSSI_PEER");
139846
- if (rssiPeer) entities.push({
139847
- key: "maint-rssi-peer",
139848
- deviceType: DeviceType.Sensor,
139849
- role: DeviceRole.NumericSensor,
139850
- capabilities: ["numeric-sensor"],
139851
- name: "Signal (peer)",
139852
- unit: rssiPeer.unit ?? "dBm",
139853
- sourceParams: ["RSSI_PEER"]
139854
- });
139855
- const dutyCycle = findParam(channel, "DUTY_CYCLE");
139856
- if (dutyCycle) if (isBooleanDataPoint(dutyCycle)) entities.push({
139857
- key: "maint-duty-cycle",
139858
- deviceType: DeviceType.Sensor,
139859
- role: DeviceRole.BinarySensor,
139860
- capabilities: ["binary"],
139861
- name: "Duty cycle",
139862
- sourceParams: ["DUTY_CYCLE"]
139863
- });
139864
- else entities.push({
139865
- key: "maint-duty-cycle",
139866
- deviceType: DeviceType.Sensor,
139867
- role: DeviceRole.NumericSensor,
139868
- capabilities: ["numeric-sensor"],
139869
- name: "Duty cycle",
139870
- unit: dutyCycle.unit ?? "%",
139871
- sourceParams: ["DUTY_CYCLE"]
139872
- });
139873
- const operatingTemp = findParam(channel, "OPERATING_TEMPERATURE");
139874
- const actualTemp = findParam(channel, "ACTUAL_TEMPERATURE");
139875
- const temp = operatingTemp ?? actualTemp;
139876
- if (temp) entities.push({
139877
- key: "maint-temperature",
139878
- deviceType: DeviceType.Sensor,
139879
- role: DeviceRole.TemperatureSensor,
139880
- capabilities: ["temperature-sensor"],
139881
- name: operatingTemp ? "Operating temperature" : "Temperature",
139882
- unit: temp.unit ?? "°C",
139883
- sourceParams: [temp.parameter.toUpperCase()]
139884
- });
139885
- return entities;
139886
- }
139887
- /**
139888
- * Decide whether a device should expose a firmware Update child. Returns the
139889
- * update entity when the device carries ANY firmware descriptor field (at
139890
- * least `firmware`, or `updatable === true`); otherwise `null`. The device
139891
- * class reads the live firmware fields to populate the `update` cap slice;
139892
- * this helper only decides whether the child exists.
139893
- */
139894
- function mapFirmwareUpdate(device) {
139895
- if (!(device.firmware !== void 0 || device.availableFirmware !== void 0 || device.firmwareUpdateState !== void 0 || device.updatable === true)) return null;
139896
- return {
139897
- key: "update",
139898
- deviceType: DeviceType.Update,
139899
- role: null,
139900
- capabilities: ["update"],
139901
- name: "Firmware"
139902
- };
139903
- }
139904
- /**
139905
- * Read the device's reachability from its MAINTENANCE channel. Returns
139906
- * `{ unreach }` when an UNREACH (or STICKY_UNREACH) datapoint is present, or
139907
- * `null` when reachability is unknown. The Container task derives
139908
- * `online = !unreach` from this.
139909
- */
139910
- function readReachability(device) {
139911
- const channel = findMaintenanceChannel(device);
139912
- if (!channel) return null;
139913
- for (const param of REACHABILITY_PARAMS$1) {
139914
- const dp = findParam(channel, param);
139915
- if (dp) return { unreach: Boolean(dp.value) };
139916
- }
139917
- return null;
139918
- }
139919
- //#endregion
139920
- //#region src/devices/hm-entity-spec.ts
139921
- var MAINTENANCE_CHANNEL_TYPE = "MAINTENANCE";
139922
- /**
139923
- * Map a custom-entity kind to the actuator discriminant + its CamStack cap +
139924
- * CamStack DeviceType. Returns null for kinds with no actuator wiring.
139925
- */
139926
- function actuatorInfo(kind) {
139927
- switch (kind) {
139928
- case "switch": return {
139929
- kind: "switch",
139930
- capName: "switch",
139931
- type: DeviceType.Switch
139932
- };
139933
- case "cover":
139934
- case "blind": return {
139935
- kind: "cover",
139936
- capName: "cover",
139937
- type: DeviceType.Cover
139938
- };
139939
- case "light": return {
139940
- kind: "light",
139941
- capName: "switch",
139942
- type: DeviceType.Light
139943
- };
139944
- case "lock": return {
139945
- kind: "lock",
139946
- capName: "lock-control",
139947
- type: DeviceType.Lock
139948
- };
139949
- case "climate": return {
139950
- kind: "climate",
139951
- capName: "climate-control",
139952
- type: DeviceType.Climate
139953
- };
139954
- default: return null;
139955
- }
139956
- }
139957
- /**
139958
- * The cover KIND of an actuator: a `blind` custom entity is a blind (slat
139959
- * tilt), a plain `cover` entity is the roller shutter (HmIP-BROLL). Exporters
139960
- * read it; every other actuator has no role.
139961
- */
139962
- function actuatorRole(kind, model) {
139963
- if (kind === "blind") return DeviceRole.CoverBlind;
139964
- if (kind === "cover") return DeviceRole.CoverShutter;
139965
- if (kind === "climate") return climateRoleOfModel(model);
139966
- return null;
139967
- }
139968
- /** Radiator valves: HmIP-eTRV-* and the classic HM-CC-RT-DN. */
139969
- var RADIATOR_MODEL = /eTRV|HM-CC-RT-DN/i;
139970
- /** Floor-heating actuators: HmIP-FAL* / HmIP-FALMOT-*. */
139971
- var FLOOR_MODEL = /FAL/i;
139972
- /**
139973
- * D1033 — which climate device a Homematic model is. A radiator valve and a
139974
- * floor-heating actuator are told apart by model; a wall thermostat, a
139975
- * heating group and an unknown model are thermostats.
139976
- */
139977
- function climateRoleOfModel(model) {
139978
- if (model !== void 0 && RADIATOR_MODEL.test(model)) return DeviceRole.ClimateRadiator;
139979
- if (model !== void 0 && FLOOR_MODEL.test(model)) return DeviceRole.ClimateFloor;
139980
- return DeviceRole.ClimateThermostat;
139981
- }
139982
- /** Actuator specs from the library's typed custom entities (correct channel). */
139983
- function deriveActuatorSpecs(customEntities, model) {
139984
- const out = [];
139985
- for (const entity of customEntities) {
139986
- const info = actuatorInfo(entity.kind);
139987
- if (info === null) continue;
139988
- out.push({
139989
- key: `act-${entity.channel}`,
139990
- deviceType: info.type,
139991
- role: actuatorRole(entity.kind, model),
139992
- capabilities: [info.capName],
139993
- name: `${entity.kind} ${entity.channel}`,
139994
- config: {
139995
- channel: entity.channel,
139996
- kind: info.kind,
139997
- capabilities: [info.capName]
139998
- }
139999
- });
140000
- }
140001
- return out;
140002
- }
140003
- /** Sensor specs (one per sensor channel) + ONE event-emitter spec over the
140004
- * union of key channels. Skips actuator caps (custom-entity-driven). */
140005
- function deriveSensorAndEventSpecs(device) {
140006
- const out = [];
140007
- const keyChannels = [];
140008
- for (const { channel, mapping } of mapHmDeviceChannels(device)) {
140009
- const sensorCaps = [];
140010
- let isEvent = false;
140011
- for (const capName of mapping.capabilities) {
140012
- if (capName === "event-emitter") {
140013
- isEvent = true;
140014
- continue;
140015
- }
140016
- if (ACTUATOR_CAP_NAMES.has(capName)) continue;
140017
- sensorCaps.push(capName);
140018
- }
140019
- if (isEvent) keyChannels.push(channel);
140020
- if (sensorCaps.length > 0) out.push({
140021
- key: `sensor-${channel.address}`,
140022
- deviceType: DeviceType.Sensor,
140023
- role: mapping.role,
140024
- capabilities: sensorCaps,
140025
- name: `Sensor ${channel.address}`,
140026
- config: {
140027
- channel: channel.address,
140028
- capabilities: sensorCaps,
140029
- ...mapping.role !== null ? { role: mapping.role } : {}
140030
- }
140031
- });
140032
- }
140033
- if (keyChannels.length > 0) {
140034
- const eventTypes = [...keyEventVocabulary(keyChannels)];
140035
- out.push({
140036
- key: "events",
140037
- deviceType: DeviceType.EventEmitter,
140038
- role: null,
140039
- capabilities: ["event-emitter"],
140040
- name: "Buttons",
140041
- config: {
140042
- capabilities: ["event-emitter"],
140043
- eventTypes
140044
- }
140045
- });
140046
- }
140047
- return out;
140048
- }
140049
- /** Diagnostic specs from the MAINTENANCE channel. */
140050
- function deriveDiagnosticSpecs(device, address) {
140051
- const channelAddress = device.channels.find((c) => c.type?.toUpperCase() === MAINTENANCE_CHANNEL_TYPE)?.address ?? `${address}:0`;
140052
- return mapMaintenanceChannel(device).map((entity) => diagnosticSpec(entity, channelAddress));
140053
- }
140054
- function diagnosticSpec(entity, channelAddress) {
140055
- return {
140056
- key: entity.key,
140057
- deviceType: entity.deviceType,
140058
- role: entity.role,
140059
- capabilities: [...entity.capabilities],
140060
- name: entity.name,
140061
- config: {
140062
- channel: channelAddress,
140063
- capabilities: [...entity.capabilities],
140064
- sourceParams: [...entity.sourceParams ?? []],
140065
- ...entity.role !== null ? { role: entity.role } : {},
140066
- ...entity.unit !== void 0 ? { unit: entity.unit } : {}
140067
- }
140068
- };
140069
- }
140070
- /** Firmware Update spec (if the device carries a firmware descriptor). */
140071
- function deriveUpdateSpec(device) {
140072
- const update = mapFirmwareUpdate(device);
140073
- if (!update) return [];
140074
- return [{
140075
- key: update.key,
140076
- deviceType: update.deviceType,
140077
- role: update.role,
140078
- capabilities: [...update.capabilities],
140079
- name: update.name,
140080
- config: { capabilities: [...update.capabilities] }
140081
- }];
140082
- }
140083
- /**
140084
- * Derive the full per-entity spec list for a single Homematic device. ONE pure
140085
- * function reused by the Container (`'devices'` granularity) and the standalone
140086
- * entity adoption (`'entities'` granularity). `customEntities` are the device's
140087
- * typed actuator entities from the facade (`[]` for the facade-less preview).
140088
- */
140089
- function deriveHmEntitySpecs(device, customEntities) {
140090
- return [
140091
- ...deriveActuatorSpecs(customEntities, device.type),
140092
- ...deriveSensorAndEventSpecs(device),
140093
- ...deriveDiagnosticSpecs(device, device.address),
140094
- ...deriveUpdateSpec(device)
140095
- ];
140096
- }
140097
- //#endregion
140098
- //#region src/devices/hm-primary-child.ts
140099
- var ACT_PREFIX = "act-";
140100
- function channelIndex(key) {
140101
- const suffix = channelIndexFromAddress(key.slice(4));
140102
- if (suffix === null) return Number.MAX_SAFE_INTEGER;
140103
- const parsed = Number(suffix);
140104
- return Number.isFinite(parsed) ? parsed : Number.MAX_SAFE_INTEGER;
140105
- }
140106
- /**
140107
- * Which child a Homematic container stands for.
140108
- *
140109
- * A device with relay channels stands for the first relay (lowest channel
140110
- * index), so a two-relay switch is not left to the namesake tie-break. A
140111
- * key-only device (no actuator) stands for its event-emitter. Anything else
140112
- * declares nothing and the shared heuristic decides.
140113
- */
140114
- function hmPrimaryChildKeys(specs) {
140115
- const first = specs.filter((spec) => spec.key.startsWith(ACT_PREFIX) && spec.config["kind"] === "switch").toSorted((a, b) => channelIndex(a.key) - channelIndex(b.key))[0];
140116
- if (first !== void 0) return [first.key];
140117
- if (specs.some((spec) => spec.key.startsWith(ACT_PREFIX))) return [];
140118
- return specs.some((spec) => spec.key === "events") ? ["events"] : [];
140119
- }
140120
- /**
140121
- * The preference to write, or null when the container already has one or
140122
- * there is nothing to declare. An operator pick is a different column.
140123
- */
140124
- function preferenceToStamp(stored, declared) {
140125
- if (stored !== void 0 && stored.length > 0) return null;
140126
- if (declared.length === 0) return null;
140127
- return declared;
140128
- }
140129
- //#endregion
140130
139533
  //#region src/devices/hm-key-link-states.ts
140131
139534
  /**
140132
139535
  * One snapshot of a device's key-channel central links, shared by the
@@ -140156,21 +139559,42 @@ async function publishKeyLinkStates(integrationId, read) {
140156
139559
  const keys = hmKeyChannels(read.device);
140157
139560
  if (keys.length === 0) return null;
140158
139561
  const names = channelNameLookup(read.facade.devices());
139562
+ const coverage = await keyEventCoverage(read);
140159
139563
  const states = [];
140160
139564
  let failed = false;
140161
139565
  for (const channel of keys) {
140162
- const one = await readKey(read, names, channel);
139566
+ const one = await readKey(read, names, channel, coverage.get(channel.address) ?? null);
140163
139567
  if (one.failed) failed = true;
140164
139568
  states.push(one.state);
140165
139569
  }
140166
139570
  published.set(storeKey(integrationId, read.deviceAddress), states);
140167
139571
  return { failed };
140168
139572
  }
140169
- async function readKey(read, names, channel) {
139573
+ /** Channel address → program name, for keys the device's key-event program covers. */
139574
+ async function keyEventCoverage(read) {
139575
+ if (!isHmipDevice(read.device)) return /* @__PURE__ */ new Map();
139576
+ const name = keyEventProgramName(read.device);
139577
+ try {
139578
+ const program = await read.facade.getKeyEventProgram(name);
139579
+ if (program === null) return /* @__PURE__ */ new Map();
139580
+ return new Map(program.channelAddresses.map((address) => [address, name]));
139581
+ } catch (err) {
139582
+ read.logger.warn("Homematic key event program could not be read", {
139583
+ tags: { deviceId: read.deviceId },
139584
+ meta: {
139585
+ address: read.deviceAddress,
139586
+ error: err instanceof Error ? err.message : String(err)
139587
+ }
139588
+ });
139589
+ return /* @__PURE__ */ new Map();
139590
+ }
139591
+ }
139592
+ async function readKey(read, names, channel, programName) {
140170
139593
  const base = {
140171
139594
  address: channel.address,
140172
139595
  name: hmName(channel.name),
140173
- index: channelIndexFromAddress(channel.address) ?? String(channel.index)
139596
+ index: channelIndexFromAddress(channel.address) ?? String(channel.index),
139597
+ programName
140174
139598
  };
140175
139599
  try {
140176
139600
  const state = await read.facade.getChannelLinkState(channel.address);
@@ -140278,129 +139702,6 @@ var HmFacadeResolver = class {
140278
139702
  /** The single in-process resolver shared between the integration and its devices. */
140279
139703
  var homematicFacades = new HmFacadeResolver();
140280
139704
  //#endregion
140281
- //#region src/devices/hm-button-events-section.ts
140282
- var ADDON_ID = "provider-homematic";
140283
- var NS$1 = "provider-homematic:device.buttonEvents";
140284
- function keyLabel(key) {
140285
- return key.name ?? `Key ${key.index}`;
140286
- }
140287
- function linkText(link) {
140288
- const target = link.receiverName ?? link.receiverDeviceName;
140289
- return target === null ? link.receiver : `${target} (${link.receiver})`;
140290
- }
140291
- function statusOf(central) {
140292
- if (central === null) return "unknown";
140293
- return central ? "ok" : "warn";
140294
- }
140295
- function toggleButton(integrationId, key) {
140296
- const enable = key.central !== true;
140297
- const label = keyLabel(key);
140298
- return {
140299
- type: "addon-action-button",
140300
- key: `buttonEvents_${key.address}`,
140301
- label,
140302
- addonId: ADDON_ID,
140303
- action: "setButtonEvents",
140304
- paramsStatic: {
140305
- integrationId,
140306
- address: key.address,
140307
- enabled: enable,
140308
- confirmed: true
140309
- },
140310
- buttonLabel: enable ? "Send presses to CamStack" : "Stop sending presses",
140311
- variant: enable ? "primary" : "default",
140312
- confirmMessage: enable ? `Create the central link of "${label}" on the CCU? Its direct links stay as they are.` : `Remove the central link of "${label}" on the CCU? CamStack stops receiving its presses; its direct links stay as they are.`
140313
- };
140314
- }
140315
- /**
140316
- * The device-page section of a Homematic button device: per key, whether the
140317
- * CCU sends its presses to CamStack (the central link), the channels it
140318
- * actuates directly, and a confirmed toggle that writes the central link.
140319
- * Empty when the device has no key channel the CCU answered for.
140320
- */
140321
- function buttonEventsSection(integrationId, keys) {
140322
- if (integrationId === void 0 || keys.length === 0) return [];
140323
- const missing = keys.some((key) => key.central === false);
140324
- const fields = [];
140325
- if (missing) fields.push({
140326
- type: "info",
140327
- key: "buttonEventsHint",
140328
- label: "Button events",
140329
- labelKey: `${NS$1}.hint.label`,
140330
- content: "The CCU does not send some of these presses — turn them on below",
140331
- contentKey: `${NS$1}.hint.content`,
140332
- variant: "warning"
140333
- });
140334
- fields.push({
140335
- type: "object-array",
140336
- key: "buttonEventsKeys",
140337
- label: "Keys",
140338
- labelKey: `${NS$1}.keys.label`,
140339
- columns: [
140340
- {
140341
- key: "key",
140342
- label: "Key",
140343
- labelKey: `${NS$1}.keys.key`
140344
- },
140345
- {
140346
- key: "central",
140347
- label: "Sent to CamStack",
140348
- labelKey: `${NS$1}.keys.central`,
140349
- kind: "status"
140350
- },
140351
- {
140352
- key: "links",
140353
- label: "Direct links",
140354
- labelKey: `${NS$1}.keys.links`
140355
- }
140356
- ],
140357
- value: keys.map((key) => ({
140358
- key: keyLabel(key),
140359
- central: statusOf(key.central),
140360
- links: key.links.length === 0 ? "—" : key.links.map(linkText).join(", ")
140361
- }))
140362
- });
140363
- for (const key of keys) if (key.central !== null) fields.push(toggleButton(integrationId, key));
140364
- return [{
140365
- id: "button-events",
140366
- title: "Button events",
140367
- titleKey: `${NS$1}.title`,
140368
- columns: 1,
140369
- fields
140370
- }];
140371
- }
140372
- //#endregion
140373
- //#region src/devices/hm-device-panel-section.ts
140374
- /** `<addonId>/<stableId>` of the device panel in this addon's widget bundle. */
140375
- var HM_DEVICE_PANEL_WIDGET_ID = "provider-homematic/device-panel";
140376
- var NS = "provider-homematic:device.panel";
140377
- /**
140378
- * The device page section of one CCU device: the Homematic panel widget
140379
- * (values, diagnostics, manual actuation, MASTER configuration). The widget
140380
- * stores nothing in CamStack — it reads and writes the CCU through the
140381
- * addon's confirmed custom actions.
140382
- */
140383
- function devicePanelSection(integrationId, address) {
140384
- return {
140385
- id: "homematic-device",
140386
- title: "Homematic",
140387
- titleKey: `${NS}.title`,
140388
- tab: "general",
140389
- order: 5,
140390
- columns: 1,
140391
- fields: [{
140392
- type: "widget",
140393
- key: "_homematicDevicePanel",
140394
- label: "",
140395
- widgetId: HM_DEVICE_PANEL_WIDGET_ID,
140396
- widgetConfig: {
140397
- integrationId,
140398
- address
140399
- }
140400
- }]
140401
- };
140402
- }
140403
- //#endregion
140404
139705
  //#region src/devices/hm-child-device.ts
140405
139706
  /**
140406
139707
  * Persisted config every Homematic accessory CHILD carries. `address` is the
@@ -141301,6 +140602,126 @@ var HmSensorDevice = class extends HmChildDevice {
141301
140602
  }
141302
140603
  };
141303
140604
  //#endregion
140605
+ //#region src/devices/hm-button-events-section.ts
140606
+ var ADDON_ID = "provider-homematic";
140607
+ var NS$1 = "provider-homematic:device.buttonEvents";
140608
+ function keyLabel(key) {
140609
+ return key.name ?? `Key ${key.index}`;
140610
+ }
140611
+ function linkText(link) {
140612
+ const target = link.receiverName ?? link.receiverDeviceName;
140613
+ return target === null ? link.receiver : `${target} (${link.receiver})`;
140614
+ }
140615
+ function escapeHtml(value) {
140616
+ return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;");
140617
+ }
140618
+ /** The CCU page, Programs tab, for this integration. */
140619
+ function programsTabHref(integrationId) {
140620
+ return `/addon/homematic-ccu?${new URLSearchParams({
140621
+ ccu: integrationId,
140622
+ tab: "programs"
140623
+ }).toString()}`;
140624
+ }
140625
+ function statusOf(central) {
140626
+ if (central === null) return "unknown";
140627
+ return central ? "ok" : "warn";
140628
+ }
140629
+ function toggleButton(integrationId, key) {
140630
+ const enable = key.central !== true;
140631
+ const label = keyLabel(key);
140632
+ return {
140633
+ type: "addon-action-button",
140634
+ key: `buttonEvents_${key.address}`,
140635
+ label,
140636
+ addonId: ADDON_ID,
140637
+ action: "setButtonEvents",
140638
+ paramsStatic: {
140639
+ integrationId,
140640
+ address: key.address,
140641
+ enabled: enable,
140642
+ confirmed: true
140643
+ },
140644
+ buttonLabel: enable ? "Send presses to CamStack" : "Stop sending presses",
140645
+ variant: enable ? "primary" : "default",
140646
+ confirmMessage: enable ? `Create the central link of "${label}" on the CCU? Its direct links stay as they are.` : `Remove the central link of "${label}" on the CCU? CamStack stops receiving its presses; its direct links stay as they are.`
140647
+ };
140648
+ }
140649
+ /**
140650
+ * The device-page section of a Homematic button device: per key, whether the
140651
+ * CCU sends its presses to CamStack (the central link), the channels it
140652
+ * actuates directly, and a confirmed toggle that writes the central link.
140653
+ * Empty when the device has no key channel the CCU answered for.
140654
+ */
140655
+ function buttonEventsSection(integrationId, keys) {
140656
+ if (integrationId === void 0 || keys.length === 0) return [];
140657
+ const missing = keys.some((key) => key.central === false);
140658
+ const fields = [];
140659
+ if (missing) fields.push({
140660
+ type: "info",
140661
+ key: "buttonEventsHint",
140662
+ label: "Button events",
140663
+ labelKey: `${NS$1}.hint.label`,
140664
+ content: "The CCU does not send some of these presses — turn them on below",
140665
+ contentKey: `${NS$1}.hint.content`,
140666
+ variant: "warning"
140667
+ });
140668
+ const programNames = [...new Set(keys.flatMap((key) => key.programName === null ? [] : [key.programName]))];
140669
+ if (programNames.length > 0) {
140670
+ const href = programsTabHref(integrationId);
140671
+ fields.push({
140672
+ type: "info",
140673
+ key: "buttonEventsProgram",
140674
+ label: "Key event program",
140675
+ labelKey: `${NS$1}.program.label`,
140676
+ content: programNames.map((name) => `<a href="${escapeHtml(href)}">${escapeHtml(name)}</a>`).join("<br>"),
140677
+ format: "html"
140678
+ });
140679
+ }
140680
+ fields.push({
140681
+ type: "object-array",
140682
+ key: "buttonEventsKeys",
140683
+ label: "Keys",
140684
+ labelKey: `${NS$1}.keys.label`,
140685
+ columns: [
140686
+ {
140687
+ key: "key",
140688
+ label: "Key",
140689
+ labelKey: `${NS$1}.keys.key`
140690
+ },
140691
+ {
140692
+ key: "central",
140693
+ label: "Sent to CamStack",
140694
+ labelKey: `${NS$1}.keys.central`,
140695
+ kind: "status"
140696
+ },
140697
+ {
140698
+ key: "program",
140699
+ label: "Program",
140700
+ labelKey: `${NS$1}.keys.program`
140701
+ },
140702
+ {
140703
+ key: "links",
140704
+ label: "Direct links",
140705
+ labelKey: `${NS$1}.keys.links`
140706
+ }
140707
+ ],
140708
+ value: keys.map((key) => ({
140709
+ key: keyLabel(key),
140710
+ central: statusOf(key.central),
140711
+ program: key.programName ?? "—",
140712
+ links: key.links.length === 0 ? "—" : key.links.map(linkText).join(", ")
140713
+ }))
140714
+ });
140715
+ for (const key of keys) if (key.central !== null) fields.push(toggleButton(integrationId, key));
140716
+ return [{
140717
+ id: "button-events",
140718
+ title: "Button events",
140719
+ titleKey: `${NS$1}.title`,
140720
+ columns: 1,
140721
+ fields
140722
+ }];
140723
+ }
140724
+ //#endregion
141304
140725
  //#region src/devices/hm-event-emitter-device.ts
141305
140726
  /** Shown on the Buttons child when none of its key channels has a central link. */
141306
140727
  var BUTTON_EVENTS_HINT = "The CCU does not send these presses — turn them on in this device's Button events section";
@@ -141809,6 +141230,345 @@ var HmChildDispatcher = class {
141809
141230
  /** The documented boundary-cast export used in the `deviceClasses` restore map. */
141810
141231
  var hmChildDeviceClass = HmChildDispatcher;
141811
141232
  //#endregion
141233
+ //#region src/devices/hm-device-panel-section.ts
141234
+ /** `<addonId>/<stableId>` of the device panel in this addon's widget bundle. */
141235
+ var HM_DEVICE_PANEL_WIDGET_ID = "provider-homematic/device-panel";
141236
+ var NS = "provider-homematic:device.panel";
141237
+ /**
141238
+ * The device page section of one CCU device: the Homematic panel widget
141239
+ * (values, diagnostics, manual actuation, MASTER configuration). The widget
141240
+ * stores nothing in CamStack — it reads and writes the CCU through the
141241
+ * addon's confirmed custom actions.
141242
+ */
141243
+ function devicePanelSection(integrationId, address) {
141244
+ return {
141245
+ id: "homematic-device",
141246
+ title: "Homematic",
141247
+ titleKey: `${NS}.title`,
141248
+ tab: "general",
141249
+ order: 5,
141250
+ columns: 1,
141251
+ fields: [{
141252
+ type: "widget",
141253
+ key: "_homematicDevicePanel",
141254
+ label: "",
141255
+ widgetId: HM_DEVICE_PANEL_WIDGET_ID,
141256
+ widgetConfig: {
141257
+ integrationId,
141258
+ address
141259
+ }
141260
+ }]
141261
+ };
141262
+ }
141263
+ //#endregion
141264
+ //#region src/homematic-diagnostics-mapping.ts
141265
+ var MAINTENANCE_CHANNEL_TYPE$1 = "MAINTENANCE";
141266
+ /** Reachability parameters that drive the Container's `online`, not a child. */
141267
+ var REACHABILITY_PARAMS$1 = ["UNREACH", "STICKY_UNREACH"];
141268
+ function findMaintenanceChannel(device) {
141269
+ return device.channels.find((channel) => channel.type?.toUpperCase() === MAINTENANCE_CHANNEL_TYPE$1);
141270
+ }
141271
+ function findParam(channel, parameter) {
141272
+ return channel.dataPoints.find((dp) => dp.parameter.toUpperCase() === parameter);
141273
+ }
141274
+ /** A datapoint is "boolean" when its declared CCU type is BOOL/ACTION. */
141275
+ function isBooleanDataPoint(dp) {
141276
+ const type = dp.type.toUpperCase();
141277
+ return type === "BOOL" || type === "ACTION";
141278
+ }
141279
+ /**
141280
+ * Map a device's MAINTENANCE channel to its diagnostic derived entities.
141281
+ * Emits one entity per recognised datapoint; returns `[]` when there is no
141282
+ * MAINTENANCE channel or no recognised datapoints. Entities are emitted even
141283
+ * when the datapoint `value` is still `null` — the value arrives via push.
141284
+ */
141285
+ function mapMaintenanceChannel(device) {
141286
+ const channel = findMaintenanceChannel(device);
141287
+ if (!channel) return [];
141288
+ const entities = [];
141289
+ if (findParam(channel, "LOW_BAT")) {
141290
+ const voltage = findParam(channel, "OPERATING_VOLTAGE");
141291
+ if (voltage) entities.push({
141292
+ key: "maint-voltage",
141293
+ deviceType: DeviceType.Sensor,
141294
+ role: DeviceRole.VoltageSensor,
141295
+ capabilities: ["numeric-sensor"],
141296
+ name: "Operating voltage",
141297
+ unit: voltage.unit ?? "V",
141298
+ sourceParams: ["OPERATING_VOLTAGE"]
141299
+ });
141300
+ else entities.push({
141301
+ key: "maint-battery-low",
141302
+ deviceType: DeviceType.Sensor,
141303
+ role: DeviceRole.BatterySensor,
141304
+ capabilities: ["binary"],
141305
+ name: "Battery low",
141306
+ sourceParams: ["LOW_BAT"]
141307
+ });
141308
+ }
141309
+ const rssiDevice = findParam(channel, "RSSI_DEVICE");
141310
+ if (rssiDevice) entities.push({
141311
+ key: "maint-rssi-device",
141312
+ deviceType: DeviceType.Sensor,
141313
+ role: DeviceRole.NumericSensor,
141314
+ capabilities: ["numeric-sensor"],
141315
+ name: "Signal (device)",
141316
+ unit: rssiDevice.unit ?? "dBm",
141317
+ sourceParams: ["RSSI_DEVICE"]
141318
+ });
141319
+ const rssiPeer = findParam(channel, "RSSI_PEER");
141320
+ if (rssiPeer) entities.push({
141321
+ key: "maint-rssi-peer",
141322
+ deviceType: DeviceType.Sensor,
141323
+ role: DeviceRole.NumericSensor,
141324
+ capabilities: ["numeric-sensor"],
141325
+ name: "Signal (peer)",
141326
+ unit: rssiPeer.unit ?? "dBm",
141327
+ sourceParams: ["RSSI_PEER"]
141328
+ });
141329
+ const dutyCycle = findParam(channel, "DUTY_CYCLE");
141330
+ if (dutyCycle) if (isBooleanDataPoint(dutyCycle)) entities.push({
141331
+ key: "maint-duty-cycle",
141332
+ deviceType: DeviceType.Sensor,
141333
+ role: DeviceRole.BinarySensor,
141334
+ capabilities: ["binary"],
141335
+ name: "Duty cycle",
141336
+ sourceParams: ["DUTY_CYCLE"]
141337
+ });
141338
+ else entities.push({
141339
+ key: "maint-duty-cycle",
141340
+ deviceType: DeviceType.Sensor,
141341
+ role: DeviceRole.NumericSensor,
141342
+ capabilities: ["numeric-sensor"],
141343
+ name: "Duty cycle",
141344
+ unit: dutyCycle.unit ?? "%",
141345
+ sourceParams: ["DUTY_CYCLE"]
141346
+ });
141347
+ const operatingTemp = findParam(channel, "OPERATING_TEMPERATURE");
141348
+ const actualTemp = findParam(channel, "ACTUAL_TEMPERATURE");
141349
+ const temp = operatingTemp ?? actualTemp;
141350
+ if (temp) entities.push({
141351
+ key: "maint-temperature",
141352
+ deviceType: DeviceType.Sensor,
141353
+ role: DeviceRole.TemperatureSensor,
141354
+ capabilities: ["temperature-sensor"],
141355
+ name: operatingTemp ? "Operating temperature" : "Temperature",
141356
+ unit: temp.unit ?? "°C",
141357
+ sourceParams: [temp.parameter.toUpperCase()]
141358
+ });
141359
+ return entities;
141360
+ }
141361
+ /**
141362
+ * Decide whether a device should expose a firmware Update child. Returns the
141363
+ * update entity when the device carries ANY firmware descriptor field (at
141364
+ * least `firmware`, or `updatable === true`); otherwise `null`. The device
141365
+ * class reads the live firmware fields to populate the `update` cap slice;
141366
+ * this helper only decides whether the child exists.
141367
+ */
141368
+ function mapFirmwareUpdate(device) {
141369
+ if (!(device.firmware !== void 0 || device.availableFirmware !== void 0 || device.firmwareUpdateState !== void 0 || device.updatable === true)) return null;
141370
+ return {
141371
+ key: "update",
141372
+ deviceType: DeviceType.Update,
141373
+ role: null,
141374
+ capabilities: ["update"],
141375
+ name: "Firmware"
141376
+ };
141377
+ }
141378
+ /**
141379
+ * Read the device's reachability from its MAINTENANCE channel. Returns
141380
+ * `{ unreach }` when an UNREACH (or STICKY_UNREACH) datapoint is present, or
141381
+ * `null` when reachability is unknown. The Container task derives
141382
+ * `online = !unreach` from this.
141383
+ */
141384
+ function readReachability(device) {
141385
+ const channel = findMaintenanceChannel(device);
141386
+ if (!channel) return null;
141387
+ for (const param of REACHABILITY_PARAMS$1) {
141388
+ const dp = findParam(channel, param);
141389
+ if (dp) return { unreach: Boolean(dp.value) };
141390
+ }
141391
+ return null;
141392
+ }
141393
+ //#endregion
141394
+ //#region src/devices/hm-entity-spec.ts
141395
+ var MAINTENANCE_CHANNEL_TYPE = "MAINTENANCE";
141396
+ /**
141397
+ * Map a custom-entity kind to the actuator discriminant + its CamStack cap +
141398
+ * CamStack DeviceType. Returns null for kinds with no actuator wiring.
141399
+ */
141400
+ function actuatorInfo(kind) {
141401
+ switch (kind) {
141402
+ case "switch": return {
141403
+ kind: "switch",
141404
+ capName: "switch",
141405
+ type: DeviceType.Switch
141406
+ };
141407
+ case "cover":
141408
+ case "blind": return {
141409
+ kind: "cover",
141410
+ capName: "cover",
141411
+ type: DeviceType.Cover
141412
+ };
141413
+ case "light": return {
141414
+ kind: "light",
141415
+ capName: "switch",
141416
+ type: DeviceType.Light
141417
+ };
141418
+ case "lock": return {
141419
+ kind: "lock",
141420
+ capName: "lock-control",
141421
+ type: DeviceType.Lock
141422
+ };
141423
+ case "climate": return {
141424
+ kind: "climate",
141425
+ capName: "climate-control",
141426
+ type: DeviceType.Climate
141427
+ };
141428
+ default: return null;
141429
+ }
141430
+ }
141431
+ /**
141432
+ * The cover KIND of an actuator: a `blind` custom entity is a blind (slat
141433
+ * tilt), a plain `cover` entity is the roller shutter (HmIP-BROLL). Exporters
141434
+ * read it; every other actuator has no role.
141435
+ */
141436
+ function actuatorRole(kind, model) {
141437
+ if (kind === "blind") return DeviceRole.CoverBlind;
141438
+ if (kind === "cover") return DeviceRole.CoverShutter;
141439
+ if (kind === "climate") return climateRoleOfModel(model);
141440
+ return null;
141441
+ }
141442
+ /** Radiator valves: HmIP-eTRV-* and the classic HM-CC-RT-DN. */
141443
+ var RADIATOR_MODEL = /eTRV|HM-CC-RT-DN/i;
141444
+ /** Floor-heating actuators: HmIP-FAL* / HmIP-FALMOT-*. */
141445
+ var FLOOR_MODEL = /FAL/i;
141446
+ /**
141447
+ * D1033 — which climate device a Homematic model is. A radiator valve and a
141448
+ * floor-heating actuator are told apart by model; a wall thermostat, a
141449
+ * heating group and an unknown model are thermostats.
141450
+ */
141451
+ function climateRoleOfModel(model) {
141452
+ if (model !== void 0 && RADIATOR_MODEL.test(model)) return DeviceRole.ClimateRadiator;
141453
+ if (model !== void 0 && FLOOR_MODEL.test(model)) return DeviceRole.ClimateFloor;
141454
+ return DeviceRole.ClimateThermostat;
141455
+ }
141456
+ /** Actuator specs from the library's typed custom entities (correct channel). */
141457
+ function deriveActuatorSpecs(customEntities, model) {
141458
+ const out = [];
141459
+ for (const entity of customEntities) {
141460
+ const info = actuatorInfo(entity.kind);
141461
+ if (info === null) continue;
141462
+ out.push({
141463
+ key: `act-${entity.channel}`,
141464
+ deviceType: info.type,
141465
+ role: actuatorRole(entity.kind, model),
141466
+ capabilities: [info.capName],
141467
+ name: `${entity.kind} ${entity.channel}`,
141468
+ config: {
141469
+ channel: entity.channel,
141470
+ kind: info.kind,
141471
+ capabilities: [info.capName]
141472
+ }
141473
+ });
141474
+ }
141475
+ return out;
141476
+ }
141477
+ /** Sensor specs (one per sensor channel) + ONE event-emitter spec over the
141478
+ * union of key channels. Skips actuator caps (custom-entity-driven). */
141479
+ function deriveSensorAndEventSpecs(device) {
141480
+ const out = [];
141481
+ const keyChannels = [];
141482
+ for (const { channel, mapping } of mapHmDeviceChannels(device)) {
141483
+ const sensorCaps = [];
141484
+ let isEvent = false;
141485
+ for (const capName of mapping.capabilities) {
141486
+ if (capName === "event-emitter") {
141487
+ isEvent = true;
141488
+ continue;
141489
+ }
141490
+ if (ACTUATOR_CAP_NAMES.has(capName)) continue;
141491
+ sensorCaps.push(capName);
141492
+ }
141493
+ if (isEvent) keyChannels.push(channel);
141494
+ if (sensorCaps.length > 0) out.push({
141495
+ key: `sensor-${channel.address}`,
141496
+ deviceType: DeviceType.Sensor,
141497
+ role: mapping.role,
141498
+ capabilities: sensorCaps,
141499
+ name: `Sensor ${channel.address}`,
141500
+ config: {
141501
+ channel: channel.address,
141502
+ capabilities: sensorCaps,
141503
+ ...mapping.role !== null ? { role: mapping.role } : {}
141504
+ }
141505
+ });
141506
+ }
141507
+ if (keyChannels.length > 0) {
141508
+ const eventTypes = [...keyEventVocabulary(keyChannels)];
141509
+ out.push({
141510
+ key: "events",
141511
+ deviceType: DeviceType.EventEmitter,
141512
+ role: null,
141513
+ capabilities: ["event-emitter"],
141514
+ name: "Buttons",
141515
+ config: {
141516
+ capabilities: ["event-emitter"],
141517
+ eventTypes
141518
+ }
141519
+ });
141520
+ }
141521
+ return out;
141522
+ }
141523
+ /** Diagnostic specs from the MAINTENANCE channel. */
141524
+ function deriveDiagnosticSpecs(device, address) {
141525
+ const channelAddress = device.channels.find((c) => c.type?.toUpperCase() === MAINTENANCE_CHANNEL_TYPE)?.address ?? `${address}:0`;
141526
+ return mapMaintenanceChannel(device).map((entity) => diagnosticSpec(entity, channelAddress));
141527
+ }
141528
+ function diagnosticSpec(entity, channelAddress) {
141529
+ return {
141530
+ key: entity.key,
141531
+ deviceType: entity.deviceType,
141532
+ role: entity.role,
141533
+ capabilities: [...entity.capabilities],
141534
+ name: entity.name,
141535
+ config: {
141536
+ channel: channelAddress,
141537
+ capabilities: [...entity.capabilities],
141538
+ sourceParams: [...entity.sourceParams ?? []],
141539
+ ...entity.role !== null ? { role: entity.role } : {},
141540
+ ...entity.unit !== void 0 ? { unit: entity.unit } : {}
141541
+ }
141542
+ };
141543
+ }
141544
+ /** Firmware Update spec (if the device carries a firmware descriptor). */
141545
+ function deriveUpdateSpec(device) {
141546
+ const update = mapFirmwareUpdate(device);
141547
+ if (!update) return [];
141548
+ return [{
141549
+ key: update.key,
141550
+ deviceType: update.deviceType,
141551
+ role: update.role,
141552
+ capabilities: [...update.capabilities],
141553
+ name: update.name,
141554
+ config: { capabilities: [...update.capabilities] }
141555
+ }];
141556
+ }
141557
+ /**
141558
+ * Derive the full per-entity spec list for a single Homematic device. ONE pure
141559
+ * function reused by the Container (`'devices'` granularity) and the standalone
141560
+ * entity adoption (`'entities'` granularity). `customEntities` are the device's
141561
+ * typed actuator entities from the facade (`[]` for the facade-less preview).
141562
+ */
141563
+ function deriveHmEntitySpecs(device, customEntities) {
141564
+ return [
141565
+ ...deriveActuatorSpecs(customEntities, device.type),
141566
+ ...deriveSensorAndEventSpecs(device),
141567
+ ...deriveDiagnosticSpecs(device, device.address),
141568
+ ...deriveUpdateSpec(device)
141569
+ ];
141570
+ }
141571
+ //#endregion
141812
141572
  //#region src/devices/hm-child-name.ts
141813
141573
  /**
141814
141574
  * Display name of one actuator child.
@@ -141846,6 +141606,38 @@ function actuatorNameWrite(input) {
141846
141606
  };
141847
141607
  }
141848
141608
  //#endregion
141609
+ //#region src/devices/hm-primary-child.ts
141610
+ var ACT_PREFIX = "act-";
141611
+ function channelIndex(key) {
141612
+ const suffix = channelIndexFromAddress(key.slice(4));
141613
+ if (suffix === null) return Number.MAX_SAFE_INTEGER;
141614
+ const parsed = Number(suffix);
141615
+ return Number.isFinite(parsed) ? parsed : Number.MAX_SAFE_INTEGER;
141616
+ }
141617
+ /**
141618
+ * Which child a Homematic container stands for.
141619
+ *
141620
+ * A device with relay channels stands for the first relay (lowest channel
141621
+ * index), so a two-relay switch is not left to the namesake tie-break. A
141622
+ * key-only device (no actuator) stands for its event-emitter. Anything else
141623
+ * declares nothing and the shared heuristic decides.
141624
+ */
141625
+ function hmPrimaryChildKeys(specs) {
141626
+ const first = specs.filter((spec) => spec.key.startsWith(ACT_PREFIX) && spec.config["kind"] === "switch").toSorted((a, b) => channelIndex(a.key) - channelIndex(b.key))[0];
141627
+ if (first !== void 0) return [first.key];
141628
+ if (specs.some((spec) => spec.key.startsWith(ACT_PREFIX))) return [];
141629
+ return specs.some((spec) => spec.key === "events") ? ["events"] : [];
141630
+ }
141631
+ /**
141632
+ * The preference to write, or null when the container already has one or
141633
+ * there is nothing to declare. An operator pick is a different column.
141634
+ */
141635
+ function preferenceToStamp(stored, declared) {
141636
+ if (stored !== void 0 && stored.length > 0) return null;
141637
+ if (declared.length === 0) return null;
141638
+ return declared;
141639
+ }
141640
+ //#endregion
141849
141641
  //#region src/devices/hm-container-device.ts
141850
141642
  /**
141851
141643
  * Persisted config for a Homematic Container (the parent of one physical CCU
@@ -142136,6 +141928,275 @@ function isStandaloneEntitySaved(saved) {
142136
141928
  return typeof key === "string" && key.length > 0;
142137
141929
  }
142138
141930
  //#endregion
141931
+ //#region src/callback-host.ts
141932
+ /**
141933
+ * Pick the hub LAN IPv4 a CCU at `ccuHost` can call back to. Prefers an
141934
+ * address on the same /24 as the CCU; otherwise the first non-internal IPv4.
141935
+ * Returns null when nothing suitable is found. Pure over the supplied addrs.
141936
+ */
141937
+ function pickCallbackHost(ccuHost, addrs) {
141938
+ const ipv4 = addrs.filter((a) => (a.family === "IPv4" || a.family === "4") && !a.internal);
141939
+ const first = ipv4[0];
141940
+ if (first === void 0) return null;
141941
+ const prefix = ccuHost.split(".").slice(0, 3).join(".");
141942
+ return ((prefix.split(".").length === 3 ? ipv4.find((a) => a.address.startsWith(prefix + ".")) : void 0) ?? first).address;
141943
+ }
141944
+ /** Resolve the hub callback host from the live OS interfaces. */
141945
+ function inferCallbackHost(ccuHost) {
141946
+ const addrs = [];
141947
+ for (const list of Object.values((0, node_os.networkInterfaces)())) for (const a of list ?? []) addrs.push({
141948
+ family: String(a.family),
141949
+ address: a.address,
141950
+ internal: a.internal
141951
+ });
141952
+ return pickCallbackHost(ccuHost, addrs);
141953
+ }
141954
+ //#endregion
141955
+ //#region src/config.ts
141956
+ /**
141957
+ * Operator-supplied CCU connection settings. Mirrors `HomematicOptions`
141958
+ * from the wrapped `nodehomematic` library, but with the addon's own
141959
+ * defaults + validation at the system boundary.
141960
+ *
141961
+ * The CCU exposes one or more XML-RPC interfaces; the operator selects
141962
+ * which ones to bind (HmIP-RF for HomematicIP, BidCos-RF for classic
141963
+ * Homematic, …). `callbackHost`/`callbackPort` are where the CCU calls
141964
+ * BACK into this addon's local XML-RPC server to push value events —
141965
+ * `callbackHost` must be an address the CCU can reach (usually the hub's
141966
+ * LAN IP), NOT `127.0.0.1`.
141967
+ *
141968
+ * Credentials are optional: they unlock the JSON-RPC hub layer (names,
141969
+ * rooms, system variables, programs). Without them the addon still works
141970
+ * over plain XML-RPC, just with raw addresses instead of friendly names.
141971
+ */
141972
+ var homematicConfigSchema = object({
141973
+ host: string().min(1).describe("CCU3 / RaspberryMatic host name or IP address"),
141974
+ enableHmipRf: boolean().default(true).describe("Enable Homematic IP (HmIP-RF)"),
141975
+ enableBidcosRf: boolean().default(false).describe("Enable Homematic (BidCos-RF). HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on"),
141976
+ enableGroups: boolean().default(true).describe("Enable groups (heating groups / VirtualDevices)"),
141977
+ enableBidcosWired: boolean().default(false).describe("Enable BidCos-Wired (HM-Wired)"),
141978
+ username: string().default("Admin").describe("WebUI username (optional — enables names / rooms / sysvars)"),
141979
+ password: string().default("").describe("WebUI password (optional)").meta({ secret: true }),
141980
+ callbackHost: string().default("").describe("Address the CCU calls back to for event push (this hub LAN IP)"),
141981
+ callbackPort: preprocess((v) => v === "" || v === null ? void 0 : v, number$1().int().min(1).max(65535).default(2128)).describe("Local XML-RPC callback server port"),
141982
+ tls: boolean().default(false).describe("Use TLS for the CCU transport")
141983
+ });
141984
+ /**
141985
+ * The XML-RPC interface names the operator's toggles select, in the library's
141986
+ * order. Only the four interfaces supported by nodehomematic are included.
141987
+ */
141988
+ function enabledInterfaces(config) {
141989
+ const interfaces = [];
141990
+ if (config.enableHmipRf) interfaces.push("HmIP-RF");
141991
+ if (config.enableBidcosRf) interfaces.push("BidCos-RF");
141992
+ if (config.enableGroups) interfaces.push("VirtualDevices");
141993
+ if (config.enableBidcosWired) interfaces.push("BidCos-Wired");
141994
+ return interfaces;
141995
+ }
141996
+ /**
141997
+ * Build the `HomematicOptions` the wrapped library constructor expects
141998
+ * from the validated addon config. Pure: same config in → same options
141999
+ * out. Credentials are forwarded when a username is set (the password may be
142000
+ * empty on a CCU without WebUI authentication); without one the library skips
142001
+ * the JSON-RPC hub layer cleanly.
142002
+ */
142003
+ function toHomematicOptions(config) {
142004
+ const hasCredentials = config.username.length > 0;
142005
+ const callbackHost = config.callbackHost.length > 0 ? config.callbackHost : inferCallbackHost(config.host) ?? "";
142006
+ const interfaces = enabledInterfaces(config);
142007
+ return {
142008
+ host: config.host,
142009
+ interfaces,
142010
+ callback: {
142011
+ host: callbackHost,
142012
+ port: config.callbackPort
142013
+ },
142014
+ tls: config.tls,
142015
+ ...hasCredentials ? { credentials: {
142016
+ username: config.username,
142017
+ password: config.password
142018
+ } } : {}
142019
+ };
142020
+ }
142021
+ /**
142022
+ * Parse an integration's stored settings, or null while the host is missing or
142023
+ * a field is invalid. Strings are trimmed; the password arrives resolved from
142024
+ * the keychain.
142025
+ */
142026
+ function connectionFromSettings(settings) {
142027
+ const raw = typeof settings === "object" && settings !== null ? settings : {};
142028
+ const parsed = homematicConfigSchema.safeParse(Object.fromEntries(Object.entries(raw).map(([k, v]) => [k, typeof v === "string" ? v.trim() : v])));
142029
+ return parsed.success ? parsed.data : null;
142030
+ }
142031
+ /**
142032
+ * Structural equality over the fields that affect the live CCU connection. Two
142033
+ * configs are "the same connection" when every field that would force a facade
142034
+ * stop+start matches. A `null` argument is never equal to anything.
142035
+ */
142036
+ function sameConnection(a, b) {
142037
+ if (a === null || b === null) return false;
142038
+ return a.host === b.host && a.enableHmipRf === b.enableHmipRf && a.enableBidcosRf === b.enableBidcosRf && a.enableGroups === b.enableGroups && a.enableBidcosWired === b.enableBidcosWired && a.callbackHost === b.callbackHost && a.callbackPort === b.callbackPort && a.username === b.username && a.password === b.password && a.tls === b.tls;
142039
+ }
142040
+ /**
142041
+ * What every Homematic device carries so the integration's cascade and offline
142042
+ * helpers find it: the provenance marker and the integration (CCU session) it
142043
+ * belongs to.
142044
+ */
142045
+ var homematicGatewayDeviceSchema = object({
142046
+ integrationId: string().min(1).describe("Integration (CCU session) the device belongs to"),
142047
+ system: literal("homematic"),
142048
+ /** The adoption candidate id the device was adopted from. */
142049
+ nativeId: string().min(1)
142050
+ });
142051
+ /** Why the form asks for credentials; shown first (translated through its `labelKey`). */
142052
+ var CREDENTIALS_NOTICE = "Device and room names come from the CCU WebUI. Enter a WebUI user (Admin by default). If the WebUI has no login, leave the password empty. Without a user, devices are listed by their address.";
142053
+ /**
142054
+ * The integration form: a discovered-CCU picker (filled by the LAN scan), the
142055
+ * host, the interfaces, the event callback, the WebUI credentials (the password
142056
+ * is a `password` field, so it lands in the keychain) and TLS.
142057
+ */
142058
+ function buildConnectionFormSchema() {
142059
+ return { sections: [
142060
+ {
142061
+ id: "connection",
142062
+ title: "CCU connection",
142063
+ titleKey: "provider-homematic:connection.s_connection.title",
142064
+ columns: 1,
142065
+ fields: [
142066
+ {
142067
+ type: "info",
142068
+ key: "credentialsNotice",
142069
+ label: CREDENTIALS_NOTICE,
142070
+ labelKey: "provider-homematic:connection.s_connection.credentialsNotice.label",
142071
+ content: ""
142072
+ },
142073
+ {
142074
+ type: "addon-action-select",
142075
+ addonId: "provider-homematic",
142076
+ key: "__homematic-discovered",
142077
+ writesKey: "host",
142078
+ omitFromSettings: true,
142079
+ label: "CCU",
142080
+ labelKey: "provider-homematic:connection.s_connection.__homematic-discovered.label",
142081
+ action: "discoverCcu",
142082
+ mapOption: {
142083
+ value: "host",
142084
+ label: "name"
142085
+ },
142086
+ hideWhenFewerThan: 2,
142087
+ emptyResultsMessage: "No CCU found on the network."
142088
+ },
142089
+ {
142090
+ type: "text",
142091
+ key: "host",
142092
+ label: "Host / IP",
142093
+ labelKey: "provider-homematic:connection.s_connection.host.label",
142094
+ description: "Filled when one CCU is found. Type the address if it is not.",
142095
+ descriptionKey: "provider-homematic:connection.s_connection.host.description",
142096
+ required: true,
142097
+ placeholder: "192.168.10.50"
142098
+ }
142099
+ ]
142100
+ },
142101
+ {
142102
+ id: "interfaces",
142103
+ title: "Interfaces",
142104
+ titleKey: "provider-homematic:connection.s_interfaces.title",
142105
+ description: "CCU-Jack and CUxD are not supported.",
142106
+ descriptionKey: "provider-homematic:connection.s_interfaces.description",
142107
+ columns: 1,
142108
+ fields: [
142109
+ {
142110
+ type: "boolean",
142111
+ key: "enableHmipRf",
142112
+ label: "Enable Homematic IP",
142113
+ labelKey: "provider-homematic:connection.s_interfaces.enableHmipRf.label",
142114
+ default: true
142115
+ },
142116
+ {
142117
+ type: "boolean",
142118
+ key: "enableBidcosRf",
142119
+ label: "Enable Homematic (BidCos-RF)",
142120
+ labelKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.label",
142121
+ description: "HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on.",
142122
+ descriptionKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.description",
142123
+ default: false
142124
+ },
142125
+ {
142126
+ type: "boolean",
142127
+ key: "enableGroups",
142128
+ label: "Enable groups (heating groups)",
142129
+ labelKey: "provider-homematic:connection.s_interfaces.enableGroups.label",
142130
+ default: true
142131
+ },
142132
+ {
142133
+ type: "boolean",
142134
+ key: "enableBidcosWired",
142135
+ label: "Enable BidCos-Wired (HM-Wired)",
142136
+ labelKey: "provider-homematic:connection.s_interfaces.enableBidcosWired.label",
142137
+ default: false
142138
+ }
142139
+ ]
142140
+ },
142141
+ {
142142
+ id: "callback",
142143
+ title: "Event callback",
142144
+ titleKey: "provider-homematic:connection.s_callback.title",
142145
+ description: "Optional; must be reachable from the CCU (not 127.0.0.1). Blank auto-infers the hub LAN address.",
142146
+ descriptionKey: "provider-homematic:connection.s_callback.description",
142147
+ columns: 2,
142148
+ fields: [{
142149
+ type: "text",
142150
+ key: "callbackHost",
142151
+ label: "Callback host (optional — auto-inferred when blank)",
142152
+ labelKey: "provider-homematic:connection.s_callback.callbackHost.label",
142153
+ placeholder: "auto (this hub LAN IP)"
142154
+ }, {
142155
+ type: "number",
142156
+ key: "callbackPort",
142157
+ label: "Callback port",
142158
+ labelKey: "provider-homematic:connection.s_callback.callbackPort.label",
142159
+ min: 1,
142160
+ max: 65535,
142161
+ default: 2128
142162
+ }]
142163
+ },
142164
+ {
142165
+ id: "credentials",
142166
+ title: "WebUI credentials",
142167
+ titleKey: "provider-homematic:connection.s_credentials.title",
142168
+ description: "Optional. Unlocks friendly names, rooms, system variables and programs.",
142169
+ descriptionKey: "provider-homematic:connection.s_credentials.description",
142170
+ columns: 2,
142171
+ fields: [{
142172
+ type: "text",
142173
+ key: "username",
142174
+ label: "Username",
142175
+ labelKey: "provider-homematic:connection.s_credentials.username.label",
142176
+ default: "Admin"
142177
+ }, {
142178
+ type: "password",
142179
+ key: "password",
142180
+ label: "Password",
142181
+ labelKey: "provider-homematic:connection.s_credentials.password.label",
142182
+ showToggle: true
142183
+ }]
142184
+ },
142185
+ {
142186
+ id: "advanced",
142187
+ title: "Advanced",
142188
+ titleKey: "provider-homematic:connection.s_advanced.title",
142189
+ columns: 1,
142190
+ fields: [{
142191
+ type: "boolean",
142192
+ key: "tls",
142193
+ label: "Use TLS",
142194
+ labelKey: "provider-homematic:connection.s_advanced.tls.label"
142195
+ }]
142196
+ }
142197
+ ] };
142198
+ }
142199
+ //#endregion
142139
142200
  //#region src/homematic-gateway-metadata.ts
142140
142201
  /** What the CCU box is known by, as device metadata (a CCU announces no model or firmware over XML-RPC). */
142141
142202
  function gatewayMetadataPatch(input) {
@@ -143596,6 +143657,107 @@ function buildHomematicConnectionTestProvider(deps) {
143596
143657
  }
143597
143658
  } };
143598
143659
  }
143660
+ var homematicConnectionsEntryKind = defineEntryKind("connections", {
143661
+ title: "Homematic CCUs",
143662
+ schema: entryBody({
143663
+ host: string().nullish(),
143664
+ enableHmipRf: boolean().nullish(),
143665
+ enableBidcosRf: boolean().nullish(),
143666
+ enableGroups: boolean().nullish(),
143667
+ enableBidcosWired: boolean().nullish(),
143668
+ username: string().nullish(),
143669
+ password: string().optional().meta({ secret: true }),
143670
+ callbackHost: string().nullish(),
143671
+ callbackPort: number$1().int().min(1).max(65535).nullish(),
143672
+ tls: boolean().nullish()
143673
+ }),
143674
+ writeTrigger: "an operator adds, edits or removes a Homematic CCU"
143675
+ });
143676
+ /** Every kind this addon declares, keyed by its name. */
143677
+ var homematicRecordKinds = { connections: homematicConnectionsEntryKind };
143678
+ /** The record body as the flat settings the connection schema parses: no name, no unset keys. */
143679
+ function connectionSettingsOf(body) {
143680
+ const out = {};
143681
+ for (const [key, value] of Object.entries(body)) {
143682
+ if (key === "name" || value === null || value === void 0) continue;
143683
+ out[key] = value;
143684
+ }
143685
+ return out;
143686
+ }
143687
+ function settingsReadOf(resolved) {
143688
+ return resolved === null ? {
143689
+ values: {},
143690
+ secretsLocked: false
143691
+ } : {
143692
+ values: connectionSettingsOf(resolved.body),
143693
+ secretsLocked: resolved.secrets === "unavailable"
143694
+ };
143695
+ }
143696
+ function buildHomematicInstances(records, deps) {
143697
+ const handle = records.kind(homematicConnectionsEntryKind);
143698
+ return new RecordIntegrationInstances(records, homematicConnectionsEntryKind, {
143699
+ description: {
143700
+ role: "devices",
143701
+ discovery: {
143702
+ mode: "lan",
143703
+ scopedToInstance: false
143704
+ },
143705
+ instanceMode: "multiple",
143706
+ kind: "connection",
143707
+ canTest: true,
143708
+ kinds: [{
143709
+ id: "connection",
143710
+ label: "Homematic",
143711
+ functionCap: "device-provider",
143712
+ role: "devices"
143713
+ }]
143714
+ },
143715
+ formSchema: () => buildConnectionFormSchema(),
143716
+ initialBody: (name) => ({ name }),
143717
+ configured: (body) => (body.host ?? "").trim().length > 0,
143718
+ onChanged: () => deps.onChanged(),
143719
+ test: async ({ id, values }) => {
143720
+ const stored = id === null ? null : (await handle.getResolved(id))?.data ?? null;
143721
+ const typed = values["password"];
143722
+ const password = typeof typed === "string" && typed !== "" && typed !== "__camstack_redacted__" ? typed : stored?.password ?? "";
143723
+ const outcome = await deps.tester.testSettings({ settings: {
143724
+ ...stored === null ? {} : connectionSettingsOf(stored),
143725
+ ...values,
143726
+ password
143727
+ } });
143728
+ if (outcome.outcome === "validated") return {
143729
+ success: true,
143730
+ status: "validated",
143731
+ ...outcome.latencyMs !== void 0 ? { latencyMs: outcome.latencyMs } : {},
143732
+ ...outcome.detail !== void 0 ? { detail: outcome.detail } : {}
143733
+ };
143734
+ return {
143735
+ success: false,
143736
+ status: outcome.outcome,
143737
+ error: outcome.error
143738
+ };
143739
+ }
143740
+ });
143741
+ }
143742
+ /** The ONE reader of a CCU's connection: the integration's record, never the legacy rows. */
143743
+ async function readCcuConnection(instances, integrationId) {
143744
+ const read = settingsReadOf(await instances.readResolved(integrationId));
143745
+ return {
143746
+ connection: connectionFromSettings(read.values),
143747
+ secretsLocked: read.secretsLocked
143748
+ };
143749
+ }
143750
+ /** The hosts of the CCUs already set up, for discovery to leave out; an unreadable one is skipped. */
143751
+ async function knownCcuHostsOf(deps) {
143752
+ const hosts = [];
143753
+ for (const id of deps.integrationIds) try {
143754
+ const { connection } = await readCcuConnection(deps.instances, id);
143755
+ if (connection !== null) hosts.push(connection.host);
143756
+ } catch (err) {
143757
+ deps.onUnreadable(id, err);
143758
+ }
143759
+ return hosts;
143760
+ }
143599
143761
  //#endregion
143600
143762
  //#region src/homematic-integration-device-cascade.ts
143601
143763
  /**
@@ -143661,6 +143823,219 @@ function setIntegrationDevicesOnline(devices, integrationId, online) {
143661
143823
  return count;
143662
143824
  }
143663
143825
  //#endregion
143826
+ //#region src/homematic-reconciler.ts
143827
+ /**
143828
+ * Keeps one live client per enabled integration. Devices are removed ONLY on an explicit
143829
+ * lifecycle event naming the integration (D49): a list that failed, an empty list or an
143830
+ * unreadable connection changes nothing about devices and is logged, never read as "gone".
143831
+ */
143832
+ var HomematicReconciler = class {
143833
+ #deps;
143834
+ #sweep;
143835
+ #rerun = null;
143836
+ constructor(deps) {
143837
+ this.#deps = deps;
143838
+ this.#sweep = new OrphanIntegrationSweep({
143839
+ logger: deps.logger,
143840
+ ...deps.sweepOptions
143841
+ });
143842
+ }
143843
+ /** Upsert a client per usable enabled integration; drop the CLIENT (never devices) of one the list answered is gone. */
143844
+ async reconcile() {
143845
+ const { logger, clients } = this.#deps;
143846
+ let all;
143847
+ try {
143848
+ all = await this.#deps.listIntegrations();
143849
+ } catch (err) {
143850
+ logger.warn("Homematic integration reconcile skipped — the integration list did not answer", { meta: { error: errMsg(err) } });
143851
+ return;
143852
+ }
143853
+ const enabled = all.filter((i) => i.addonId === this.#deps.addonId && i.enabled);
143854
+ for (const integration of enabled) try {
143855
+ if (!await this.#deps.applySettings(integration)) logger.warn("Homematic integration has no usable connection — left as it is", { meta: { integrationId: integration.id } });
143856
+ } catch (err) {
143857
+ logger.warn("Homematic reconcile failed for integration — left as it is", { meta: {
143858
+ integrationId: integration.id,
143859
+ error: errMsg(err)
143860
+ } });
143861
+ }
143862
+ const enabledIds = new Set(enabled.map((i) => i.id));
143863
+ for (const id of clients.list()) if (!enabledIds.has(id)) await clients.remove(id);
143864
+ await this.#sweepOrphans(all.map((i) => i.id));
143865
+ }
143866
+ /** Stop the scheduled second read (addon stop). */
143867
+ dispose() {
143868
+ if (this.#rerun !== null) clearTimeout(this.#rerun);
143869
+ this.#rerun = null;
143870
+ }
143871
+ /**
143872
+ * An integration deleted while this addon was down emits nothing it sees: its id owns devices
143873
+ * yet is absent from the ANSWERED list. Removal needs a second answered read later, so one
143874
+ * re-run is scheduled when a suspect appears (bounded: one timer, no retry loop).
143875
+ */
143876
+ async #sweepOrphans(listedIds) {
143877
+ const { ownerIntegrationIds, removeDevices, logger } = this.#deps;
143878
+ if (ownerIntegrationIds === void 0) return;
143879
+ try {
143880
+ const ownerIds = await ownerIntegrationIds();
143881
+ if ((await this.#sweep.sweep({
143882
+ ownerIds,
143883
+ listedIds,
143884
+ removeDevices
143885
+ })).newSuspects > 0 && this.#rerun === null) {
143886
+ this.#rerun = setTimeout(() => {
143887
+ this.#rerun = null;
143888
+ this.reconcile();
143889
+ }, this.#sweep.minIntervalMs + 1e3);
143890
+ this.#rerun.unref();
143891
+ }
143892
+ } catch (err) {
143893
+ logger.warn("Orphan integration sweep failed — devices left as they are", { meta: { error: errMsg(err) } });
143894
+ }
143895
+ }
143896
+ /** An explicit lifecycle event: only `deleted` / `disabled` of a named integration remove devices. */
143897
+ async onLifecycle(kind, integrationId) {
143898
+ await this.reconcile();
143899
+ if (kind === "enabled" || integrationId === null) return;
143900
+ try {
143901
+ const removed = await this.#deps.removeDevices(integrationId);
143902
+ this.#deps.logger.info("Homematic integration devices removed", { meta: {
143903
+ integrationId,
143904
+ kind,
143905
+ removed
143906
+ } });
143907
+ } catch (err) {
143908
+ this.#deps.logger.warn("Homematic integration device removal failed", { meta: {
143909
+ integrationId,
143910
+ kind,
143911
+ error: errMsg(err)
143912
+ } });
143913
+ }
143914
+ }
143915
+ };
143916
+ //#endregion
143917
+ //#region src/migrations/integration-rows-to-record.ts
143918
+ /**
143919
+ * Every Homematic integration moves from legacy `integration_settings` rows into its own
143920
+ * `connections` record under the registry id (planning#416, D1007): the CCU connection the live
143921
+ * session dials, the WebUI password a keychain secret declared by the kind. Each integration's
143922
+ * record is built from ITS OWN rows, never from another's. Only the integration configuration
143923
+ * moves: adopted devices, their stable ids and their history are not touched.
143924
+ *
143925
+ * Keys nothing reads any more are named in a warning, by key, and dropped with the rows once the
143926
+ * record has been read back; a value of the wrong type is left out and named by key as well.
143927
+ */
143928
+ var HOMEMATIC_ROWS_TO_RECORD_ID = "provider-homematic/2026-11-05-integration-rows-to-record";
143929
+ var TEXT_KEYS = [
143930
+ "host",
143931
+ "username",
143932
+ "callbackHost"
143933
+ ];
143934
+ var FLAG_KEYS = [
143935
+ "enableHmipRf",
143936
+ "enableBidcosRf",
143937
+ "enableGroups",
143938
+ "enableBidcosWired",
143939
+ "tls"
143940
+ ];
143941
+ function portOf(value) {
143942
+ const n = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
143943
+ return typeof n === "number" && Number.isInteger(n) && n >= 1 && n <= 65535 ? n : null;
143944
+ }
143945
+ /** The record body of one integration, from its resolved legacy rows. Never logs a value. */
143946
+ function homematicBodyFromRows(values, log, integration) {
143947
+ const body = { name: integration.name };
143948
+ const unusable = [];
143949
+ const known = new Set([
143950
+ "password",
143951
+ "callbackPort",
143952
+ ...TEXT_KEYS,
143953
+ ...FLAG_KEYS
143954
+ ]);
143955
+ for (const key of TEXT_KEYS) {
143956
+ if (!(key in values)) continue;
143957
+ const raw = values[key];
143958
+ if (typeof raw === "string") {
143959
+ if (raw.trim() !== "") body[key] = raw.trim();
143960
+ } else unusable.push(key);
143961
+ }
143962
+ for (const key of FLAG_KEYS) {
143963
+ if (!(key in values)) continue;
143964
+ const raw = values[key];
143965
+ if (typeof raw === "boolean") body[key] = raw;
143966
+ else unusable.push(key);
143967
+ }
143968
+ if ("callbackPort" in values) {
143969
+ const raw = values["callbackPort"];
143970
+ if (raw !== "" && raw !== null) {
143971
+ const port = portOf(raw);
143972
+ if (port === null) unusable.push("callbackPort");
143973
+ else body["callbackPort"] = port;
143974
+ }
143975
+ }
143976
+ if ("password" in values) {
143977
+ const password = values["password"];
143978
+ if (typeof password === "string") {
143979
+ if (password.length > 0) body["password"] = password;
143980
+ } else unusable.push("password");
143981
+ }
143982
+ const unknown = Object.keys(values).filter((key) => !known.has(key));
143983
+ if (unknown.length > 0) log.warn(`integration '${integration.id}': legacy settings nothing reads any more are dropped: ${unknown.join(", ")}`);
143984
+ if (unusable.length > 0) log.warn(`integration '${integration.id}': legacy settings with an unusable value are left out: ${unusable.join(", ")}`);
143985
+ return homematicConnectionsEntryKind.schema.parse(body);
143986
+ }
143987
+ var HOMEMATIC_ROWS_TO_RECORD_MIGRATION = {
143988
+ meta: {
143989
+ id: HOMEMATIC_ROWS_TO_RECORD_ID,
143990
+ owner: "provider-homematic",
143991
+ level: "addon-state",
143992
+ seq: 1,
143993
+ dependsOn: [],
143994
+ store: "settings",
143995
+ scope: "cluster",
143996
+ onFailure: "block-owner",
143997
+ bodyKind: "procedure",
143998
+ description: "Move every Homematic CCU integration into its own connection record keyed by its registry id, the WebUI password as a keychain secret, then clear its legacy integration settings rows; adopted devices are not touched",
143999
+ fixtureMark: "a legacy setting key the migration does not know"
144000
+ },
144001
+ procedure: (ports) => moveIntegrationRowsToRecords(ports, {
144002
+ addonId: "provider-homematic",
144003
+ secretPaths: homematicConnectionsEntryKind.declaration.secretPaths,
144004
+ bodyFrom: homematicBodyFromRows
144005
+ })
144006
+ };
144007
+ //#endregion
144008
+ //#region src/widget-catalog.ts
144009
+ /**
144010
+ * The addon's widgets for `addon-widgets-source.listWidgets`. The bundle is
144011
+ * built by `vite.widgets.config.ts` into `dist/widgets/` (beside the page
144012
+ * bundle, which owns `dist/remoteEntry.js`).
144013
+ */
144014
+ var homematicWidgets = [{
144015
+ tab: "device-tab",
144016
+ label: "Homematic device",
144017
+ preAuth: false,
144018
+ kind: "remote",
144019
+ remote: {
144020
+ remoteName: "addon_provider_homematic_widgets",
144021
+ exposedModule: "./widgets",
144022
+ componentKey: "device-panel"
144023
+ },
144024
+ stableId: "device-panel",
144025
+ description: "CCU values, diagnostics, manual actuation and MASTER configuration of one device.",
144026
+ icon: "plug",
144027
+ bundle: "widgets/remoteEntry.js",
144028
+ hosts: ["device-tab"],
144029
+ requires: {
144030
+ deviceContext: true,
144031
+ integrationContext: false
144032
+ },
144033
+ defaultSize: "xl",
144034
+ allowedSizes: ["lg", "xl"],
144035
+ defaultColumns: 12,
144036
+ defaultRows: 4
144037
+ }];
144038
+ //#endregion
143664
144039
  //#region src/addon.ts
143665
144040
  /**
143666
144041
  * Homematic CCU3 / RaspberryMatic: `mode: account`, one integration per CCU.
@@ -143752,6 +144127,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
143752
144127
  ...buildCcuConfigHandlers(this.ccuActionDeps()),
143753
144128
  ...buildButtonEventHandlers(this.ccuActionDeps()),
143754
144129
  ...buildCcuLinkHandlers(this.ccuActionDeps()),
144130
+ ...buildCcuProgramHandlers(this.ccuActionDeps()),
143755
144131
  ...buildCcuRenameHandlers(this.ccuActionDeps()),
143756
144132
  ...buildCcuRoomHandlers(this.ccuActionDeps()),
143757
144133
  ...buildCcuDeviceStateHandlers(this.ccuActionDeps()),
@@ -143795,19 +144171,35 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
143795
144171
  }
143796
144172
  /** CCU address → CamStack device id for containers adopted from one integration. */
143797
144173
  async adoptedCcuAddresses(integrationId) {
144174
+ return (await this.adoptedContainers(integrationId)).ids;
144175
+ }
144176
+ /** CCU address → CamStack device name, for the same containers. */
144177
+ async adoptedCcuNames(integrationId) {
144178
+ return (await this.adoptedContainers(integrationId)).names;
144179
+ }
144180
+ async adoptedContainers(integrationId) {
143798
144181
  const reg = this.ctx.kernel.deviceRegistry;
143799
144182
  const devices = this.ctx.kernel.devices;
143800
- const byAddress = /* @__PURE__ */ new Map();
143801
- if (!reg || !devices) return byAddress;
144183
+ const ids = /* @__PURE__ */ new Map();
144184
+ const names = /* @__PURE__ */ new Map();
144185
+ if (!reg || !devices) return {
144186
+ ids,
144187
+ names
144188
+ };
143802
144189
  for (const device of reg.getAllForAddon(this.addonId)) {
143803
144190
  if (device.parentDeviceId !== null) continue;
143804
144191
  const config = await devices.loadConfig(device.id).catch(() => ({}));
143805
144192
  if (config["integrationId"] !== integrationId) continue;
143806
144193
  if (typeof config["hmEntityKey"] === "string") continue;
143807
144194
  const address = config["hmAddress"];
143808
- if (typeof address === "string" && address.length > 0) byAddress.set(address, device.id);
144195
+ if (typeof address !== "string" || address.length === 0) continue;
144196
+ ids.set(address, device.id);
144197
+ names.set(address, device.name);
143809
144198
  }
143810
- return byAddress;
144199
+ return {
144200
+ ids,
144201
+ names
144202
+ };
143811
144203
  }
143812
144204
  /** What the CCU management actions reach: connected sessions only, never a half-started facade. */
143813
144205
  ccuActionDeps() {
@@ -143825,6 +144217,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
143825
144217
  },
143826
144218
  logger: this.ctx.logger,
143827
144219
  adoptedAddresses: (integrationId) => this.adoptedCcuAddresses(integrationId),
144220
+ adoptedNames: (integrationId) => this.adoptedCcuNames(integrationId),
143828
144221
  ccuChanged: (integrationId) => homematicFacades.emitSnapshot(integrationId)
143829
144222
  };
143830
144223
  }