@camstack/addon-provider-bosch 0.1.46 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.47] - 2026-11-09
11
+
12
+ ### Changed
13
+
14
+ - A HomeCom gateway with a heat pump is adopted as one heat pump, with a climate child per circuit and a Hot water child; a circuit already adopted on its own stays there
15
+
10
16
  ## [0.1.46] - 2026-11-09
11
17
 
12
18
  ### Changed
@@ -1,4 +1,4 @@
1
- import { X as errMsg } from "./bosch-instances-DkUo6BfT.mjs";
1
+ import { X as errMsg } from "./bosch-instances-DAqkAsRO.mjs";
2
2
  import { randomBytes } from "node:crypto";
3
3
  //#region src/shared/sign-in-redirects.ts
4
4
  /** The addresses each vendor sends the browser to after a sign-in; no browser can open them. Kept free of imports so the form schema can name them. */
@@ -1,4 +1,4 @@
1
- const require_bosch_instances = require("./bosch-instances-BD-Valeo.js");
1
+ const require_bosch_instances = require("./bosch-instances-D0eF-Jjy.js");
2
2
  let node_crypto = require("node:crypto");
3
3
  //#region src/shared/sign-in-redirects.ts
4
4
  /** The addresses each vendor sends the browser to after a sign-in; no browser can open them. Kept free of imports so the form schema can name them. */
@@ -802,7 +802,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
802
802
  return EventCategory;
803
803
  }({});
804
804
  //#endregion
805
- //#region ../types/dist/device-type-DTTZKB2I.mjs
805
+ //#region ../types/dist/composed-stable-id-DLcPInGv.mjs
806
806
  /**
807
807
  import { errMsg } from '@camstack/types'
808
808
  * Extract a human-readable message from an unknown error value.
@@ -1204,6 +1204,12 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1204
1204
  DeviceRole["IrTransmitter"] = "ir-transmitter";
1205
1205
  return DeviceRole;
1206
1206
  }({});
1207
+ /**
1208
+ * A composed device's stableId is this prefix plus the block id. Its own module,
1209
+ * free of zod, so the addon runner can read it through `@camstack/types/addon`
1210
+ * without loading the schema barrel (D28).
1211
+ */
1212
+ var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
1207
1213
  //#endregion
1208
1214
  //#region ../../node_modules/zod/v4/core/core.js
1209
1215
  var _a$1;
