homebridge-pagerduty 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.1.1](https://github.com/tbaur/homebridge-pagerduty/compare/v2.1.0...v2.1.1) (2026-10-26)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * show the severity a plugin signal already has ([#25](https://github.com/tbaur/homebridge-pagerduty/issues/25)) ([36f139e](https://github.com/tbaur/homebridge-pagerduty/commit/36f139e6b5d630a64e20deb4d34f4b7b2bf09505))
9
+
3
10
  ## [2.1.0](https://github.com/tbaur/homebridge-pagerduty/compare/v2.0.2...v2.1.0) (2026-10-25)
4
11
 
5
12
 
package/README.md CHANGED
@@ -22,6 +22,19 @@
22
22
 
23
23
  The [detailed documentation](docs/README-DETAILED.md) describes every accessory, setting and log line.
24
24
 
25
+ ## Integrated Plugins with Signal
26
+
27
+ These plugins write to the [signal store](docs/SIGNALS.md). Each one pages only after you allow it. No HomeKit automation rules are required.
28
+
29
+ - [homebridge-myleviton](https://github.com/tbaur/homebridge-myleviton)
30
+ - [homebridge-navilink](https://github.com/tbaur/homebridge-navilink)
31
+ - [homebridge-myalarmcom](https://github.com/tbaur/homebridge-myalarmcom)
32
+ - [homebridge-mynest](https://github.com/tbaur/homebridge-mynest)
33
+ - [homebridge-myresideo](https://github.com/tbaur/homebridge-myresideo)
34
+ - [homebridge-concert](https://github.com/tbaur/homebridge-concert)
35
+
36
+ If you have integrated another plugin, [let me know](https://github.com/tbaur/homebridge-pagerduty/issues) and I will add it to this list.
37
+
25
38
  ## Quick Start
26
39
 
27
40
  ### 1. Install
@@ -63,7 +63,8 @@ export declare class AlertController {
63
63
  private reader;
64
64
  private storeUnreadableSince;
65
65
  private catalog;
66
- private catalogNames;
66
+ /** Plugin, signal, and severity. A new summary does not refresh the settings screen. */
67
+ private catalogStamp;
67
68
  private lastStoreWarnAt;
68
69
  private pendingRowSweep;
69
70
  private started;
@@ -122,7 +123,7 @@ export declare class AlertController {
122
123
  * untrusted.
123
124
  */
124
125
  signalCatalog(): readonly CatalogEntry[] | undefined;
125
- /** Called when a plugin or signal appears in the store or leaves it. */
126
+ /** Called when a plugin or signal appears or leaves, or a signal's severity changes. */
126
127
  onCatalogChange(listener: () => void): void;
127
128
  private pollSignals;
128
129
  private updateCatalog;
@@ -57,7 +57,8 @@ class AlertController {
57
57
  reader;
58
58
  storeUnreadableSince = null;
59
59
  catalog;
60
- catalogNames = '';
60
+ /** Plugin, signal, and severity. A new summary does not refresh the settings screen. */
61
+ catalogStamp = '';
61
62
  lastStoreWarnAt = 0;
62
63
  pendingRowSweep = false;
63
64
  started = false;
@@ -412,7 +413,7 @@ class AlertController {
412
413
  signalCatalog() {
413
414
  return this.catalog;
414
415
  }
415
- /** Called when a plugin or signal appears in the store or leaves it. */
416
+ /** Called when a plugin or signal appears or leaves, or a signal's severity changes. */
416
417
  onCatalogChange(listener) {
417
418
  this.catalogListeners.push(listener);
418
419
  }
@@ -441,11 +442,11 @@ class AlertController {
441
442
  }
442
443
  updateCatalog(catalog) {
443
444
  this.catalog = catalog;
444
- const names = catalog.map((entry) => (0, schema_1.signalRefKey)(entry)).join('\n');
445
- if (names === this.catalogNames) {
445
+ const stamp = catalog.map((entry) => `${(0, schema_1.signalRefKey)(entry)} ${entry.severity}`).join('\n');
446
+ if (stamp === this.catalogStamp) {
446
447
  return;
447
448
  }
448
- this.catalogNames = names;
449
+ this.catalogStamp = stamp;
449
450
  for (const listener of this.catalogListeners) {
450
451
  try {
451
452
  listener();
@@ -15,7 +15,7 @@
15
15
  * keys and condition code. A plugin's text is only ever a field's default
16
16
  * value, never a title or description, which Config UI X renders as markup.
17
17
  */
18
- import type { CatalogEntry, PluginLogger, ResolvedSignalPlugin } from './types';
18
+ import { type CatalogEntry, type PluginLogger, type ResolvedSignalPlugin } from './types';
19
19
  /** Title of the layout fieldset this file fills. A test asserts the static schema has it. */
20
20
  export declare const PLUGIN_SIGNALS_TITLE = "Plugin Signals";
21
21
  type JsonObject = Record<string, unknown>;
@@ -23,6 +23,7 @@ const node_fs_1 = require("node:fs");
23
23
  const node_path_1 = require("node:path");
24
24
  const schema_1 = require("./signals/schema");
25
25
  const settings_1 = require("./settings");
26
+ const types_1 = require("./types");
26
27
  const atomic_file_1 = require("./utils/atomic-file");
27
28
  const errors_1 = require("./utils/errors");
28
29
  /** Title of the layout fieldset this file fills. A test asserts the static schema has it. */
@@ -30,6 +31,16 @@ exports.PLUGIN_SIGNALS_TITLE = 'Plugin Signals';
30
31
  /** Bootstrap classes that Config UI X loads. A box per plugin and a rule per signal show what belongs to what. */
31
32
  const PLUGIN_FIELDSET_CLASS = 'border rounded px-3 pt-3 pb-0 mb-3';
32
33
  const SIGNAL_FIELDSET_CLASS = 'border-start border-2 ps-3 mb-2';
34
+ /** Highest first, matching the severity menu on a HomeKit alert. */
35
+ const SEVERITY_CHOICES = [...types_1.SEVERITIES].reverse().map((severity) => ({
36
+ value: severity,
37
+ name: `${severity[0]?.toUpperCase() ?? ''}${severity.slice(1)}`,
38
+ }));
39
+ /**
40
+ * What a page uses when the plugin has not written a severity yet.
41
+ * Same fallback as a signal raised from its switch before any row exists.
42
+ */
43
+ const SEVERITY_BEFORE_PLUGIN_WRITES = 'critical';
33
44
  /** Build the settings screen. Pure. */
34
45
  function buildDynamicSchema(input) {
35
46
  const schema = structuredClone(input.baseSchema);
@@ -54,16 +65,12 @@ function buildDynamicSchema(input) {
54
65
  function collectPlugins(catalog, configured) {
55
66
  const byPlugin = new Map();
56
67
  for (const entry of configured) {
57
- byPlugin.set(entry.plugin, new Map(entry.signals.map((signal) => [signal.signal, undefined])));
68
+ byPlugin.set(entry.plugin, new Map(entry.signals.map((signal) => [signal.signal, { override: signal.severity }])));
58
69
  }
59
70
  for (const entry of [...catalog].sort(compareEntries)) {
60
- let signals = byPlugin.get(entry.plugin);
61
- if (signals === undefined && byPlugin.size < settings_1.MAX_SIGNAL_PLUGINS) {
62
- signals = new Map();
63
- byPlugin.set(entry.plugin, signals);
64
- }
71
+ const signals = signalsFor(byPlugin, entry.plugin);
65
72
  if (signals !== undefined && (signals.has(entry.signal) || signals.size < settings_1.MAX_SIGNALS_PER_PLUGIN)) {
66
- signals.set(entry.signal, cleanDefault(entry.summary));
73
+ signals.set(entry.signal, withCatalog(signals.get(entry.signal), entry));
67
74
  }
68
75
  }
69
76
  return [...byPlugin]
@@ -72,9 +79,33 @@ function collectPlugins(catalog, configured) {
72
79
  plugin,
73
80
  signals: [...signals]
74
81
  .sort(([a], [b]) => a.localeCompare(b))
75
- .map(([signal, summary]) => (summary === undefined ? { signal } : { signal, summary })),
82
+ .map(([signal, draft]) => signalForm(signal, draft)),
76
83
  }));
77
84
  }
85
+ function signalsFor(byPlugin, plugin) {
86
+ let signals = byPlugin.get(plugin);
87
+ if (signals === undefined && byPlugin.size < settings_1.MAX_SIGNAL_PLUGINS) {
88
+ signals = new Map();
89
+ byPlugin.set(plugin, signals);
90
+ }
91
+ return signals;
92
+ }
93
+ function withCatalog(draft, entry) {
94
+ const summary = cleanDefault(entry.summary);
95
+ return {
96
+ ...(draft?.override === undefined ? {} : { override: draft.override }),
97
+ pluginSeverity: entry.severity,
98
+ ...(summary === undefined ? {} : { summary }),
99
+ };
100
+ }
101
+ function signalForm(signal, draft) {
102
+ return {
103
+ signal,
104
+ ...(draft.summary === undefined ? {} : { summary: draft.summary }),
105
+ ...(draft.pluginSeverity === undefined ? {} : { pluginSeverity: draft.pluginSeverity }),
106
+ ...(draft.override === undefined ? {} : { override: draft.override }),
107
+ };
108
+ }
78
109
  function compareEntries(a, b) {
79
110
  return a.plugin.localeCompare(b.plugin) || a.signal.localeCompare(b.signal);
80
111
  }
@@ -101,6 +132,7 @@ function pluginSchema(entry) {
101
132
  };
102
133
  }
103
134
  function signalSchema(signal) {
135
+ const severity = severityControl(signal);
104
136
  return {
105
137
  type: 'object',
106
138
  required: ['severity'],
@@ -116,8 +148,8 @@ function signalSchema(signal) {
116
148
  severity: {
117
149
  title: 'Severity',
118
150
  type: 'string',
119
- enum: [settings_1.SEVERITY_FROM_PLUGIN, 'critical', 'error', 'warning', 'info'],
120
- default: settings_1.SEVERITY_FROM_PLUGIN,
151
+ enum: severity.enum,
152
+ default: severity.default,
121
153
  },
122
154
  bypassMaintenance: {
123
155
  title: 'Page During Maintenance',
@@ -151,17 +183,35 @@ function pluginLayout(entry) {
151
183
  expanded: false,
152
184
  items: [
153
185
  `signals[${key}].allow`,
154
- ...entry.signals.map((signal) => signalLayout(key, signal.signal)),
186
+ ...entry.signals.map((signal) => signalLayout(key, signal)),
155
187
  ],
156
188
  };
157
189
  }
190
+ /**
191
+ * Until the user picks a severity, the choice that matches the plugin's
192
+ * severity is stored as `plugin`. The screen shows that severity, and saving
193
+ * without a change keeps following the plugin. A different choice is stored
194
+ * as that severity.
195
+ */
196
+ function severityControl(signal) {
197
+ if (signal.override !== undefined) {
198
+ return {
199
+ enum: SEVERITY_CHOICES.map((choice) => choice.value),
200
+ default: signal.override,
201
+ titleMap: SEVERITY_CHOICES.map((choice) => ({ ...choice })),
202
+ };
203
+ }
204
+ const shown = signal.pluginSeverity ?? SEVERITY_BEFORE_PLUGIN_WRITES;
205
+ const titleMap = SEVERITY_CHOICES.map((choice) => (choice.value === shown ? { value: settings_1.SEVERITY_FROM_PLUGIN, name: choice.name } : choice));
206
+ return { enum: titleMap.map((choice) => choice.value), default: settings_1.SEVERITY_FROM_PLUGIN, titleMap };
207
+ }
158
208
  function signalLayout(pluginKey, signal) {
159
- const path = `signals[${pluginKey}].signals[${JSON.stringify(signal)}]`;
209
+ const path = `signals[${pluginKey}].signals[${JSON.stringify(signal.signal)}]`;
160
210
  const model = `model.signals?.[${pluginKey}]`;
161
- const settings = `${model}?.signals?.[${JSON.stringify(signal)}]`;
211
+ const settings = `${model}?.signals?.[${JSON.stringify(signal.signal)}]`;
162
212
  return {
163
213
  type: 'fieldset',
164
- title: signal,
214
+ title: signal.signal,
165
215
  htmlClass: SIGNAL_FIELDSET_CLASS,
166
216
  expandable: true,
167
217
  expanded: false,
@@ -172,13 +222,7 @@ function signalLayout(pluginKey, signal) {
172
222
  {
173
223
  key: `${path}.severity`,
174
224
  type: 'select',
175
- titleMap: [
176
- { value: settings_1.SEVERITY_FROM_PLUGIN, name: 'Set by the plugin' },
177
- { value: 'critical', name: 'Critical' },
178
- { value: 'error', name: 'Error' },
179
- { value: 'warning', name: 'Warning' },
180
- { value: 'info', name: 'Info' },
181
- ],
225
+ titleMap: severityControl(signal).titleMap,
182
226
  },
183
227
  {
184
228
  key: `${path}.bypassMaintenance`,
@@ -127,7 +127,12 @@ export declare const CONTROL_CHARACTERS: RegExp;
127
127
  * bridge can hold.
128
128
  */
129
129
  export declare const MAX_SIGNAL_SWITCHES = 20;
130
- /** `severity` value in `signals` that keeps the plugin's own severity. */
130
+ /**
131
+ * `severity` value in `signals` that keeps the plugin's own severity.
132
+ *
133
+ * The settings screen does not show this word. It labels the choice with the
134
+ * severity the plugin wrote, and a different choice replaces it.
135
+ */
131
136
  export declare const SEVERITY_FROM_PLUGIN = "plugin";
132
137
  /**
133
138
  * Must match `dynamicSchemaVersion` in `config.schema.json`. Config UI X then
package/dist/settings.js CHANGED
@@ -135,7 +135,12 @@ exports.CONTROL_CHARACTERS = /[\u0000-\u001F\u007F]/;
135
135
  * bridge can hold.
136
136
  */
137
137
  exports.MAX_SIGNAL_SWITCHES = 20;
138
- /** `severity` value in `signals` that keeps the plugin's own severity. */
138
+ /**
139
+ * `severity` value in `signals` that keeps the plugin's own severity.
140
+ *
141
+ * The settings screen does not show this word. It labels the choice with the
142
+ * severity the plugin wrote, and a different choice replaces it.
143
+ */
139
144
  exports.SEVERITY_FROM_PLUGIN = 'plugin';
140
145
  // --- Settings screen ---------------------------------------------------------
141
146
  /**
@@ -109,7 +109,7 @@ class SignalReader {
109
109
  ino: stats.ino,
110
110
  rows: this.options.allowed.length === 0 ? undefined : db.prepare('SELECT plugin, signal, active, severity, summary, updated_at FROM signals '
111
111
  + `WHERE plugin IN (${placeholders}) ORDER BY updated_at DESC LIMIT ${settings_1.MAX_SIGNAL_ROWS + 1}`),
112
- catalog: db.prepare('SELECT plugin, signal, summary FROM signals WHERE plugin <> ? '
112
+ catalog: db.prepare('SELECT plugin, signal, severity, summary FROM signals WHERE plugin <> ? '
113
113
  + `ORDER BY plugin, signal LIMIT ${settings_1.MAX_CATALOG_SCAN_ROWS}`),
114
114
  dataVersion: db.prepare('PRAGMA data_version'),
115
115
  lastDataVersion: undefined,
@@ -134,10 +134,10 @@ function validateRow(raw) {
134
134
  * plugin's own name are dropped, because it can never be allowed.
135
135
  */
136
136
  function validateCatalogEntry(raw) {
137
- const { plugin, signal } = raw;
137
+ const { plugin, signal, severity } = raw;
138
138
  const summary = cleanSummaryText(raw.summary);
139
- return isAllowableSource(plugin) && isValidSignalName(signal) && summary !== undefined
140
- ? { plugin, signal, summary }
139
+ return isAllowableSource(plugin) && isValidSignalName(signal) && (0, types_1.isSeverity)(severity) && summary !== undefined
140
+ ? { plugin, signal, severity, summary }
141
141
  : undefined;
142
142
  }
143
143
  /**
@@ -193,6 +193,8 @@ export interface SignalRow extends SignalRef {
193
193
  export interface CatalogEntry extends SignalRef {
194
194
  /** Untrusted text from the other plugin. Only ever used as a field's default value. */
195
195
  summary: string;
196
+ /** The severity the plugin wrote. Already checked against {@link SEVERITIES}. */
197
+ severity: Severity;
196
198
  }
197
199
  /**
198
200
  * What the delivery sensor should say.
@@ -174,7 +174,7 @@ Each signal takes:
174
174
  | --- | --- | --- |
175
175
  | `enabled` | `true` | Page for this signal |
176
176
  | `summary` | the plugin's text | PagerDuty Message, up to 1024 characters. Blank uses the plugin's text |
177
- | `severity` | `plugin` | `plugin` keeps the plugin's severity. `info`, `warning`, `error` or `critical` overrides it |
177
+ | `severity` | `plugin` | The settings screen shows the severity the plugin wrote. `plugin` keeps that severity, including when the plugin changes it. `info`, `warning`, `error` or `critical` replaces it |
178
178
  | `bypassMaintenance` | `false` | Page even while maintenance is on |
179
179
  | `switch` | `false` | Add a HomeKit switch for this signal. Up to 20 signal switches |
180
180
  | `switchName` | the signal name in title case | The switch's name in HomeKit, up to 64 characters |
package/docs/SIGNALS.md CHANGED
@@ -28,7 +28,7 @@ signal store: homebridge-example writes signals; allow it under Plugin Signals t
28
28
  |---|---|
29
29
  | **Page for this signal** | On by default. Turn it off to stop this one signal from paging. |
30
30
  | **PagerDuty Message** | The text sent to PagerDuty when the plugin raises this signal. It starts as the plugin's own text, and you can change it. Leave it blank to use whatever text the plugin writes. |
31
- | **Severity** | **Set by the plugin** by default. Pick a severity to always page at that level instead. |
31
+ | **Severity** | The severity the plugin set. Choose a different severity to page at that level instead. |
32
32
  | **Page During Maintenance** | Page even while the maintenance switch is on. Shown only when the maintenance switch is turned on. |
33
33
  | **Create HomeKit Switch** | Adds a switch to HomeKit for this signal. See [Signal switches](#signal-switches). |
34
34
  | **Switch Name** | The name that HomeKit shows. Shown only when Create HomeKit Switch is checked. You can rename it at any time, and it keeps its room and automations. |
@@ -46,6 +46,8 @@ In `config.json`, these settings sit under `signals`, keyed by package name. A s
46
46
  }
47
47
  ```
48
48
 
49
+ `severity` stays `plugin` in that file until you choose a severity. The screen shows the severity the other plugin wrote. Paging uses that severity, including after that plugin changes it. A severity you choose stays at that level.
50
+
49
51
  A signal that an allowed plugin starts writing after you saved the settings pages with the defaults, as if you had left every setting alone.
50
52
 
51
53
  ### What happens once a plugin is allowed
@@ -59,7 +61,7 @@ A signal that an allowed plugin starts writing after you saved the settings page
59
61
  A signal switch shows the signal in the Home app, and lets you test it.
60
62
 
61
63
  - The switch is on while the signal is active, and turns off when it clears.
62
- - Turning the switch on by hand pages with the signal's settings. Turning it off resolves the alert. If the plugin has not written the signal yet and its severity is left to the plugin, a page by hand is sent as `critical`.
64
+ - Turning the switch on by hand pages with the signal's settings. Turning it off resolves the alert. If the plugin has not written the signal yet, the severity shows as Critical, and a page by hand is sent as `critical`.
63
65
  - Whichever changed last wins. A person can flip the switch, and it stays that way until the plugin next changes the signal.
64
66
 
65
67
  ### What allowing a plugin protects against
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-pagerduty",
3
3
  "displayName": "Homebridge PagerDuty",
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
5
5
  "description": "Homebridge plugin that pages through PagerDuty: each alert is a HomeKit switch that triggers and resolves a PagerDuty alert, with severity levels, resolve timers, a maintenance switch, a delivery-fault sensor and a local signal store other plugins can raise alerts through",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",