@camstack/addon-provider-homematic 1.2.209 → 1.2.210

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 +7 -0
  2. package/dist/.bundle-modules.json +11 -6
  3. package/dist/_stub.js +2791 -1972
  4. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-B8JEAJoX.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-DqBsgmV2.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-BkwWlzBp.mjs +26 -0
  6. package/dist/addon-provider-homematic.css +1 -1
  7. package/dist/addon.js +440 -237
  8. package/dist/addon.mjs +440 -237
  9. package/dist/{hostInit-dkdwmlIf.mjs → hostInit-Veh_hTYB.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-D2zDM5LH.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-B6NDlkw9.mjs} +1 -1
  12. package/dist/widgets/_stub.js +222 -48
  13. package/dist/widgets/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-CR6dsJ2l.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-D4FsZKYN.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-dFo8NWrS.mjs +26 -0
  15. package/dist/widgets/{hostInit-C1PiC4_E.mjs → hostInit-xLDLUgao.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-DUSr1RDG.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-DkWTmjd2.mjs +0 -26
package/dist/addon.mjs CHANGED
@@ -27026,7 +27026,12 @@ var TargetKindTextCapsSchema = object({
27026
27026
  title: boolean(),
27027
27027
  body: boolean()
27028
27028
  });
27029
- _enum([
27029
+ /**
27030
+ * The message fields a rule can author for a target (#483). Derived from a
27031
+ * kind's caps by `deliverableFields` — the ONE reading of the declaration, used
27032
+ * by the dispatcher (drop), the admin rule editor (show) and the viewer.
27033
+ */
27034
+ var NotificationFieldSchema = _enum([
27030
27035
  "title",
27031
27036
  "body",
27032
27037
  "attachments",
@@ -66089,9 +66094,10 @@ object({
66089
66094
  /** Longest silence a push integration may keep before the core re-reads it and asks it to resubscribe. */
66090
66095
  heartbeatMs: number$1().int().positive().optional(),
66091
66096
  /**
66092
- * Bumped by the provider each time its push subscription reconnected on its
66093
- * own. A change makes the core re-read every device of the integration
66094
- * (pushes lost while it was down; events may be dropped, D8).
66097
+ * Changes on every reconnect of the provider's push subscription; any change
66098
+ * makes the core read every device of the integration once (pushes lost while
66099
+ * it was down; events may be dropped, D8). It need not grow: a provider whose
66100
+ * counter restarts with its process is still understood.
66095
66101
  */
66096
66102
  connectionEpoch: number$1().int().nonnegative().optional()
66097
66103
  });
@@ -66116,15 +66122,28 @@ var DeviceStateRefreshInputSchema = object({
66116
66122
  var DeviceStateResubscribeInputSchema = object({ deviceId: number$1().int().nonnegative() });
66117
66123
  var DeviceStateRefreshResultSchema = object({ ok: literal(true) });
66118
66124
  var NOT_OPERATOR_FACING = "the core schedules state refreshes itself; an operator never asks for one";
66119
- method(DeviceStateRefreshInputSchema, DeviceStateRefreshResultSchema, {
66120
- kind: "mutation",
66121
- auth: "admin",
66122
- notOperatorFacing: NOT_OPERATOR_FACING
66123
- }), method(DeviceStateResubscribeInputSchema, DeviceStateRefreshResultSchema, {
66124
- kind: "mutation",
66125
- auth: "admin",
66126
- notOperatorFacing: NOT_OPERATOR_FACING
66127
- });
66125
+ var deviceStateRefreshCapability = {
66126
+ name: "device-state-refresh",
66127
+ scope: "device",
66128
+ deviceNative: true,
66129
+ mode: "singleton",
66130
+ methods: {
66131
+ refresh: method(DeviceStateRefreshInputSchema, DeviceStateRefreshResultSchema, {
66132
+ kind: "mutation",
66133
+ auth: "admin",
66134
+ notOperatorFacing: NOT_OPERATOR_FACING
66135
+ }),
66136
+ resubscribe: method(DeviceStateResubscribeInputSchema, DeviceStateRefreshResultSchema, {
66137
+ kind: "mutation",
66138
+ auth: "admin",
66139
+ notOperatorFacing: NOT_OPERATOR_FACING
66140
+ })
66141
+ },
66142
+ vocabulary: {
66143
+ noun: t("State refresh", "Aggiornamento dello stato"),
66144
+ order: 3247
66145
+ }
66146
+ };
66128
66147
  /**
66129
66148
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
66130
66149
  * for every device, regardless of provider — the kernel needs a uniform
@@ -83720,6 +83739,15 @@ var NcRuleInputSchema = object({
83720
83739
  */
83721
83740
  askVerdict: boolean().optional(),
83722
83741
  /**
83742
+ * An ALERT notification (`alert-critical`, `alert-error`, device attention)
83743
+ * carries the alert's own action — an open-URL button and, for an `invoke`
83744
+ * action, a token-authed button that runs it. Absent and `true` mean ON;
83745
+ * `false` switches it off for this rule. `.optional()`, never `.default()`
83746
+ * (a Zod default does not run on the addon cap path), so a rule authored
83747
+ * before this field keeps the action.
83748
+ */
83749
+ offerAlertAction: boolean().optional(),
83750
+ /**
83723
83751
  * Operator tags (D1054), kept on the rule like a core block's. Absent = no
83724
83752
  * tags. `.optional()`, never `.default()`: a partial `updateRule` patch that
83725
83753
  * does not name `tags` keeps the stored ones (the store merges), and an
@@ -118934,6 +118962,14 @@ object({
118934
118962
  nodeId: string().optional(),
118935
118963
  /** The alert's own action link (where the operator acts on it), when it has one. */
118936
118964
  actionUrl: string().optional(),
118965
+ /**
118966
+ * The alert's WHOLE action — label, link, navigation and `invoke` — on a
118967
+ * raised episode, so a notification can offer it (an absolute open-URL
118968
+ * button, a token-authed invoke button). `actionUrl` stays for the
118969
+ * `{{actionUrl}}` template variable. Additive: an episode published before
118970
+ * this field has none.
118971
+ */
118972
+ action: AlertActionSchema.optional(),
118937
118973
  /** A device fault episode: every active fault (`metadata.faults`), principal first. */
118938
118974
  faults: array(DeviceFaultSchema).optional(),
118939
118975
  at: number$1()
@@ -120162,6 +120198,34 @@ object({
120162
120198
  delay: number$1().nonnegative().optional(),
120163
120199
  commands: record$1(string(), unknown$1())
120164
120200
  });
120201
+ /** When a member receives: always, inside a schedule, or while an alarm panel is in a state. */
120202
+ var GroupMemberWhenSchema = discriminatedUnion("kind", [
120203
+ object({ kind: literal("always") }),
120204
+ object({
120205
+ kind: literal("schedule"),
120206
+ schedule: NcScheduleSchema
120207
+ }),
120208
+ object({
120209
+ kind: literal("alarm"),
120210
+ deviceId: number$1().int().nonnegative(),
120211
+ states: array(AlarmStateSchema).min(1)
120212
+ })
120213
+ ]);
120214
+ object({
120215
+ targetId: string().min(1),
120216
+ enabled: boolean().optional(),
120217
+ when: GroupMemberWhenSchema.optional(),
120218
+ /** Which message fields this member receives. Absent = all of them. */
120219
+ fields: array(NotificationFieldSchema).optional(),
120220
+ /** `{{title}}`, `{{body}}`, `{{priority}}` and any `{{key}}` of the notification's metadata. */
120221
+ templates: object({
120222
+ title: string().optional(),
120223
+ body: string().optional()
120224
+ }).optional(),
120225
+ minPriority: number$1().int().min(1).max(5).optional(),
120226
+ /** At most one delivery per window; a burst becomes one. 0 or absent = no throttle. */
120227
+ throttleSec: number$1().int().nonnegative().optional()
120228
+ });
120165
120229
  //#endregion
120166
120230
  //#region src/devices/hm-cold-start.ts
120167
120231
  /**
@@ -121090,6 +121154,277 @@ function buildCcuDevicesHandlers(deps) {
121090
121154
  } };
121091
121155
  }
121092
121156
  //#endregion
121157
+ //#region src/homematic-fault-mapping.ts
121158
+ /**
121159
+ * PURE mapping of what a CCU reports as faulty to `error` cap readings, with no
121160
+ * session and no I/O: the WatchDog system variables of the box, and the
121161
+ * MAINTENANCE service flags of one device.
121162
+ *
121163
+ * A reading is UNKNOWN (`active: null`, the cold slice) until the CCU has said
121164
+ * something about the flags; "no fault" is only ever written from a value that
121165
+ * was read (D315, D393).
121166
+ *
121167
+ * The cap's `label` is a plain string the provider translates, and the server
121168
+ * has no per-operator language: the label carries the English words, and the
121169
+ * Italian beside it stays in the table for the surface that can pick one.
121170
+ */
121171
+ /** The two languages of one fault, side by side so neither is forgotten. */
121172
+ function words(en, it) {
121173
+ return {
121174
+ en,
121175
+ it
121176
+ };
121177
+ }
121178
+ var SEVERITY_ORDER = {
121179
+ error: 0,
121180
+ warning: 1
121181
+ };
121182
+ function toFault(rule) {
121183
+ return {
121184
+ code: rule.key,
121185
+ label: rule.words.en,
121186
+ severity: rule.severity
121187
+ };
121188
+ }
121189
+ /** Errors first, then warnings; the order inside a tier is the rule order. */
121190
+ function rank(faults) {
121191
+ return [...faults].sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity]);
121192
+ }
121193
+ function reading(faults, now) {
121194
+ const ranked = rank(faults);
121195
+ const principal = ranked[0];
121196
+ if (principal === void 0) return {
121197
+ ...ERROR_STATUS_COLD,
121198
+ active: false,
121199
+ faults: [],
121200
+ lastFetchedAt: now
121201
+ };
121202
+ return {
121203
+ active: true,
121204
+ code: principal.code,
121205
+ label: principal.label,
121206
+ severity: principal.severity,
121207
+ since: null,
121208
+ faults: ranked,
121209
+ lastFetchedAt: now
121210
+ };
121211
+ }
121212
+ function unknown(now) {
121213
+ return {
121214
+ ...ERROR_STATUS_COLD,
121215
+ lastFetchedAt: now
121216
+ };
121217
+ }
121218
+ /** A LOGIC value as the CCU hands it over: a boolean, 0/1, or its text. `null` is unread. */
121219
+ function truthy(value) {
121220
+ if (value === null) return null;
121221
+ if (typeof value === "boolean") return value;
121222
+ if (typeof value === "number") return value !== 0;
121223
+ const text = value.trim().toLowerCase();
121224
+ return text === "true" || text === "1" || text === "on" || text === "yes";
121225
+ }
121226
+ /** The WatchDog add-on names its variables "SV WatchDog: <key>". */
121227
+ var WATCHDOG_PREFIX = /^sv\s*watchdog\s*:\s*/i;
121228
+ var WATCHDOG_FAULTS = [
121229
+ {
121230
+ key: "hb-rf-eth-connection",
121231
+ severity: "error",
121232
+ words: words("HB-RF-ETH connection lost", "Connessione HB-RF-ETH persa")
121233
+ },
121234
+ {
121235
+ key: "low-voltage",
121236
+ severity: "error",
121237
+ words: words("CCU supply voltage low", "Tensione di alimentazione della CCU bassa")
121238
+ },
121239
+ {
121240
+ key: "rfd-restart",
121241
+ severity: "warning",
121242
+ words: words("The radio service restarted", "Il servizio radio si è riavviato")
121243
+ },
121244
+ {
121245
+ key: "regahss-restart",
121246
+ severity: "warning",
121247
+ words: words("The ReGa service restarted", "Il servizio ReGa si è riavviato")
121248
+ },
121249
+ {
121250
+ key: "no-internet",
121251
+ severity: "warning",
121252
+ words: words("The CCU has no internet", "La CCU non ha internet")
121253
+ },
121254
+ {
121255
+ key: "unclean-shutdown",
121256
+ severity: "warning",
121257
+ words: words("The CCU shut down uncleanly", "La CCU si è spenta in modo anomalo")
121258
+ }
121259
+ ];
121260
+ /** Which WatchDog fault a system variable is, or `null` when it is not one of them. */
121261
+ function watchdogRuleOf(name) {
121262
+ const key = name.trim().replace(WATCHDOG_PREFIX, "").trim().toLowerCase();
121263
+ return WATCHDOG_FAULTS.find((rule) => rule.key === key) ?? null;
121264
+ }
121265
+ /**
121266
+ * The gateway's reading from a system-variable snapshot. No WatchDog variable
121267
+ * with a value (no snapshot, no credentials, the add-on not installed) is
121268
+ * UNKNOWN, never "no fault".
121269
+ */
121270
+ function watchdogFaultReading(vars, now) {
121271
+ const faults = [];
121272
+ let known = 0;
121273
+ for (const variable of vars) {
121274
+ const rule = watchdogRuleOf(variable.name);
121275
+ if (rule === null) continue;
121276
+ const on = truthy(variable.value);
121277
+ if (on === null) continue;
121278
+ known += 1;
121279
+ if (on) faults.push(toFault(rule));
121280
+ }
121281
+ if (known === 0) return unknown(now);
121282
+ return reading(faults, now);
121283
+ }
121284
+ var MAINTENANCE_FAULTS = [
121285
+ {
121286
+ key: "UNREACH",
121287
+ severity: "error",
121288
+ words: words("Device unreachable", "Dispositivo non raggiungibile")
121289
+ },
121290
+ {
121291
+ key: "STICKY_UNREACH",
121292
+ severity: "warning",
121293
+ words: words("Device was unreachable (not acknowledged)", "Dispositivo stato non raggiungibile")
121294
+ },
121295
+ {
121296
+ key: "LOW_BAT",
121297
+ severity: "warning",
121298
+ words: words("Battery low", "Batteria scarica")
121299
+ },
121300
+ {
121301
+ key: "LOWBAT",
121302
+ severity: "warning",
121303
+ words: words("Battery low", "Batteria scarica")
121304
+ },
121305
+ {
121306
+ key: "CONFIG_PENDING",
121307
+ severity: "warning",
121308
+ words: words("Configuration pending", "Configurazione in attesa")
121309
+ },
121310
+ {
121311
+ key: "DUTY_CYCLE",
121312
+ severity: "warning",
121313
+ words: words("Radio duty cycle exhausted", "Duty cycle radio esaurito")
121314
+ }
121315
+ ];
121316
+ /** Every `ERROR_*` boolean flag the device raises is its own fault (overheat, overload, jammed…). */
121317
+ function errorFlagRule(param) {
121318
+ const name = param.slice(6).toLowerCase().replace(/_/g, " ");
121319
+ return {
121320
+ key: param,
121321
+ severity: "error",
121322
+ words: words(`Device error: ${name}`, `Errore del dispositivo: ${name}`)
121323
+ };
121324
+ }
121325
+ function maintenanceRuleOf(param, value) {
121326
+ const upper = param.toUpperCase();
121327
+ const fixed = MAINTENANCE_FAULTS.find((rule) => rule.key === upper);
121328
+ if (fixed !== void 0) return fixed;
121329
+ if (upper.startsWith("ERROR_") && typeof value === "boolean") return errorFlagRule(upper);
121330
+ return null;
121331
+ }
121332
+ /**
121333
+ * A device's reading from its MAINTENANCE channel values (parameter -> value).
121334
+ * Until a service flag has a value the reading is UNKNOWN.
121335
+ */
121336
+ function maintenanceFaultReading(values, now) {
121337
+ const faults = [];
121338
+ let known = 0;
121339
+ for (const [param, value] of values) {
121340
+ const rule = maintenanceRuleOf(param, value);
121341
+ if (rule === null) continue;
121342
+ const on = truthy(value);
121343
+ if (on === null) continue;
121344
+ known += 1;
121345
+ if (on) faults.push(toFault(rule));
121346
+ }
121347
+ if (known === 0) return unknown(now);
121348
+ return reading(faults, now);
121349
+ }
121350
+ /** The faults the CCU box can raise: its WatchDog variables. */
121351
+ function watchdogFaultTypes() {
121352
+ return WATCHDOG_FAULTS.map(toFault);
121353
+ }
121354
+ /**
121355
+ * The faults a device's MAINTENANCE channel can raise, by their fixed flags.
121356
+ * The per-model `ERROR_*` flags are discovered from the channel, so they are
121357
+ * published when raised but not listed here.
121358
+ */
121359
+ function maintenanceFaultTypes() {
121360
+ return MAINTENANCE_FAULTS.map(toFault);
121361
+ }
121362
+ //#endregion
121363
+ //#region src/ccu/ccu-faults-actions.ts
121364
+ /** A device's MAINTENANCE channel as the parameter map the fault mapping reads. */
121365
+ function maintenanceValues(device) {
121366
+ const values = /* @__PURE__ */ new Map();
121367
+ for (const point of maintenanceChannel(device)?.dataPoints ?? []) values.set(point.parameter, point.value);
121368
+ return values;
121369
+ }
121370
+ /** When the CCU raised a fault: the timestamp of its service message of the same code, else unknown. */
121371
+ function faultSince(address, code, messages) {
121372
+ return messages.find((message) => message.address !== null && (message.address === address || message.address.startsWith(`${address}:`)) && message.type === code && message.timestamp !== null)?.timestamp ?? null;
121373
+ }
121374
+ /**
121375
+ * The active faults CamStack derives from the CCU: the same pure mapping that
121376
+ * fills a device's `error` cap, read from the facade's cached MAINTENANCE values.
121377
+ * A device whose flags the CCU has not reported is UNKNOWN: it is not a fault
121378
+ * row but is named in `unreported`, so no caller reads it as "no fault". Only the `since` lookup is best effort; the device read
121379
+ * itself throws, so the page shows its warning instead of an empty list.
121380
+ */
121381
+ function buildCcuFaultHandlers(deps) {
121382
+ return { listCcuFaults: async (input) => {
121383
+ const facade = requireFacade(deps, input.integrationId);
121384
+ const adopted = await deps.adoptedAddresses(input.integrationId);
121385
+ const messages = await facade.serviceMessages().catch((error) => {
121386
+ deps.logger.warn("listCcuFaults: service messages unreadable, fault start times omitted", { meta: {
121387
+ integrationId: input.integrationId,
121388
+ error: error instanceof Error ? error.message : String(error)
121389
+ } });
121390
+ return [];
121391
+ });
121392
+ const now = Date.now();
121393
+ const faults = [];
121394
+ const unreported = [];
121395
+ for (const device of facade.devices()) {
121396
+ const reading = maintenanceFaultReading(maintenanceValues(device), now);
121397
+ if (reading.active === null) {
121398
+ unreported.push(device.address);
121399
+ continue;
121400
+ }
121401
+ const readingFaults = reading.faults ?? [];
121402
+ const principal = readingFaults[0];
121403
+ if (reading.active !== true || principal === void 0) continue;
121404
+ const all = readingFaults.map((fault) => ({
121405
+ code: fault.code,
121406
+ label: fault.label,
121407
+ severity: fault.severity
121408
+ }));
121409
+ faults.push({
121410
+ address: device.address,
121411
+ name: device.name ?? null,
121412
+ deviceId: adopted.get(device.address) ?? null,
121413
+ severity: principal.severity,
121414
+ code: principal.code,
121415
+ label: principal.label,
121416
+ since: faultSince(device.address, principal.code, messages),
121417
+ faults: all
121418
+ });
121419
+ }
121420
+ faults.sort((a, b) => a.severity === b.severity ? 0 : a.severity === "error" ? -1 : 1);
121421
+ return {
121422
+ faults,
121423
+ unreported
121424
+ };
121425
+ } };
121426
+ }
121427
+ //#endregion
121093
121428
  //#region src/ccu/ccu-schemas.ts
121094
121429
  /**
121095
121430
  * Wire shapes of the CCU management custom actions. Shared by the addon (handler
@@ -121556,6 +121891,27 @@ var SetValueInputSchema = IntegrationRefSchema.extend({
121556
121891
  deviceId: number$1().int().optional(),
121557
121892
  confirmed: ConfirmedSchema
121558
121893
  });
121894
+ var CcuFaultSchema = object({
121895
+ code: string(),
121896
+ label: string(),
121897
+ severity: _enum(["error", "warning"])
121898
+ });
121899
+ var CcuFaultsResultSchema = object({
121900
+ faults: array(object({
121901
+ address: string(),
121902
+ name: string().nullable(),
121903
+ /** CamStack device id when the CCU device is adopted. */
121904
+ deviceId: number$1().int().nullable(),
121905
+ severity: _enum(["error", "warning"]),
121906
+ code: string(),
121907
+ label: string(),
121908
+ /** Epoch milliseconds of the matching service message; `null` when the CCU did not say. */
121909
+ since: number$1().nullable(),
121910
+ faults: array(CcuFaultSchema)
121911
+ })),
121912
+ /** Devices whose service flags the CCU has not reported: unknown, never "no fault". */
121913
+ unreported: array(string())
121914
+ });
121559
121915
  //#endregion
