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