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