121560
121916
  //#region src/ccu/ccu-heating-actions.ts
121561
121917
  /**
@@ -147303,6 +147659,10 @@ var homematicActions = defineCustomActions({
147303
147659
  kind: "query",
147304
147660
  auth: "admin"
147305
147661
  }),
147662
+ listCcuFaults: customAction(IntegrationRefSchema, CcuFaultsResultSchema, {
147663
+ kind: "query",
147664
+ auth: "admin"
147665
+ }),
147306
147666
  listCcuDevices: customAction(IntegrationRefSchema, CcuDevicesResultSchema, {
147307
147667
  kind: "query",
147308
147668
  auth: "admin"
@@ -149294,212 +149654,6 @@ function devicePanelSection(integrationId, address) {
149294
149654
  };
149295
149655
  }
149296
149656
  //#endregion
149297
- //#region src/homematic-fault-mapping.ts
149298
- /**
149299
- * PURE mapping of what a CCU reports as faulty to `error` cap readings, with no
149300
- * session and no I/O: the WatchDog system variables of the box, and the
149301
- * MAINTENANCE service flags of one device.
149302
- *
149303
- * A reading is UNKNOWN (`active: null`, the cold slice) until the CCU has said
149304
- * something about the flags; "no fault" is only ever written from a value that
149305
- * was read (D315, D393).
149306
- *
149307
- * The cap's `label` is a plain string the provider translates, and the server
149308
- * has no per-operator language: the label carries the English words, and the
149309
- * Italian beside it stays in the table for the surface that can pick one.
149310
- */
149311
- /** The two languages of one fault, side by side so neither is forgotten. */
149312
- function words(en, it) {
149313
- return {
149314
- en,
149315
- it
149316
- };
149317
- }
149318
- var SEVERITY_ORDER = {
149319
- error: 0,
149320
- warning: 1
149321
- };
149322
- function toFault(rule) {
149323
- return {
149324
- code: rule.key,
149325
- label: rule.words.en,
149326
- severity: rule.severity
149327
- };
149328
- }
149329
- /** Errors first, then warnings; the order inside a tier is the rule order. */
149330
- function rank(faults) {
149331
- return [...faults].sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity]);
149332
- }
149333
- function reading(faults, now) {
149334
- const ranked = rank(faults);
149335
- const principal = ranked[0];
149336
- if (principal === void 0) return {
149337
- ...ERROR_STATUS_COLD,
149338
- active: false,
149339
- faults: [],
149340
- lastFetchedAt: now
149341
- };
149342
- return {
149343
- active: true,
149344
- code: principal.code,
149345
- label: principal.label,
149346
- severity: principal.severity,
149347
- since: null,
149348
- faults: ranked,
149349
- lastFetchedAt: now
149350
- };
149351
- }
149352
- function unknown(now) {
149353
- return {
149354
- ...ERROR_STATUS_COLD,
149355
- lastFetchedAt: now
149356
- };
149357
- }
149358
- /** A LOGIC value as the CCU hands it over: a boolean, 0/1, or its text. `null` is unread. */
149359
- function truthy(value) {
149360
- if (value === null) return null;
149361
- if (typeof value === "boolean") return value;
149362
- if (typeof value === "number") return value !== 0;
149363
- const text = value.trim().toLowerCase();
149364
- return text === "true" || text === "1" || text === "on" || text === "yes";
149365
- }
149366
- /** The WatchDog add-on names its variables "SV WatchDog: <key>". */
149367
- var WATCHDOG_PREFIX = /^sv\s*watchdog\s*:\s*/i;
149368
- var WATCHDOG_FAULTS = [
149369
- {
149370
- key: "hb-rf-eth-connection",
149371
- severity: "error",
149372
- words: words("HB-RF-ETH connection lost", "Connessione HB-RF-ETH persa")
149373
- },
149374
- {
149375
- key: "low-voltage",
149376
- severity: "error",
149377
- words: words("CCU supply voltage low", "Tensione di alimentazione della CCU bassa")
149378
- },
149379
- {
149380
- key: "rfd-restart",
149381
- severity: "warning",
149382
- words: words("The radio service restarted", "Il servizio radio si è riavviato")
149383
- },
149384
- {
149385
- key: "regahss-restart",
149386
- severity: "warning",
149387
- words: words("The ReGa service restarted", "Il servizio ReGa si è riavviato")
149388
- },
149389
- {
149390
- key: "no-internet",
149391
- severity: "warning",
149392
- words: words("The CCU has no internet", "La CCU non ha internet")
149393
- },
149394
- {
149395
- key: "unclean-shutdown",
149396
- severity: "warning",
149397
- words: words("The CCU shut down uncleanly", "La CCU si è spenta in modo anomalo")
149398
- }
149399
- ];
149400
- /** Which WatchDog fault a system variable is, or `null` when it is not one of them. */
149401
- function watchdogRuleOf(name) {
149402
- const key = name.trim().replace(WATCHDOG_PREFIX, "").trim().toLowerCase();
149403
- return WATCHDOG_FAULTS.find((rule) => rule.key === key) ?? null;
149404
- }
149405
- /**
149406
- * The gateway's reading from a system-variable snapshot. No WatchDog variable
149407
- * with a value (no snapshot, no credentials, the add-on not installed) is
149408
- * UNKNOWN, never "no fault".
149409
- */
149410
- function watchdogFaultReading(vars, now) {
149411
- const faults = [];
149412
- let known = 0;
149413
- for (const variable of vars) {
149414
- const rule = watchdogRuleOf(variable.name);
149415
- if (rule === null) continue;
149416
- const on = truthy(variable.value);
149417
- if (on === null) continue;
149418
- known += 1;
149419
- if (on) faults.push(toFault(rule));
149420
- }
149421
- if (known === 0) return unknown(now);
149422
- return reading(faults, now);
149423
- }
149424
- var MAINTENANCE_FAULTS = [
149425
- {
149426
- key: "UNREACH",
149427
- severity: "error",
149428
- words: words("Device unreachable", "Dispositivo non raggiungibile")
149429
- },
149430
- {
149431
- key: "STICKY_UNREACH",
149432
- severity: "warning",
149433
- words: words("Device was unreachable (not acknowledged)", "Dispositivo stato non raggiungibile")
149434
- },
149435
- {
149436
- key: "LOW_BAT",
149437
- severity: "warning",
149438
- words: words("Battery low", "Batteria scarica")
149439
- },
149440
- {
149441
- key: "LOWBAT",
149442
- severity: "warning",
149443
- words: words("Battery low", "Batteria scarica")
149444
- },
149445
- {
149446
- key: "CONFIG_PENDING",
149447
- severity: "warning",
149448
- words: words("Configuration pending", "Configurazione in attesa")
149449
- },
149450
- {
149451
- key: "DUTY_CYCLE",
149452
- severity: "warning",
149453
- words: words("Radio duty cycle exhausted", "Duty cycle radio esaurito")
149454
- }
149455
- ];
149456
- /** Every `ERROR_*` boolean flag the device raises is its own fault (overheat, overload, jammed…). */
149457
- function errorFlagRule(param) {
149458
- const name = param.slice(6).toLowerCase().replace(/_/g, " ");
149459
- return {
149460
- key: param,
149461
- severity: "error",
149462
- words: words(`Device error: ${name}`, `Errore del dispositivo: ${name}`)
149463
- };
149464
- }
149465
- function maintenanceRuleOf(param, value) {
149466
- const upper = param.toUpperCase();
149467
- const fixed = MAINTENANCE_FAULTS.find((rule) => rule.key === upper);
149468
- if (fixed !== void 0) return fixed;
149469
- if (upper.startsWith("ERROR_") && typeof value === "boolean") return errorFlagRule(upper);
149470
- return null;
149471
- }
149472
- /**
149473
- * A device's reading from its MAINTENANCE channel values (parameter -> value).
149474
- * Until a service flag has a value the reading is UNKNOWN.
149475
- */
149476
- function maintenanceFaultReading(values, now) {
149477
- const faults = [];
149478
- let known = 0;
149479
- for (const [param, value] of values) {
149480
- const rule = maintenanceRuleOf(param, value);
149481
- if (rule === null) continue;
149482
- const on = truthy(value);
149483
- if (on === null) continue;
149484
- known += 1;
149485
- if (on) faults.push(toFault(rule));
149486
- }
149487
- if (known === 0) return unknown(now);
149488
- return reading(faults, now);
149489
- }
149490
- /** The faults the CCU box can raise: its WatchDog variables. */
149491
- function watchdogFaultTypes() {
149492
- return WATCHDOG_FAULTS.map(toFault);
149493
- }
149494
- /**
149495
- * The faults a device's MAINTENANCE channel can raise, by their fixed flags.
149496
- * The per-model `ERROR_*` flags are discovered from the channel, so they are
149497
- * published when raised but not listed here.
149498
- */
149499
- function maintenanceFaultTypes() {
149500
- return MAINTENANCE_FAULTS.map(toFault);
149501
- }
149502
- //#endregion
149503
149657
  //#region src/homematic-diagnostics-mapping.ts
