homebridge-navilink 1.0.4 → 1.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 +14 -0
- package/README.md +11 -80
- package/config.schema.json +6 -0
- package/dist/diagnostics/collector.js +1 -0
- package/dist/navilink-signals.d.ts +96 -0
- package/dist/navilink-signals.js +272 -0
- package/dist/pagerduty-signals.d.ts +46 -0
- package/dist/pagerduty-signals.js +138 -0
- package/dist/platform.d.ts +23 -0
- package/dist/platform.js +96 -2
- package/dist/session.d.ts +10 -0
- package/dist/session.js +11 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/utils/validators.d.ts +1 -0
- package/dist/utils/validators.js +2 -0
- package/docs/FEATURES.md +1 -0
- package/docs/README-DETAILED.md +46 -0
- package/homebridge-ui/public/index.html +10 -0
- package/homebridge-ui/public/index.js +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.1.1](https://github.com/tbaur/homebridge-navilink/compare/v1.1.0...v1.1.1) (2026-10-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* name PagerDuty fault signals from the appliance ([2ee282f](https://github.com/tbaur/homebridge-navilink/commit/2ee282f38a62c1dc60d31f819c7342b37f0fa819))
|
|
9
|
+
|
|
10
|
+
## [1.1.0](https://github.com/tbaur/homebridge-navilink/compare/v1.0.4...v1.1.0) (2026-10-25)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* page appliance faults and a rejected sign-in ([#37](https://github.com/tbaur/homebridge-navilink/issues/37)) ([d517887](https://github.com/tbaur/homebridge-navilink/commit/d517887c223665cfadfb0916d4e10da051fb1b2c))
|
|
16
|
+
|
|
3
17
|
## [1.0.4](https://github.com/tbaur/homebridge-navilink/compare/v1.0.3...v1.0.4) (2026-10-18)
|
|
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,58 +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
|
|
77
|
+
## Supported devices
|
|
106
78
|
|
|
107
|
-
Any Navien appliance that the NaviLink app controls.
|
|
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:
|
|
116
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
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.
|
|
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.
|
|
149
80
|
|
|
150
81
|
## Not Working?
|
|
151
82
|
|
|
@@ -160,7 +91,7 @@ The [full troubleshooting list](docs/README-DETAILED.md#troubleshooting) covers
|
|
|
160
91
|
|
|
161
92
|
## Security
|
|
162
93
|
|
|
163
|
-
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.
|
|
164
95
|
|
|
165
96
|
## Requirements
|
|
166
97
|
|
|
@@ -170,8 +101,6 @@ This plugin needs your NaviLink password, stores it in the Homebridge configurat
|
|
|
170
101
|
- A NaviLink account with at least one gateway online
|
|
171
102
|
- A working internet connection
|
|
172
103
|
|
|
173
|
-
|
|
174
|
-
|
|
175
104
|
## More Info
|
|
176
105
|
|
|
177
106
|
- [Detailed documentation](docs/README-DETAILED.md)
|
|
@@ -181,7 +110,9 @@ This plugin needs your NaviLink password, stores it in the Homebridge configurat
|
|
|
181
110
|
- [Report Issues](https://github.com/tbaur/homebridge-navilink/issues)
|
|
182
111
|
- [Changelog](CHANGELOG.md)
|
|
183
112
|
|
|
113
|
+
## Trademarks
|
|
184
114
|
|
|
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.
|
|
185
116
|
|
|
186
117
|
## License
|
|
187
118
|
|
package/config.schema.json
CHANGED
|
@@ -77,6 +77,12 @@
|
|
|
77
77
|
"maxLength": 64,
|
|
78
78
|
"examples": ["Zone One"],
|
|
79
79
|
"description": "HomeKit tiles become this plus the accessory: \"Zone One Hot Water\", \"Zone One Heating\", and so on. Leave blank to use each appliance's own name. Changing it renames the tiles; it does not detach rooms or automations."
|
|
80
|
+
},
|
|
81
|
+
"pagerdutySignals": {
|
|
82
|
+
"title": "Send Signals to PagerDuty",
|
|
83
|
+
"type": "boolean",
|
|
84
|
+
"default": false,
|
|
85
|
+
"description": "Write this plugin's alert conditions to homebridge-pagerduty's signal store. Then allow homebridge-navilink to page in homebridge-pagerduty's settings. Needs Node 22.13 or later."
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
88
|
},
|
|
@@ -244,6 +244,7 @@ function redactConfig(config) {
|
|
|
244
244
|
structuredLogs: options?.structuredLogs ?? false,
|
|
245
245
|
readOnly: options?.readOnly === true,
|
|
246
246
|
allowPowerOff: options?.allowPowerOff === true,
|
|
247
|
+
pagerdutySignals: options?.pagerdutySignals === true,
|
|
247
248
|
accessoryPrefix: typeof options?.accessoryPrefix === 'string'
|
|
248
249
|
&& options.accessoryPrefix.trim().length > 0,
|
|
249
250
|
devices: Array.isArray(config.devices) ? config.devices.length : 0,
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 tbaur
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0
|
|
5
|
+
* See LICENSE file for full license text
|
|
6
|
+
*
|
|
7
|
+
* @fileoverview Turns appliance faults and a rejected NaviLink sign-in into
|
|
8
|
+
* homebridge-pagerduty signals.
|
|
9
|
+
*
|
|
10
|
+
* The store writer is the copied module. This file decides which conditions
|
|
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
|
+
*/
|
|
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
|
+
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
|
+
}
|
|
26
|
+
/** The subset of the store writer this class uses. */
|
|
27
|
+
export interface SignalWriter {
|
|
28
|
+
write(signal: string, state: SignalState): void;
|
|
29
|
+
list(): readonly ListedSignal[];
|
|
30
|
+
close(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The signal name for one appliance, from its configured name.
|
|
34
|
+
*
|
|
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.
|
|
38
|
+
*/
|
|
39
|
+
export declare function faultSignalName(name: string): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The PagerDuty title for an appliance fault.
|
|
42
|
+
*
|
|
43
|
+
* The name is the one in config. The error code stays in the Homebridge log,
|
|
44
|
+
* because a saved PagerDuty message is fixed text and would keep an old code.
|
|
45
|
+
*/
|
|
46
|
+
export declare function faultSummary(name: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Fault and sign-in signals for this plugin.
|
|
49
|
+
*
|
|
50
|
+
* Fault rows are written when a status frame arrives, not before: a clear
|
|
51
|
+
* written at startup would resolve a lockout that is still in progress.
|
|
52
|
+
* Auth is written when sign-in is accepted or refused, and left alone for
|
|
53
|
+
* every failure the session will retry.
|
|
54
|
+
*/
|
|
55
|
+
export declare class NaviLinkSignals {
|
|
56
|
+
private readonly writer;
|
|
57
|
+
private readonly log;
|
|
58
|
+
private readonly warned;
|
|
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: {
|
|
64
|
+
warn(message: string): void;
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
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.
|
|
71
|
+
*/
|
|
72
|
+
syncDevices(devices: readonly {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
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;
|
|
84
|
+
/** Record whether this appliance's latest status frame has an error code. */
|
|
85
|
+
setFault(deviceId: string, name: string, isActive: boolean): void;
|
|
86
|
+
/** Record whether NaviLink has rejected the account and stopped sign-in. */
|
|
87
|
+
setAuthenticationRejected(isRejected: boolean): void;
|
|
88
|
+
/** Close the store. Does not clear any signal. */
|
|
89
|
+
close(): void;
|
|
90
|
+
private listedSignals;
|
|
91
|
+
private warnUnusable;
|
|
92
|
+
private warnTaken;
|
|
93
|
+
private warnOnce;
|
|
94
|
+
}
|
|
95
|
+
/** Build the signals for this plugin, backed by the homebridge-pagerduty store. */
|
|
96
|
+
export declare function createNaviLinkSignals(options: PagerDutySignalsOptions): NaviLinkSignals;
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 tbaur
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0
|
|
6
|
+
* See LICENSE file for full license text
|
|
7
|
+
*
|
|
8
|
+
* @fileoverview Turns appliance faults and a rejected NaviLink sign-in into
|
|
9
|
+
* homebridge-pagerduty signals.
|
|
10
|
+
*
|
|
11
|
+
* The store writer is the copied module. This file decides which conditions
|
|
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
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.NaviLinkSignals = exports.SIGNAL_AUTH_FAILED = exports.PAGERDUTY_STARTUP_LOG = void 0;
|
|
18
|
+
exports.faultSignalName = faultSignalName;
|
|
19
|
+
exports.faultSummary = faultSummary;
|
|
20
|
+
exports.createNaviLinkSignals = createNaviLinkSignals;
|
|
21
|
+
const identity_1 = require("./api/identity");
|
|
22
|
+
const pagerduty_signals_1 = require("./pagerduty-signals");
|
|
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)';
|
|
26
|
+
exports.SIGNAL_AUTH_FAILED = 'auth-failed';
|
|
27
|
+
const AUTH_FAILED_SUMMARY = 'NaviLink rejected the account email or password. Sign-in has stopped until it is corrected in Homebridge.';
|
|
28
|
+
const FAULT_SUMMARY_FALLBACK = 'Navien appliance is reporting a fault';
|
|
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;
|
|
33
|
+
/**
|
|
34
|
+
* The signal name for one appliance, from its configured name.
|
|
35
|
+
*
|
|
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.
|
|
39
|
+
*/
|
|
40
|
+
function faultSignalName(name) {
|
|
41
|
+
const slug = faultSlug(name);
|
|
42
|
+
if (slug === undefined) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return `${FAULT_PREFIX}${slug}`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The PagerDuty title for an appliance fault.
|
|
49
|
+
*
|
|
50
|
+
* The name is the one in config. The error code stays in the Homebridge log,
|
|
51
|
+
* because a saved PagerDuty message is fixed text and would keep an old code.
|
|
52
|
+
*/
|
|
53
|
+
function faultSummary(name) {
|
|
54
|
+
const cleaned = name.replace(/[\u0000-\u001F\u007F]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
55
|
+
if (cleaned.length === 0) {
|
|
56
|
+
return FAULT_SUMMARY_FALLBACK;
|
|
57
|
+
}
|
|
58
|
+
return `Navien ${cleaned} is reporting a fault`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fault and sign-in signals for this plugin.
|
|
62
|
+
*
|
|
63
|
+
* Fault rows are written when a status frame arrives, not before: a clear
|
|
64
|
+
* written at startup would resolve a lockout that is still in progress.
|
|
65
|
+
* Auth is written when sign-in is accepted or refused, and left alone for
|
|
66
|
+
* every failure the session will retry.
|
|
67
|
+
*/
|
|
68
|
+
class NaviLinkSignals {
|
|
69
|
+
writer;
|
|
70
|
+
log;
|
|
71
|
+
warned = new Set();
|
|
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) {
|
|
77
|
+
this.writer = writer;
|
|
78
|
+
this.log = log;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
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.
|
|
85
|
+
*/
|
|
86
|
+
syncDevices(devices) {
|
|
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;
|
|
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
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** Record whether this appliance's latest status frame has an error code. */
|
|
130
|
+
setFault(deviceId, name, isActive) {
|
|
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);
|
|
137
|
+
if (signal === undefined) {
|
|
138
|
+
this.warnUnusable(name);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.writer.write(signal, {
|
|
142
|
+
active: isActive,
|
|
143
|
+
severity: 'critical',
|
|
144
|
+
summary: faultSummary(name),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/** Record whether NaviLink has rejected the account and stopped sign-in. */
|
|
148
|
+
setAuthenticationRejected(isRejected) {
|
|
149
|
+
this.writer.write(exports.SIGNAL_AUTH_FAILED, {
|
|
150
|
+
active: isRejected,
|
|
151
|
+
severity: 'error',
|
|
152
|
+
summary: AUTH_FAILED_SUMMARY,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/** Close the store. Does not clear any signal. */
|
|
156
|
+
close() {
|
|
157
|
+
this.writer.close();
|
|
158
|
+
}
|
|
159
|
+
listedSignals() {
|
|
160
|
+
try {
|
|
161
|
+
return this.writer.list();
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
this.warnOnce('PagerDuty signals could not be read; removed appliances will not be cleared this start');
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
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`);
|
|
173
|
+
}
|
|
174
|
+
warnOnce(message) {
|
|
175
|
+
if (this.warned.has(message)) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this.warned.add(message);
|
|
179
|
+
this.log.warn(message);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.NaviLinkSignals = NaviLinkSignals;
|
|
183
|
+
/** Build the signals for this plugin, backed by the homebridge-pagerduty store. */
|
|
184
|
+
function createNaviLinkSignals(options) {
|
|
185
|
+
return new NaviLinkSignals(new pagerduty_signals_1.PagerDutySignals(options), options.log);
|
|
186
|
+
}
|
|
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)) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
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);
|
|
229
|
+
}
|
|
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);
|
|
241
|
+
}
|
|
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;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type SignalSeverity = 'info' | 'warning' | 'error' | 'critical';
|
|
2
|
+
export interface SignalState {
|
|
3
|
+
active: boolean;
|
|
4
|
+
severity: SignalSeverity;
|
|
5
|
+
summary: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PagerDutySignalsOptions {
|
|
8
|
+
/** This plugin's npm package name, exactly as in package.json. */
|
|
9
|
+
plugin: string;
|
|
10
|
+
/** `api.user.storagePath()` */
|
|
11
|
+
storagePath: string;
|
|
12
|
+
log: {
|
|
13
|
+
warn(message: string): void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Writes this plugin's conditions to the homebridge-pagerduty signal store.
|
|
18
|
+
* Never throws: a failure is logged once, and the next write tries again.
|
|
19
|
+
*/
|
|
20
|
+
export declare class PagerDutySignals {
|
|
21
|
+
private readonly options;
|
|
22
|
+
private db;
|
|
23
|
+
private readonly lastWritten;
|
|
24
|
+
private isDisabled;
|
|
25
|
+
private hasWarned;
|
|
26
|
+
constructor(options: PagerDutySignalsOptions);
|
|
27
|
+
/** Record a signal's current state. Skipped when nothing changed since the last write. */
|
|
28
|
+
write(signal: string, state: SignalState): void;
|
|
29
|
+
/** Close the connection. Call on Homebridge `shutdown`. Never clears a signal. */
|
|
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
|
+
}[];
|
|
43
|
+
private open;
|
|
44
|
+
private disable;
|
|
45
|
+
private warnOnce;
|
|
46
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PagerDutySignals = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const STORE_DIR = 'homebridge-pagerduty';
|
|
7
|
+
// The signal store interface this module writes. Change it only by copying a
|
|
8
|
+
// newer version of this module from homebridge-pagerduty's docs/SIGNALS-AGENT.md.
|
|
9
|
+
const INTERFACE_ID = 'signals-2026-10-24';
|
|
10
|
+
const STORE_FILE = 'signals.sqlite';
|
|
11
|
+
const MAX_SUMMARY_LENGTH = 1024;
|
|
12
|
+
const CONTROL_CHARACTERS = /[\u0000-\u001F\u007F]+/g;
|
|
13
|
+
// The table definition of interface signals-2026-10-24. Every writer must run
|
|
14
|
+
// this exact text: the first process to run it defines the table.
|
|
15
|
+
const SCHEMA = `PRAGMA journal_mode = WAL;
|
|
16
|
+
CREATE TABLE IF NOT EXISTS signals (
|
|
17
|
+
plugin TEXT NOT NULL CHECK (length(plugin) BETWEEN 1 AND 128 AND plugin NOT GLOB '*[^a-z0-9@/._-]*'),
|
|
18
|
+
signal TEXT NOT NULL CHECK (length(signal) BETWEEN 1 AND 64 AND signal NOT GLOB '*[^a-z0-9._-]*'),
|
|
19
|
+
active INTEGER NOT NULL CHECK (active IN (0, 1)),
|
|
20
|
+
severity TEXT NOT NULL CHECK (severity IN ('info', 'warning', 'error', 'critical')),
|
|
21
|
+
summary TEXT NOT NULL CHECK (length(summary) BETWEEN 1 AND 1024),
|
|
22
|
+
updated_at INTEGER NOT NULL,
|
|
23
|
+
PRIMARY KEY (plugin, signal)
|
|
24
|
+
) STRICT;`;
|
|
25
|
+
const UPSERT = 'INSERT INTO signals (plugin, signal, active, severity, summary, updated_at) VALUES (?, ?, ?, ?, ?, ?) '
|
|
26
|
+
+ 'ON CONFLICT (plugin, signal) DO UPDATE SET active = excluded.active, severity = excluded.severity, '
|
|
27
|
+
+ 'summary = excluded.summary, updated_at = excluded.updated_at';
|
|
28
|
+
/**
|
|
29
|
+
* Writes this plugin's conditions to the homebridge-pagerduty signal store.
|
|
30
|
+
* Never throws: a failure is logged once, and the next write tries again.
|
|
31
|
+
*/
|
|
32
|
+
class PagerDutySignals {
|
|
33
|
+
options;
|
|
34
|
+
db;
|
|
35
|
+
lastWritten = new Map();
|
|
36
|
+
isDisabled = false;
|
|
37
|
+
hasWarned = false;
|
|
38
|
+
constructor(options) {
|
|
39
|
+
this.options = options;
|
|
40
|
+
}
|
|
41
|
+
/** Record a signal's current state. Skipped when nothing changed since the last write. */
|
|
42
|
+
write(signal, state) {
|
|
43
|
+
const summary = state.summary.replace(CONTROL_CHARACTERS, ' ').slice(0, MAX_SUMMARY_LENGTH);
|
|
44
|
+
const fingerprint = `${state.active ? 1 : 0}|${state.severity}|${summary}`;
|
|
45
|
+
if (this.isDisabled || this.lastWritten.get(signal) === fingerprint) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const db = this.db ?? this.open();
|
|
50
|
+
db.prepare(UPSERT).run(this.options.plugin, signal, state.active ? 1 : 0, state.severity, summary, Date.now());
|
|
51
|
+
this.lastWritten.set(signal, fingerprint);
|
|
52
|
+
this.hasWarned = false;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.warnOnce(`PagerDuty signal ${signal} was not written: ${error instanceof Error ? error.message : String(error)}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Close the connection. Call on Homebridge `shutdown`. Never clears a signal. */
|
|
59
|
+
close() {
|
|
60
|
+
this.db?.close();
|
|
61
|
+
this.db = undefined;
|
|
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
|
+
}
|
|
97
|
+
open() {
|
|
98
|
+
// Loaded here, not imported at the top, so the plugin still loads on a
|
|
99
|
+
// Node version without node:sqlite.
|
|
100
|
+
const sqlite = typeof process.getBuiltinModule === 'function'
|
|
101
|
+
? process.getBuiltinModule('node:sqlite')
|
|
102
|
+
: undefined;
|
|
103
|
+
if (sqlite === undefined) {
|
|
104
|
+
this.disable('PagerDuty signals need Node 22.13 or later; not writing signals');
|
|
105
|
+
}
|
|
106
|
+
const dir = (0, node_path_1.join)(this.options.storagePath, STORE_DIR, INTERFACE_ID);
|
|
107
|
+
const file = (0, node_path_1.join)(dir, STORE_FILE);
|
|
108
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true, mode: 0o700 });
|
|
109
|
+
(0, node_fs_1.closeSync)((0, node_fs_1.openSync)(file, 'a', 0o600));
|
|
110
|
+
const db = new sqlite.DatabaseSync(file);
|
|
111
|
+
try {
|
|
112
|
+
db.exec('PRAGMA busy_timeout = 1000');
|
|
113
|
+
db.exec(SCHEMA);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
db.close();
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
this.db = db;
|
|
120
|
+
return db;
|
|
121
|
+
}
|
|
122
|
+
disable(message) {
|
|
123
|
+
this.isDisabled = true;
|
|
124
|
+
this.hasWarned = false;
|
|
125
|
+
this.warnOnce(message);
|
|
126
|
+
throw new Error(message);
|
|
127
|
+
}
|
|
128
|
+
warnOnce(message) {
|
|
129
|
+
if (!this.hasWarned) {
|
|
130
|
+
this.hasWarned = true;
|
|
131
|
+
this.options.log.warn(message);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
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
|
@@ -44,6 +44,12 @@ export declare class NaviLinkPlatform implements DynamicPlatformPlugin, Accessor
|
|
|
44
44
|
private readonly devices;
|
|
45
45
|
private options;
|
|
46
46
|
private session;
|
|
47
|
+
/** PagerDuty signals, present only when the user turned them on. */
|
|
48
|
+
private signals;
|
|
49
|
+
/** The startup line is once per process, including a second call to start. */
|
|
50
|
+
private hasAnnouncedPagerDuty;
|
|
51
|
+
/** The missing-storage warning is once per process. */
|
|
52
|
+
private hasWarnedMissingSignalStorage;
|
|
47
53
|
private readonly platformConfig;
|
|
48
54
|
private readonly diagnostics;
|
|
49
55
|
private diagnosticsTimer;
|
|
@@ -60,6 +66,23 @@ export declare class NaviLinkPlatform implements DynamicPlatformPlugin, Accessor
|
|
|
60
66
|
configureAccessory(accessory: PlatformAccessory): void;
|
|
61
67
|
private start;
|
|
62
68
|
private stop;
|
|
69
|
+
/**
|
|
70
|
+
* Open PagerDuty signals when the user asked for them.
|
|
71
|
+
*
|
|
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.
|
|
78
|
+
*/
|
|
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;
|
|
84
|
+
/** A status frame is the first moment a fault is known, tile or no tile. */
|
|
85
|
+
private noteFault;
|
|
63
86
|
/** Keep cached accessories registered when configuration is unusable. */
|
|
64
87
|
private keepRestoredRegistered;
|
|
65
88
|
/**
|
package/dist/platform.js
CHANGED
|
@@ -35,6 +35,7 @@ const protocol_1 = require("./api/protocol");
|
|
|
35
35
|
const devices_1 = require("./devices");
|
|
36
36
|
const collector_1 = require("./diagnostics/collector");
|
|
37
37
|
const format_1 = require("./diagnostics/format");
|
|
38
|
+
const navilink_signals_1 = require("./navilink-signals");
|
|
38
39
|
const session_1 = require("./session");
|
|
39
40
|
const settings_1 = require("./settings");
|
|
40
41
|
const types_1 = require("./types");
|
|
@@ -59,8 +60,15 @@ class NaviLinkPlatform {
|
|
|
59
60
|
diagnosticsInterval: 0,
|
|
60
61
|
structuredLogs: false,
|
|
61
62
|
accessoryPrefix: '',
|
|
63
|
+
pagerdutySignals: false,
|
|
62
64
|
};
|
|
63
65
|
session;
|
|
66
|
+
/** PagerDuty signals, present only when the user turned them on. */
|
|
67
|
+
signals;
|
|
68
|
+
/** The startup line is once per process, including a second call to start. */
|
|
69
|
+
hasAnnouncedPagerDuty = false;
|
|
70
|
+
/** The missing-storage warning is once per process. */
|
|
71
|
+
hasWarnedMissingSignalStorage = false;
|
|
64
72
|
platformConfig;
|
|
65
73
|
diagnostics;
|
|
66
74
|
diagnosticsTimer;
|
|
@@ -124,6 +132,7 @@ class NaviLinkPlatform {
|
|
|
124
132
|
this.log.warn(warning);
|
|
125
133
|
}
|
|
126
134
|
this.syncAccessories(accessories);
|
|
135
|
+
this.openPagerDuty(devices);
|
|
127
136
|
const session = new session_1.NaviLinkSession({
|
|
128
137
|
log: this.log,
|
|
129
138
|
account,
|
|
@@ -131,8 +140,12 @@ class NaviLinkPlatform {
|
|
|
131
140
|
statusIntervalSec: this.options.statusIntervalSec,
|
|
132
141
|
metrics: this.diagnostics,
|
|
133
142
|
onCircuitOpen: () => this.diagnostics.breakerTrip(),
|
|
143
|
+
onAuthentication: (result) => {
|
|
144
|
+
this.signals?.setAuthenticationRejected(result === 'rejected');
|
|
145
|
+
},
|
|
134
146
|
});
|
|
135
147
|
session.onObservation((deviceId, observation, reason) => {
|
|
148
|
+
this.noteFault(deviceId, observation);
|
|
136
149
|
this.distribute(deviceId, observation, reason);
|
|
137
150
|
});
|
|
138
151
|
session.onUnreachable((error) => this.markAllUnreachable(error));
|
|
@@ -148,8 +161,89 @@ class NaviLinkPlatform {
|
|
|
148
161
|
handler.stop();
|
|
149
162
|
}
|
|
150
163
|
this.handlers.clear();
|
|
151
|
-
|
|
152
|
-
|
|
164
|
+
try {
|
|
165
|
+
await this.session?.stop();
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
this.session = undefined;
|
|
169
|
+
this.signals?.close();
|
|
170
|
+
this.signals = undefined;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Open PagerDuty signals when the user asked for them.
|
|
175
|
+
*
|
|
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.
|
|
182
|
+
*/
|
|
183
|
+
openPagerDuty(devices) {
|
|
184
|
+
if (!this.options.pagerdutySignals) {
|
|
185
|
+
this.retirePagerDuty();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const storagePath = this.storagePathForSignals();
|
|
189
|
+
if (storagePath === undefined) {
|
|
190
|
+
this.warnMissingSignalStorage();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (!this.hasAnnouncedPagerDuty) {
|
|
194
|
+
this.hasAnnouncedPagerDuty = true;
|
|
195
|
+
this.log.info(navilink_signals_1.PAGERDUTY_STARTUP_LOG);
|
|
196
|
+
}
|
|
197
|
+
if (this.signals === undefined) {
|
|
198
|
+
this.signals = (0, navilink_signals_1.createNaviLinkSignals)({
|
|
199
|
+
plugin: settings_1.PLUGIN_NAME,
|
|
200
|
+
storagePath,
|
|
201
|
+
log: this.log,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
this.signals.syncDevices(devices);
|
|
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
|
+
}
|
|
240
|
+
/** A status frame is the first moment a fault is known, tile or no tile. */
|
|
241
|
+
noteFault(deviceId, observation) {
|
|
242
|
+
const device = this.devices.get(deviceId);
|
|
243
|
+
if (device === undefined) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
this.signals?.setFault(device.id, device.name, observation.readings.errorCode !== 0);
|
|
153
247
|
}
|
|
154
248
|
/** Keep cached accessories registered when configuration is unusable. */
|
|
155
249
|
keepRestoredRegistered() {
|
package/dist/session.d.ts
CHANGED
|
@@ -74,6 +74,14 @@ export interface NaviLinkSessionOptions {
|
|
|
74
74
|
metrics?: SessionMetrics;
|
|
75
75
|
/** Fired when REST trips OPEN, so diagnostics can count a trip. */
|
|
76
76
|
onCircuitOpen?: () => void;
|
|
77
|
+
/**
|
|
78
|
+
* Sign-in finished one way or the other.
|
|
79
|
+
*
|
|
80
|
+
* `accepted` means the account was taken. A later network failure or a
|
|
81
|
+
* rejected session token is not this. `rejected` means NaviLink refused
|
|
82
|
+
* the email or password and sign-in has stopped.
|
|
83
|
+
*/
|
|
84
|
+
onAuthentication?: (result: 'accepted' | 'rejected') => void;
|
|
77
85
|
}
|
|
78
86
|
/** Owns the plugin's entire relationship with the NaviLink cloud. */
|
|
79
87
|
export declare class NaviLinkSession {
|
|
@@ -202,6 +210,8 @@ export declare class NaviLinkSession {
|
|
|
202
210
|
private waitForSessionEnd;
|
|
203
211
|
/** Stop trying, and say why exactly once. */
|
|
204
212
|
private stopPermanently;
|
|
213
|
+
/** Tell the platform, and keep a thrown listener from stopping the session. */
|
|
214
|
+
private reportAuthentication;
|
|
205
215
|
/** True when the session has given up for a reason the user must fix. */
|
|
206
216
|
get hasStoppedPermanently(): boolean;
|
|
207
217
|
private requestChannelInfo;
|
package/dist/session.js
CHANGED
|
@@ -301,6 +301,7 @@ class NaviLinkSession {
|
|
|
301
301
|
this.clearTimers();
|
|
302
302
|
this.dropConnection();
|
|
303
303
|
const tokens = await this.rest.signIn(this.options.account.email, this.options.account.password);
|
|
304
|
+
this.reportAuthentication('accepted');
|
|
304
305
|
this.expiresAt = tokens.expiresAt;
|
|
305
306
|
if (this.lastRefreshAt !== undefined) {
|
|
306
307
|
this.options.metrics?.sessionRefresh();
|
|
@@ -509,8 +510,18 @@ class NaviLinkSession {
|
|
|
509
510
|
this.clearTimers();
|
|
510
511
|
this.dropConnection();
|
|
511
512
|
this.log.error(`${error.message}; sign-in stopped`);
|
|
513
|
+
this.reportAuthentication('rejected');
|
|
512
514
|
this.notifyUnreachable(error);
|
|
513
515
|
}
|
|
516
|
+
/** Tell the platform, and keep a thrown listener from stopping the session. */
|
|
517
|
+
reportAuthentication(result) {
|
|
518
|
+
try {
|
|
519
|
+
this.options.onAuthentication?.(result);
|
|
520
|
+
}
|
|
521
|
+
catch (error) {
|
|
522
|
+
this.log.debug(`an authentication listener threw: ${(0, utils_1.describeError)(error)}`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
514
525
|
/** True when the session has given up for a reason the user must fix. */
|
|
515
526
|
get hasStoppedPermanently() {
|
|
516
527
|
return this.fatal !== undefined;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -122,6 +122,13 @@ export interface NaviLinkPlatformOptions {
|
|
|
122
122
|
* attached if you rename later.
|
|
123
123
|
*/
|
|
124
124
|
accessoryPrefix?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Write fault and sign-in conditions to homebridge-pagerduty's signal store.
|
|
127
|
+
*
|
|
128
|
+
* Off by default. The plugin does not page until the user also allows it
|
|
129
|
+
* in homebridge-pagerduty. Needs Node 22.13 or later.
|
|
130
|
+
*/
|
|
131
|
+
pagerdutySignals?: boolean;
|
|
125
132
|
}
|
|
126
133
|
/** Shape of one `platforms[]` entry in `config.json`. */
|
|
127
134
|
export interface NaviLinkPlatformConfig {
|
package/dist/utils/validators.js
CHANGED
|
@@ -293,6 +293,7 @@ function validateConfig(config) {
|
|
|
293
293
|
diagnosticsInterval: 0,
|
|
294
294
|
structuredLogs: false,
|
|
295
295
|
accessoryPrefix: '',
|
|
296
|
+
pagerdutySignals: false,
|
|
296
297
|
};
|
|
297
298
|
if (typeof config !== 'object' || config === null) {
|
|
298
299
|
return { errors: ['platform configuration is missing'], warnings, account: undefined, devices: [], options: defaults };
|
|
@@ -306,6 +307,7 @@ function validateConfig(config) {
|
|
|
306
307
|
diagnosticsInterval: resolveDiagnosticsIntervalSec(platform.options?.diagnosticsInterval, warnings),
|
|
307
308
|
structuredLogs: platform.options?.structuredLogs === true,
|
|
308
309
|
accessoryPrefix: resolveAccessoryPrefix(platform.options?.accessoryPrefix, warnings),
|
|
310
|
+
pagerdutySignals: platform.options?.pagerdutySignals === true,
|
|
309
311
|
};
|
|
310
312
|
const rawDevices = platform.devices;
|
|
311
313
|
if (rawDevices === undefined) {
|
package/docs/FEATURES.md
CHANGED
|
@@ -22,6 +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.<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
|
|
25
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
|
|
26
27
|
- ✅ **A connected socket is not a live appliance.** Readings carry the time they were taken, and a stale one becomes No Response
|
|
27
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.
|
|
@@ -71,6 +93,8 @@ A ContactSensor that reads **open** when the appliance reports a non-zero error
|
|
|
71
93
|
|
|
72
94
|
The code and sub-code go to the log once per change (`error 12.3`, then `fault cleared`). Look the number up in your installation manual; naming them in the plugin is on the [roadmap](#roadmap).
|
|
73
95
|
|
|
96
|
+
Paging this condition through homebridge-pagerduty does not require this tile. See [PagerDuty](#pagerduty).
|
|
97
|
+
|
|
74
98
|
### Temperature sensors (`temperatureSensors`)
|
|
75
99
|
|
|
76
100
|
One tick, four sensors:
|
|
@@ -112,6 +136,8 @@ An appliance with no probe reports `0`. The plugin treats that as absent, not as
|
|
|
112
136
|
|
|
113
137
|
## Full configuration reference
|
|
114
138
|
|
|
139
|
+
Only one `NaviLink` platform block is supported. It can hold as many appliances as the account owns.
|
|
140
|
+
|
|
115
141
|
### Platform options
|
|
116
142
|
|
|
117
143
|
| Key | Type | Default | Description |
|
|
@@ -126,6 +152,7 @@ An appliance with no probe reports `0`. The plugin treats that as absent, not as
|
|
|
126
152
|
| `options.diagnosticsInterval` | integer | `0` | Health heartbeat in the log, in seconds. `0` is off; otherwise `30`–`3600` |
|
|
127
153
|
| `options.structuredLogs` | boolean | `false` | With diagnostics, also emit each report as JSON |
|
|
128
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 |
|
|
155
|
+
| `options.pagerdutySignals` | boolean | `false` | Write `fault.<name>` and `auth-failed` to homebridge-pagerduty. See [PagerDuty](#pagerduty) |
|
|
129
156
|
|
|
130
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.
|
|
131
158
|
|
|
@@ -298,6 +325,25 @@ In rough order, matching [FEATURES.md](FEATURES.md#not-built-yet):
|
|
|
298
325
|
|
|
299
326
|
Weekly schedules, commissioning settings and descaling reminders are [not planned](FEATURES.md#not-planned).
|
|
300
327
|
|
|
328
|
+
## PagerDuty
|
|
329
|
+
|
|
330
|
+
This plugin can page through [homebridge-pagerduty](https://github.com/tbaur/homebridge-pagerduty) when something needs attention. It needs Node 22.13 or later.
|
|
331
|
+
|
|
332
|
+
1. Turn on **Send Signals to PagerDuty** (`options.pagerdutySignals`) in this plugin's settings.
|
|
333
|
+
2. Restart Homebridge.
|
|
334
|
+
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.
|
|
335
|
+
|
|
336
|
+
Each condition below then opens a PagerDuty alert while it is present, and resolves it when it clears.
|
|
337
|
+
|
|
338
|
+
| Signal | Severity | Active when |
|
|
339
|
+
| --- | --- | --- |
|
|
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 |
|
|
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 |
|
|
342
|
+
|
|
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`.
|
|
346
|
+
|
|
301
347
|
## Troubleshooting
|
|
302
348
|
|
|
303
349
|
**1. "NaviLink rejected the email address or password."**
|
|
@@ -144,6 +144,16 @@
|
|
|
144
144
|
Also emit each diagnostics report as JSON
|
|
145
145
|
</label>
|
|
146
146
|
</div>
|
|
147
|
+
|
|
148
|
+
<div class="nl-options">
|
|
149
|
+
<label class="nl-check">
|
|
150
|
+
<input type="checkbox" id="pagerduty-signals" />
|
|
151
|
+
Send signals to PagerDuty
|
|
152
|
+
</label>
|
|
153
|
+
</div>
|
|
154
|
+
<div class="nl-meta">
|
|
155
|
+
Write fault and sign-in conditions to homebridge-pagerduty. Then allow homebridge-navilink to page in that plugin's settings. Needs Node 22.13 or later.
|
|
156
|
+
</div>
|
|
147
157
|
</div>
|
|
148
158
|
|
|
149
159
|
<div class="nl-actions">
|
|
@@ -257,6 +257,7 @@
|
|
|
257
257
|
byId('diagnostics-interval').value = String(diagnostics)
|
|
258
258
|
syncDiagnosticsLabel()
|
|
259
259
|
byId('structured-logs').checked = platformConfig.options.structuredLogs === true
|
|
260
|
+
byId('pagerduty-signals').checked = platformConfig.options.pagerdutySignals === true
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
/** Keep the slider's number in step with the thumb. 0 is Off. */
|
|
@@ -295,6 +296,7 @@
|
|
|
295
296
|
platformConfig.options.diagnosticsInterval = diagnostics
|
|
296
297
|
}
|
|
297
298
|
setFlag('structuredLogs', byId('structured-logs').checked === true)
|
|
299
|
+
setFlag('pagerdutySignals', byId('pagerduty-signals').checked === true)
|
|
298
300
|
|
|
299
301
|
const email = byId('email').value.trim()
|
|
300
302
|
const password = byId('password').value.trim()
|
|
@@ -520,6 +522,7 @@
|
|
|
520
522
|
changed()
|
|
521
523
|
})
|
|
522
524
|
byId('structured-logs').addEventListener('change', () => changed())
|
|
525
|
+
byId('pagerduty-signals').addEventListener('change', () => changed())
|
|
523
526
|
byId('toggle-json').addEventListener('click', () => {
|
|
524
527
|
schemaFormVisible = !schemaFormVisible
|
|
525
528
|
if (schemaFormVisible) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-navilink",
|
|
3
3
|
"displayName": "Homebridge NaviLink",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
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",
|