@@ -6016,7 +6022,7 @@ var ZodIssueCode = {
6016
6022
  var ZodFirstPartyTypeKind;
6017
6023
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6018
6024
  //#endregion
6019
- //#region ../types/dist/sleep-DnVqHJc4.mjs
6025
+ //#region ../types/dist/sleep-B36hHDDz.mjs
6020
6026
  /**
6021
6027
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6022
6028
  * window to float samples (D455).
@@ -17406,7 +17412,7 @@ Object.freeze({
17406
17412
  }
17407
17413
  });
17408
17414
  //#endregion
17409
- //#region ../types/dist/composition-C6TZGqUb.mjs
17415
+ //#region ../types/dist/composition-BFJq1Y88.mjs
17410
17416
  /**
17411
17417
  * The ffmpeg build every CamStack node downloads, per platform and arch.
17412
17418
  *
@@ -18361,8 +18367,6 @@ var HelperSpecSchema = discriminatedUnion("kind", [
18361
18367
  source: HelperMemberSchema
18362
18368
  })
18363
18369
  ]);
18364
- /** A composed device's stableId is this prefix plus the block id. */
18365
- var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
18366
18370
  /** Longest snippet a `code` source may carry (slice 4). */
18367
18371
  var MAX_COMPOSITION_CODE_LENGTH = 2e4;
18368
18372
  /** One field of one capability of one source device. */
@@ -53620,7 +53624,13 @@ method(object({
53620
53624
  auth: "admin"
53621
53625
  }), method(object({ deviceId: number$1() }), record(string(), unknown()), { auth: "admin" }), method(object({ deviceId: number$1() }), record(string(), unknown()), { auth: "admin" }), method(object({ deviceId: number$1() }), DeviceMetaSchema.nullable()), method(object({
53622
53626
  deviceId: number$1(),
53623
- name: string()
53627
+ name: string(),
53628
+ /**
53629
+ * Absent or true: an operator rename, which stamps `userNamed`.
53630
+ * False: the system copying a block name onto the device. That write
53631
+ * must not look like the operator's, or the next reconcile freezes it.
53632
+ */
53633
+ stampUserNamed: boolean().optional()
53624
53634
  }), _void(), {
53625
53635
  kind: "mutation",
53626
53636
  auth: "admin"
@@ -84335,6 +84345,7 @@ var BaseDeviceProvider = class extends BaseAddon {
84335
84345
  return toDeviceSummary(device, this.addonId);
84336
84346
  }
84337
84347
  };
84348
+ DeviceType.HeatPump;
84338
84349
  DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Heater, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
84339
84350
  new Set(Object.values(DeviceType));
84340
84351
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
@@ -86081,7 +86092,7 @@ var CLIMATE_FAMILY_CONTRIBUTIONS = {
86081
86092
  /**
86082
86093
  * The heat pump's contribution to a hero (D1026): the compressor scene, every
86083
86094
  * circuit as a row with its own label and icon, the powers as pills (the
86084
- * instantaneous COP only when both powers are known) and a "System" group with
86095
+ * instantaneous COP is "—" when it cannot be computed) and a "System" group with
86085
86096
  * one selector per mode. Values and their limits come from the slice, which the
86086
86097
  * gateway filled: a selector with no allowed value is not drawn, a missing
86087
86098
  * reading is never a 0 (D393).
@@ -86153,9 +86164,22 @@ function circuitRow(circuit) {
86153
86164
  };
86154
86165
  }
86155
86166
  var kilowatts = (watts) => `${Number((watts / 1e3).toFixed(2))} kW`;
86167
+ /** A COP that cannot be computed is still the pill: "—", never an absent reading (D393). */
86168
+ function copPill(cop) {
86169
+ if (cop === null) return {
86170
+ icon: "gauge",
86171
+ text: t("Instantaneous COP —", "COP istantaneo —"),
86172
+ tone: "muted"
86173
+ };
86174
+ const text = String(Number(cop.toFixed(1)));
86175
+ return {
86176
+ icon: "gauge",
86177
+ text: t(`Instantaneous COP ${text}`, `COP istantaneo ${text}`),
86178
+ tone: "success"
86179
+ };
86180
+ }
86156
86181
  function powerPills(status) {
86157
86182
  const { thermalW, electricalW } = status.power;
86158
- const cop = heatPumpInstantCop(status.power);
86159
86183
  const pills = [];
86160
86184
  if (thermalW !== null) pills.push({
86161
86185
  icon: "flame",
@@ -86167,14 +86191,7 @@ function powerPills(status) {
86167
86191
  text: t(`Electrical ${kilowatts(electricalW)}`, `Elettrica ${kilowatts(electricalW)}`),
86168
86192
  tone: "muted"
86169
86193
  });
86170
- if (cop !== null) {
86171
- const text = String(Number(cop.toFixed(1)));
86172
- pills.push({
86173
- icon: "gauge",
86174
- text: t(`Instantaneous COP ${text}`, `COP istantaneo ${text}`),
86175
- tone: "success"
86176
- });
86177
- }
86194
+ pills.push(copPill(heatPumpInstantCop(status.power)));
86178
86195
  return pills;
86179
86196
  }
86180
86197
  /** The independent system modes, in the order the card draws them. */
@@ -802,7 +802,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
802
802
  return EventCategory;
803
803
  }({});
804
804
  //#endregion
805
- //#region ../types/dist/device-type-DTTZKB2I.mjs
805
+ //#region ../types/dist/composed-stable-id-DLcPInGv.mjs
806
806
  /**
807
807
  import { errMsg } from '@camstack/types'
808
808
  * Extract a human-readable message from an unknown error value.
@@ -1204,6 +1204,12 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1204
1204
  DeviceRole["IrTransmitter"] = "ir-transmitter";
1205
1205
  return DeviceRole;
1206
1206
  }({});
1207
+ /**
1208
+ * A composed device's stableId is this prefix plus the block id. Its own module,
1209
+ * free of zod, so the addon runner can read it through `@camstack/types/addon`
1210
+ * without loading the schema barrel (D28).
1211
+ */
1212
+ var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
1207
1213
  //#endregion
1208
1214
  //#region ../../node_modules/zod/v4/core/core.js
1209
1215
  var _a$1;
@@ -6016,7 +6022,7 @@ var ZodIssueCode = {
6016
6022
  var ZodFirstPartyTypeKind;
6017
6023
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6018
6024
  //#endregion
6019
- //#region ../types/dist/sleep-DnVqHJc4.mjs
6025
+ //#region ../types/dist/sleep-B36hHDDz.mjs
6020
6026
  /**
6021
6027
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6022
6028
  * window to float samples (D455).
@@ -17406,7 +17412,7 @@ Object.freeze({
17406
17412
  }
17407
17413
  });
17408
17414
  //#endregion
17409
- //#region ../types/dist/composition-C6TZGqUb.mjs
17415
+ //#region ../types/dist/composition-BFJq1Y88.mjs
17410
17416
  /**
17411
17417
  * The ffmpeg build every CamStack node downloads, per platform and arch.
17412
17418
  *
@@ -18361,8 +18367,6 @@ var HelperSpecSchema = discriminatedUnion("kind", [
18361
18367
  source: HelperMemberSchema
18362
18368
  })
18363
18369
  ]);
18364
- /** A composed device's stableId is this prefix plus the block id. */
18365
- var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
18366
18370
  /** Longest snippet a `code` source may carry (slice 4). */
18367
18371
  var MAX_COMPOSITION_CODE_LENGTH = 2e4;
18368
18372
  /** One field of one capability of one source device. */
@@ -53620,7 +53624,13 @@ method(object({
53620
53624
  auth: "admin"
53621
53625
  }), method(object({ deviceId: number$1() }), record(string(), unknown()), { auth: "admin" }), method(object({ deviceId: number$1() }), record(string(), unknown()), { auth: "admin" }), method(object({ deviceId: number$1() }), DeviceMetaSchema.nullable()), method(object({
53622
53626
  deviceId: number$1(),
53623
- name: string()
53627
+ name: string(),
53628
+ /**
53629
+ * Absent or true: an operator rename, which stamps `userNamed`.
53630
+ * False: the system copying a block name onto the device. That write
53631
+ * must not look like the operator's, or the next reconcile freezes it.
53632
+ */
53633
+ stampUserNamed: boolean().optional()
53624
53634
  }), _void(), {
53625
53635
  kind: "mutation",
53626
53636
  auth: "admin"
@@ -84335,6 +84345,7 @@ var BaseDeviceProvider = class extends BaseAddon {
84335
84345
  return toDeviceSummary(device, this.addonId);
84336
84346
  }
84337
84347
  };
84348
+ DeviceType.HeatPump;
84338
84349
  DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Heater, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
84339
84350
  new Set(Object.values(DeviceType));
84340
84351
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
@@ -86081,7 +86092,7 @@ var CLIMATE_FAMILY_CONTRIBUTIONS = {
86081
86092
  /**
86082
86093
  * The heat pump's contribution to a hero (D1026): the compressor scene, every
86083
86094
  * circuit as a row with its own label and icon, the powers as pills (the
86084
- * instantaneous COP only when both powers are known) and a "System" group with
86095
+ * instantaneous COP is "—" when it cannot be computed) and a "System" group with
86085
86096
  * one selector per mode. Values and their limits come from the slice, which the
86086
86097
  * gateway filled: a selector with no allowed value is not drawn, a missing
86087
86098
  * reading is never a 0 (D393).
@@ -86153,9 +86164,22 @@ function circuitRow(circuit) {
86153
86164
  };
86154
86165
  }
86155
86166
  var kilowatts = (watts) => `${Number((watts / 1e3).toFixed(2))} kW`;
86167
+ /** A COP that cannot be computed is still the pill: "—", never an absent reading (D393). */
86168
+ function copPill(cop) {
86169
+ if (cop === null) return {
86170
+ icon: "gauge",
86171
+ text: t("Instantaneous COP —", "COP istantaneo —"),
86172
+ tone: "muted"
86173
+ };
86174
+ const text = String(Number(cop.toFixed(1)));
86175
+ return {
86176
+ icon: "gauge",
86177
+ text: t(`Instantaneous COP ${text}`, `COP istantaneo ${text}`),
86178
+ tone: "success"
86179
+ };
86180
+ }
86156
86181
  function powerPills(status) {
86157
86182
  const { thermalW, electricalW } = status.power;
86158
- const cop = heatPumpInstantCop(status.power);
86159
86183
  const pills = [];
86160
86184
  if (thermalW !== null) pills.push({
86161
86185
  icon: "flame",
@@ -86167,14 +86191,7 @@ function powerPills(status) {
86167
86191
  text: t(`Electrical ${kilowatts(electricalW)}`, `Elettrica ${kilowatts(electricalW)}`),
86168
86192
  tone: "muted"
86169
86193
  });
86170
- if (cop !== null) {
86171
- const text = String(Number(cop.toFixed(1)));
86172
- pills.push({
86173
- icon: "gauge",
86174
- text: t(`Instantaneous COP ${text}`, `COP istantaneo ${text}`),
86175
- tone: "success"
86176
- });
86177
- }
86194
+ pills.push(copPill(heatPumpInstantCop(status.power)));
86178
86195
  return pills;
86179
86196
  }
86180
86197
  /** The independent system modes, in the order the card draws them. */
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_bosch_instances = require("../bosch-instances-BD-Valeo.js");
3
- const require_account_integration_offline = require("../account-integration-offline-BfsMnlJo.js");
2
+ const require_bosch_instances = require("../bosch-instances-D0eF-Jjy.js");
3
+ const require_account_integration_offline = require("../account-integration-offline-C6tzFB-H.js");
4
4
  let node_crypto = require("node:crypto");
5
5
  let node_tls = require("node:tls");
6
6
  let node_zlib = require("node:zlib");
@@ -1,5 +1,5 @@
1
- import { A as RecordIntegrationInstances, B as array, C as powerMeterCapability, E as runningStateCapability, F as entryBody, G as string, I as isSecretMarker, J as DeviceRole, K as union, L as isSecretMarkerLike, M as customAction, N as defineCustomActions, P as defineEntryKind, R as rowsDepsOver, S as numericSensorCapability, T as runningFromDishwasherOperation, U as object, V as literal, W as record, X as errMsg, Y as DeviceType, Z as EventCategory, a as BaseDevice, b as ingestReading, c as RUNNING_STATE_COLD, f as consumablesCapability, g as eventEmitterCapability, h as enumSensorCapability, i as testBoschInstance, j as createEvent, m as dishwasherCapability, n as boschRowsPorts, o as BaseDeviceProvider, p as deviceAdoptionCapability, q as unknown, r as keepBodyKeys, s as DishwasherOperationStateSchema, t as boschRowsMigration, u as binaryCapability, w as quantityFromUnit, x as integrationInstancesCapability, z as _enum } from "../bosch-instances-DkUo6BfT.mjs";
2
- import { a as loginFailureForAttempt, c as HOME_CONNECT_REDIRECT_URI, i as createSignInAttemptStore, n as cascadeRemoveDevicesForIntegration, o as parseOAuthCallback, r as buildSignInGuideFields, t as setIntegrationDevicesOnline } from "../account-integration-offline-BGH1q3tj.mjs";
1
+ import { A as RecordIntegrationInstances, B as array, C as powerMeterCapability, E as runningStateCapability, F as entryBody, G as string, I as isSecretMarker, J as DeviceRole, K as union, L as isSecretMarkerLike, M as customAction, N as defineCustomActions, P as defineEntryKind, R as rowsDepsOver, S as numericSensorCapability, T as runningFromDishwasherOperation, U as object, V as literal, W as record, X as errMsg, Y as DeviceType, Z as EventCategory, a as BaseDevice, b as ingestReading, c as RUNNING_STATE_COLD, f as consumablesCapability, g as eventEmitterCapability, h as enumSensorCapability, i as testBoschInstance, j as createEvent, m as dishwasherCapability, n as boschRowsPorts, o as BaseDeviceProvider, p as deviceAdoptionCapability, q as unknown, r as keepBodyKeys, s as DishwasherOperationStateSchema, t as boschRowsMigration, u as binaryCapability, w as quantityFromUnit, x as integrationInstancesCapability, z as _enum } from "../bosch-instances-DAqkAsRO.mjs";
2
+ import { a as loginFailureForAttempt, c as HOME_CONNECT_REDIRECT_URI, i as createSignInAttemptStore, n as cascadeRemoveDevicesForIntegration, o as parseOAuthCallback, r as buildSignInGuideFields, t as setIntegrationDevicesOnline } from "../account-integration-offline-Bie4aS5e.mjs";
3
3
  import { createHash, randomBytes } from "node:crypto";
4
4
  import { connect } from "node:tls";
5
5
  import { inflateRawSync } from "node:zlib";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_bosch_instances = require("../bosch-instances-BD-Valeo.js");
3
- const require_account_integration_offline = require("../account-integration-offline-BfsMnlJo.js");
2
+ const require_bosch_instances = require("../bosch-instances-D0eF-Jjy.js");
3
+ const require_account_integration_offline = require("../account-integration-offline-C6tzFB-H.js");
4
4
  let node_crypto = require("node:crypto");
5
5
  //#region src/homecom/config.ts
6
6
  var HOMECOM_BRANDS = ["bosch", "buderus"];
@@ -1807,6 +1807,129 @@ function buildHomeComGatewayPersister(deps) {
1807
1807
  return (integrationId, gatewayId) => patch(integrationId, { gatewayId });
1808
1808
  }
1809
1809
  //#endregion
1810
+ //#region src/homecom/homecom-gateway.ts
1811
+ /** Stable id of one HomeCom device. Adoption matches an existing row on this. */
1812
+ function homeComStableId(integrationId, nativeId) {
1813
+ return `homecom:${integrationId}:${nativeId}`;
1814
+ }
1815
+ /** The hot-water child of a heat pump. A boiler's own row keeps its longer name. */
1816
+ var HOMECOM_HOT_WATER_CHILD_NAME = "Hot water";
1817
+ var HomeComConnectionResolver = class {
1818
+ #surfaces = /* @__PURE__ */ new Map();
1819
+ set(integrationId, surface) {
1820
+ if (surface === null) {
1821
+ this.#surfaces.delete(integrationId);
1822
+ return;
1823
+ }
1824
+ this.#surfaces.set(integrationId, surface);
1825
+ }
1826
+ has(integrationId) {
1827
+ return this.#surfaces.has(integrationId);
1828
+ }
1829
+ list() {
1830
+ return Array.from(this.#surfaces.keys()).map((id) => ({ id }));
1831
+ }
1832
+ discoverables(integrationId) {
1833
+ return this.#surfaces.get(integrationId)?.discoverables ?? [];
1834
+ }
1835
+ getClient(integrationId) {
1836
+ return this.#surfaces.get(integrationId)?.client ?? null;
1837
+ }
1838
+ getSnapshot(integrationId) {
1839
+ return this.#surfaces.get(integrationId)?.snapshot ?? null;
1840
+ }
1841
+ updateSnapshot(integrationId, snapshot) {
1842
+ const existing = this.#surfaces.get(integrationId);
1843
+ if (!existing) return;
1844
+ this.#surfaces.set(integrationId, {
1845
+ ...existing,
1846
+ snapshot,
1847
+ discoverables: buildDiscoverables(snapshot)
1848
+ });
1849
+ }
1850
+ clear() {
1851
+ this.#surfaces.clear();
1852
+ }
1853
+ };
1854
+ var BOILER_DHW_NAME = "Domestic hot water";
1855
+ function circuitDiscoverable(circuit) {
1856
+ return {
1857
+ nativeId: `hc:${circuit.id}`,
1858
+ name: circuit.name,
1859
+ kind: "heating-circuit",
1860
+ circuitId: circuit.id
1861
+ };
1862
+ }
1863
+ function dhwDiscoverable(name) {
1864
+ return {
1865
+ nativeId: "dhw:0",
1866
+ name,
1867
+ kind: "dhw"
1868
+ };
1869
+ }
1870
+ /**
1871
+ * A gateway with a heat pump is one pick. A boiler still offers each circuit
1872
+ * and the hot-water row on its own.
1873
+ */
1874
+ function buildDiscoverables(snapshot) {
1875
+ const circuits = snapshot.circuits.map(circuitDiscoverable);
1876
+ if (snapshot.heatPump !== void 0) return [{
1877
+ nativeId: "hp:0",
1878
+ name: "Heat pump",
1879
+ kind: "heat-pump",
1880
+ children: [...circuits, ...snapshot.dhw === null ? [] : [dhwDiscoverable(HOMECOM_HOT_WATER_CHILD_NAME)]]
1881
+ }];
1882
+ return [...circuits, ...snapshot.dhw === null ? [] : [dhwDiscoverable(BOILER_DHW_NAME)]];
1883
+ }
1884
+ var homeComConnections = new HomeComConnectionResolver();
1885
+ //#endregion
1886
+ //#region src/homecom/homecom-adoption-plan.ts
1887
+ function createOf(device, parentNativeId) {
1888
+ return {
1889
+ nativeId: device.nativeId,
1890
+ name: device.name,
1891
+ kind: device.kind,
1892
+ circuitId: device.circuitId,
1893
+ parentNativeId
1894
+ };
1895
+ }
1896
+ /**
1897
+ * The devices one pick creates. A heat pump also creates its children, except
1898
+ * a circuit or hot-water row that already exists: a top-level one is reported
1899
+ * so the caller can log why it stayed there, and any existing row is not
1900
+ * created again.
1901
+ */
1902
+ function planHomeComAdoption(device, integrationId, adopted) {
1903
+ const root = createOf(device, null);
1904
+ if (device.kind !== "heat-pump") return {
1905
+ create: [root],
1906
+ stayedTopLevel: [],
1907
+ alreadyPresent: []
1908
+ };
1909
+ const byStableId = new Map(adopted.map((row) => [row.stableId, row]));
1910
+ const create = [root];
1911
+ const stayedTopLevel = [];
1912
+ const alreadyPresent = [];
1913
+ for (const child of device.children ?? []) {
1914
+ const existing = byStableId.get(homeComStableId(integrationId, child.nativeId));
1915
+ if (existing === void 0) {
1916
+ create.push(createOf(child, device.nativeId));
1917
+ continue;
1918
+ }
1919
+ const skip = {
1920
+ nativeId: child.nativeId,
1921
+ deviceId: existing.id
1922
+ };
1923
+ if (existing.parentDeviceId === null) stayedTopLevel.push(skip);
1924
+ else alreadyPresent.push(skip);
1925
+ }
1926
+ return {
1927
+ create,
1928
+ stayedTopLevel,
1929
+ alreadyPresent
1930
+ };
1931
+ }
1932
+ //#endregion
1810
1933
  //#region src/homecom/homecom-discovery.ts
1811
1934
  function buildHomeComCandidates(input) {
1812
1935
  const out = [];
@@ -1826,6 +1949,9 @@ function buildHomeComCandidates(input) {
1826
1949
  }
1827
1950
  return out;
1828
1951
  }
1952
+ function homeComDeviceType(kind) {
1953
+ return shapeOf(kind).type;
1954
+ }
1829
1955
  function shapeOf(kind) {
1830
1956
  switch (kind) {
1831
1957
  case "heating-circuit": return {
@@ -1849,6 +1975,62 @@ var DEVICES_FILTER = {
1849
1975
  label: "Devices",
1850
1976
  isDefault: true
1851
1977
  };
1978
+ var STAYED_TOP_LEVEL = "HomeCom device stayed top-level: it was already adopted, so it was not created again under the heat pump";
1979
+ var ALREADY_PRESENT = "HomeCom device was not created again: a device with this stable id already exists";
1980
+ async function adoptOne(input) {
1981
+ const { dev, integrationId, name, known, adoptDevice, logger, logOnce } = input;
1982
+ const plan = planHomeComAdoption(dev, integrationId, known);
1983
+ for (const skip of plan.stayedTopLevel) logOnce(skip.deviceId, STAYED_TOP_LEVEL);
1984
+ for (const skip of plan.alreadyPresent) logOnce(skip.deviceId, ALREADY_PRESENT);
1985
+ const root = plan.create[0];
1986
+ if (root === void 0) return { ok: false };
1987
+ let parentDeviceId;
1988
+ try {
1989
+ parentDeviceId = (await adoptDevice({
1990
+ nativeId: root.nativeId,
1991
+ integrationId,
1992
+ type: homeComDeviceType(root.kind),
1993
+ name,
1994
+ kind: root.kind,
1995
+ ...root.circuitId === void 0 ? {} : { circuitId: root.circuitId },
1996
+ parentDeviceId: null
1997
+ })).deviceId;
1998
+ } catch (err) {
1999
+ logger.warn("homecom adopt failed", { meta: {
2000
+ nativeId: root.nativeId,
2001
+ integrationId,
2002
+ error: require_bosch_instances.errMsg(err)
2003
+ } });
2004
+ return { ok: false };
2005
+ }
2006
+ const accessoryDeviceIds = [];
2007
+ for (const child of plan.create.slice(1)) try {
2008
+ const created = await adoptDevice({
2009
+ nativeId: child.nativeId,
2010
+ integrationId,
2011
+ type: homeComDeviceType(child.kind),
2012
+ name: child.name,
2013
+ kind: child.kind,
2014
+ ...child.circuitId === void 0 ? {} : { circuitId: child.circuitId },
2015
+ parentDeviceId
2016
+ });
2017
+ accessoryDeviceIds.push(created.deviceId);
2018
+ } catch (err) {
2019
+ logger.warn("homecom adopt child failed", {
2020
+ tags: { deviceId: parentDeviceId },
2021
+ meta: {
2022
+ nativeId: child.nativeId,
2023
+ integrationId,
2024
+ error: require_bosch_instances.errMsg(err)
2025
+ }
2026
+ });
2027
+ }
2028
+ return {
2029
+ ok: true,
2030
+ parentDeviceId,
2031
+ accessoryDeviceIds
2032
+ };
2033
+ }
1852
2034
  async function adoptedMapForIntegration(integrationId, listAdopted) {
1853
2035
  const all = await listAdopted();
1854
2036
  const map = /* @__PURE__ */ new Map();
@@ -1860,6 +2042,12 @@ async function adoptedMapForIntegration(integrationId, listAdopted) {
1860
2042
  }
1861
2043
  function buildHomeComAdoptionProvider(deps) {
1862
2044
  const { registry, hasIntegration, listIntegrations, listAdopted, adoptDevice, removeDevice, findDeviceConfig, logger } = deps;
2045
+ const logged = /* @__PURE__ */ new Set();
2046
+ const logOnce = (deviceId, message) => {
2047
+ if (logged.has(deviceId)) return;
2048
+ logged.add(deviceId);
2049
+ logger.info(message, { tags: { deviceId } });
2050
+ };
1863
2051
  async function allCandidatesForIntegration(integrationId) {
1864
2052
  return buildHomeComCandidates({
1865
2053
  devices: registry.discoverables(integrationId),
@@ -1914,48 +2102,36 @@ function buildHomeComAdoptionProvider(deps) {
1914
2102
  adopt: async ({ integrationId, childNativeIds, perCandidate }) => {
1915
2103
  if (!registry.has(integrationId)) throw new Error(`homecom adopt: integration ${integrationId} not connected`);
1916
2104
  const devices = registry.discoverables(integrationId);
2105
+ const known = await listAdopted();
1917
2106
  const adopted = [];
1918
2107
  let failures = 0;
1919
- for (const nativeId of childNativeIds) try {
2108
+ for (const nativeId of childNativeIds) {
1920
2109
  const dev = devices.find((d) => d.nativeId === nativeId);
1921
2110
  if (!dev) {
1922
2111
  failures++;
1923
2112
  continue;
1924
2113
  }
1925
- const candidate = buildHomeComCandidates({
1926
- devices: [dev],
1927
- adopted: /* @__PURE__ */ new Map()
1928
- })[0];
1929
- if (!candidate) {
2114
+ const outcome = await adoptOne({
2115
+ dev,
2116
+ integrationId,
2117
+ name: perCandidate?.[nativeId]?.name ?? dev.name,
2118
+ known,
2119
+ adoptDevice,
2120
+ logger,
2121
+ logOnce
2122
+ });
2123
+ if (!outcome.ok) {
1930
2124
  failures++;
1931
2125
  continue;
1932
2126
  }
1933
- const name = perCandidate?.[nativeId]?.name ?? dev.name;
1934
- const { deviceId } = await adoptDevice({
1935
- nativeId,
1936
- integrationId,
1937
- type: candidate.type,
1938
- name,
1939
- kind: dev.kind,
1940
- circuitId: dev.circuitId
1941
- });
1942
2127
  adopted.push({
1943
2128
  childNativeId: nativeId,
1944
- parentDeviceId: deviceId
2129
+ parentDeviceId: outcome.parentDeviceId,
2130
+ accessoryDeviceIds: outcome.accessoryDeviceIds
1945
2131
  });
1946
- } catch (err) {
1947
- logger.warn("homecom adopt failed", { meta: {
1948
- nativeId,
1949
- integrationId,
1950
- error: require_bosch_instances.errMsg(err)
1951
- } });
1952
- failures++;
1953
2132
  }
1954
2133
  if (adopted.length === 0 && failures > 0) throw new Error(`homecom adopt: all ${failures} adopt(s) failed`);
1955
- return { adopted: adopted.map((a) => ({
1956
- ...a,
1957
- accessoryDeviceIds: []
1958
- })) };
2134
+ return { adopted };
1959
2135
  },
1960
2136
  release: async ({ camDeviceId }) => {
1961
2137
  await removeDevice(camDeviceId);
@@ -1975,66 +2151,6 @@ function buildHomeComAdoptionProvider(deps) {
1975
2151
  };
1976
2152
  }
1977
2153
  //#endregion
1978
- //#region src/homecom/homecom-gateway.ts
1979
- var HomeComConnectionResolver = class {
1980
- #surfaces = /* @__PURE__ */ new Map();
1981
- set(integrationId, surface) {
1982
- if (surface === null) {
1983
- this.#surfaces.delete(integrationId);
1984
- return;
1985
- }
1986
- this.#surfaces.set(integrationId, surface);
1987
- }
1988
- has(integrationId) {
1989
- return this.#surfaces.has(integrationId);
1990
- }
1991
- list() {
1992
- return Array.from(this.#surfaces.keys()).map((id) => ({ id }));
1993
- }
1994
- discoverables(integrationId) {
1995
- return this.#surfaces.get(integrationId)?.discoverables ?? [];
1996
- }
1997
- getClient(integrationId) {
1998
- return this.#surfaces.get(integrationId)?.client ?? null;
1999
- }
2000
- getSnapshot(integrationId) {
2001
- return this.#surfaces.get(integrationId)?.snapshot ?? null;
2002
- }
2003
- updateSnapshot(integrationId, snapshot) {
2004
- const existing = this.#surfaces.get(integrationId);
2005
- if (!existing) return;
2006
- this.#surfaces.set(integrationId, {
2007
- ...existing,
2008
- snapshot,
2009
- discoverables: buildDiscoverables(snapshot)
2010
- });
2011
- }
2012
- clear() {
2013
- this.#surfaces.clear();
2014
- }
2015
- };
2016
- function buildDiscoverables(snapshot) {
2017
- const out = [];
2018
- for (const circuit of snapshot.circuits) out.push({
2019
- nativeId: `hc:${circuit.id}`,
2020
- name: circuit.name,
2021
- kind: "heating-circuit",
2022
- circuitId: circuit.id
2023
- });
2024
- if (snapshot.dhw) out.push({
2025
- nativeId: "dhw:0",
2026
- name: "Domestic hot water",
2027
- kind: "dhw"
2028
- });
2029
- if (snapshot.heatPump !== void 0) out.push({
2030
- nativeId: "hp:0",
2031
- name: "Heat pump",
2032
- kind: "heat-pump"
2033
- });
2034
- return out;
2035
- }
2036
- var homeComConnections = new HomeComConnectionResolver();
2037
- //#endregion
2038
2154
  //#region src/homecom/homecom-integration-manager.ts
2039
2155
  var HomeComIntegrationManager = class {
2040
2156
  #id;
@@ -2933,7 +3049,7 @@ var BoschHomeComProviderAddon = class extends require_bosch_instances.BaseDevice
2933
3049
  if (typeof integrationId !== "string" || integrationId.length === 0) throw new Error("homecom generateStableId: brokerId required");
2934
3050
  const nativeId = config?.["nativeId"];
2935
3051
  if (typeof nativeId !== "string" || nativeId.length === 0) throw new Error("homecom generateStableId: nativeId required");
2936
- return `homecom:${integrationId}:${nativeId}`;
3052
+ return homeComStableId(integrationId, nativeId);
2937
3053
  }
2938
3054
  async reconcileIntegrations() {
2939
3055
  const reg = this.requireClients();
@@ -2995,12 +3111,14 @@ var BoschHomeComProviderAddon = class extends require_bosch_instances.BaseDevice
2995
3111
  const config = await devices.loadConfig(d.id).catch(() => ({}));
2996
3112
  out.push({
2997
3113
  id: d.id,
3114
+ stableId: d.stableId,
3115
+ parentDeviceId: d.parentDeviceId,
2998
3116
  config
2999
3117
  });
3000
3118
  }
3001
3119
  return out;
3002
3120
  },
3003
- adoptDevice: async ({ nativeId, integrationId, type, name, kind, circuitId }) => {
3121
+ adoptDevice: async ({ nativeId, integrationId, type, name, kind, circuitId, parentDeviceId }) => {
3004
3122
  const devices = this.ctx.kernel.devices;
3005
3123
  if (!devices) throw new Error("homecom adopt: devices unavailable");
3006
3124
  const config = {
@@ -3014,7 +3132,7 @@ var BoschHomeComProviderAddon = class extends require_bosch_instances.BaseDevice
3014
3132
  const stableId = this.generateStableId(type, config);
3015
3133
  const DeviceClass = this.deviceClasses[type];
3016
3134
  if (!DeviceClass) throw new Error(`homecom adopt: unsupported type ${type}`);
3017
- return { deviceId: (await devices.create(stableId, DeviceClass, config, null, {
3135
+ return { deviceId: (await devices.create(stableId, DeviceClass, config, parentDeviceId, {
3018
3136
  type,
3019
3137
  name,
3020
3138
  integrationId
@@ -1,5 +1,5 @@
1
- import { A as RecordIntegrationInstances, B as array, F as entryBody, G as string, H as number, M as customAction, N as defineCustomActions, P as defineEntryKind, R as rowsDepsOver, U as object, V as literal, X as errMsg, Y as DeviceType, Z as EventCategory, _ as heatPumpControlCapability, a as BaseDevice, d as climateControlCapability, i as testBoschInstance, k as waterHeaterCapability, n as boschRowsPorts, o as BaseDeviceProvider, p as deviceAdoptionCapability, r as keepBodyKeys, t as boschRowsMigration, v as heatPumpStatusCapability, x as integrationInstancesCapability, z as _enum } from "../bosch-instances-DkUo6BfT.mjs";
2
- import { a as loginFailureForAttempt, i as createSignInAttemptStore, n as cascadeRemoveDevicesForIntegration, o as parseOAuthCallback, r as buildSignInGuideFields, s as HOMECOM_REDIRECT_URI, t as setIntegrationDevicesOnline } from "../account-integration-offline-BGH1q3tj.mjs";
1
+ import { A as RecordIntegrationInstances, B as array, F as entryBody, G as string, H as number, M as customAction, N as defineCustomActions, P as defineEntryKind, R as rowsDepsOver, U as object, V as literal, X as errMsg, Y as DeviceType, Z as EventCategory, _ as heatPumpControlCapability, a as BaseDevice, d as climateControlCapability, i as testBoschInstance, k as waterHeaterCapability, n as boschRowsPorts, o as BaseDeviceProvider, p as deviceAdoptionCapability, r as keepBodyKeys, t as boschRowsMigration, v as heatPumpStatusCapability, x as integrationInstancesCapability, z as _enum } from "../bosch-instances-DAqkAsRO.mjs";
2
+ import { a as loginFailureForAttempt, i as createSignInAttemptStore, n as cascadeRemoveDevicesForIntegration, o as parseOAuthCallback, r as buildSignInGuideFields, s as HOMECOM_REDIRECT_URI, t as setIntegrationDevicesOnline } from "../account-integration-offline-Bie4aS5e.mjs";
3
3
  import { createHash, randomBytes } from "node:crypto";
4
4
  //#region src/homecom/config.ts
5
5
  var HOMECOM_BRANDS = ["bosch", "buderus"];
@@ -1806,6 +1806,129 @@ function buildHomeComGatewayPersister(deps) {
1806
1806
  return (integrationId, gatewayId) => patch(integrationId, { gatewayId });
1807
1807
  }
1808
1808
  //#endregion
1809
+ //#region src/homecom/homecom-gateway.ts
1810
+ /** Stable id of one HomeCom device. Adoption matches an existing row on this. */
1811
+ function homeComStableId(integrationId, nativeId) {
1812
+ return `homecom:${integrationId}:${nativeId}`;
1813
+ }
1814
+ /** The hot-water child of a heat pump. A boiler's own row keeps its longer name. */
1815
+ var HOMECOM_HOT_WATER_CHILD_NAME = "Hot water";
1816
+ var HomeComConnectionResolver = class {
1817
+ #surfaces = /* @__PURE__ */ new Map();
1818
+ set(integrationId, surface) {
1819
+ if (surface === null) {
1820
+ this.#surfaces.delete(integrationId);
1821
+ return;
1822
+ }
1823
+ this.#surfaces.set(integrationId, surface);
1824
+ }
1825
+ has(integrationId) {
1826
+ return this.#surfaces.has(integrationId);
1827
+ }
1828
+ list() {
1829
+ return Array.from(this.#surfaces.keys()).map((id) => ({ id }));
1830
+ }
1831
+ discoverables(integrationId) {
1832
+ return this.#surfaces.get(integrationId)?.discoverables ?? [];
1833
+ }
1834
+ getClient(integrationId) {
1835
+ return this.#surfaces.get(integrationId)?.client ?? null;
1836
+ }
1837
+ getSnapshot(integrationId) {
1838
+ return this.#surfaces.get(integrationId)?.snapshot ?? null;
1839
+ }
1840
+ updateSnapshot(integrationId, snapshot) {
1841
+ const existing = this.#surfaces.get(integrationId);
1842
+ if (!existing) return;
1843
+ this.#surfaces.set(integrationId, {
1844
+ ...existing,
1845
+ snapshot,
1846
+ discoverables: buildDiscoverables(snapshot)
1847
+ });
1848
+ }
1849
+ clear() {
1850
+ this.#surfaces.clear();
1851
+ }
1852
+ };
1853
+ var BOILER_DHW_NAME = "Domestic hot water";
1854
+ function circuitDiscoverable(circuit) {
1855
+ return {
1856
+ nativeId: `hc:${circuit.id}`,
1857
+ name: circuit.name,
1858
+ kind: "heating-circuit",
1859
+ circuitId: circuit.id
1860
+ };
1861
+ }
1862
+ function dhwDiscoverable(name) {
1863
+ return {
1864
+ nativeId: "dhw:0",
1865
+ name,
1866
+ kind: "dhw"
1867
+ };
1868
+ }
1869
+ /**
1870
+ * A gateway with a heat pump is one pick. A boiler still offers each circuit
1871
+ * and the hot-water row on its own.
1872
+ */
1873
+ function buildDiscoverables(snapshot) {
1874
+ const circuits = snapshot.circuits.map(circuitDiscoverable);
1875
+ if (snapshot.heatPump !== void 0) return [{
1876
+ nativeId: "hp:0",
1877
+ name: "Heat pump",
1878
+ kind: "heat-pump",
1879
+ children: [...circuits, ...snapshot.dhw === null ? [] : [dhwDiscoverable(HOMECOM_HOT_WATER_CHILD_NAME)]]
1880
+ }];
1881
+ return [...circuits, ...snapshot.dhw === null ? [] : [dhwDiscoverable(BOILER_DHW_NAME)]];
1882
+ }
1883
+ var homeComConnections = new HomeComConnectionResolver();
1884
+ //#endregion
1885
+ //#region src/homecom/homecom-adoption-plan.ts
1886
+ function createOf(device, parentNativeId) {
1887
+ return {
1888
+ nativeId: device.nativeId,
1889
+ name: device.name,
1890
+ kind: device.kind,
1891
+ circuitId: device.circuitId,
1892
+ parentNativeId
1893
+ };
1894
+ }
1895
+ /**
1896
+ * The devices one pick creates. A heat pump also creates its children, except
1897
+ * a circuit or hot-water row that already exists: a top-level one is reported
1898
+ * so the caller can log why it stayed there, and any existing row is not
1899
+ * created again.
1900
+ */
1901
+ function planHomeComAdoption(device, integrationId, adopted) {
1902
+ const root = createOf(device, null);
1903
+ if (device.kind !== "heat-pump") return {
1904
+ create: [root],
1905
+ stayedTopLevel: [],
1906
+ alreadyPresent: []
1907
+ };
1908
+ const byStableId = new Map(adopted.map((row) => [row.stableId, row]));
1909
+ const create = [root];
1910
+ const stayedTopLevel = [];
1911
+ const alreadyPresent = [];
1912
+ for (const child of device.children ?? []) {
1913
+ const existing = byStableId.get(homeComStableId(integrationId, child.nativeId));
1914
+ if (existing === void 0) {
1915
+ create.push(createOf(child, device.nativeId));
1916
+ continue;
1917
+ }
1918
+ const skip = {
1919
+ nativeId: child.nativeId,
1920
+ deviceId: existing.id
1921
+ };
1922
+ if (existing.parentDeviceId === null) stayedTopLevel.push(skip);
1923
+ else alreadyPresent.push(skip);
1924
+ }
1925
+ return {
1926
+ create,
1927
+ stayedTopLevel,
1928
+ alreadyPresent
1929
+ };
1930
+ }
1931
+ //#endregion
1809
1932
  //#region src/homecom/homecom-discovery.ts
1810
1933
  function buildHomeComCandidates(input) {
1811
1934
  const out = [];
@@ -1825,6 +1948,9 @@ function buildHomeComCandidates(input) {
1825
1948
  }
1826
1949
  return out;
1827
1950
  }
1951
+ function homeComDeviceType(kind) {
1952
+ return shapeOf(kind).type;
1953
+ }
1828
1954
  function shapeOf(kind) {
1829
1955
  switch (kind) {
1830
1956
  case "heating-circuit": return {
@@ -1848,6 +1974,62 @@ var DEVICES_FILTER = {
1848
1974
  label: "Devices",
1849
1975
  isDefault: true
1850
1976
  };
1977
+ var STAYED_TOP_LEVEL = "HomeCom device stayed top-level: it was already adopted, so it was not created again under the heat pump";
1978
+ var ALREADY_PRESENT = "HomeCom device was not created again: a device with this stable id already exists";
1979
+ async function adoptOne(input) {
1980
+ const { dev, integrationId, name, known, adoptDevice, logger, logOnce } = input;
1981
+ const plan = planHomeComAdoption(dev, integrationId, known);
1982
+ for (const skip of plan.stayedTopLevel) logOnce(skip.deviceId, STAYED_TOP_LEVEL);
1983
+ for (const skip of plan.alreadyPresent) logOnce(skip.deviceId, ALREADY_PRESENT);
1984
+ const root = plan.create[0];
1985
+ if (root === void 0) return { ok: false };
1986
+ let parentDeviceId;
1987
+ try {
1988
+ parentDeviceId = (await adoptDevice({
1989
+ nativeId: root.nativeId,
1990
+ integrationId,
1991
+ type: homeComDeviceType(root.kind),
1992
+ name,
1993
+ kind: root.kind,
1994
+ ...root.circuitId === void 0 ? {} : { circuitId: root.circuitId },
1995
+ parentDeviceId: null
1996
+ })).deviceId;
1997
+ } catch (err) {
1998
+ logger.warn("homecom adopt failed", { meta: {
1999
+ nativeId: root.nativeId,
2000
+ integrationId,
2001
+ error: errMsg(err)
2002
+ } });
2003
+ return { ok: false };
2004
+ }
2005
+ const accessoryDeviceIds = [];
2006
+ for (const child of plan.create.slice(1)) try {
2007
+ const created = await adoptDevice({
2008
+ nativeId: child.nativeId,
2009
+ integrationId,
2010
+ type: homeComDeviceType(child.kind),
2011
+ name: child.name,
2012
+ kind: child.kind,
2013
+ ...child.circuitId === void 0 ? {} : { circuitId: child.circuitId },
2014
+ parentDeviceId
2015
+ });
2016
+ accessoryDeviceIds.push(created.deviceId);
2017
+ } catch (err) {
2018
+ logger.warn("homecom adopt child failed", {
2019
+ tags: { deviceId: parentDeviceId },
2020
+ meta: {
2021
+ nativeId: child.nativeId,
2022
+ integrationId,
2023
+ error: errMsg(err)
2024
+ }
2025
+ });
2026
+ }
2027
+ return {
2028
+ ok: true,
2029
+ parentDeviceId,
2030
+ accessoryDeviceIds
2031
+ };
2032
+ }
1851
2033
  async function adoptedMapForIntegration(integrationId, listAdopted) {
1852
2034
  const all = await listAdopted();
1853
2035
  const map = /* @__PURE__ */ new Map();
@@ -1859,6 +2041,12 @@ async function adoptedMapForIntegration(integrationId, listAdopted) {
1859
2041
  }
1860
2042
  function buildHomeComAdoptionProvider(deps) {
1861
2043
  const { registry, hasIntegration, listIntegrations, listAdopted, adoptDevice, removeDevice, findDeviceConfig, logger } = deps;
2044
+ const logged = /* @__PURE__ */ new Set();
2045
+ const logOnce = (deviceId, message) => {
2046
+ if (logged.has(deviceId)) return;
2047
+ logged.add(deviceId);
2048
+ logger.info(message, { tags: { deviceId } });
2049
+ };
1862
2050
  async function allCandidatesForIntegration(integrationId) {
1863
2051
  return buildHomeComCandidates({
1864
2052
  devices: registry.discoverables(integrationId),
@@ -1913,48 +2101,36 @@ function buildHomeComAdoptionProvider(deps) {
1913
2101
  adopt: async ({ integrationId, childNativeIds, perCandidate }) => {
1914
2102
  if (!registry.has(integrationId)) throw new Error(`homecom adopt: integration ${integrationId} not connected`);
1915
2103
  const devices = registry.discoverables(integrationId);
2104
+ const known = await listAdopted();
1916
2105
  const adopted = [];
1917
2106
  let failures = 0;
1918
- for (const nativeId of childNativeIds) try {
2107
+ for (const nativeId of childNativeIds) {
1919
2108
  const dev = devices.find((d) => d.nativeId === nativeId);
1920
2109
  if (!dev) {
1921
2110
  failures++;
1922
2111
  continue;
1923
2112
  }
1924
- const candidate = buildHomeComCandidates({
1925
- devices: [dev],
1926
- adopted: /* @__PURE__ */ new Map()
1927
- })[0];
1928
- if (!candidate) {
2113
+ const outcome = await adoptOne({
2114
+ dev,
2115
+ integrationId,
2116
+ name: perCandidate?.[nativeId]?.name ?? dev.name,
2117
+ known,
2118
+ adoptDevice,
2119
+ logger,
2120
+ logOnce
2121
+ });
2122
+ if (!outcome.ok) {
1929
2123
  failures++;
1930
2124
  continue;
1931
2125
  }
1932
- const name = perCandidate?.[nativeId]?.name ?? dev.name;
1933
- const { deviceId } = await adoptDevice({
1934
- nativeId,
1935
- integrationId,
1936
- type: candidate.type,
1937
- name,
1938
- kind: dev.kind,
1939
- circuitId: dev.circuitId
1940
- });
1941
2126
  adopted.push({
1942
2127
  childNativeId: nativeId,
1943
- parentDeviceId: deviceId
2128
+ parentDeviceId: outcome.parentDeviceId,
2129
+ accessoryDeviceIds: outcome.accessoryDeviceIds
1944
2130
  });
1945
- } catch (err) {
1946
- logger.warn("homecom adopt failed", { meta: {
1947
- nativeId,
1948
- integrationId,
1949
- error: errMsg(err)
1950
- } });
1951
- failures++;
1952
2131
  }
1953
2132
  if (adopted.length === 0 && failures > 0) throw new Error(`homecom adopt: all ${failures} adopt(s) failed`);
1954
- return { adopted: adopted.map((a) => ({
1955
- ...a,
1956
- accessoryDeviceIds: []
1957
- })) };
2133
+ return { adopted };
1958
2134
  },
1959
2135
  release: async ({ camDeviceId }) => {
1960
2136
  await removeDevice(camDeviceId);
@@ -1974,66 +2150,6 @@ function buildHomeComAdoptionProvider(deps) {
1974
2150
  };
1975
2151
  }
1976
2152
  //#endregion
1977
- //#region src/homecom/homecom-gateway.ts
1978
- var HomeComConnectionResolver = class {
1979
- #surfaces = /* @__PURE__ */ new Map();
1980
- set(integrationId, surface) {
1981
- if (surface === null) {
1982
- this.#surfaces.delete(integrationId);
1983
- return;
1984
- }
1985
- this.#surfaces.set(integrationId, surface);
1986
- }
1987
- has(integrationId) {
1988
- return this.#surfaces.has(integrationId);
1989
- }
1990
- list() {
1991
- return Array.from(this.#surfaces.keys()).map((id) => ({ id }));
1992
- }
1993
- discoverables(integrationId) {
1994
- return this.#surfaces.get(integrationId)?.discoverables ?? [];
1995
- }
1996
- getClient(integrationId) {
1997
- return this.#surfaces.get(integrationId)?.client ?? null;
1998
- }
1999
- getSnapshot(integrationId) {
2000
- return this.#surfaces.get(integrationId)?.snapshot ?? null;
2001
- }
2002
- updateSnapshot(integrationId, snapshot) {
2003
- const existing = this.#surfaces.get(integrationId);
2004
- if (!existing) return;
2005
- this.#surfaces.set(integrationId, {
2006
- ...existing,
2007
- snapshot,
2008
- discoverables: buildDiscoverables(snapshot)
2009
- });
2010
- }
2011
- clear() {
2012
- this.#surfaces.clear();
2013
- }
2014
- };
2015
- function buildDiscoverables(snapshot) {
2016
- const out = [];
2017
- for (const circuit of snapshot.circuits) out.push({
2018
- nativeId: `hc:${circuit.id}`,
2019
- name: circuit.name,
2020
- kind: "heating-circuit",
2021
- circuitId: circuit.id
2022
- });
2023
- if (snapshot.dhw) out.push({
2024
- nativeId: "dhw:0",
2025
- name: "Domestic hot water",
2026
- kind: "dhw"
2027
- });
2028
- if (snapshot.heatPump !== void 0) out.push({
2029
- nativeId: "hp:0",
2030
- name: "Heat pump",
2031
- kind: "heat-pump"
2032
- });
2033
- return out;
2034
- }
2035
- var homeComConnections = new HomeComConnectionResolver();
2036
- //#endregion
2037
2153
  //#region src/homecom/homecom-integration-manager.ts
2038
2154
  var HomeComIntegrationManager = class {
2039
2155
  #id;
@@ -2932,7 +3048,7 @@ var BoschHomeComProviderAddon = class extends BaseDeviceProvider {
2932
3048
  if (typeof integrationId !== "string" || integrationId.length === 0) throw new Error("homecom generateStableId: brokerId required");
2933
3049
  const nativeId = config?.["nativeId"];
2934
3050
  if (typeof nativeId !== "string" || nativeId.length === 0) throw new Error("homecom generateStableId: nativeId required");
2935
- return `homecom:${integrationId}:${nativeId}`;
3051
+ return homeComStableId(integrationId, nativeId);
2936
3052
  }
2937
3053
  async reconcileIntegrations() {
2938
3054
  const reg = this.requireClients();
@@ -2994,12 +3110,14 @@ var BoschHomeComProviderAddon = class extends BaseDeviceProvider {
2994
3110
  const config = await devices.loadConfig(d.id).catch(() => ({}));
2995
3111
  out.push({
2996
3112
  id: d.id,
3113
+ stableId: d.stableId,
3114
+ parentDeviceId: d.parentDeviceId,
2997
3115
  config
2998
3116
  });
2999
3117
  }
3000
3118
  return out;
3001
3119
  },
3002
- adoptDevice: async ({ nativeId, integrationId, type, name, kind, circuitId }) => {
3120
+ adoptDevice: async ({ nativeId, integrationId, type, name, kind, circuitId, parentDeviceId }) => {
3003
3121
  const devices = this.ctx.kernel.devices;
3004
3122
  if (!devices) throw new Error("homecom adopt: devices unavailable");
3005
3123
  const config = {
@@ -3013,7 +3131,7 @@ var BoschHomeComProviderAddon = class extends BaseDeviceProvider {
3013
3131
  const stableId = this.generateStableId(type, config);
3014
3132
  const DeviceClass = this.deviceClasses[type];
3015
3133
  if (!DeviceClass) throw new Error(`homecom adopt: unsupported type ${type}`);
3016
- return { deviceId: (await devices.create(stableId, DeviceClass, config, null, {
3134
+ return { deviceId: (await devices.create(stableId, DeviceClass, config, parentDeviceId, {
3017
3135
  type,
3018
3136
  name,
3019
3137
  integrationId
package/dist/shc/addon.js CHANGED
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region \0rolldown/runtime.js
3
3
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
4
  //#endregion
5
- const require_bosch_instances = require("../bosch-instances-BD-Valeo.js");
5
+ const require_bosch_instances = require("../bosch-instances-D0eF-Jjy.js");
6
6
  let node_crypto = require("node:crypto");
7
7
  let node_https = require("node:https");
8
8
  let node_child_process = require("node:child_process");
@@ -1,4 +1,4 @@
1
- import { A as RecordIntegrationInstances, B as array, D as switchCapability, F as entryBody, G as string, H as number, M as customAction, N as defineCustomActions, O as temperatureSensorCapability, P as defineEntryKind, R as rowsDepsOver, U as object, V as literal, X as errMsg, Y as DeviceType, Z as EventCategory, a as BaseDevice, d as climateControlCapability, i as testBoschInstance, l as batteryCapability, n as boschRowsPorts, o as BaseDeviceProvider, p as deviceAdoptionCapability, r as keepBodyKeys, t as boschRowsMigration, x as integrationInstancesCapability, y as heatingValveCapability, z as _enum } from "../bosch-instances-DkUo6BfT.mjs";
1
+ import { A as RecordIntegrationInstances, B as array, D as switchCapability, F as entryBody, G as string, H as number, M as customAction, N as defineCustomActions, O as temperatureSensorCapability, P as defineEntryKind, R as rowsDepsOver, U as object, V as literal, X as errMsg, Y as DeviceType, Z as EventCategory, a as BaseDevice, d as climateControlCapability, i as testBoschInstance, l as batteryCapability, n as boschRowsPorts, o as BaseDeviceProvider, p as deviceAdoptionCapability, r as keepBodyKeys, t as boschRowsMigration, x as integrationInstancesCapability, y as heatingValveCapability, z as _enum } from "../bosch-instances-DAqkAsRO.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { request } from "node:https";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-bosch",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "description": "Bosch smart-home device-provider addons for CamStack — SHC, Home Connect, and HomeCom cloud integrations (scaffold)",
5
5
  "keywords": [
6
6
  "camstack",
@@ -138,7 +138,7 @@
138
138
  }
139
139
  ],
140
140
  "requires": {
141
- "server": ">=1.2.822"
141
+ "server": ">=1.2.823"
142
142
  }
143
143
  },
144
144
  "files": [