149504
149658
  var MAINTENANCE_CHANNEL_TYPE$1 = "MAINTENANCE";
149505
149659
  /** Reachability parameters that drive the Container's `online`, not a child. */
@@ -150489,9 +150643,37 @@ function gatewayMetadataPatch(input) {
150489
150643
  };
150490
150644
  }
150491
150645
  //#endregion
150646
+ //#region src/homematic-state-refresh.ts
150647
+ /**
150648
+ * Homematic's side of the core state refresh (D1062): HOW to read, never WHEN.
150649
+ *
150650
+ * The CCU pushes every radio device event over the XML-RPC callback, so those
150651
+ * devices are never read on a clock. The one thing it does NOT push is its own
150652
+ * WatchDog system variables (the gateway's `error` cap): they are a snapshot the
150653
+ * gateway has to read, so the gateway registers `device-state-refresh` with
150654
+ * `push: 'none'` and the core reads it at {@link HOMEMATIC_GATEWAY_REFRESH_MS}.
150655
+ */
150656
+ /** How often the core reads the CCU's WatchDog system variables. */
150657
+ var HOMEMATIC_GATEWAY_REFRESH_MS = 3e4;
150658
+ function homematicGatewayRefreshPolicy(integrationId) {
150659
+ return {
150660
+ integrationId,
150661
+ minIntervalMs: HOMEMATIC_GATEWAY_REFRESH_MS,
150662
+ batch: false,
150663
+ push: "none"
150664
+ };
150665
+ }
150666
+ function registerHomematicStateRefresh(target) {
150667
+ target.ctx.registerNativeCap(deviceStateRefreshCapability, {
150668
+ refresh: async () => {
150669
+ await target.readFaults();
150670
+ return { ok: true };
150671
+ },
150672
+ resubscribe: async () => ({ ok: true })
150673
+ }, { stateRefresh: homematicGatewayRefreshPolicy(target.integrationId) });
150674
+ }
150675
+ //#endregion
150492
150676
  //#region src/devices/homematic-gateway-device.ts
