@camstack/addon-provider-homematic 1.2.195 → 1.2.196

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 (19) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/.bundle-modules.json +12 -11
  3. package/dist/_stub.js +512 -374
  4. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-BxmxWSOr.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-D8eX6qCZ.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-BPCGkZg7.mjs +26 -0
  6. package/dist/addon-provider-homematic.css +1 -1
  7. package/dist/addon.js +383 -213
  8. package/dist/addon.mjs +383 -213
  9. package/dist/{hostInit-DVAY-ltL.mjs → hostInit-DuBY5RFc.mjs} +3 -3
  10. package/dist/remoteEntry.js +1 -1
  11. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-B3yyDS0x.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-v2rx1eLb.mjs} +1 -1
  12. package/dist/widgets/_stub.js +22 -5
  13. package/dist/widgets/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-BPDLKZtI.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-Cn_SmgI_.mjs} +2 -2
  14. package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-jVV0iLqt.mjs +26 -0
  15. package/dist/widgets/{hostInit-BlyQmRnG.mjs → hostInit-qp7M4JAF.mjs} +2 -2
  16. package/dist/widgets/remoteEntry.js +1 -1
  17. package/package.json +3 -3
  18. package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DMlVGmnP.mjs +0 -26
  19. package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-C6zY_Ytj.mjs +0 -26
package/dist/addon.js CHANGED
@@ -6071,7 +6071,7 @@ var ZodIssueCode = {
6071
6071
  var ZodFirstPartyTypeKind;
6072
6072
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6073
6073
  //#endregion
6074
- //#region ../types/dist/sleep-Cykc2bzi.mjs
6074
+ //#region ../types/dist/sleep-BCWQQG52.mjs
6075
6075
  /**
6076
6076
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6077
6077
  * window to float samples (D455).
@@ -10717,41 +10717,57 @@ var CAP_VOCABULARY_BY_NAME = {
10717
10717
  en: "Switch",
10718
10718
  it: "Interruttore"
10719
10719
  },
10720
- actions: [{
10721
- id: "switch.on",
10722
- method: "setState",
10723
- label: {
10724
- en: "Turn on",
10725
- it: "Accendi"
10726
- },
10727
- phrase: {
10728
- en: "Turn on {device}",
10729
- it: "Accendi {device}"
10730
- },
10731
- icon: "power",
10732
- args: { on: true },
10733
- effect: {
10734
- field: "on",
10735
- value: true
10736
- }
10737
- }, {
10738
- id: "switch.off",
10739
- method: "setState",
10740
- label: {
10741
- en: "Turn off",
10742
- it: "Spegni"
10720
+ actions: [
10721
+ {
10722
+ id: "switch.on",
10723
+ method: "setState",
10724
+ label: {
10725
+ en: "Turn on",
10726
+ it: "Accendi"
10727
+ },
10728
+ phrase: {
10729
+ en: "Turn on {device}",
10730
+ it: "Accendi {device}"
10731
+ },
10732
+ icon: "power",
10733
+ args: { on: true },
10734
+ effect: {
10735
+ field: "on",
10736
+ value: true
10737
+ }
10743
10738
  },
10744
- phrase: {
10745
- en: "Turn off {device}",
10746
- it: "Spegni {device}"
10739
+ {
10740
+ id: "switch.off",
10741
+ method: "setState",
10742
+ label: {
10743
+ en: "Turn off",
10744
+ it: "Spegni"
10745
+ },
10746
+ phrase: {
10747
+ en: "Turn off {device}",
10748
+ it: "Spegni {device}"
10749
+ },
10750
+ icon: "power-off",
10751
+ args: { on: false },
10752
+ effect: {
10753
+ field: "on",
10754
+ value: false
10755
+ }
10747
10756
  },
10748
- icon: "power-off",
10749
- args: { on: false },
10750
- effect: {
10751
- field: "on",
10752
- value: false
10757
+ {
10758
+ id: "switch.toggle",
10759
+ method: "toggle",
10760
+ label: {
10761
+ en: "Toggle",
10762
+ it: "Commuta"
10763
+ },
10764
+ phrase: {
10765
+ en: "Toggle {device}",
10766
+ it: "Commuta {device}"
10767
+ },
10768
+ icon: "toggle-right"
10753
10769
  }
10754
- }],
10770
+ ],
10755
10771
  state: [{
10756
10772
  kind: "boolean",
10757
10773
  field: "on",
@@ -55463,7 +55479,9 @@ var ClusterUpdateFailureReasonSchema = _enum([
55463
55479
  "status-unreadable",
55464
55480
  "addon-update-failed",
55465
55481
  "addons-not-converged",
55466
- "interrupted"
55482
+ "interrupted",
55483
+ "timeout-stall",
55484
+ "timeout-ceiling"
55467
55485
  ]);
55468
55486
  var ClusterUpdateStepSchema = object({
55469
55487
  kind: ClusterUpdateStepKindSchema,
@@ -59733,9 +59751,15 @@ var SiteZoneSchema = object({
59733
59751
  locationKeys: array(string())
59734
59752
  });
59735
59753
  var DeviceSearchRequiresSchema = object({
59736
- /** Capability names the field wants a value of. */
59737
- caps: array(string()).readonly(),
59738
- /** `any` (default): a device with one of them is compatible. `all`: it must hold every one. */
59754
+ /** Capability names the field wants a value of. Absent when the field wants actions only. */
59755
+ caps: array(string()).readonly().optional(),
59756
+ /**
59757
+ * Vocabulary action ids (`cover.open`) the device must offer. Compatible means
59758
+ * the device's bindings resolve those actions; `values` stays empty when no
59759
+ * cap was required. `mode` applies the same way as for `caps`.
59760
+ */
59761
+ actions: array(string()).readonly().optional(),
59762
+ /** `any` (default): one of the named caps, and one of the named actions, is enough. `all`: every one. */
59739
59763
  mode: _enum(["any", "all"]).optional()
59740
59764
  });
