@camstack/addon-provider-homematic 1.2.210 → 1.2.211

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 (18) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/.bundle-modules.json +4 -4
  3. package/dist/_stub.js +107 -61
  4. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-DqBsgmV2.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-D5at7Q9l.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-BHT2wfZN.mjs +26 -0
  6. package/dist/addon.js +363 -17
  7. package/dist/addon.mjs +363 -17
  8. package/dist/{hostInit-Veh_hTYB.mjs → hostInit-UNRy49MK.mjs} +3 -3
  9. package/dist/remoteEntry.js +1 -1
  10. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-B6NDlkw9.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-BSgPYGJt.mjs} +1 -1
  11. package/dist/widgets/_stub.js +9 -2
  12. package/dist/widgets/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-D4FsZKYN.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-CTToHFHm.mjs} +2 -2
  13. package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BxH-K-yr.mjs +26 -0
  14. package/dist/widgets/{hostInit-xLDLUgao.mjs → hostInit-D-2FhaC8.mjs} +2 -2
  15. package/dist/widgets/remoteEntry.js +1 -1
  16. package/package.json +3 -3
  17. package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BkwWlzBp.mjs +0 -26
  18. package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-dFo8NWrS.mjs +0 -26
package/dist/addon.mjs CHANGED
@@ -51916,6 +51916,7 @@ function macroOnly(macro) {
51916
51916
  };
51917
51917
  }
51918
51918
  }