150493
- /** How often the CCU system variables are re-read: they are a snapshot, the CCU pushes no event for them. */
150494
- var WATCHDOG_POLL_MS = 3e4;
150495
150677
  /**
150496
150678
  * The physical CCU3 / RaspberryMatic box, as a {@link DeviceType.Gateway}. Its
150497
150679
  * connection and password live on the INTEGRATION; this device follows whether
@@ -150501,7 +150683,8 @@ var WATCHDOG_POLL_MS = 3e4;
150501
150683
  * - `device-admin-link`, the CCU's own WebUI.
150502
150684
  *
150503
150685
  * - `error`, the faults the CCU WatchDog add-on raises as system variables
150504
- * (`homematic-fault-mapping.ts`), re-read every {@link WATCHDOG_POLL_MS}.
150686
+ * (`homematic-fault-mapping.ts`), read by the core's `device-state-refresh` (D1062),
150687
+ * because the CCU pushes no event for them.
150505
150688
  *
150506
150689
  * There is no `reboot` and no `update`: nodehomematic has no call that restarts
150507
150690
  * the CCU, and its firmware call installs an update on a radio DEVICE by its
@@ -150516,7 +150699,6 @@ var HomematicGatewayDevice = class extends BaseDevice {
150516
150699
  snapshotUnsub = null;
150517
150700
  /** The last metadata written, so a state change that altered nothing writes nothing. */