59741
59765
  var DeviceSearchFiltersSchema = object({
@@ -79275,6 +79299,13 @@ var NcHistoryEntrySchema = object({
79275
79299
  error: string().optional(),
79276
79300
  subject: NcHistorySubjectSchema,
79277
79301
  /**
79302
+ * The title and body actually sent, frozen at delivery. Absent on a row
79303
+ * still pending, a row suppressed before a notification was built, and a
79304
+ * row delivered before this field shipped.
79305
+ */
79306
+ title: string().optional(),
79307
+ body: string().optional(),
79308
+ /**
79278
79309
  * Ids of the artefacts (still, then gif, then clip) this row's successful
79279
79310
  * delivery indexed in the artefact library — a REFERENCE, never the bytes
79280
79311
  * (an artefact is often megabytes; this row is durable JSON rewritten on
@@ -87585,7 +87616,8 @@ var ServerUpdateActionResultSchema = object({
87585
87616
  outcome: ServerUpdateOutcomeSchema.optional(),
87586
87617
  /**
87587
87618
  * Stable, greppable cause for `refused` / `failed` (the engine's
87588
- * `UpdateRefusalReason`, `staging-failed`, …). `null` on success.
87619
+ * `UpdateRefusalReason`, `staging-failed`, `timeout-stall`,
87620
+ * `timeout-ceiling`). `null` on success.
87589
87621
  */
87590
87622
  reason: string().nullable().optional(),
87591
87623
  /**
@@ -87707,6 +87739,14 @@ var smokeCapability = {
87707
87739
  }]
87708
87740
  }
87709
87741
  };
87742
+ var EmailImagePartSchema = object({
87743
+ ticket: PeerBytesTicketSchema,
87744
+ mime: string().min(1),
87745
+ name: string().min(1),
87746
+ contentId: string().min(1),
87747
+ placement: _enum(["inline", "attachment"]),
87748
+ deviceId: number$1().int().nonnegative().optional()
87749
+ });
87710
87750
  /**
87711
87751
  * `smtp-provider` — pluggable email delivery surface.
87712
87752
  *
@@ -87716,8 +87756,8 @@ var smokeCapability = {
87716
87756
  * ready provider OR target a specific addonId.
87717
87757
  *
87718
87758
  * The shape stays small on purpose — `sendEmail` is enough for the
87719
- * 90% case. Attachments / HTML templating / multi-part are room for
87720
- * future fields without breaking the existing call sites.
87759
+ * 90% case. An image is not a byte field on this method (D613): `images`
87760
+ * names `peerBytes` tickets the sender opens and folds into one MIME body.
87721
87761
  */
87722
87762
  var EmailAddressSchema = email();
87723
87763
  /**
@@ -87744,7 +87784,12 @@ var SendEmailInputSchema = object({
87744
87784
  * for clients that strip HTML — including most spam filters). */
87745
87785
  text: string(),
87746
87786
  /** Optional HTML body. Renders alongside `text` as multi-part. */
87747
- html: string().optional()
87787
+ html: string().optional(),
87788
+ /**
87789
+ * Images the caller already offered over `peerBytes`. Absent = a mail with
87790
+ * no image. The sender opens each ticket; one it cannot read is left out.
87791
+ */
87792
+ images: array(EmailImagePartSchema).max(3).optional()
87748
87793
  });
87749
87794
  var SendEmailResultSchema = object({
87750
87795
  messageId: string(),
@@ -88774,34 +88819,46 @@ var switchCapability = {
88774
88819
  DeviceType.Light,
88775
88820
  DeviceType.Fan
88776
88821
  ],
88777
- methods: { setState: method(object({
88778
- deviceId: number$1(),
88779
- on: boolean()
88780
- }), _void(), {
88781
- kind: "mutation",
88782
- auth: "protected",
88783
- actions: [{
88784
- id: "switch.on",
88785
- label: t("Turn on", "Accendi"),
88786
- phrase: t("Turn on {device}", "Accendi {device}"),
88787
- icon: "power",
88788
- effect: {
88789
- field: "on",
88790
- value: true
88791
- },
88792
- args: { on: true }
88793
- }, {
88794
- id: "switch.off",
88795
- label: t("Turn off", "Spegni"),
88796
- phrase: t("Turn off {device}", "Spegni {device}"),
88797
- icon: "power-off",
88798
- effect: {
88799
- field: "on",
88800
- value: false
88801
- },
88802
- args: { on: false }
88803
- }]
88804
- }) },
88822
+ methods: {
88823
+ setState: method(object({
88824
+ deviceId: number$1(),
88825
+ on: boolean()
88826
+ }), _void(), {
88827
+ kind: "mutation",
88828
+ auth: "protected",
88829
+ actions: [{
88830
+ id: "switch.on",
88831
+ label: t("Turn on", "Accendi"),
88832
+ phrase: t("Turn on {device}", "Accendi {device}"),
88833
+ icon: "power",
88834
+ effect: {
88835
+ field: "on",
88836
+ value: true
88837
+ },
88838
+ args: { on: true }
88839
+ }, {
88840
+ id: "switch.off",
88841
+ label: t("Turn off", "Spegni"),
88842
+ phrase: t("Turn off {device}", "Spegni {device}"),
88843
+ icon: "power-off",
88844
+ effect: {
88845
+ field: "on",
88846
+ value: false
88847
+ },
88848
+ args: { on: false }
88849
+ }]
88850
+ }),
88851
+ toggle: optionalMethod(object({ deviceId: number$1() }), _void(), {
88852
+ kind: "mutation",
88853
+ auth: "protected",
88854
+ actions: [{
88855
+ id: "switch.toggle",
88856
+ label: t("Toggle", "Commuta"),
88857
+ phrase: t("Toggle {device}", "Commuta {device}"),
88858
+ icon: "toggle-right"
88859
+ }]
88860
+ })
88861
+ },
88805
88862
  events: { onStateChanged: {
88806
88863
  data: object({
88807
88864
  deviceId: number$1(),
@@ -106885,6 +106942,13 @@ Object.freeze({
106885
106942
  access: "create",
106886
106943
  role: "viewer"
106887
106944
  },
106945
+ "switch.toggle": {
106946
+ capName: "switch",
106947
+ capScope: "device",
106948
+ addonId: null,
106949
+ access: "create",
106950
+ role: "viewer"
106951
+ },
106888
106952
  "system.debugWatch": {
106889
106953
  capName: "system",
106890
106954
  capScope: "system",
@@ -110855,6 +110919,12 @@ Object.freeze({
110855
110919
  form: "single",
110856
110920
  optional: false
110857
110921
  }],
110922
+ "smtpProvider.sendEmail": [{
110923
+ name: "images",
110924
+ form: "object-array",
110925
+ optional: true,
110926
+ itemField: "deviceId"
110927
+ }],
110858
110928
  "snapshot.applyDeviceSettingsPatch": [{
110859
110929
  name: "deviceId",
110860
110930
  form: "single",
@@ -111021,6 +111091,11 @@ Object.freeze({
111021
111091
  form: "single",
111022
111092
  optional: false
111023
111093
  }],
111094
+ "switch.toggle": [{
111095
+ name: "deviceId",
111096
+ form: "single",
111097
+ optional: false
111098
+ }],
111024
111099
  "system.debugWatch": [{
111025
111100
  name: "deviceIds",
111026
111101
  form: "array",
@@ -111884,6 +111959,28 @@ var STATE_SUMMARY_VARS = [
111884
111959
  systemEventKinds: [...SUMMARISABLE],
111885
111960
  systemEventDeliveries: ["summary"]
111886
111961
  },
111962
+ {
111963
+ name: "offlineCount",
111964
+ label: "Summary: how many went offline",
111965
+ example: "2",
111966
+ group: "system",
111967
+ families: ["rule"],
111968
+ fields: [...RULE_TEXT],
111969
+ kinds: ["system"],
111970
+ systemEventKinds: [...SUMMARISABLE],
111971
+ systemEventDeliveries: ["summary"]
111972
+ },
111973
+ {
111974
+ name: "onlineCount",
111975
+ label: "Summary: how many came back",
111976
+ example: "5",
111977
+ group: "system",
111978
+ families: ["rule"],
111979
+ fields: [...RULE_TEXT],
111980
+ kinds: ["system"],
111981
+ systemEventKinds: [...SUMMARISABLE],
111982
+ systemEventDeliveries: ["summary"]
111983
+ },
111887
111984
  {
111888
111985
  name: "summaryCount",
111889
111986
  label: "Summary: items reported",
@@ -111925,6 +112022,7 @@ var STATE_SUMMARY_VARS = [
111925
112022
  ([...RULE_TEXT], [...COMBINED_ALARM]),
111926
112023
  ([...RULE_TEXT], [...COMBINED_ALARM]),
111927
112024
  [...RULE_TEXT],
112025
+ [...RULE_TEXT],
111928
112026
  ([...RULE_TEXT], [...COMBINED_ALARM]),
111929
112027
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),
111930
112028
  [...RULE_TEXT],
@@ -113474,6 +113572,7 @@ function toCcuDeviceRow(device) {
113474
113572
  unreach: asBool$1(readParam(maintenance, ["UNREACH", "STICKY_UNREACH"])),
113475
113573
  configPending: asBool$1(readParam(maintenance, ["CONFIG_PENDING"])),
113476
113574
  sabotage: asBool$1(readParam(maintenance, ["SABOTAGE", "ERROR_SABOTAGE"])),
113575
+ deviceId: null,
113477
113576
  keyChannels: [],
113478
113577
  channels: device.channels.filter((channel) => channel.index !== 0).map((channel) => ({
113479
113578
  address: channel.address,
@@ -113492,7 +113591,10 @@ function buildCcuDevicesHandlers(deps) {
113492
113591
  const adopted = await deps.adoptedAddresses(input.integrationId);
113493
113592
  return { devices: await Promise.all(facade.devices().map(async (device) => {
113494
113593
  const links = await keyChannelsForDevice(deps, input.integrationId, device, adopted);
113495
- return withKeyChannels(toCcuDeviceRow(device), links);
113594
+ return {
113595
+ ...withKeyChannels(toCcuDeviceRow(device), links),
113596
+ deviceId: adopted.get(device.address) ?? null
113597
+ };
113496
113598
  })) };
113497
113599
  } };
113498
113600
  }
@@ -113695,6 +113797,11 @@ var CcuDevicesResultSchema = object({ devices: array(object({
113695
113797
  configPending: boolean().nullable(),
113696
113798
  sabotage: boolean().nullable(),
113697
113799
  /**
113800
+ * CamStack device id when this CCU device is adopted as a container.
113801
+ * `null` when it is not adopted — the page then has nowhere to link.
113802
+ */
113803
+ deviceId: number$1().int().nullable().default(null),
113804
+ /**
113698
113805
  * Key channels of an ADOPTED device, and whether the CCU sends their presses
113699
113806
  * (a central link). Empty for a device that is not adopted or has no keys.
113700
113807
  */
@@ -139717,6 +139824,81 @@ function preferenceToStamp(stored, declared) {
139717
139824
  return declared;
139718
139825
  }
139719
139826
  //#endregion
139827
+ //#region src/devices/hm-key-link-states.ts
139828
+ /**
139829
+ * One snapshot of a device's key-channel central links, shared by the
139830
+ * container page and the Buttons child. Both publish through
139831
+ * {@link publishKeyLinkStates}; neither keeps a second copy.
139832
+ */
139833
+ var published = /* @__PURE__ */ new Map();
139834
+ function storeKey(integrationId, address) {
139835
+ return `${integrationId}\n${address}`;
139836
+ }
139837
+ /** The last CCU answer for this device, or nothing when it has not answered. */
139838
+ function storedKeyLinkStates(integrationId, address) {
139839
+ if (integrationId === void 0) return [];
139840
+ return published.get(storeKey(integrationId, address)) ?? [];
139841
+ }
139842
+ /** Drop every snapshot. Called when the facade registry shuts down. */
139843
+ function clearStoredKeyLinkStates() {
139844
+ published.clear();
139845
+ }
139846
+ /**
139847
+ * Read each key channel's central link from the CCU and publish that list.
139848
+ * `null` when the device has no key channel — the previous snapshot stays,
139849
+ * because an empty channel list is not evidence the buttons are gone.
139850
+ * A failed read is published as `central: null` and `failed: true`.
139851
+ */
139852
+ async function publishKeyLinkStates(integrationId, read) {
139853
+ const keys = hmKeyChannels(read.device);
139854
+ if (keys.length === 0) return null;
139855
+ const names = channelNameLookup(read.facade.devices());
139856
+ const states = [];
139857
+ let failed = false;
139858
+ for (const channel of keys) {
139859
+ const one = await readKey(read, names, channel);
139860
+ if (one.failed) failed = true;
139861
+ states.push(one.state);
139862
+ }
139863
+ published.set(storeKey(integrationId, read.deviceAddress), states);
139864
+ return { failed };
139865
+ }
139866
+ async function readKey(read, names, channel) {
139867
+ const base = {
139868
+ address: channel.address,
139869
+ name: hmName(channel.name),
139870
+ index: channelIndexFromAddress(channel.address) ?? String(channel.index)
139871
+ };
139872
+ try {
139873
+ const state = await read.facade.getChannelLinkState(channel.address);
139874
+ return {
139875
+ failed: false,
139876
+ state: {
139877
+ ...base,
139878
+ central: state.central,
139879
+ links: directLinksOfKey(channel.address, state.links, names)
139880
+ }
139881
+ };
139882
+ } catch (err) {
139883
+ read.logger.warn("Homematic key channel link state could not be read", {
139884
+ tags: { deviceId: read.deviceId },
139885
+ meta: {
139886
+ address: read.deviceAddress,
139887
+ channel: channel.address,
139888
+ error: err instanceof Error ? err.message : String(err)
139889
+ }
139890
+ });
139891
+ return {
139892
+ failed: true,
139893
+ state: {
139894
+ ...base,
139895
+ central: null,
139896
+ links: []
139897
+ }
139898
+ };
139899
+ }
139900
+ }
139901
+ //#endregion
139720
139902
  //#region src/homematic-facade-resolver.ts
139721
139903
  /**
139722
139904
  * Per-integration registry that device classes use to reach the live
@@ -139787,15 +139969,108 @@ var HmFacadeResolver = class {
139787
139969
  this.#facades.clear();
139788
139970
  this.#sessions.clear();
139789
139971
  this.#snapshotSubs.clear();
139972
+ clearStoredKeyLinkStates();
139790
139973
  }
139791
139974
  };
139792
139975
  /** The single in-process resolver shared between the integration and its devices. */
139793
139976
  var homematicFacades = new HmFacadeResolver();
139794
139977
  //#endregion
139978
+ //#region src/devices/hm-button-events-section.ts
139979
+ var ADDON_ID = "provider-homematic";
139980
+ var NS$1 = "provider-homematic:device.buttonEvents";
139981
+ function keyLabel(key) {
139982
+ return key.name ?? `Key ${key.index}`;
139983
+ }
139984
+ function linkText(link) {
139985
+ const target = link.receiverName ?? link.receiverDeviceName;
139986
+ return target === null ? link.receiver : `${target} (${link.receiver})`;
139987
+ }
139988
+ function statusOf(central) {
139989
+ if (central === null) return "unknown";
139990
+ return central ? "ok" : "warn";
139991
+ }
139992
+ function toggleButton(integrationId, key) {
139993
+ const enable = key.central !== true;
139994
+ const label = keyLabel(key);
139995
+ return {
139996
+ type: "addon-action-button",
139997
+ key: `buttonEvents_${key.address}`,
139998
+ label,
139999
+ addonId: ADDON_ID,
140000
+ action: "setButtonEvents",
140001
+ paramsStatic: {
140002
+ integrationId,
140003
+ address: key.address,
140004
+ enabled: enable,
140005
+ confirmed: true
140006
+ },
140007
+ buttonLabel: enable ? "Send presses to CamStack" : "Stop sending presses",
140008
+ variant: enable ? "primary" : "default",
140009
+ 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.`
140010
+ };
140011
+ }
140012
+ /**
140013
+ * The device-page section of a Homematic button device: per key, whether the
140014
+ * CCU sends its presses to CamStack (the central link), the channels it
140015
+ * actuates directly, and a confirmed toggle that writes the central link.
140016
+ * Empty when the device has no key channel the CCU answered for.
140017
+ */
140018
+ function buttonEventsSection(integrationId, keys) {
140019
+ if (integrationId === void 0 || keys.length === 0) return [];
140020
+ const missing = keys.some((key) => key.central === false);
140021
+ const fields = [];
140022
+ if (missing) fields.push({
140023
+ type: "info",
140024
+ key: "buttonEventsHint",
140025
+ label: "Button events",
140026
+ labelKey: `${NS$1}.hint.label`,
140027
+ content: "The CCU does not send some of these presses — turn them on below",
140028
+ contentKey: `${NS$1}.hint.content`,
140029
+ variant: "warning"
140030
+ });
140031
+ fields.push({
140032
+ type: "object-array",
140033
+ key: "buttonEventsKeys",
140034
+ label: "Keys",
140035
+ labelKey: `${NS$1}.keys.label`,
140036
+ columns: [
140037
+ {
140038
+ key: "key",
140039
+ label: "Key",
140040
+ labelKey: `${NS$1}.keys.key`
140041
+ },
140042
+ {
140043
+ key: "central",
140044
+ label: "Sent to CamStack",
140045
+ labelKey: `${NS$1}.keys.central`,
140046
+ kind: "status"
140047
+ },
140048
+ {
140049
+ key: "links",
140050
+ label: "Direct links",
140051
+ labelKey: `${NS$1}.keys.links`
140052
+ }
140053
+ ],
140054
+ value: keys.map((key) => ({
140055
+ key: keyLabel(key),
140056
+ central: statusOf(key.central),
140057
+ links: key.links.length === 0 ? "—" : key.links.map(linkText).join(", ")
140058
+ }))
140059
+ });
140060
+ for (const key of keys) if (key.central !== null) fields.push(toggleButton(integrationId, key));
140061
+ return [{
140062
+ id: "button-events",
140063
+ title: "Button events",
140064
+ titleKey: `${NS$1}.title`,
140065
+ columns: 1,
140066
+ fields
140067
+ }];
140068
+ }
140069
+ //#endregion
139795
140070
  //#region src/devices/hm-device-panel-section.ts
139796
140071
  /** `<addonId>/<stableId>` of the device panel in this addon's widget bundle. */
139797
140072
  var HM_DEVICE_PANEL_WIDGET_ID = "provider-homematic/device-panel";
139798
- var NS$1 = "provider-homematic:device.panel";
140073
+ var NS = "provider-homematic:device.panel";
139799
140074
  /**
139800
140075
  * The device page section of one CCU device: the Homematic panel widget
139801
140076
  * (values, diagnostics, manual actuation, MASTER configuration). The widget
@@ -139806,7 +140081,7 @@ function devicePanelSection(integrationId, address) {
139806
140081
  return {
139807
140082
  id: "homematic-device",
139808
140083
  title: "Homematic",
139809
- titleKey: `${NS$1}.title`,
140084
+ titleKey: `${NS}.title`,
139810
140085
  tab: "general",
139811
140086
  order: 5,
139812
140087
  columns: 1,
@@ -140723,98 +140998,6 @@ var HmSensorDevice = class extends HmChildDevice {
140723
140998
  }
140724
140999
  };
140725
141000
  //#endregion
140726
- //#region src/devices/hm-button-events-section.ts
140727
- var ADDON_ID = "provider-homematic";
140728
- var NS = "provider-homematic:device.buttonEvents";
140729
- function keyLabel(key) {
140730
- return key.name ?? `Key ${key.index}`;
140731
- }
140732
- function linkText(link) {
140733
- const target = link.receiverName ?? link.receiverDeviceName;
140734
- return target === null ? link.receiver : `${target} (${link.receiver})`;
140735
- }
140736
- function statusOf(central) {
140737
- if (central === null) return "unknown";
140738
- return central ? "ok" : "warn";
140739
- }
140740
- function toggleButton(integrationId, key) {
140741
- const enable = key.central !== true;
140742
- const label = keyLabel(key);
140743
- return {
140744
- type: "addon-action-button",
140745
- key: `buttonEvents_${key.address}`,
140746
- label,
140747
- addonId: ADDON_ID,
140748
- action: "setButtonEvents",
140749
- paramsStatic: {
140750
- integrationId,
140751
- address: key.address,
140752
- enabled: enable,
140753
- confirmed: true
140754
- },
140755
- buttonLabel: enable ? "Send presses to CamStack" : "Stop sending presses",
140756
- variant: enable ? "primary" : "default",
140757
- 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.`
140758
- };
140759
- }
140760
- /**
140761
- * The device-page section of a Homematic button device: per key, whether the
140762
- * CCU sends its presses to CamStack (the central link), the channels it
140763
- * actuates directly, and a confirmed toggle that writes the central link.
140764
- * Empty when the device has no key channel the CCU answered for.
140765
- */
140766
- function buttonEventsSection(integrationId, keys) {
140767
- if (integrationId === void 0 || keys.length === 0) return [];
140768
- const missing = keys.some((key) => key.central === false);
140769
- const fields = [];
140770
- if (missing) fields.push({
140771
- type: "info",
140772
- key: "buttonEventsHint",
140773
- label: "Button events",
140774
- labelKey: `${NS}.hint.label`,
140775
- content: "The CCU does not send some of these presses — turn them on below",
140776
- contentKey: `${NS}.hint.content`,
140777
- variant: "warning"
140778
- });
140779
- fields.push({
140780
- type: "object-array",
140781
- key: "buttonEventsKeys",
140782
- label: "Keys",
140783
- labelKey: `${NS}.keys.label`,
140784
- columns: [
140785
- {
140786
- key: "key",
140787
- label: "Key",
140788
- labelKey: `${NS}.keys.key`
140789
- },
140790
- {
140791
- key: "central",
140792
- label: "Sent to CamStack",
140793
- labelKey: `${NS}.keys.central`,
140794
- kind: "status"
140795
- },
140796
- {
140797
- key: "links",
140798
- label: "Direct links",
140799
- labelKey: `${NS}.keys.links`
140800
- }
140801
- ],
140802
- value: keys.map((key) => ({
140803
- key: keyLabel(key),
140804
- central: statusOf(key.central),
140805
- links: key.links.length === 0 ? "—" : key.links.map(linkText).join(", ")
140806
- }))
140807
- });
140808
- for (const key of keys) if (key.central !== null) fields.push(toggleButton(integrationId, key));
140809
- return [{
140810
- id: "button-events",
140811
- title: "Button events",
140812
- titleKey: `${NS}.title`,
140813
- columns: 1,
140814
- fields
140815
- }];
140816
- }
140817
- //#endregion
140818
141001
  //#region src/devices/hm-event-emitter-device.ts
140819
141002
  /** Shown on the Buttons child when none of its key channels has a central link. */
140820
141003
  var BUTTON_EVENTS_HINT = "The CCU does not send these presses — turn them on in this device's Button events section";
@@ -140843,8 +141026,6 @@ var HmEventEmitterDevice = class extends HmChildDevice {
140843
141026
  #pressSeen = /* @__PURE__ */ new Set();
140844
141027
  /** True once we know a key channel lacks a central link. */
140845
141028
  #centralLinkMissing = false;
140846
- /** Per key channel: central link and direct links, as the CCU last answered. */
140847
- #keyStates = [];
140848
141029
  #eventSeq = 0;
140849
141030
  #eventCount = 0;
140850
141031
  /** Unsubscribe for the integration's state-change fan-out. */
@@ -140862,7 +141043,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
140862
141043
  this.refreshCentralLinks();
140863
141044
  }
140864
141045
  getSettingsUISchema() {
140865
- return { sections: buttonEventsSection(this.integrationId, this.#keyStates) };
141046
+ return { sections: buttonEventsSection(this.integrationId, storedKeyLinkStates(this.integrationId, this.address)) };
140866
141047
  }
140867
141048
  /**
140868
141049
  * Rewrite the slice with the buttons once the CCU's channel list carries
@@ -140898,45 +141079,16 @@ var HmEventEmitterDevice = class extends HmChildDevice {
140898
141079
  async refreshCentralLinks() {
140899
141080
  const facade = this.integrationId === void 0 ? null : homematicFacades.get(this.integrationId);
140900
141081
  const device = this.resolveHmDevice();
140901
- if (facade === null || device === null) return;
140902
- const keys = hmKeyChannels(device);
140903
- if (keys.length === 0) return;
140904
- const names = channelNameLookup(facade.devices());
140905
- const states = [];
140906
- let failed = false;
140907
- for (const channel of keys) {
140908
- const base = {
140909
- address: channel.address,
140910
- name: hmName(channel.name),
140911
- index: channelIndexFromAddress(channel.address) ?? String(channel.index)
140912
- };
140913
- try {
140914
- const state = await facade.getChannelLinkState(channel.address);
140915
- states.push({
140916
- ...base,
140917
- central: state.central,
140918
- links: directLinksOfKey(channel.address, state.links, names)
140919
- });
140920
- } catch (err) {
140921
- failed = true;
140922
- states.push({
140923
- ...base,
140924
- central: null,
140925
- links: []
140926
- });
140927
- this.ctx.logger.warn("Homematic key channel link state could not be read", {
140928
- tags: { deviceId: this.ctx.id },
140929
- meta: {
140930
- address: this.address,
140931
- channel: channel.address,
140932
- error: err instanceof Error ? err.message : String(err)
140933
- }
140934
- });
140935
- }
140936
- }
140937
- this.#keyStates = states;
140938
- if (failed) return;
140939
- const missing = states.some((state) => state.central === false);
141082
+ if (facade === null || device === null || this.integrationId === void 0) return;
141083
+ const loaded = await publishKeyLinkStates(this.integrationId, {
141084
+ facade,
141085
+ device,
141086
+ deviceAddress: this.address,
141087
+ deviceId: this.ctx.id,
141088
+ logger: this.ctx.logger
141089
+ });
141090
+ if (loaded === null || loaded.failed) return;
141091
+ const missing = storedKeyLinkStates(this.integrationId, this.address).some((state) => state.central === false);
140940
141092
  if (missing === this.#centralLinkMissing) return;
140941
141093
  this.#centralLinkMissing = missing;
140942
141094
  const current = this.runtimeState.getCapState("event-emitter");
@@ -141434,6 +141586,7 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
141434
141586
  this.features = HmContainerDevice.deriveFeatures(hmDevice);
141435
141587
  this.online = this.deriveOnline(hmDevice);
141436
141588
  this.attachReachabilityListener();
141589
+ this.refreshButtonEvents();
141437
141590
  this.updateSourceInfo({
141438
141591
  id: this.address,
141439
141592
  system: "homematic"
@@ -141471,15 +141624,32 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
141471
141624
  if (this.online !== next) this.markOnline(next);
141472
141625
  });
141473
141626
  }
141474
- /** The device page's Homematic panel (values, diagnostics, actuation, MASTER configuration). */
141627
+ /** The device page: the CCU panel, then Button events when this device has keys. */
141475
141628
  getSettingsUISchema() {
141476
- return { sections: [devicePanelSection(this.integrationId, this.address)] };
141629
+ return { sections: [devicePanelSection(this.integrationId, this.address), ...buttonEventsSection(this.integrationId, storedKeyLinkStates(this.integrationId, this.address))] };
141630
+ }
141631
+ /**
141632
+ * Publish this device's key-channel central links into the snapshot the
141633
+ * Buttons child also writes. A device without key channels publishes nothing.
141634
+ */
141635
+ async refreshButtonEvents() {
141636
+ const facade = this.facade;
141637
+ const device = this.resolveHmDevice();
141638
+ if (facade === null || device === null) return;
141639
+ await publishKeyLinkStates(this.integrationId, {
141640
+ facade,
141641
+ device,
141642
+ deviceAddress: this.address,
141643
+ deviceId: this.id,
141644
+ logger: this.ctx.logger
141645
+ });
141477
141646
  }
141478
141647
  async onActivate() {
141479
141648
  await super.onActivate();
141480
141649
  await this.reconcileDerived();
141481
141650
  this.reconcileUnsub = homematicFacades.onSnapshot(this.integrationId, () => {
141482
141651
  this.reconcileDerived();
141652
+ this.refreshButtonEvents();
141483
141653
  });
141484
141654
  }
141485
141655
  async removeDevice() {
@@ -143320,21 +143490,21 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
143320
143490
  connectedFacade(integrationId) {
143321
143491
  return this.clients?.sessions().some((session) => session.id === integrationId && session.status === "connected") === true ? homematicFacades.get(integrationId) : null;
143322
143492
  }
143323
- /** CCU addresses adopted as containers from one integration. */
143493
+ /** CCU address → CamStack device id for containers adopted from one integration. */
143324
143494
  async adoptedCcuAddresses(integrationId) {
143325
143495
  const reg = this.ctx.kernel.deviceRegistry;
143326
143496
  const devices = this.ctx.kernel.devices;
143327
- const addresses = /* @__PURE__ */ new Set();
143328
- if (!reg || !devices) return addresses;
143497
+ const byAddress = /* @__PURE__ */ new Map();
143498
+ if (!reg || !devices) return byAddress;
143329
143499
  for (const device of reg.getAllForAddon(this.addonId)) {
143330
143500
  if (device.parentDeviceId !== null) continue;
143331
143501
  const config = await devices.loadConfig(device.id).catch(() => ({}));
143332
143502
  if (config["integrationId"] !== integrationId) continue;
143333
143503
  if (typeof config["hmEntityKey"] === "string") continue;
143334
143504
  const address = config["hmAddress"];
143335
- if (typeof address === "string" && address.length > 0) addresses.add(address);
143505
+ if (typeof address === "string" && address.length > 0) byAddress.set(address, device.id);
143336
143506
  }
143337
- return addresses;
143507
+ return byAddress;
143338
143508
  }
143339
143509
  /** What the CCU management actions reach: connected sessions only, never a half-started facade. */
143340
143510
  ccuActionDeps() {