51919
+ var FaultCodesSchema = array(string().min(1)).max(64);
51919
51920
  /**
51920
51921
  * Hold semantics — "for N seconds" on a leaf of the `when` tree (#498).
51921
51922
  *
@@ -52050,6 +52051,17 @@ var DeviceBecomesLeafSchema = object({
52050
52051
  path: ["value"]
52051
52052
  });
52052
52053
  });
52054
+ /**
52055
+ * A matching fault BECOMES active on a device (`device-fault.ts`): the device's
52056
+ * whole fault list is read, not only its principal code. `codes` empty = any
52057
+ * fault. Fires once per appearance; a fault already raised at start only seeds.
52058
+ */
52059
+ var DeviceFaultRaisedLeafSchema = object({
52060
+ kind: literal("device-fault-raised"),
52061
+ ...eventLeafId,
52062
+ deviceId: number$1().int().nonnegative(),
52063
+ codes: FaultCodesSchema
52064
+ });
52053
52065
  var DeviceEventLeafSchema = object({
52054
52066
  kind: literal("device-event"),
52055
52067
  ...eventLeafId,
@@ -52127,6 +52139,12 @@ var StationaryLeafSchema = object({
52127
52139
  /** `appeared`: it became parked. `departed`: the registry retired it. */
52128
52140
  phase: _enum(["appeared", "departed"])
52129
52141
  });
52142
+ /** "has a fault": a matching fault is active on the device NOW (its whole fault list). `codes` empty = any. */
52143
+ var DeviceFaultIsLeafSchema = object({
52144
+ kind: literal("device-fault-is"),
52145
+ deviceId: number$1().int().nonnegative(),
52146
+ codes: FaultCodesSchema
52147
+ });
52130
52148
  /** "is": one device field compared to one value, NOW. */
52131
52149
  var DeviceIsLeafSchema = object({
52132
52150
  kind: literal("device-is"),
@@ -52249,12 +52267,14 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
52249
52267
  DeviceBecomesLeafSchema,
52250
52268
  DeviceEventLeafSchema,
52251
52269
  DeviceFiredLeafSchema,
52270
+ DeviceFaultRaisedLeafSchema,
52252
52271
  ScheduleLeafSchema,
52253
52272
  ManualLeafSchema,
52254
52273
  IntervalLeafSchema,
52255
52274
  DetectionLeafSchema,
52256
52275
  StationaryLeafSchema,
52257
52276
  DeviceIsLeafSchema,
52277
+ DeviceFaultIsLeafSchema,
52258
52278
  StationaryPresentLeafSchema,
52259
52279
  ExpressionLeafSchema,
52260
52280
  TimeIsLeafSchema,
@@ -52264,6 +52284,7 @@ var EVENT_KINDS = new Set([
52264
52284
  "device-becomes",
52265
52285
  "device-event",
52266
52286
  "device-fired",
52287
+ "device-fault-raised",
52267
52288
  "schedule",
52268
52289
  "manual",
52269
52290
  "interval",
@@ -52345,6 +52366,7 @@ var LEAF_WORDS = {
52345
52366
  "device-becomes": "a device value that becomes",
52346
52367
  "device-event": "a device event",
52347
52368
  "device-fired": "a device firing an event",
52369
+ "device-fault-raised": "a device fault being raised",
52348
52370
  schedule: "a schedule",
52349
52371
  manual: "a manual run",
52350
52372
  interval: "an interval",
@@ -52826,6 +52848,86 @@ var AutomationNotifyStepSchema = object({
52826
52848
  body: string().min(1, "a notification needs a message").max(NOTIFY_BODY_MAX),
52827
52849
  ...continueOnErrorShape
52828
52850
  });
52851
+ var HTTP_URL_MAX = 2e3;
52852
+ var HTTP_BODY_MAX = 16384;
52853
+ var HTTP_HEADER_VALUE_MAX = 1e3;
52854
+ var saveAsSchema = string().regex(SET_VAR_NAME_RE, "a variable name is letters, digits and _, not starting with a digit (max 40)").refine((name) => !RESERVED_RUN_VARS.includes(name), { message: `the names ${RESERVED_RUN_VARS.join(", ")} belong to the run and cannot be used` });
52855
+ var retryUntilSecondsSchema = number$1().int().min(1).max(600, `a retry window is at most 600 s`);
52856
+ /**
52857
+ * Whether a TCP port on a host answers. TCP only: an ICMP echo needs a raw
52858
+ * socket or a `ping` binary with extra privileges, and the hub image ships
52859
+ * neither for its non-root user, so it is not offered.
52860
+ *
52861
+ * Without `expect` the step wants the host REACHABLE. The result
52862
+ * (`{ reachable, rttMs, error }`) goes to the run variable `saveAs`.
52863
+ */
52864
+ var AutomationProbeStepSchema = object({
52865
+ kind: literal("probe"),
52866
+ ...stepEnabledShape,
52867
+ /** A host name or an address; may carry `{{vars.x}}` slots. */
52868
+ host: string().min(1, "a probe needs a host").max(253).regex(/^[^\s/]+$/, "a host has no spaces or slashes"),
52869
+ port: number$1().int().min(1, "a port is 1 to 65535").max(65535, "a port is 1 to 65535"),
52870
+ timeoutSeconds: number$1().int().min(1).max(30),
52871
+ expect: _enum(["reachable", "unreachable"]).optional(),
52872
+ /** Keep probing every {@link REACH_RETRY_INTERVAL_S} s until the expectation holds, for this long. */
52873
+ retryUntilSeconds: retryUntilSecondsSchema.optional(),
52874
+ saveAs: saveAsSchema.optional(),
52875
+ ...continueOnErrorShape
52876
+ }).strict();
52877
+ var HTTP_METHODS = [
52878
+ "GET",
52879
+ "POST",
52880
+ "PUT",
52881
+ "PATCH",
52882
+ "DELETE"
52883
+ ];
52884
+ /**
52885
+ * What an HTTP request must answer for the step to pass: its status, or a field
52886
+ * of the parsed JSON body, compared the way a device field is.
52887
+ */
52888
+ var AutomationHttpExpectSchema = object({
52889
+ on: _enum(["status", "json"]),
52890
+ /** A dotted path into the JSON body (`sysInfo.rawUartRemoteAddress`); needed for `json`. */
52891
+ fieldPath: string().min(1).max(200).optional(),
52892
+ operator: AutomationConditionOperatorSchema,
52893
+ value: union([
52894
+ string(),
52895
+ number$1(),
52896
+ boolean()
52897
+ ])
52898
+ }).strict().refine((expect) => expect.on !== "json" || expect.fieldPath !== void 0, {
52899
+ message: "a JSON expectation names the field it reads",
52900
+ path: ["fieldPath"]
52901
+ });
52902
+ function isHttpUrl(url) {
52903
+ if (url.includes("{{")) return /^https?:\/\/\S+$/i.test(url);
52904
+ try {
52905
+ const parsed = new URL(url);
52906
+ return parsed.protocol === "http:" || parsed.protocol === "https:";
52907
+ } catch {
52908
+ return false;
52909
+ }
52910
+ }
52911
+ /**
52912
+ * One HTTP request. Without `expect` the step wants a 2xx answer. The result
52913
+ * (`{ status, ok, json, text, error }`) goes to the run variable `saveAs`.
52914
+ * Header values are stored as typed, in plain text: they are in the recipe and
52915
+ * in the generated source, so anyone who can open the automation can read a
52916
+ * token put in one. Header values and bodies are never logged or traced.
52917
+ */
52918
+ var AutomationHttpRequestStepSchema = object({
52919
+ kind: literal("http-request"),
52920
+ ...stepEnabledShape,
52921
+ method: _enum(HTTP_METHODS),
52922
+ url: string().max(HTTP_URL_MAX).refine(isHttpUrl, "the address is an http:// or https:// URL"),
52923
+ headers: record$1(string().regex(/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/, "not a valid header name"), string().max(HTTP_HEADER_VALUE_MAX)).refine((headers) => Object.keys(headers).length <= 20, { message: `at most 20 headers` }).optional(),
52924
+ body: string().max(HTTP_BODY_MAX).optional(),
52925
+ timeoutSeconds: number$1().int().min(1).max(60),
52926
+ expect: AutomationHttpExpectSchema.optional(),
52927
+ retryUntilSeconds: retryUntilSecondsSchema.optional(),
52928
+ saveAs: saveAsSchema.optional(),
52929
+ ...continueOnErrorShape
52930
+ }).strict();
52829
52931
  var AutomationRunActionStepSchema = object({
52830
52932
  kind: literal("action"),
52831
52933
  ...stepEnabledShape,
@@ -52881,7 +52983,9 @@ var plainStepSchemas = [
52881
52983
  AutomationStopStepSchema.omit({ if: true }).strict(),
52882
52984
  AutomationSetStepSchema.omit({ if: true }).strict(),
52883
52985
  AutomationRunActionStepSchema.strict(),
52884
- AutomationNotifyStepSchema.strict()
52986
+ AutomationNotifyStepSchema.strict(),
52987
+ AutomationProbeStepSchema,
52988
+ AutomationHttpRequestStepSchema
52885
52989
  ];
52886
52990
  /**
52887
52991
  * A plain step: a flow step with no condition of its own and no step inside
@@ -52981,6 +53085,8 @@ var AutomationActionSchema = discriminatedUnion("kind", [
52981
53085
  AutomationRepeatStepSchema,
52982
53086
  AutomationRunActionStepSchema,
52983
53087
  AutomationNotifyStepSchema,
53088
+ AutomationProbeStepSchema,
53089
+ AutomationHttpRequestStepSchema,
52984
53090
  object({
52985
53091
  kind: literal("code"),
52986
53092
  ...stepEnabledShape,
@@ -53305,6 +53411,7 @@ var AutomationConditionTraceNodeSchema = object({
53305
53411
  "not",
53306
53412
  "condition",
53307
53413
  "device-is",
53414
+ "device-fault-is",
53308
53415
  "expression",
53309
53416
  "stationary-present",
53310
53417
  "time-is",
@@ -53312,6 +53419,7 @@ var AutomationConditionTraceNodeSchema = object({
53312
53419
  "device-becomes",
53313
53420
  "device-event",
53314
53421
  "device-fired",
53422
+ "device-fault-raised",
53315
53423
  "schedule",
53316
53424
  "interval",
53317
53425
  "manual",
@@ -53370,6 +53478,9 @@ var StepTraceBaseSchema = object({
53370
53478
  * (D1021): why a sentence says "—" where a number was expected. Bounded.
53371
53479
  */
53372
53480
  templates: array(string()).max(20).optional(),
53481
+ /** A probe or an HTTP request: how many tries it made, and what the last one saw (no header, no body). */
53482
+ attempts: number$1().int().optional(),
53483
+ lastAttempt: string().optional(),
53373
53484
  /**
53374
53485
  * What the step's own `if` read when the step was reached (#472): `true` the
53375
53486
  * step ran, `false` its `else` ran (or nothing did), `unknown` a state leaf
@@ -121223,8 +121334,14 @@ function truthy(value) {
121223
121334
  const text = value.trim().toLowerCase();
121224
121335
  return text === "true" || text === "1" || text === "on" || text === "yes";
121225
121336
  }
121226
- /** The WatchDog add-on names its variables "SV WatchDog: <key>". */
121227
- var WATCHDOG_PREFIX = /^sv\s*watchdog\s*:\s*/i;
121337
+ /**
121338
+ * WatchDog is part of RaspberryMatic / OpenCCU itself (since 3.59.6): it creates
121339
+ * an alarm system variable named "WatchDog: <alarm>" the first time that alarm
121340
+ * fires. The older "SV WatchDog: <alarm>" spelling is accepted too. The alarm
121341
+ * keys in {@link WATCHDOG_FAULTS} are not verified against real names, so a
121342
+ * WatchDog-prefixed variable that matches no rule is reported to the caller.
121343
+ */
121344
+ var WATCHDOG_PREFIX = /^(?:sv\s*)?watchdog\s*:\s*/i;
121228
121345
  var WATCHDOG_FAULTS = [
121229
121346
  {
121230
121347
  key: "hb-rf-eth-connection",
@@ -121267,12 +121384,15 @@ function watchdogRuleOf(name) {
121267
121384
  * with a value (no snapshot, no credentials, the add-on not installed) is
121268
121385
  * UNKNOWN, never "no fault".
121269
121386
  */
121270
- function watchdogFaultReading(vars, now) {
121387
+ function watchdogFaultReading(vars, now, onUnmatched) {
121271
121388
  const faults = [];
121272
121389
  let known = 0;
121273
121390
  for (const variable of vars) {
121274
121391
  const rule = watchdogRuleOf(variable.name);
121275
- if (rule === null) continue;
121392
+ if (rule === null) {
121393
+ if (onUnmatched !== void 0 && WATCHDOG_PREFIX.test(variable.name.trim())) onUnmatched(variable.name);
121394
+ continue;
121395
+ }
121276
121396
  const on = truthy(variable.value);
121277
121397
  if (on === null) continue;
121278
121398
  known += 1;
@@ -121281,6 +121401,39 @@ function watchdogFaultReading(vars, now) {
121281
121401
  if (known === 0) return unknown(now);
121282
121402
  return reading(faults, now);
121283
121403
  }
121404
+ /** Several HmIP-RF devices went unreachable together (`homematic-radio-unreachable.ts`). */
121405
+ var RADIO_UNREACHABLE_FAULT = {
121406
+ key: "radio-unreachable",
121407
+ severity: "error",
121408
+ words: words("Several radio devices became unreachable", "Più dispositivi radio non raggiungibili")
121409
+ };
121410
+ /** No radio device event for too long (`homematic-radio-silent.ts`). */
121411
+ var RADIO_SILENT_FAULT = {
121412
+ key: "radio-silent",
121413
+ severity: "error",
121414
+ words: words("No radio events received", "Nessun evento radio ricevuto")
121415
+ };
121416
+ /** A reading for one rule: raised, fine, or unknown (`null`). */
121417
+ function ruleReading(rule, active, now) {
121418
+ if (active === null) return unknown(now);
121419
+ return reading(active ? [toFault(rule)] : [], now);
121420
+ }
121421
+ /**
121422
+ * Merge the readings of several sources. A fault from any source is active
121423
+ * (one entry per code); unknown from every source is unknown; a source that
121424
+ * reads "fine" beside one that is unknown is fine.
121425
+ */
121426
+ function mergeFaultReadings(readings, now) {
121427
+ const byCode = /* @__PURE__ */ new Map();
121428
+ let known = 0;
121429
+ for (const item of readings) {
121430
+ if (item.active === null) continue;
121431
+ known += 1;
121432
+ for (const fault of item.faults ?? []) byCode.set(fault.code, fault);
121433
+ }
121434
+ if (known === 0) return unknown(now);
121435
+ return reading([...byCode.values()], now);
121436
+ }
121284
121437
  var MAINTENANCE_FAULTS = [
121285
121438
  {
121286
121439
  key: "UNREACH",
@@ -121347,9 +121500,13 @@ function maintenanceFaultReading(values, now) {
121347
121500
  if (known === 0) return unknown(now);
121348
121501
  return reading(faults, now);
121349
121502
  }
121350
- /** The faults the CCU box can raise: its WatchDog variables. */
121351
- function watchdogFaultTypes() {
121352
- return WATCHDOG_FAULTS.map(toFault);
121503
+ /** Every fault the gateway can raise: WatchDog's plus the two derived from radio behaviour. */
121504
+ function gatewayFaultTypes() {
121505
+ return [
121506
+ ...WATCHDOG_FAULTS,
121507
+ RADIO_UNREACHABLE_FAULT,
121508
+ RADIO_SILENT_FAULT
121509
+ ].map(toFault);
121353
121510
  }
121354
121511
  /**
121355
121512
  * The faults a device's MAINTENANCE channel can raise, by their fixed flags.
@@ -121418,9 +121575,15 @@ function buildCcuFaultHandlers(deps) {
121418
121575
  });
121419
121576
  }
121420
121577
  faults.sort((a, b) => a.severity === b.severity ? 0 : a.severity === "error" ? -1 : 1);
121578
+ const reported = deps.gatewayFaults?.(input.integrationId) ?? null;
121421
121579
  return {
121422
121580
  faults,
121423
- unreported
121581
+ unreported,
121582
+ gatewayFaults: reported === null ? null : reported.map((fault) => ({
121583
+ code: fault.code,
121584
+ label: fault.label,
121585
+ severity: fault.severity
121586
+ }))
121424
121587
  };
121425
121588
  } };
121426
121589
  }
@@ -121910,7 +122073,9 @@ var CcuFaultsResultSchema = object({
121910
122073
  faults: array(CcuFaultSchema)
121911
122074
  })),
121912
122075
  /** Devices whose service flags the CCU has not reported: unknown, never "no fault". */
121913
- unreported: array(string())
122076
+ unreported: array(string()),
122077
+ /** What the gateway (the CCU box and its radio) reports: WatchDog, mass unreachable, radio silence. `null` is unknown (never read, or no source answered), never "none". */
122078
+ gatewayFaults: array(CcuFaultSchema).nullable().default(null)
121914
122079
  });
121915
122080
  //#endregion
121916
122081
  //#region src/ccu/ccu-heating-actions.ts
@@ -147922,10 +148087,32 @@ var HmFacadeResolver = class {
147922
148087
  #sessions = /* @__PURE__ */ new Map();
147923
148088
  /** Per-integration state-change fan-out (connect, disconnect, error). */
147924
148089
  #snapshotSubs = /* @__PURE__ */ new Map();
148090
+ /** Per-integration stamps of the real radio events (`radio-silent`). */
148091
+ #radioActivity = /* @__PURE__ */ new Map();
148092
+ /** The faults the gateway device last published, for the CCU page's overview. */
148093
+ #gatewayFaults = /* @__PURE__ */ new Map();
148094
+ /** Publish the radio-event tracker of an integration (a fresh one per facade). */
148095
+ setRadioActivity(integrationId, tracker) {
148096
+ if (tracker === null) this.#radioActivity.delete(integrationId);
148097
+ else this.#radioActivity.set(integrationId, tracker);
148098
+ }
148099
+ radioActivity(integrationId) {
148100
+ return this.#radioActivity.get(integrationId) ?? null;
148101
+ }
148102
+ /** The gateway device records what it published; read by the overview, never the other way. */
148103
+ setGatewayFaults(integrationId, faults) {
148104
+ this.#gatewayFaults.set(integrationId, faults);
148105
+ }
148106
+ /** `null` is unknown: nothing was published yet, or the last reading had no answering source. */
148107
+ gatewayFaults(integrationId) {
148108
+ return this.#gatewayFaults.get(integrationId) ?? null;
148109
+ }
147925
148110
  /** Publish or remove the facade for an integration id. `null` removes the entry. */
147926
148111
  set(integrationId, facade) {
147927
148112
  if (facade === null) {
147928
148113
  this.#facades.delete(integrationId);
148114
+ this.#radioActivity.delete(integrationId);
148115
+ this.#gatewayFaults.delete(integrationId);
147929
148116
  return;
147930
148117
  }
147931
148118
  this.#facades.set(integrationId, facade);
@@ -147974,6 +148161,8 @@ var HmFacadeResolver = class {
147974
148161
  clear() {
147975
148162
  clearCcuCallLimiters();
147976
148163
  this.#facades.clear();
148164
+ this.#radioActivity.clear();
148165
+ this.#gatewayFaults.clear();
147977
148166
  this.#sessions.clear();
147978
148167
  this.#snapshotSubs.clear();
147979
148168
  clearStoredKeyLinkStates();
@@ -150633,6 +150822,59 @@ function buildConnectionFormSchema() {
150633
150822
  ] };
150634
150823
  }
150635
150824
  //#endregion
150825
+ //#region src/homematic-radio-interface.ts
150826
+ /** The radio interface a data-point id belongs to, or `null`. */
150827
+ function radioInterfaceOfDataPointId(id) {
150828
+ const owner = (id.split(":")[0] ?? "").toLowerCase();
150829
+ if (owner.endsWith("-hmip-rf")) return "HmIP-RF";
150830
+ if (owner.endsWith("-bidcos-rf")) return "BidCos-RF";
150831
+ return null;
150832
+ }
150833
+ /** The radio interface of a device (all its data points share one), or `null` when it has none. */
150834
+ function radioInterfaceOfDevice(device) {
150835
+ for (const channel of device.channels) for (const point of channel.dataPoints) return radioInterfaceOfDataPointId(point.id);
150836
+ return null;
150837
+ }
150838
+ /** … each with an UNREACH start inside one window of this length. */
150839
+ var RADIO_UNREACHABLE_WINDOW_MS = 10 * 6e4;
150840
+ function unreachOf(device) {
150841
+ const point = maintenanceChannel(device)?.dataPoints.find((p) => p.parameter === "UNREACH");
150842
+ return typeof point?.value === "boolean" ? point.value : null;
150843
+ }
150844
+ /** The most UNREACH starts that fall inside any one window. */
150845
+ function largestCluster(starts) {
150846
+ const sorted = [...starts].sort((a, b) => a - b);
150847
+ let best = 0;
150848
+ let low = 0;
150849
+ for (let high = 0; high < sorted.length; high += 1) {
150850
+ while ((sorted[high] ?? 0) - (sorted[low] ?? 0) > RADIO_UNREACHABLE_WINDOW_MS) low += 1;
150851
+ best = Math.max(best, high - low + 1);
150852
+ }
150853
+ return best;
150854
+ }
150855
+ /**
150856
+ * Active when several HmIP-RF devices became UNREACH close together: enough of
150857
+ * them AND enough of the interface. A device whose UNREACH start the CCU did not
150858
+ * stamp cannot be placed in a window and is not counted. The population is the
150859
+ * HmIP-RF devices whose flag was read; none read is UNKNOWN, never "fine".
150860
+ */
150861
+ function radioUnreachableReading(devices, messages, now) {
150862
+ const starts = [];
150863
+ let population = 0;
150864
+ for (const device of devices) {
150865
+ if (radioInterfaceOfDevice(device) !== "HmIP-RF") continue;
150866
+ const unreach = unreachOf(device);
150867
+ if (unreach === null) continue;
150868
+ population += 1;
150869
+ if (!unreach) continue;
150870
+ const since = faultSince(device.address, "UNREACH", messages);
150871
+ if (since !== null) starts.push(since);
150872
+ }
150873
+ if (population === 0) return ruleReading(RADIO_UNREACHABLE_FAULT, null, now);
150874
+ const clustered = largestCluster(starts);
150875
+ return ruleReading(RADIO_UNREACHABLE_FAULT, clustered >= 3 && clustered / population >= .25, now);
150876
+ }
150877
+ //#endregion
150636
150878
  //#region src/homematic-gateway-metadata.ts
150637
150879
  /** What the CCU box is known by, as device metadata (a CCU announces no model or firmware over XML-RPC). */
150638
150880
  function gatewayMetadataPatch(input) {
@@ -150682,9 +150924,10 @@ function registerHomematicStateRefresh(target) {
150682
150924
  *
150683
150925
  * - `device-admin-link`, the CCU's own WebUI.
150684
150926
  *
150685
- * - `error`, the faults the CCU WatchDog add-on raises as system variables
150686
- * (`homematic-fault-mapping.ts`), read by the core's `device-state-refresh` (D1062),
150687
- * because the CCU pushes no event for them.
150927
+ * - `error`, the merge of every fault source (`homematic-fault-mapping.ts`): the
150928
+ * CCU's built-in WatchDog alarm variables, several HmIP-RF devices unreachable
150929
+ * together, and radio silence. Read by the core's `device-state-refresh` (D1062), because
150930
+ * the CCU pushes no event for them.
150688
150931
  *
150689
150932
  * There is no `reboot` and no `update`: nodehomematic has no call that restarts
150690
150933
  * the CCU, and its firmware call installs an update on a radio DEVICE by its
@@ -150701,13 +150944,15 @@ var HomematicGatewayDevice = class extends BaseDevice {
150701
150944
  lastMetadataKey = "";
150702
150945
  polling = false;
150703
150946
  warnedReadFailure = false;
150947
+ warnedSources = /* @__PURE__ */ new Set();
150948
+ seenUnmatchedWatchdog = /* @__PURE__ */ new Set();
150704
150949
  constructor(ctx) {
150705
150950
  const cfg = homematicGatewayDeviceSchema.parse(ctx.persistedConfig ?? {});
150706
150951
  super(ctx, homematicGatewayDeviceSchema, { type: DeviceType.Gateway });
150707
150952
  this.integrationId = cfg.integrationId;
150708
150953
  this.online = this.sessionUp();
150709
150954
  this.registerAdminLinkCap();
150710
- this.declareFaultTypes(watchdogFaultTypes());
150955
+ this.declareFaultTypes(gatewayFaultTypes());
150711
150956
  this.registerErrorCap();
150712
150957
  registerHomematicStateRefresh({
150713
150958
  ctx,
@@ -150756,11 +151001,56 @@ var HomematicGatewayDevice = class extends BaseDevice {
150756
151001
  }
150757
151002
  async readFaultsFrom(facade) {
150758
151003
  await facade.refreshHub();
150759
- const reading = watchdogFaultReading(facade.systemVariables(), Date.now());
150760
- if (reading.active === null) this.ctx.logger.debug("Homematic gateway: no WatchDog system variable readable on the CCU, faults stay unknown", { tags: { deviceId: this.id } });
151004
+ const now = Date.now();
151005
+ const reading = mergeFaultReadings([
151006
+ watchdogFaultReading(facade.systemVariables(), now, (name) => this.noteUnmatchedWatchdog(name)),
151007
+ await this.readRadioUnreachable(facade, now),
151008
+ this.readRadioSilent(facade, now)
151009
+ ], now);
151010
+ if (reading.active === null) this.ctx.logger.debug("Homematic gateway: no WatchDog system variable and no other fault source readable, faults stay unknown", { tags: { deviceId: this.id } });
151011
+ homematicFacades.setGatewayFaults(this.integrationId, reading.active === null ? null : reading.faults ?? []);
150761
151012
  this.warnedReadFailure = false;
150762
151013
  await this.publishError(reading);
150763
151014
  }
151015
+ /** A WatchDog variable no rule knows: logged once per name so the real names get learned. */
151016
+ noteUnmatchedWatchdog(name) {
151017
+ if (this.seenUnmatchedWatchdog.has(name)) return;
151018
+ this.seenUnmatchedWatchdog.add(name);
151019
+ this.ctx.logger.debug("Homematic gateway: WatchDog variable matches no fault rule", {
151020
+ tags: { deviceId: this.id },
151021
+ meta: { variable: name }
151022
+ });
151023
+ }
151024
+ /** A source that cannot be read is unknown; the first failure is a warning, the repeats debug. */
151025
+ noteSourceFailure(source, error) {
151026
+ const log = this.warnedSources.has(source) ? this.ctx.logger.debug : this.ctx.logger.warn;
151027
+ this.warnedSources.add(source);
151028
+ log.call(this.ctx.logger, `Homematic gateway: ${source} unreadable, that source stays unknown`, {
151029
+ tags: { deviceId: this.id },
151030
+ meta: { error }
151031
+ });
151032
+ }
151033
+ /** Several HmIP-RF devices unreachable together; needs the service messages for the start times. */
151034
+ async readRadioUnreachable(facade, now) {
151035
+ try {
151036
+ const messages = await facade.serviceMessages();
151037
+ return radioUnreachableReading(facade.devices(), messages, now);
151038
+ } catch (err) {
151039
+ this.noteSourceFailure("radio unreachable check", errMsg(err));
151040
+ return ruleReading(RADIO_UNREACHABLE_FAULT, null, now);
151041
+ }
151042
+ }
151043
+ /** No real radio event for too long, from the stamps the registry's event listener keeps. */
151044
+ readRadioSilent(facade, now) {
151045
+ const tracker = homematicFacades.radioActivity(this.integrationId);
151046
+ if (tracker === null) return ruleReading(RADIO_SILENT_FAULT, null, now);
151047
+ try {
151048
+ return tracker.reading(facade.devices(), now);
151049
+ } catch (err) {
151050
+ this.noteSourceFailure("radio silence check", errMsg(err));
151051
+ return ruleReading(RADIO_SILENT_FAULT, null, now);
151052
+ }
151053
+ }
150764
151054
  /**
150765
151055
  * Read the faults when the CCU announced a new snapshot (it just reconnected
150766
151056
  * or changed). A read that fails changes nothing (the previous reading
@@ -151692,6 +151982,58 @@ function isConnectionArg(arg) {
151692
151982
  return typeof arg === "object" && arg !== null && "interfaceId" in arg && "state" in arg && typeof arg["state"] === "string";
151693
151983
  }
151694
151984
  //#endregion
151985
+ //#region src/homematic-radio-silent.ts
151986
+ /**
151987
+ * Feed a tracker from the library's `valueChanged`. The event's `ts` is epoch
151988
+ * milliseconds (the library stamps `Date.now()`), the unit the tracker keeps;
151989
+ * it is passed through untouched. Returns the unsubscribe function.
151990
+ */
151991
+ function attachRadioActivity(source, tracker) {
151992
+ return source.on("valueChanged", (event) => tracker.record(event.dpId, event.ts));
151993
+ }
151994
+ /**
151995
+ * Stamps the REAL device datapoint events of each radio interface (fed from the
151996
+ * library's `valueChanged`). A connection ping, an interface-level event or a
151997
+ * virtual / group device never passes {@link record}'s interface check, so none
151998
+ * of them keeps the silence alive. The reading rides the core state-refresh tick:
151999
+ * there is no timer here.
152000
+ */
152001
+ var RadioActivityTracker = class {
152002
+ #lastEventAt = /* @__PURE__ */ new Map();
152003
+ #startedAt;
152004
+ constructor(startedAt) {
152005
+ this.#startedAt = startedAt;
152006
+ }
152007
+ /** Stamp one real device event, named by its data-point id. */
152008
+ record(dataPointId, at) {
152009
+ const radio = radioInterfaceOfDataPointId(dataPointId);
152010
+ if (radio === null) return;
152011
+ if (at > (this.#lastEventAt.get(radio) ?? 0)) this.#lastEventAt.set(radio, at);
152012
+ }
152013
+ /**
152014
+ * Silent when an interface with enough devices has had no event for
152015
+ * {@link RADIO_SILENT_AFTER_MS}. Before the first event the clock runs from
152016
+ * the tracker's start, so it is UNKNOWN until that long has passed.
152017
+ */
152018
+ reading(devices, now) {
152019
+ const counts = /* @__PURE__ */ new Map();
152020
+ for (const device of devices) {
152021
+ const radio = radioInterfaceOfDevice(device);
152022
+ if (radio !== null) counts.set(radio, (counts.get(radio) ?? 0) + 1);
152023
+ }
152024
+ let judged = false;
152025
+ let silent = false;
152026
+ for (const [radio, count] of counts) {
152027
+ if (count < 5) continue;
152028
+ const last = this.#lastEventAt.get(radio);
152029
+ if (last === void 0 && now - this.#startedAt < 9e5) continue;
152030
+ judged = true;
152031
+ if (now - (last ?? this.#startedAt) >= 9e5) silent = true;
152032
+ }
152033
+ return ruleReading(RADIO_SILENT_FAULT, judged ? silent : null, now);
152034
+ }
152035
+ };
152036
+ //#endregion
151695
152037
  //#region src/homematic-client-registry.ts
151696
152038
  /**
151697
152039
  * Delays (ms) between background retries after a failed `facade.start()` (e.g.
@@ -151750,6 +152092,9 @@ var HmClientRegistry = class {
151750
152092
  const raw = new Homematic(toHomematicOptions(config));
151751
152093
  this.#facades.set(opts.id, raw);
151752
152094
  homematicFacades.set(opts.id, raw);
152095
+ const tracker = new RadioActivityTracker(Date.now());
152096
+ homematicFacades.setRadioActivity(opts.id, tracker);
152097
+ attachRadioActivity(raw, tracker);
151753
152098
  return wrapFacade(raw);
151754
152099
  }
151755
152100
  });
@@ -152767,7 +153112,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
152767
153112
  logger: this.ctx.logger,
152768
153113
  adoptedAddresses: (integrationId) => this.adoptedCcuAddresses(integrationId),
152769
153114
  adoptedNames: (integrationId) => this.adoptedCcuNames(integrationId),
152770
- ccuChanged: (integrationId) => homematicFacades.emitSnapshot(integrationId)
153115
+ ccuChanged: (integrationId) => homematicFacades.emitSnapshot(integrationId),
153116
+ gatewayFaults: (integrationId) => homematicFacades.gatewayFaults(integrationId)
152771
153117
  };
152772
153118
  }
152773
153119
  async onShutdown() {
@@ -45,7 +45,7 @@ async function r() {
45
45
  }
46
46
  },
47
47
  "@camstack/types": {
48
- version: "1.2.616",
48
+ version: "1.2.617",
49
49
  scope: "default",
50
50
  shareConfig: {
51
51
  singleton: !0,
@@ -81,11 +81,11 @@ async function r() {
81
81
  }
82
82
  },
83
83
  "@camstack/ui-library": {
84
- version: "1.2.486",
84
+ version: "1.2.487",
85
85
  scope: "default",
86
86
  shareConfig: {
87
87
  singleton: !0,
88
- requiredVersion: ">=1.2.486",
88
+ requiredVersion: ">=1.2.487",
89
89
  import: !1
90
90
  }
91
91
  },
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-B6NDlkw9.mjs";
1
+ import { n as e, t } from "./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-BSgPYGJt.mjs";
2
2
  export { t as get, e as init };
@@ -2753,7 +2753,7 @@ async function rr(e) {
2753
2753
  }
2754
2754
  }
2755
2755
  async function ir() {
2756
- return tr ||= rr(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-DqBsgmV2.mjs")).catch((e) => {
2756
+ return tr ||= rr(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-D5at7Q9l.mjs")).catch((e) => {
2757
2757
  throw tr = void 0, e;
2758
2758
  }), tr;
2759
2759
  }
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, p as c, r as l, s as u, t as d, u as f } from "./_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-dFo8NWrS.mjs";
1
+ import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, p as c, r as l, s as u, t as d, u as f } from "./_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BxH-K-yr.mjs";
2
2
  import { a as p, i as m, n as h, o as ee, r as g, s as _, t as v } from "./_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare__react__loadShare__.js-Cz6ebdBh.mjs";
3
3
  import { n as y, t as b } from "./_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-B8RWlLTT.mjs";
4
4
  //#region ../../node_modules/zod/v4/core/core.js
@@ -3700,7 +3700,8 @@ Y({
3700
3700
  since: K().nullable(),
3701
3701
  faults: J(as)
3702
3702
  })),
3703
- unreported: J(W())
3703
+ unreported: J(W()),
3704
+ gatewayFaults: J(as).nullable().default(null)
3704
3705
  });
3705
3706
  //#endregion
3706
3707
  //#region src/i18n/index.ts
@@ -3763,6 +3764,9 @@ var { useT: $, Trans: os, translate: ss } = d("provider-homematic", {
3763
3764
  severityError: "Error",
3764
3765
  severityWarning: "Warning",
3765
3766
  faultsMore: "+{{count}} more",
3767
+ gatewayLabel: "CCU gateway",
3768
+ gatewayFaults: "Gateway faults",
3769
+ gatewayUnknown: "The gateway status is not known yet.",
3766
3770
  openDevice: "Open device",
3767
3771
  faultsUnreported_one: "{{count}} device has not reported its service flags yet, so its state is unknown",
3768
3772
  faultsUnreported_other: "{{count}} devices have not reported their service flags yet, so their state is unknown"
@@ -4207,6 +4211,9 @@ var { useT: $, Trans: os, translate: ss } = d("provider-homematic", {
4207
4211
  severityError: "Errore",
4208
4212
  severityWarning: "Avviso",
4209
4213
  faultsMore: "+{{count}} altri",
4214
+ gatewayLabel: "Gateway CCU",
4215
+ gatewayFaults: "Guasti del gateway",
4216
+ gatewayUnknown: "Lo stato del gateway non è ancora noto.",
4210
4217
  openDevice: "Apri dispositivo",
4211
4218
  faultsUnreported_one: "{{count}} dispositivo non ha ancora riportato i flag di servizio, quindi il suo stato è sconosciuto",
4212
4219
  faultsUnreported_other: "{{count}} dispositivi non hanno ancora riportato i flag di servizio, quindi il loro stato è sconosciuto"
@@ -18,7 +18,7 @@ var e = {
18
18
  },
19
19
  "@camstack/types": {
20
20
  name: "@camstack/types",
21
- version: "1.2.616",
21
+ version: "1.2.617",
22
22
  scope: ["default"],
23
23
  loaded: !1,
24
24
  from: "addon_provider_homematic_widgets",
@@ -33,7 +33,7 @@ var e = {
33
33
  },
34
34
  "@camstack/ui-library": {
35
35
  name: "@camstack/ui-library",
36
- version: "1.2.486",
36
+ version: "1.2.487",
37
37
  scope: ["default"],
38
38
  loaded: !1,
39
39
  from: "addon_provider_homematic_widgets",