150518
150701
  lastMetadataKey = "";
150519
- pollTimer = null;
150520
150702
  polling = false;
150521
150703
  warnedReadFailure = false;
150522
150704
  constructor(ctx) {
@@ -150527,6 +150709,11 @@ var HomematicGatewayDevice = class extends BaseDevice {
150527
150709
  this.registerAdminLinkCap();
150528
150710
  this.declareFaultTypes(watchdogFaultTypes());
150529
150711
  this.registerErrorCap();
150712
+ registerHomematicStateRefresh({
150713
+ ctx,
150714
+ integrationId: cfg.integrationId,
150715
+ readFaults: () => this.refreshFaults()
150716
+ });
150530
150717
  this.updateSourceInfo({
150531
150718
  id: cfg.nativeId,
150532
150719
  system: "homematic"
@@ -150539,15 +150726,9 @@ var HomematicGatewayDevice = class extends BaseDevice {
150539
150726
  if (this.sessionUp()) this.pollFaults();
150540
150727
  });
150541
150728
  await this.sync();
150542
- this.pollTimer = setInterval(() => {
150543
- this.pollFaults();
150544
- }, WATCHDOG_POLL_MS);
150545
- this.pollTimer.unref();
150546
150729
  await this.pollFaults();
150547
150730
  }
150548
150731
  async removeDevice() {
150549
- if (this.pollTimer !== null) clearInterval(this.pollTimer);
150550
- this.pollTimer = null;
150551
150732
  this.snapshotUnsub?.();
150552
150733
  this.snapshotUnsub = null;
150553
150734
  await super.removeDevice();
@@ -150556,9 +150737,34 @@ var HomematicGatewayDevice = class extends BaseDevice {
150556
150737
  return homematicFacades.getSession(this.integrationId)?.getInfo().status === "connected";
150557
150738
  }
150558
150739
  /**
150559
- * Read the CCU's WatchDog system variables and publish them as faults. A read
150560
- * that fails changes nothing (the previous reading stands), and every branch
150561
- * that publishes nothing leaves a line on the device.
150740
+ * The core's read (D1062): the CCU's WatchDog system variables, published as
150741
+ * faults. It THROWS when the session is down or the CCU does not answer, so
150742
+ * the core backs the cadence off; the previous reading stands meanwhile. It
150743
+ * shares the `polling` guard with `pollFaults`: a read already in flight
150744
+ * publishes the same reading, so a second one is not started.
150745
+ */
150746
+ async refreshFaults() {
150747
+ if (this.polling) return;
150748
+ const facade = homematicFacades.get(this.integrationId);
150749
+ if (!this.sessionUp() || facade === null) throw new Error(`Homematic CCU not connected (integration ${this.integrationId})`);
150750
+ this.polling = true;
150751
+ try {
150752
+ await this.readFaultsFrom(facade);
150753
+ } finally {
150754
+ this.polling = false;
150755
+ }
150756
+ }
150757
+ async readFaultsFrom(facade) {
150758
+ 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 } });
150761
+ this.warnedReadFailure = false;
150762
+ await this.publishError(reading);
150763
+ }
150764
+ /**
150765
+ * Read the faults when the CCU announced a new snapshot (it just reconnected
150766
+ * or changed). A read that fails changes nothing (the previous reading
150767
+ * stands), and every branch that publishes nothing leaves a line on the device.
150562
150768
  */
