homebridge-navilink 1.1.0 → 1.1.2
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 +14 -0
- package/README.md +9 -100
- package/dist/devices/base-accessory.js +2 -2
- package/dist/navilink-signals.d.ts +39 -20
- package/dist/navilink-signals.js +162 -100
- package/dist/pagerduty-signals.d.ts +12 -0
- package/dist/pagerduty-signals.js +37 -0
- package/dist/platform.d.ts +12 -3
- package/dist/platform.js +48 -8
- package/docs/FEATURES.md +1 -1
- package/docs/README-DETAILED.md +29 -3
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.1.2](https://github.com/tbaur/homebridge-navilink/compare/v1.1.1...v1.1.2) (2026-11-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* bump @homebridge/plugin-ui-utils from 2.2.6 to 2.3.0 ([#49](https://github.com/tbaur/homebridge-navilink/issues/49)) ([6375875](https://github.com/tbaur/homebridge-navilink/commit/6375875062e8b7091e0ee48a2a61bdc89283fa22))
|
|
9
|
+
|
|
10
|
+
## [1.1.1](https://github.com/tbaur/homebridge-navilink/compare/v1.1.0...v1.1.1) (2026-10-25)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* name PagerDuty fault signals from the appliance ([2ee282f](https://github.com/tbaur/homebridge-navilink/commit/2ee282f38a62c1dc60d31f819c7342b37f0fa819))
|
|
16
|
+
|
|
3
17
|
## [1.1.0](https://github.com/tbaur/homebridge-navilink/compare/v1.0.4...v1.1.0) (2026-10-25)
|
|
4
18
|
|
|
5
19
|
|
package/README.md
CHANGED
|
@@ -14,44 +14,20 @@ Scheduling, weekly programmes and commissioning stay in the NaviLink app, which
|
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### Per appliance
|
|
20
|
-
|
|
21
17
|
- **Hot water thermostat:** the domestic hot water setpoint, reading the actual outlet temperature
|
|
22
18
|
- **Heating thermostat:** the space-heating flow temperature. This is the boiler's water temperature
|
|
23
19
|
- **Power switch:** on and off, with switching *off* refused by default because it stops central heating
|
|
24
|
-
- **Recirculation switch:** starts the on-demand pump, so hot water reaches the tap without running it first. Only offered where a pump is fitted
|
|
20
|
+
- **Recirculation switch:** starts the on-demand pump, so hot water reaches the tap without running it first. Only offered where a pump is fitted
|
|
25
21
|
- **Fault sensor:** a contact sensor that opens and logs on an error code, so HomeKit can notify you
|
|
26
22
|
- **Temperature sensors:** hot water in and out, heating flow and return, and the optional outdoor probe
|
|
23
|
+
- **Push, not polling.** A change at the wall controller or in the NaviLink app reaches HomeKit in about a second. A rejected password is never retried
|
|
24
|
+
- **No analytics.** Nothing is sent anywhere except Navien's own service
|
|
25
|
+
- **PagerDuty** *(optional)*: pages through [homebridge-pagerduty](https://github.com/tbaur/homebridge-pagerduty) on a boiler fault or a rejected sign-in. See [setup](docs/README-DETAILED.md#pagerduty)
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
### Reliability
|
|
31
|
-
|
|
32
|
-
- **Push, not polling.** The gateway sends changes as they happen, so a setpoint changed at the wall controller or in the NaviLink app reaches HomeKit in about a second. The poll is only a backstop
|
|
33
|
-
- **A rejected password is never retried.** Repeating a wrong password at a cloud is how an account gets locked. The plugin stops, says so once, and waits for you
|
|
34
|
-
- **Credentials are renewed on a clock,** a few minutes before they expire
|
|
35
|
-
- **A connected socket is not a live appliance.** Readings carry the time they were taken, and a stale one becomes No Response instead
|
|
36
|
-
- **State:** No Response until the appliance has actually been read, and not a value it cannot confirm
|
|
37
|
-
- **Never loses your rooms:** a broken config disables the platform without unregistering anything
|
|
38
|
-
- **A REST circuit breaker** fails fast during a sustained cloud outage. The log is `Circuit breaker CLOSED -> OPEN`, then `HALF_OPEN` and `CLOSED` when it recovers. Firmware reads do not trip it
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
### Quality
|
|
43
|
-
|
|
44
|
-
- **Strict TypeScript,** with `noUncheckedIndexedAccess` and type-aware lint
|
|
45
|
-
- **Tested:** a behavioural Jest suite against fixtures recorded from real hardware, with a guard that fails the build if anything identifying reaches them
|
|
46
|
-
- **No analytics:** nothing is sent anywhere except Navien's own service
|
|
47
|
-
- **One runtime dependency,** Homebridge's own UI helper. The MQTT client is a small in-repo codec, not a `mqtt.js` dependency tree
|
|
48
|
-
|
|
49
|
-
Every accessory, field and log line is documented in [Detailed documentation](docs/README-DETAILED.md).
|
|
27
|
+
The [detailed documentation](docs/README-DETAILED.md) describes every accessory, setting and log line.
|
|
50
28
|
|
|
51
29
|
## Quick Start
|
|
52
30
|
|
|
53
|
-
|
|
54
|
-
|
|
55
31
|
### 1. Install
|
|
56
32
|
|
|
57
33
|
**Homebridge UI** (recommended): Plugins → Search `homebridge-navilink` → Install
|
|
@@ -60,8 +36,6 @@ Every accessory, field and log line is documented in [Detailed documentation](do
|
|
|
60
36
|
npm install -g homebridge-navilink
|
|
61
37
|
```
|
|
62
38
|
|
|
63
|
-
|
|
64
|
-
|
|
65
39
|
### 2. Prepare your appliance
|
|
66
40
|
|
|
67
41
|
Your NaviLink gateway must be connected and showing as online in the NaviLink app. Nothing needs enabling: the plugin uses the same service the app does. If the app cannot see the appliance, neither can this.
|
|
@@ -94,74 +68,15 @@ Or in `config.json`:
|
|
|
94
68
|
}
|
|
95
69
|
```
|
|
96
70
|
|
|
97
|
-
The `id` is your gateway's MAC address and the channel. The settings page writes it for you
|
|
98
|
-
|
|
99
|
-
See the [full configuration reference](docs/README-DETAILED.md#full-configuration-reference) for every option.
|
|
71
|
+
The `id` is your gateway's MAC address and the channel. The settings page writes it for you. The [configuration reference](docs/README-DETAILED.md#full-configuration-reference) lists every option.
|
|
100
72
|
|
|
101
73
|
### 4. Restart Homebridge
|
|
102
74
|
|
|
103
75
|
Accessories appear in the Home app after restart, showing No Response for the few seconds it takes to sign in and read the first status frame.
|
|
104
76
|
|
|
105
|
-
## Supported
|
|
106
|
-
|
|
107
|
-
Any Navien appliance that the NaviLink app controls. The cloud interface is the same for all of them; what differs is which capabilities an appliance reports.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
| Verified against | Notes |
|
|
111
|
-
| ----------------- | ------------------------------------------------- |
|
|
112
|
-
| **NCB-240E (NG)** | Combi: hot water and space heating, firmware 4352 |
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Other families are decoded from the same table the NaviLink app uses and are expected to work, but nobody has confirmed them here:
|
|
77
|
+
## Supported devices
|
|
116
78
|
|
|
117
|
-
|
|
118
|
-
| Family | Expected |
|
|
119
|
-
| ------------------ | ------------------------------------------------------------------------------ |
|
|
120
|
-
| **NPE, NPE2, NPN** | Tankless water heaters. Hot water only; the heating thermostat disables itself |
|
|
121
|
-
| **NCB-H** | Combi with a buffer tank |
|
|
122
|
-
| **NHB** | Boiler. Space heating only |
|
|
123
|
-
| **NFB, NFC** | Boilers with hot water and space heating |
|
|
124
|
-
| **NVW** | Water heater with a tank |
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
If yours is not listed, it will most likely work. Please open an issue with the output of `node scripts/capture-fixture.js --redact` either way, so the table can say so with confidence.
|
|
128
|
-
|
|
129
|
-
## Configuration Options
|
|
130
|
-
|
|
131
|
-
Only one `NaviLink` platform block is supported. It can hold as many appliances as the account owns.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
| Option | Required to run | Description |
|
|
135
|
-
| ----------------------------- | --------------- | ------------------------------------------------------------------------------- |
|
|
136
|
-
| `name` | ✓ | Plugin instance name shown in Homebridge logs |
|
|
137
|
-
| `email` | ✓ | Your NaviLink account address. Needed before the plugin signs in |
|
|
138
|
-
| `password` | ✓ | Your NaviLink password. Needed before the plugin signs in |
|
|
139
|
-
| `devices` | ✓ | List of appliances. Needed before the plugin signs in |
|
|
140
|
-
| `options.statusIntervalSec` | | Backstop refresh, 30–3600 seconds (default 120) |
|
|
141
|
-
| `options.readOnly` | | Report everything, change nothing (default false) |
|
|
142
|
-
| `options.allowPowerOff` | | Let HomeKit switch the appliance off (default false) |
|
|
143
|
-
| `options.diagnosticsInterval` | | Seconds between health lines in the log; `0` is off (default), else `30`–`3600` |
|
|
144
|
-
| `options.structuredLogs` | | With diagnostics, also emit a JSON line (default false) |
|
|
145
|
-
| `options.accessoryPrefix` | | Prefix for every HomeKit name. Blank uses each appliance's name |
|
|
146
|
-
| `options.pagerdutySignals` | | Send alert conditions to homebridge-pagerduty (default off). See [PagerDuty](#pagerduty) |
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
Each entry in `devices[]` takes `id` and `name`, plus an optional `channel` and one flag per accessory: `dhw`, `heating`, `power`, `recirculation`, `fault`, `temperatureSensors` and `outdoorSensor`. The [detailed documentation](docs/README-DETAILED.md#devices-entries) describes each one.
|
|
150
|
-
|
|
151
|
-
## PagerDuty
|
|
152
|
-
|
|
153
|
-
This plugin can page through [homebridge-pagerduty](https://github.com/tbaur/homebridge-pagerduty) when something needs attention. It needs Node 22.13 or later.
|
|
154
|
-
|
|
155
|
-
1. Turn on **Send Signals to PagerDuty** (`options.pagerdutySignals`) in this plugin's settings.
|
|
156
|
-
2. Restart Homebridge.
|
|
157
|
-
3. In homebridge-pagerduty's settings, allow homebridge-navilink to page, save, and restart Homebridge again. [Signals from other plugins](https://github.com/tbaur/homebridge-pagerduty/blob/main/docs/SIGNALS.md#let-a-plugin-page) explains each step and what else you can set for each signal.
|
|
158
|
-
|
|
159
|
-
Each condition below then opens a PagerDuty alert while it is present, and resolves it when it clears.
|
|
160
|
-
|
|
161
|
-
| Signal | Severity | Active when |
|
|
162
|
-
| --- | --- | --- |
|
|
163
|
-
| `fault.<gateway>.<channel>` | critical | That appliance's latest status frame has a non-zero error code |
|
|
164
|
-
| `auth-failed` | error | NaviLink rejected the email or password and sign-in has stopped |
|
|
79
|
+
Any Navien appliance that the NaviLink app controls. Confirmed on an NCB-240E (firmware 4352). Other families are decoded from the same table the app uses. The [device table](docs/README-DETAILED.md#supported-devices) lists what each family is expected to expose.
|
|
165
80
|
|
|
166
81
|
## Not Working?
|
|
167
82
|
|
|
@@ -176,7 +91,7 @@ The [full troubleshooting list](docs/README-DETAILED.md#troubleshooting) covers
|
|
|
176
91
|
|
|
177
92
|
## Security
|
|
178
93
|
|
|
179
|
-
This plugin needs your NaviLink password, stores it in the Homebridge configuration file as every Homebridge credential is stored, and sends it to Navien to sign in. It is never written to the Homebridge log, never put into an accessory's cache, and redacted from anything the plugin prints.
|
|
94
|
+
This plugin needs your NaviLink password, stores it in the Homebridge configuration file as every Homebridge credential is stored, and sends it to Navien to sign in. It is never written to the Homebridge log, never put into an accessory's cache, and redacted from anything the plugin prints. [SECURITY.md](SECURITY.md) has the detail, including what a capture contains and why the fixtures in this repository are pseudonymised.
|
|
180
95
|
|
|
181
96
|
## Requirements
|
|
182
97
|
|
|
@@ -186,8 +101,6 @@ This plugin needs your NaviLink password, stores it in the Homebridge configurat
|
|
|
186
101
|
- A NaviLink account with at least one gateway online
|
|
187
102
|
- A working internet connection
|
|
188
103
|
|
|
189
|
-
|
|
190
|
-
|
|
191
104
|
## More Info
|
|
192
105
|
|
|
193
106
|
- [Detailed documentation](docs/README-DETAILED.md)
|
|
@@ -197,14 +110,10 @@ This plugin needs your NaviLink password, stores it in the Homebridge configurat
|
|
|
197
110
|
- [Report Issues](https://github.com/tbaur/homebridge-navilink/issues)
|
|
198
111
|
- [Changelog](CHANGELOG.md)
|
|
199
112
|
|
|
200
|
-
|
|
201
|
-
|
|
202
113
|
## Trademarks
|
|
203
114
|
|
|
204
115
|
homebridge-navilink is an independent project. It is not affiliated with or endorsed by Navien. Navien and NaviLink are trademarks of Kyungdong Navien Co., Ltd.
|
|
205
116
|
|
|
206
|
-
|
|
207
|
-
|
|
208
117
|
## License
|
|
209
118
|
|
|
210
119
|
Copyright 2026 tbaur
|
|
@@ -94,7 +94,7 @@ class BaseAccessory {
|
|
|
94
94
|
}
|
|
95
95
|
/** The HAP error that makes a tile show No Response. */
|
|
96
96
|
communicationFailure() {
|
|
97
|
-
return new this.host.api.hap.HapStatusError(
|
|
97
|
+
return new this.host.api.hap.HapStatusError(this.host.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Run a write, answering HomeKit within its budget.
|
|
@@ -207,7 +207,7 @@ class BaseAccessory {
|
|
|
207
207
|
*/
|
|
208
208
|
markUnavailable() {
|
|
209
209
|
const { HapStatusError, HAPStatus } = this.host.api.hap;
|
|
210
|
-
const error = new HapStatusError(
|
|
210
|
+
const error = new HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
211
211
|
const infoUuid = this.host.hap.Service.AccessoryInformation.UUID;
|
|
212
212
|
for (const service of this.accessory.services) {
|
|
213
213
|
if (service.UUID === infoUuid) {
|
|
@@ -8,27 +8,35 @@
|
|
|
8
8
|
* homebridge-pagerduty signals.
|
|
9
9
|
*
|
|
10
10
|
* The store writer is the copied module. This file decides which conditions
|
|
11
|
-
* are worth a page
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* are worth a page. A fault signal is the appliance's name from config. A
|
|
12
|
+
* fault still in the store under a name that is no longer configured is
|
|
13
|
+
* cleared from the store itself, so this plugin keeps no list of its own.
|
|
14
14
|
*/
|
|
15
|
-
import type { PagerDutySignalsOptions, SignalState } from './pagerduty-signals';
|
|
16
|
-
/** Logged once, with the pattern rather than each
|
|
17
|
-
export declare const PAGERDUTY_STARTUP_LOG = "homebridge-pagerduty support is enabled (fault.<
|
|
15
|
+
import type { PagerDutySignalsOptions, SignalSeverity, SignalState } from './pagerduty-signals';
|
|
16
|
+
/** Logged once, with the pattern rather than each appliance name. */
|
|
17
|
+
export declare const PAGERDUTY_STARTUP_LOG = "homebridge-pagerduty support is enabled (fault.<name>, auth-failed)";
|
|
18
18
|
export declare const SIGNAL_AUTH_FAILED = "auth-failed";
|
|
19
|
+
/** One row this plugin has already written. */
|
|
20
|
+
export interface ListedSignal {
|
|
21
|
+
signal: string;
|
|
22
|
+
active: boolean;
|
|
23
|
+
severity: SignalSeverity;
|
|
24
|
+
summary: string;
|
|
25
|
+
}
|
|
19
26
|
/** The subset of the store writer this class uses. */
|
|
20
27
|
export interface SignalWriter {
|
|
21
28
|
write(signal: string, state: SignalState): void;
|
|
29
|
+
list(): readonly ListedSignal[];
|
|
22
30
|
close(): void;
|
|
23
31
|
}
|
|
24
32
|
/**
|
|
25
|
-
* The signal name for one appliance.
|
|
33
|
+
* The signal name for one appliance, from its configured name.
|
|
26
34
|
*
|
|
27
|
-
* The
|
|
28
|
-
*
|
|
29
|
-
*
|
|
35
|
+
* The store only accepts lowercase letters, digits, `.`, `_` and `-`. A space
|
|
36
|
+
* or anything else becomes a hyphen. Undefined when the name has none of the
|
|
37
|
+
* accepted characters.
|
|
30
38
|
*/
|
|
31
|
-
export declare function faultSignalName(
|
|
39
|
+
export declare function faultSignalName(name: string): string | undefined;
|
|
32
40
|
/**
|
|
33
41
|
* The PagerDuty title for an appliance fault.
|
|
34
42
|
*
|
|
@@ -36,8 +44,6 @@ export declare function faultSignalName(deviceId: string): string | undefined;
|
|
|
36
44
|
* because a saved PagerDuty message is fixed text and would keep an old code.
|
|
37
45
|
*/
|
|
38
46
|
export declare function faultSummary(name: string): string;
|
|
39
|
-
/** Where the remembered appliance list lives. Local storage, not the repo. */
|
|
40
|
-
export declare function rememberedDevicesPath(storagePath: string): string;
|
|
41
47
|
/**
|
|
42
48
|
* Fault and sign-in signals for this plugin.
|
|
43
49
|
*
|
|
@@ -48,29 +54,42 @@ export declare function rememberedDevicesPath(storagePath: string): string;
|
|
|
48
54
|
*/
|
|
49
55
|
export declare class NaviLinkSignals {
|
|
50
56
|
private readonly writer;
|
|
51
|
-
private readonly storagePath;
|
|
52
57
|
private readonly log;
|
|
53
58
|
private readonly warned;
|
|
54
|
-
|
|
59
|
+
/** Signal name for each configured appliance, including collision suffixes. */
|
|
60
|
+
private signalFor;
|
|
61
|
+
/** Appliances that had a name but no free signal. */
|
|
62
|
+
private readonly unassigned;
|
|
63
|
+
constructor(writer: SignalWriter, log: {
|
|
55
64
|
warn(message: string): void;
|
|
56
65
|
});
|
|
57
66
|
/**
|
|
58
|
-
* Clear fault signals
|
|
59
|
-
*
|
|
60
|
-
* fault state is not known
|
|
67
|
+
* Clear fault signals whose names are no longer configured.
|
|
68
|
+
*
|
|
69
|
+
* Does not write the current appliances: their fault state is not known
|
|
70
|
+
* until a status frame arrives.
|
|
61
71
|
*/
|
|
62
72
|
syncDevices(devices: readonly {
|
|
63
73
|
id: string;
|
|
64
74
|
name: string;
|
|
65
75
|
}[]): void;
|
|
76
|
+
/**
|
|
77
|
+
* Resolve every active signal.
|
|
78
|
+
*
|
|
79
|
+
* Used when the user turns signals off. A restart with the setting on must
|
|
80
|
+
* not do this, or a lockout that is still in progress would resolve and
|
|
81
|
+
* open again.
|
|
82
|
+
*/
|
|
83
|
+
clearActive(): void;
|
|
66
84
|
/** Record whether this appliance's latest status frame has an error code. */
|
|
67
85
|
setFault(deviceId: string, name: string, isActive: boolean): void;
|
|
68
86
|
/** Record whether NaviLink has rejected the account and stopped sign-in. */
|
|
69
87
|
setAuthenticationRejected(isRejected: boolean): void;
|
|
70
88
|
/** Close the store. Does not clear any signal. */
|
|
71
89
|
close(): void;
|
|
72
|
-
private
|
|
73
|
-
private
|
|
90
|
+
private listedSignals;
|
|
91
|
+
private warnUnusable;
|
|
92
|
+
private warnTaken;
|
|
74
93
|
private warnOnce;
|
|
75
94
|
}
|
|
76
95
|
/** Build the signals for this plugin, backed by the homebridge-pagerduty store. */
|
package/dist/navilink-signals.js
CHANGED
|
@@ -9,42 +9,40 @@
|
|
|
9
9
|
* homebridge-pagerduty signals.
|
|
10
10
|
*
|
|
11
11
|
* The store writer is the copied module. This file decides which conditions
|
|
12
|
-
* are worth a page
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* are worth a page. A fault signal is the appliance's name from config. A
|
|
13
|
+
* fault still in the store under a name that is no longer configured is
|
|
14
|
+
* cleared from the store itself, so this plugin keeps no list of its own.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.NaviLinkSignals = exports.SIGNAL_AUTH_FAILED = exports.PAGERDUTY_STARTUP_LOG = void 0;
|
|
18
18
|
exports.faultSignalName = faultSignalName;
|
|
19
19
|
exports.faultSummary = faultSummary;
|
|
20
|
-
exports.rememberedDevicesPath = rememberedDevicesPath;
|
|
21
20
|
exports.createNaviLinkSignals = createNaviLinkSignals;
|
|
22
|
-
const node_fs_1 = require("node:fs");
|
|
23
|
-
const node_path_1 = require("node:path");
|
|
24
21
|
const identity_1 = require("./api/identity");
|
|
25
22
|
const pagerduty_signals_1 = require("./pagerduty-signals");
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const validators_1 = require("./utils/validators");
|
|
24
|
+
/** Logged once, with the pattern rather than each appliance name. */
|
|
25
|
+
exports.PAGERDUTY_STARTUP_LOG = 'homebridge-pagerduty support is enabled (fault.<name>, auth-failed)';
|
|
28
26
|
exports.SIGNAL_AUTH_FAILED = 'auth-failed';
|
|
29
27
|
const AUTH_FAILED_SUMMARY = 'NaviLink rejected the account email or password. Sign-in has stopped until it is corrected in Homebridge.';
|
|
30
28
|
const FAULT_SUMMARY_FALLBACK = 'Navien appliance is reporting a fault';
|
|
31
|
-
/**
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
29
|
+
/** Signal names the store will accept: lowercase, digits, and . _ - */
|
|
30
|
+
const MAX_SIGNAL_LENGTH = 64;
|
|
31
|
+
const FAULT_PREFIX = 'fault.';
|
|
32
|
+
const MAX_SLUG_LENGTH = MAX_SIGNAL_LENGTH - FAULT_PREFIX.length;
|
|
35
33
|
/**
|
|
36
|
-
* The signal name for one appliance.
|
|
34
|
+
* The signal name for one appliance, from its configured name.
|
|
37
35
|
*
|
|
38
|
-
* The
|
|
39
|
-
*
|
|
40
|
-
*
|
|
36
|
+
* The store only accepts lowercase letters, digits, `.`, `_` and `-`. A space
|
|
37
|
+
* or anything else becomes a hyphen. Undefined when the name has none of the
|
|
38
|
+
* accepted characters.
|
|
41
39
|
*/
|
|
42
|
-
function faultSignalName(
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
40
|
+
function faultSignalName(name) {
|
|
41
|
+
const slug = faultSlug(name);
|
|
42
|
+
if (slug === undefined) {
|
|
45
43
|
return undefined;
|
|
46
44
|
}
|
|
47
|
-
return
|
|
45
|
+
return `${FAULT_PREFIX}${slug}`;
|
|
48
46
|
}
|
|
49
47
|
/**
|
|
50
48
|
* The PagerDuty title for an appliance fault.
|
|
@@ -53,16 +51,12 @@ function faultSignalName(deviceId) {
|
|
|
53
51
|
* because a saved PagerDuty message is fixed text and would keep an old code.
|
|
54
52
|
*/
|
|
55
53
|
function faultSummary(name) {
|
|
56
|
-
const cleaned = name.replace(
|
|
54
|
+
const cleaned = name.replace(/[\u0000-\u001F\u007F]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
57
55
|
if (cleaned.length === 0) {
|
|
58
56
|
return FAULT_SUMMARY_FALLBACK;
|
|
59
57
|
}
|
|
60
58
|
return `Navien ${cleaned} is reporting a fault`;
|
|
61
59
|
}
|
|
62
|
-
/** Where the remembered appliance list lives. Local storage, not the repo. */
|
|
63
|
-
function rememberedDevicesPath(storagePath) {
|
|
64
|
-
return (0, node_path_1.join)(storagePath, REMEMBERED_DIR, REMEMBERED_FILE);
|
|
65
|
-
}
|
|
66
60
|
/**
|
|
67
61
|
* Fault and sign-in signals for this plugin.
|
|
68
62
|
*
|
|
@@ -73,33 +67,75 @@ function rememberedDevicesPath(storagePath) {
|
|
|
73
67
|
*/
|
|
74
68
|
class NaviLinkSignals {
|
|
75
69
|
writer;
|
|
76
|
-
storagePath;
|
|
77
70
|
log;
|
|
78
71
|
warned = new Set();
|
|
79
|
-
|
|
72
|
+
/** Signal name for each configured appliance, including collision suffixes. */
|
|
73
|
+
signalFor = new Map();
|
|
74
|
+
/** Appliances that had a name but no free signal. */
|
|
75
|
+
unassigned = new Set();
|
|
76
|
+
constructor(writer, log) {
|
|
80
77
|
this.writer = writer;
|
|
81
|
-
this.storagePath = storagePath;
|
|
82
78
|
this.log = log;
|
|
83
79
|
}
|
|
84
80
|
/**
|
|
85
|
-
* Clear fault signals
|
|
86
|
-
*
|
|
87
|
-
* fault state is not known
|
|
81
|
+
* Clear fault signals whose names are no longer configured.
|
|
82
|
+
*
|
|
83
|
+
* Does not write the current appliances: their fault state is not known
|
|
84
|
+
* until a status frame arrives.
|
|
88
85
|
*/
|
|
89
86
|
syncDevices(devices) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
for (const
|
|
93
|
-
if (
|
|
94
|
-
this.
|
|
87
|
+
this.unassigned.clear();
|
|
88
|
+
this.signalFor = assignFaultSignals(devices);
|
|
89
|
+
for (const device of devices) {
|
|
90
|
+
if (faultSlug(device.name) === undefined) {
|
|
91
|
+
this.warnUnusable(device.name);
|
|
92
|
+
}
|
|
93
|
+
else if (!this.signalFor.has(device.id)) {
|
|
94
|
+
this.unassigned.add(device.id);
|
|
95
|
+
this.warnTaken(device.name);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const current = new Set(this.signalFor.values());
|
|
99
|
+
for (const row of this.listedSignals()) {
|
|
100
|
+
if (!row.signal.startsWith(FAULT_PREFIX) || !row.active || current.has(row.signal)) {
|
|
101
|
+
continue;
|
|
95
102
|
}
|
|
103
|
+
this.writer.write(row.signal, {
|
|
104
|
+
active: false,
|
|
105
|
+
severity: 'critical',
|
|
106
|
+
summary: row.summary.length > 0 ? row.summary : FAULT_SUMMARY_FALLBACK,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Resolve every active signal.
|
|
112
|
+
*
|
|
113
|
+
* Used when the user turns signals off. A restart with the setting on must
|
|
114
|
+
* not do this, or a lockout that is still in progress would resolve and
|
|
115
|
+
* open again.
|
|
116
|
+
*/
|
|
117
|
+
clearActive() {
|
|
118
|
+
for (const row of this.listedSignals()) {
|
|
119
|
+
if (!row.active) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
this.writer.write(row.signal, {
|
|
123
|
+
active: false,
|
|
124
|
+
severity: row.severity,
|
|
125
|
+
summary: row.summary.length > 0 ? row.summary : FAULT_SUMMARY_FALLBACK,
|
|
126
|
+
});
|
|
96
127
|
}
|
|
97
|
-
this.writeRemembered(current);
|
|
98
128
|
}
|
|
99
129
|
/** Record whether this appliance's latest status frame has an error code. */
|
|
100
130
|
setFault(deviceId, name, isActive) {
|
|
101
|
-
|
|
131
|
+
if (this.unassigned.has(deviceId)) {
|
|
132
|
+
this.warnTaken(name);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const assigned = this.signalFor.get(deviceId);
|
|
136
|
+
const signal = assigned ?? (this.signalFor.size === 0 ? faultSignalName(name) : undefined);
|
|
102
137
|
if (signal === undefined) {
|
|
138
|
+
this.warnUnusable(name);
|
|
103
139
|
return;
|
|
104
140
|
}
|
|
105
141
|
this.writer.write(signal, {
|
|
@@ -120,53 +156,20 @@ class NaviLinkSignals {
|
|
|
120
156
|
close() {
|
|
121
157
|
this.writer.close();
|
|
122
158
|
}
|
|
123
|
-
|
|
124
|
-
const file = rememberedDevicesPath(this.storagePath);
|
|
125
|
-
if (!(0, node_fs_1.existsSync)(file)) {
|
|
126
|
-
return [];
|
|
127
|
-
}
|
|
159
|
+
listedSignals() {
|
|
128
160
|
try {
|
|
129
|
-
|
|
130
|
-
const devices = rememberedDevices(parsed);
|
|
131
|
-
if (devices === undefined) {
|
|
132
|
-
this.warnOnce('PagerDuty device list could not be read; removed appliances will not be cleared this start');
|
|
133
|
-
return [];
|
|
134
|
-
}
|
|
135
|
-
return devices;
|
|
161
|
+
return this.writer.list();
|
|
136
162
|
}
|
|
137
163
|
catch {
|
|
138
|
-
this.warnOnce('PagerDuty
|
|
164
|
+
this.warnOnce('PagerDuty signals could not be read; removed appliances will not be cleared this start');
|
|
139
165
|
return [];
|
|
140
166
|
}
|
|
141
167
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
(0, node_fs_1.mkdirSync)(dir, { recursive: true, mode: 0o700 });
|
|
148
|
-
(0, node_fs_1.chmodSync)(dir, 0o700);
|
|
149
|
-
const payload = JSON.stringify({ devices });
|
|
150
|
-
const fd = (0, node_fs_1.openSync)(temporary, 'w', 0o600);
|
|
151
|
-
try {
|
|
152
|
-
(0, node_fs_1.writeFileSync)(fd, payload);
|
|
153
|
-
}
|
|
154
|
-
finally {
|
|
155
|
-
(0, node_fs_1.closeSync)(fd);
|
|
156
|
-
}
|
|
157
|
-
(0, node_fs_1.chmodSync)(temporary, 0o600);
|
|
158
|
-
(0, node_fs_1.renameSync)(temporary, file);
|
|
159
|
-
(0, node_fs_1.chmodSync)(file, 0o600);
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
try {
|
|
163
|
-
(0, node_fs_1.unlinkSync)(temporary);
|
|
164
|
-
}
|
|
165
|
-
catch {
|
|
166
|
-
// The temporary file may not exist. The warning below is the outcome.
|
|
167
|
-
}
|
|
168
|
-
this.warnOnce('PagerDuty device list could not be saved');
|
|
169
|
-
}
|
|
168
|
+
warnUnusable(name) {
|
|
169
|
+
this.warnOnce(`PagerDuty fault signal skipped for ${(0, validators_1.forLog)(name)}; the name has no usable characters`);
|
|
170
|
+
}
|
|
171
|
+
warnTaken(name) {
|
|
172
|
+
this.warnOnce(`PagerDuty fault signal skipped for ${(0, validators_1.forLog)(name)}; its signal name is already in use`);
|
|
170
173
|
}
|
|
171
174
|
warnOnce(message) {
|
|
172
175
|
if (this.warned.has(message)) {
|
|
@@ -179,32 +182,91 @@ class NaviLinkSignals {
|
|
|
179
182
|
exports.NaviLinkSignals = NaviLinkSignals;
|
|
180
183
|
/** Build the signals for this plugin, backed by the homebridge-pagerduty store. */
|
|
181
184
|
function createNaviLinkSignals(options) {
|
|
182
|
-
return new NaviLinkSignals(new pagerduty_signals_1.PagerDutySignals(options), options.
|
|
185
|
+
return new NaviLinkSignals(new pagerduty_signals_1.PagerDutySignals(options), options.log);
|
|
183
186
|
}
|
|
184
|
-
/**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
/** The part of a name the store will accept, or undefined when nothing is left. */
|
|
188
|
+
function faultSlug(name) {
|
|
189
|
+
const slug = name
|
|
190
|
+
.trim()
|
|
191
|
+
.toLowerCase()
|
|
192
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
193
|
+
.replace(/-+/g, '-')
|
|
194
|
+
.replace(/^[.-]+|[.-]+$/g, '')
|
|
195
|
+
.slice(0, MAX_SLUG_LENGTH)
|
|
196
|
+
.replace(/[.-]+$/g, '');
|
|
197
|
+
if (slug.length === 0 || !/^[a-z0-9]/.test(slug)) {
|
|
191
198
|
return undefined;
|
|
192
199
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
return slug;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* One signal per appliance.
|
|
204
|
+
*
|
|
205
|
+
* The name is the key. Two appliances whose names slug the same way get the
|
|
206
|
+
* channel appended, so each still has its own row. The order follows the
|
|
207
|
+
* device id, which does not move when the config is reordered.
|
|
208
|
+
*/
|
|
209
|
+
function assignFaultSignals(devices) {
|
|
210
|
+
const ready = devices.flatMap((device) => {
|
|
211
|
+
const slug = faultSlug(device.name);
|
|
212
|
+
return slug === undefined ? [] : [{ id: device.id, slug }];
|
|
213
|
+
});
|
|
214
|
+
const shared = sharedSlugs(ready);
|
|
215
|
+
const used = new Set();
|
|
216
|
+
const assigned = new Map();
|
|
217
|
+
const ordered = [...ready].sort((left, right) => compareId(left.id, right.id));
|
|
218
|
+
for (const device of ordered) {
|
|
219
|
+
const channel = (0, identity_1.parseDeviceId)(device.id)?.channel;
|
|
220
|
+
const base = shared.has(device.slug) && channel !== undefined
|
|
221
|
+
? `${FAULT_PREFIX}${device.slug}.${channel}`
|
|
222
|
+
: `${FAULT_PREFIX}${device.slug}`;
|
|
223
|
+
const signal = uniqueSignal(base, used);
|
|
224
|
+
if (signal === undefined) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
used.add(signal);
|
|
228
|
+
assigned.set(device.id, signal);
|
|
196
229
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
230
|
+
return assigned;
|
|
231
|
+
}
|
|
232
|
+
function sharedSlugs(devices) {
|
|
233
|
+
const seen = new Set();
|
|
234
|
+
const shared = new Set();
|
|
235
|
+
for (const device of devices) {
|
|
236
|
+
if (seen.has(device.slug)) {
|
|
237
|
+
shared.add(device.slug);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
seen.add(device.slug);
|
|
201
241
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
242
|
+
}
|
|
243
|
+
return shared;
|
|
244
|
+
}
|
|
245
|
+
function compareId(left, right) {
|
|
246
|
+
if (left < right) {
|
|
247
|
+
return -1;
|
|
248
|
+
}
|
|
249
|
+
if (left > right) {
|
|
250
|
+
return 1;
|
|
251
|
+
}
|
|
252
|
+
return 0;
|
|
253
|
+
}
|
|
254
|
+
/** Shorten a signal to the column limit without leaving a trailing separator. */
|
|
255
|
+
function fitSignal(signal) {
|
|
256
|
+
return signal.slice(0, MAX_SIGNAL_LENGTH).replace(/[.-]+$/g, '');
|
|
257
|
+
}
|
|
258
|
+
function uniqueSignal(base, used) {
|
|
259
|
+
const first = fitSignal(base);
|
|
260
|
+
if (first.length > 0 && !used.has(first)) {
|
|
261
|
+
return first;
|
|
262
|
+
}
|
|
263
|
+
for (let suffix = 2; suffix < 100; suffix += 1) {
|
|
264
|
+
const tail = `.${suffix}`;
|
|
265
|
+
const stem = fitSignal(base.slice(0, MAX_SIGNAL_LENGTH - tail.length));
|
|
266
|
+
const candidate = `${stem}${tail}`;
|
|
267
|
+
if (candidate.length > 0 && !used.has(candidate)) {
|
|
268
|
+
return candidate;
|
|
206
269
|
}
|
|
207
|
-
parsed.push({ id, name });
|
|
208
270
|
}
|
|
209
|
-
return
|
|
271
|
+
return undefined;
|
|
210
272
|
}
|
|
@@ -28,6 +28,18 @@ export declare class PagerDutySignals {
|
|
|
28
28
|
write(signal: string, state: SignalState): void;
|
|
29
29
|
/** Close the connection. Call on Homebridge `shutdown`. Never clears a signal. */
|
|
30
30
|
close(): void;
|
|
31
|
+
/**
|
|
32
|
+
* This plugin's rows, or an empty list when the store does not exist yet.
|
|
33
|
+
*
|
|
34
|
+
* A removed appliance is cleared from these rows. Nothing is created here,
|
|
35
|
+
* so a start with nothing to say leaves no store.
|
|
36
|
+
*/
|
|
37
|
+
list(): readonly {
|
|
38
|
+
signal: string;
|
|
39
|
+
active: boolean;
|
|
40
|
+
severity: SignalSeverity;
|
|
41
|
+
summary: string;
|
|
42
|
+
}[];
|
|
31
43
|
private open;
|
|
32
44
|
private disable;
|
|
33
45
|
private warnOnce;
|
|
@@ -60,6 +60,40 @@ class PagerDutySignals {
|
|
|
60
60
|
this.db?.close();
|
|
61
61
|
this.db = undefined;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* This plugin's rows, or an empty list when the store does not exist yet.
|
|
65
|
+
*
|
|
66
|
+
* A removed appliance is cleared from these rows. Nothing is created here,
|
|
67
|
+
* so a start with nothing to say leaves no store.
|
|
68
|
+
*/
|
|
69
|
+
list() {
|
|
70
|
+
if (this.isDisabled) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
const file = (0, node_path_1.join)(this.options.storagePath, STORE_DIR, INTERFACE_ID, STORE_FILE);
|
|
74
|
+
if (!(0, node_fs_1.existsSync)(file)) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const db = this.db ?? this.open();
|
|
79
|
+
const rows = db.prepare('SELECT signal, active, severity, summary FROM signals WHERE plugin = ? ORDER BY signal').all(this.options.plugin);
|
|
80
|
+
return rows.flatMap((row) => {
|
|
81
|
+
if (!isSeverity(row.severity)) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
return [{
|
|
85
|
+
signal: row.signal,
|
|
86
|
+
active: row.active === 1,
|
|
87
|
+
severity: row.severity,
|
|
88
|
+
summary: row.summary,
|
|
89
|
+
}];
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.warnOnce(`PagerDuty signals could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
63
97
|
open() {
|
|
64
98
|
// Loaded here, not imported at the top, so the plugin still loads on a
|
|
65
99
|
// Node version without node:sqlite.
|
|
@@ -99,3 +133,6 @@ class PagerDutySignals {
|
|
|
99
133
|
}
|
|
100
134
|
}
|
|
101
135
|
exports.PagerDutySignals = PagerDutySignals;
|
|
136
|
+
function isSeverity(value) {
|
|
137
|
+
return value === 'info' || value === 'warning' || value === 'error' || value === 'critical';
|
|
138
|
+
}
|
package/dist/platform.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ export declare class NaviLinkPlatform implements DynamicPlatformPlugin, Accessor
|
|
|
48
48
|
private signals;
|
|
49
49
|
/** The startup line is once per process, including a second call to start. */
|
|
50
50
|
private hasAnnouncedPagerDuty;
|
|
51
|
+
/** The missing-storage warning is once per process. */
|
|
52
|
+
private hasWarnedMissingSignalStorage;
|
|
51
53
|
private readonly platformConfig;
|
|
52
54
|
private readonly diagnostics;
|
|
53
55
|
private diagnosticsTimer;
|
|
@@ -67,11 +69,18 @@ export declare class NaviLinkPlatform implements DynamicPlatformPlugin, Accessor
|
|
|
67
69
|
/**
|
|
68
70
|
* Open PagerDuty signals when the user asked for them.
|
|
69
71
|
*
|
|
70
|
-
* The log line comes before sign-in,
|
|
71
|
-
*
|
|
72
|
-
*
|
|
72
|
+
* The log line comes before sign-in, and only once a storage directory is
|
|
73
|
+
* known. Current fault state is not written here: that waits for a status
|
|
74
|
+
* frame, so a restart during a lockout does not resolve the page.
|
|
75
|
+
*
|
|
76
|
+
* Turning the setting off clears active rows. A restart with the setting
|
|
77
|
+
* on does not, or a page that is still true would resolve and open again.
|
|
73
78
|
*/
|
|
74
79
|
private openPagerDuty;
|
|
80
|
+
/** Resolve every active signal. Leaves the store alone when it is not there. */
|
|
81
|
+
private retirePagerDuty;
|
|
82
|
+
private storagePathForSignals;
|
|
83
|
+
private warnMissingSignalStorage;
|
|
75
84
|
/** A status frame is the first moment a fault is known, tile or no tile. */
|
|
76
85
|
private noteFault;
|
|
77
86
|
/** Keep cached accessories registered when configuration is unusable. */
|
package/dist/platform.js
CHANGED
|
@@ -67,6 +67,8 @@ class NaviLinkPlatform {
|
|
|
67
67
|
signals;
|
|
68
68
|
/** The startup line is once per process, including a second call to start. */
|
|
69
69
|
hasAnnouncedPagerDuty = false;
|
|
70
|
+
/** The missing-storage warning is once per process. */
|
|
71
|
+
hasWarnedMissingSignalStorage = false;
|
|
70
72
|
platformConfig;
|
|
71
73
|
diagnostics;
|
|
72
74
|
diagnosticsTimer;
|
|
@@ -171,12 +173,21 @@ class NaviLinkPlatform {
|
|
|
171
173
|
/**
|
|
172
174
|
* Open PagerDuty signals when the user asked for them.
|
|
173
175
|
*
|
|
174
|
-
* The log line comes before sign-in,
|
|
175
|
-
*
|
|
176
|
-
*
|
|
176
|
+
* The log line comes before sign-in, and only once a storage directory is
|
|
177
|
+
* known. Current fault state is not written here: that waits for a status
|
|
178
|
+
* frame, so a restart during a lockout does not resolve the page.
|
|
179
|
+
*
|
|
180
|
+
* Turning the setting off clears active rows. A restart with the setting
|
|
181
|
+
* on does not, or a page that is still true would resolve and open again.
|
|
177
182
|
*/
|
|
178
183
|
openPagerDuty(devices) {
|
|
179
184
|
if (!this.options.pagerdutySignals) {
|
|
185
|
+
this.retirePagerDuty();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const storagePath = this.storagePathForSignals();
|
|
189
|
+
if (storagePath === undefined) {
|
|
190
|
+
this.warnMissingSignalStorage();
|
|
180
191
|
return;
|
|
181
192
|
}
|
|
182
193
|
if (!this.hasAnnouncedPagerDuty) {
|
|
@@ -184,11 +195,6 @@ class NaviLinkPlatform {
|
|
|
184
195
|
this.log.info(navilink_signals_1.PAGERDUTY_STARTUP_LOG);
|
|
185
196
|
}
|
|
186
197
|
if (this.signals === undefined) {
|
|
187
|
-
const storagePath = this.api.user.storagePath();
|
|
188
|
-
if (storagePath.length === 0) {
|
|
189
|
-
this.log.warn('PagerDuty signals need a Homebridge storage directory; not writing signals');
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
198
|
this.signals = (0, navilink_signals_1.createNaviLinkSignals)({
|
|
193
199
|
plugin: settings_1.PLUGIN_NAME,
|
|
194
200
|
storagePath,
|
|
@@ -197,6 +203,40 @@ class NaviLinkPlatform {
|
|
|
197
203
|
}
|
|
198
204
|
this.signals.syncDevices(devices);
|
|
199
205
|
}
|
|
206
|
+
/** Resolve every active signal. Leaves the store alone when it is not there. */
|
|
207
|
+
retirePagerDuty() {
|
|
208
|
+
const storagePath = this.storagePathForSignals();
|
|
209
|
+
if (storagePath === undefined) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const signals = (0, navilink_signals_1.createNaviLinkSignals)({
|
|
213
|
+
plugin: settings_1.PLUGIN_NAME,
|
|
214
|
+
storagePath,
|
|
215
|
+
log: this.log,
|
|
216
|
+
});
|
|
217
|
+
try {
|
|
218
|
+
signals.clearActive();
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
signals.close();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
storagePathForSignals() {
|
|
225
|
+
try {
|
|
226
|
+
const storagePath = this.api.user.storagePath();
|
|
227
|
+
return storagePath.length === 0 ? undefined : storagePath;
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
warnMissingSignalStorage() {
|
|
234
|
+
if (this.hasWarnedMissingSignalStorage) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
this.hasWarnedMissingSignalStorage = true;
|
|
238
|
+
this.log.warn('PagerDuty signals need a Homebridge storage directory; not writing signals');
|
|
239
|
+
}
|
|
200
240
|
/** A status frame is the first moment a fault is known, tile or no tile. */
|
|
201
241
|
noteFault(deviceId, observation) {
|
|
202
242
|
const device = this.devices.get(deviceId);
|
package/docs/FEATURES.md
CHANGED
|
@@ -22,7 +22,7 @@ A checklist of what is built. The plugin aims to cover everything about a Navien
|
|
|
22
22
|
|
|
23
23
|
- ✅ **Push, not polling.** A change made in the NaviLink app or at the wall controller reaches HomeKit in about a second. The poll is only a backstop
|
|
24
24
|
- ✅ **A rejected password is never retried.** The session stops and logs `NaviLink rejected the email address or password; sign-in stopped`
|
|
25
|
-
- ✅ **PagerDuty signals** (`options.pagerdutySignals`, off by default): `fault.<
|
|
25
|
+
- ✅ **PagerDuty signals** (`options.pagerdutySignals`, off by default): `fault.<name>` when an appliance reports an error code, using that appliance's name from config, and `auth-failed` when NaviLink rejects the account and sign-in stops
|
|
26
26
|
- ✅ **Credentials are renewed on a clock,** a few minutes before they expire. A planned refresh is not logged as an outage; tiles stay current
|
|
27
27
|
- ✅ **A connected socket is not a live appliance.** Readings carry the time they were taken, and a stale one becomes No Response
|
|
28
28
|
- ✅ **State:** No Response until the appliance has actually been read, and not a value it cannot confirm
|
package/docs/README-DETAILED.md
CHANGED
|
@@ -5,6 +5,7 @@ Everything the [README](../README.md) summarises, in full.
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
7
|
- [Scope](#scope)
|
|
8
|
+
- [Supported devices](#supported-devices)
|
|
8
9
|
- [Accessories in detail](#accessories-in-detail)
|
|
9
10
|
- [Reliability in detail](#reliability-in-detail)
|
|
10
11
|
- [Full configuration reference](#full-configuration-reference)
|
|
@@ -12,6 +13,7 @@ Everything the [README](../README.md) summarises, in full.
|
|
|
12
13
|
- [Reading the log](#reading-the-log)
|
|
13
14
|
- [Apple Shortcuts](#apple-shortcuts)
|
|
14
15
|
- [Roadmap](#roadmap)
|
|
16
|
+
- [PagerDuty](#pagerduty)
|
|
15
17
|
- [Troubleshooting](#troubleshooting)
|
|
16
18
|
- [Security](#security)
|
|
17
19
|
- [Quality](#quality)
|
|
@@ -25,6 +27,26 @@ Scheduling is the clearest example. The appliance has a weekly programme and the
|
|
|
25
27
|
|
|
26
28
|
HomeKit is good at noticing. The NaviLink app is not. A contact sensor that opens when the boiler faults will tell you before the shower does.
|
|
27
29
|
|
|
30
|
+
## Supported devices
|
|
31
|
+
|
|
32
|
+
Any Navien appliance that the NaviLink app controls. The cloud interface is the same for all of them; what differs is which capabilities an appliance reports.
|
|
33
|
+
|
|
34
|
+
| Verified against | Notes |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| **NCB-240E (NG)** | Combi: hot water and space heating, firmware 4352 |
|
|
37
|
+
|
|
38
|
+
Other families are decoded from the same table the NaviLink app uses and are expected to work, but nobody has confirmed them here:
|
|
39
|
+
|
|
40
|
+
| Family | Expected |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| **NPE, NPE2, NPN** | Tankless water heaters. Hot water only; the heating thermostat disables itself |
|
|
43
|
+
| **NCB-H** | Combi with a buffer tank |
|
|
44
|
+
| **NHB** | Boiler. Space heating only |
|
|
45
|
+
| **NFB, NFC** | Boilers with hot water and space heating |
|
|
46
|
+
| **NVW** | Water heater with a tank |
|
|
47
|
+
|
|
48
|
+
If yours is not listed, it will most likely work. Please open an issue with the output of `node scripts/capture-fixture.js --redact` either way, so the table can say so with confidence.
|
|
49
|
+
|
|
28
50
|
## Accessories in detail
|
|
29
51
|
|
|
30
52
|
Each tile is named from the appliance (`Boiler Hot Water`) unless you set `options.accessoryPrefix`. Then every tile uses that stem instead (`Zone One Hot Water`). Two appliances on one prefix keep the appliance name in the tile so Siri can tell them apart.
|
|
@@ -114,6 +136,8 @@ An appliance with no probe reports `0`. The plugin treats that as absent, not as
|
|
|
114
136
|
|
|
115
137
|
## Full configuration reference
|
|
116
138
|
|
|
139
|
+
Only one `NaviLink` platform block is supported. It can hold as many appliances as the account owns.
|
|
140
|
+
|
|
117
141
|
### Platform options
|
|
118
142
|
|
|
119
143
|
| Key | Type | Default | Description |
|
|
@@ -128,7 +152,7 @@ An appliance with no probe reports `0`. The plugin treats that as absent, not as
|
|
|
128
152
|
| `options.diagnosticsInterval` | integer | `0` | Health heartbeat in the log, in seconds. `0` is off; otherwise `30`–`3600` |
|
|
129
153
|
| `options.structuredLogs` | boolean | `false` | With diagnostics, also emit each report as JSON |
|
|
130
154
|
| `options.accessoryPrefix` | string | *(blank)* | HomeKit names become `Prefix Hot Water`, `Prefix Heating`, and so on. Blank uses each appliance's name. Two appliances with the same prefix keep the appliance name in the tile so Siri can tell them apart |
|
|
131
|
-
| `options.pagerdutySignals` | boolean | `false` | Write `fault.<
|
|
155
|
+
| `options.pagerdutySignals` | boolean | `false` | Write `fault.<name>` and `auth-failed` to homebridge-pagerduty. See [PagerDuty](#pagerduty) |
|
|
132
156
|
|
|
133
157
|
A trailing space on the password is trimmed. A password manager will happily paste one. The trim is mentioned once in the log. Without that, the cloud rejects a password that looks right and the failure is unexplainable.
|
|
134
158
|
|
|
@@ -313,10 +337,12 @@ Each condition below then opens a PagerDuty alert while it is present, and resol
|
|
|
313
337
|
|
|
314
338
|
| Signal | Severity | Active when |
|
|
315
339
|
| --- | --- | --- |
|
|
316
|
-
| `fault.<
|
|
340
|
+
| `fault.<name>` | critical | That appliance's latest status frame has a non-zero error code. `<name>` is the appliance's name from the configuration, in lowercase. A space, or any other character the signal store does not allow, becomes a hyphen. One signal per configured appliance, whether or not the HomeKit fault tile is on. The error code stays in the Homebridge log |
|
|
317
341
|
| `auth-failed` | error | NaviLink rejected the email or password and sign-in has stopped. A network failure, an open circuit breaker, or a rejected session token does not turn this on |
|
|
318
342
|
|
|
319
|
-
A fault is written when the first status frame for that appliance arrives, and again when the code changes. It is not written clear before that frame, so a restart during a lockout does not resolve the page and open it again. Shutdown does not clear a signal. An appliance removed from the configuration is cleared on the next start with the setting on. A configuration that fails validation does not change the store.
|
|
343
|
+
A fault is written when the first status frame for that appliance arrives, and again when the code changes. It is not written clear before that frame, so a restart during a lockout does not resolve the page and open it again. Shutdown does not clear a signal. Turning the setting off does: the next start writes every active signal clear, so a page does not stay open after you stop sending them. An appliance removed from the configuration is cleared on the next start with the setting on. A configuration that fails validation does not change the store.
|
|
344
|
+
|
|
345
|
+
The signal follows the name in the configuration. `NCB-240E` is `fault.ncb-240e`. Renaming the appliance clears the old signal on the next start and opens a new one. homebridge-pagerduty stores your message and severity under the signal name, so the new name starts from the defaults. Two appliances whose names reduce to the same signal get the channel appended, as in `fault.boiler.1`.
|
|
320
346
|
|
|
321
347
|
## Troubleshooting
|
|
322
348
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-navilink",
|
|
3
3
|
"displayName": "Homebridge NaviLink",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "Homebridge plugin for Navien combi boilers and water heaters through the North American NaviLink cloud: hot water and space-heating thermostats, power, recirculation, fault and temperature accessories. Verified on an NCB-240E (firmware 4352)",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -42,10 +42,13 @@
|
|
|
42
42
|
"overrides": {
|
|
43
43
|
"js-yaml": "^4.3.2",
|
|
44
44
|
"brace-expansion": "^5.0.12",
|
|
45
|
-
"
|
|
45
|
+
"deepmerge": "4.1.2",
|
|
46
|
+
"handlebars": "^4.7.10",
|
|
47
|
+
"glob": "^14.0.2",
|
|
48
|
+
"minimatch": "^11.0.1"
|
|
46
49
|
},
|
|
47
50
|
"dependencies": {
|
|
48
|
-
"@homebridge/plugin-ui-utils": "2.
|
|
51
|
+
"@homebridge/plugin-ui-utils": "2.3.0"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@types/jest": "^30.0.0",
|
|
@@ -56,7 +59,7 @@
|
|
|
56
59
|
"globals": "^17.12.0",
|
|
57
60
|
"homebridge": "^2.4.0",
|
|
58
61
|
"jest": "^30.5.2",
|
|
59
|
-
"ts-jest": "29.4.
|
|
62
|
+
"ts-jest": "29.4.15",
|
|
60
63
|
"typescript": "^6.0.3"
|
|
61
64
|
},
|
|
62
65
|
"engines": {
|