150563
150769
  async pollFaults() {
150564
150770
  if (this.polling) return;
@@ -150570,11 +150776,7 @@ var HomematicGatewayDevice = class extends BaseDevice {
150570
150776
  }
150571
150777
  this.polling = true;
150572
150778
  try {
150573
- await facade.refreshHub();
150574
- const reading = watchdogFaultReading(facade.systemVariables(), Date.now());
150575
- if (reading.active === null) this.ctx.logger.debug("Homematic gateway: no WatchDog system variable readable on the CCU, faults stay unknown", { tags });
150576
- this.warnedReadFailure = false;
150577
- await this.publishError(reading);
150779
+ await this.readFaultsFrom(facade);
150578
150780
  } catch (err) {
150579
150781
  const log = this.warnedReadFailure ? this.ctx.logger.debug : this.ctx.logger.warn;
150580
150782
  this.warnedReadFailure = true;
@@ -152468,6 +152670,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
152468
152670
  actionHandlers: {
152469
152671
  ...buildCcuOverviewHandlers(this.ccuActionDeps()),
152470
152672
  ...buildCcuDevicesHandlers(this.ccuActionDeps()),
152673
+ ...buildCcuFaultHandlers(this.ccuActionDeps()),
152471
152674
  ...buildCcuHeatingHandlers(this.ccuActionDeps()),
152472
152675
  ...buildCcuPairingHandlers(this.ccuActionDeps()),
152473
152676
  ...buildCcuConfigHandlers(this.ccuActionDeps()),