homebridge-nas-power 0.1.0
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/README.md +279 -0
- package/config.schema.json +156 -0
- package/dist/accessory.d.ts +39 -0
- package/dist/accessory.d.ts.map +1 -0
- package/dist/accessory.js +382 -0
- package/dist/accessory.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.d.ts +15 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +79 -0
- package/dist/platform.js.map +1 -0
- package/dist/ssh.d.ts +34 -0
- package/dist/ssh.d.ts.map +1 -0
- package/dist/ssh.js +277 -0
- package/dist/ssh.js.map +1 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/wol.d.ts +9 -0
- package/dist/wol.d.ts.map +1 -0
- package/dist/wol.js +122 -0
- package/dist/wol.js.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# homebridge-nas-power
|
|
2
|
+
|
|
3
|
+
Homebridge plugin to expose your NAS as a switch in Apple HomeKit.
|
|
4
|
+
|
|
5
|
+
- **ON** → Sends Wake-on-LAN magic packets, then retries SSH port check until the NAS responds
|
|
6
|
+
- **OFF** → Connects via SSH and runs a shutdown command
|
|
7
|
+
- **State** → Detected by polling SSH port connectivity (TOFU host key verification)
|
|
8
|
+
|
|
9
|
+
Tested against OpenMediaVault (OMV). Should work with any Linux NAS that has SSH enabled.
|
|
10
|
+
|
|
11
|
+
## Maintenance Status
|
|
12
|
+
|
|
13
|
+
This project is **unmaintained**. The original author has no plans to actively maintain or update it. You are welcome to fork this repository and continue development at your leisure.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
- Homebridge ≥ 1.6.0
|
|
20
|
+
- Node.js ≥ 18
|
|
21
|
+
- SSH enabled on your NAS
|
|
22
|
+
- The SSH user must have permission to run the shutdown command (see below)
|
|
23
|
+
- WOL enabled in your NAS BIOS/UEFI and network switch (only required for power-on)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g homebridge-nas-power
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Or install via the Homebridge UI by searching `homebridge-nas-power`.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## OMV SSH Sudo Setup
|
|
38
|
+
|
|
39
|
+
The plugin runs `sudo shutdown -h now` over SSH by default. On OMV, allow this without a password prompt:
|
|
40
|
+
|
|
41
|
+
1. Verify the path to `shutdown` on your system:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
which shutdown
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
2. Run `visudo` and add (substituting the correct path if different):
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
yourusername ALL=(ALL) NOPASSWD: /sbin/shutdown, /usr/sbin/shutdown
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> **Note:** On modern systemd-based systems, `sudo systemctl poweroff` is often more reliable. Set this via the `shutdownCommand` config option.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## SSH Authentication
|
|
58
|
+
|
|
59
|
+
One of `password` or `privateKeyPath` is required. Private key auth is strongly recommended.
|
|
60
|
+
|
|
61
|
+
### Password auth
|
|
62
|
+
|
|
63
|
+
Set `username` and `password` in your device config.
|
|
64
|
+
|
|
65
|
+
### Private key auth (recommended)
|
|
66
|
+
|
|
67
|
+
1. Generate a key pair on your Homebridge host:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
ssh-keygen -t ed25519 -f ~/.homebridge/nas_key -C "homebridge-nas-power"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
2. Copy the public key to your NAS:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
ssh-copy-id -i ~/.homebridge/nas_key.pub yourusername@192.168.1.100
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
3. Set `privateKeyPath` in your device config.
|
|
80
|
+
|
|
81
|
+
> **Note:** The private key is cached in memory at startup. If you rotate the key file on disk while Homebridge is running, the plugin will continue using the old key until Homebridge is restarted.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Security: Shutdown Command
|
|
86
|
+
|
|
87
|
+
The `shutdownCommand` config value is executed directly on the NAS over SSH without sanitization. **Only use trusted values here.** Do not expose your Homebridge `config.json` to untrusted users.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Homebridge config.json
|
|
92
|
+
|
|
93
|
+
### Password authentication example
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"platforms": [
|
|
98
|
+
{
|
|
99
|
+
"platform": "NasPower",
|
|
100
|
+
"name": "NAS Power",
|
|
101
|
+
"devices": [
|
|
102
|
+
{
|
|
103
|
+
"name": "NAS",
|
|
104
|
+
"host": "192.168.1.100",
|
|
105
|
+
"mac": "AA:BB:CC:DD:EE:FF",
|
|
106
|
+
"port": 22,
|
|
107
|
+
"username": "admin",
|
|
108
|
+
"password": "yourpassword",
|
|
109
|
+
"shutdownCommand": "sudo shutdown -h now",
|
|
110
|
+
"pollInterval": 30
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Private key authentication example (recommended)
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"platforms": [
|
|
123
|
+
{
|
|
124
|
+
"platform": "NasPower",
|
|
125
|
+
"name": "NAS Power",
|
|
126
|
+
"devices": [
|
|
127
|
+
{
|
|
128
|
+
"name": "NAS",
|
|
129
|
+
"host": "192.168.1.100",
|
|
130
|
+
"mac": "AA:BB:CC:DD:EE:FF",
|
|
131
|
+
"port": 22,
|
|
132
|
+
"username": "admin",
|
|
133
|
+
"privateKeyPath": "/home/homebridge/.homebridge/nas_key",
|
|
134
|
+
"shutdownCommand": "sudo shutdown -h now",
|
|
135
|
+
"pollInterval": 30
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Config options
|
|
144
|
+
|
|
145
|
+
| Field | Required | Default | Description |
|
|
146
|
+
|---|---|---|---|
|
|
147
|
+
| `name` | Yes | — | Display name in HomeKit |
|
|
148
|
+
| `host` | Yes | — | NAS IP address or hostname |
|
|
149
|
+
| `mac` | No | — | MAC address for WOL. If omitted, power-on is unavailable |
|
|
150
|
+
| `port` | No | `22` | SSH port |
|
|
151
|
+
| `username` | Yes | — | SSH username |
|
|
152
|
+
| `password` | Conditional | — | SSH password. Required if `privateKeyPath` not set |
|
|
153
|
+
| `privateKeyPath` | Conditional | — | Path to SSH private key. Required if `password` not set |
|
|
154
|
+
| `passphrase` | No | — | Passphrase for an encrypted private key. Only meaningful when `privateKeyPath` is set |
|
|
155
|
+
| `shutdownCommand` | No | `sudo shutdown -h now` | Command to run over SSH to shut down the NAS |
|
|
156
|
+
| `pollInterval` | No | `30` | Seconds between state polls (min 5) |
|
|
157
|
+
| `wolVerifyDelay` | No | `10` | Duration in seconds of the boot verification window after WOL. The plugin retries every 5s within this window — increase for slow-booting hardware |
|
|
158
|
+
| `shutdownCooldownDelay` | No | `30` | Seconds to suppress polling after a shutdown command to prevent the switch flickering back to ON. Cancelled immediately if the user toggles the switch again |
|
|
159
|
+
| `execTimeout` | No | `30` | Seconds to wait for the SSH shutdown command before timing out. Increase for slow-shutting hardware |
|
|
160
|
+
| `wolBroadcastAddress` | No | `255.255.255.255` | WOL broadcast address. Change for VLAN setups. IPv4 only — WOL does not support IPv6 |
|
|
161
|
+
| `uuidOverride` | No | — | Advanced: manually specify the UUID seed string for this device. Use when you need a stable UUID that is independent of MAC address or name/host — for example, to rename a device without losing HomeKit history |
|
|
162
|
+
| `knownHostsPath` | No | `$HOMEBRIDGE_USER_STORAGE_PATH/nas-power-known-hosts` | Path for SSH fingerprint storage. The directory is created automatically if it does not exist |
|
|
163
|
+
| `manufacturer` | No | `OpenMediaVault` | Shown in HomeKit accessory info |
|
|
164
|
+
| `model` | No | `NAS` | Shown in HomeKit accessory info |
|
|
165
|
+
| `firmwareRevision` | No | — | Shown in HomeKit accessory info |
|
|
166
|
+
| `hardwareRevision` | No | — | Shown in HomeKit accessory info |
|
|
167
|
+
|
|
168
|
+
> **UUID stability:** Each device's HomeKit UUID is derived from its MAC address. If no MAC is provided, the UUID falls back to `name + host`. Changing the name or IP without a MAC causes HomeKit to treat it as a new accessory. Providing a MAC is strongly recommended.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## SSH Host Key Verification
|
|
173
|
+
|
|
174
|
+
The plugin uses Trust On First Use (TOFU). On first connection it stores the host's SHA256 fingerprint. All subsequent connections verify against it, protecting against MITM attacks.
|
|
175
|
+
|
|
176
|
+
**Known-hosts file format:** Each line stores one host entry:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
host:port SHA256:base64encodedfingerprint
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
For example:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
192.168.1.100:22 SHA256:AbCdEf1234...
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
You can pre-populate this file manually for scripted deployments, or delete individual lines to force re-verification of a specific host.
|
|
189
|
+
|
|
190
|
+
If the fingerprint changes legitimately (e.g. after reinstalling OMV), verify the new key first:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Then delete the stored fingerprints and restart Homebridge:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
rm $HOMEBRIDGE_USER_STORAGE_PATH/nas-power-known-hosts
|
|
200
|
+
sudo systemctl restart homebridge
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Understanding State
|
|
206
|
+
|
|
207
|
+
### What "OFF" means
|
|
208
|
+
|
|
209
|
+
**"OFF" means SSH port unreachable — not necessarily powered off.** The following all appear identical to the plugin:
|
|
210
|
+
|
|
211
|
+
- NAS is powered off
|
|
212
|
+
- NAS is booting (SSH not yet started)
|
|
213
|
+
- SSH daemon has crashed
|
|
214
|
+
- Firewall blocking port 22
|
|
215
|
+
- Network unreachable
|
|
216
|
+
|
|
217
|
+
After 3 consecutive TCP failures the plugin reports OFF regardless of last known state — this handles hard power cuts so the switch doesn't stay stuck ON indefinitely.
|
|
218
|
+
|
|
219
|
+
> **Note:** State is determined by a raw TCP port check, not a full SSH handshake. A device spoofing your NAS IP on port 22 would cause the plugin to report ON. Host key verification only applies to SSH shutdown commands. This is an acceptable trade-off for home networks.
|
|
220
|
+
|
|
221
|
+
### Optimistic updates
|
|
222
|
+
|
|
223
|
+
- The switch updates **immediately** when toggled — HomeKit gets instant feedback.
|
|
224
|
+
- Verification (WOL retry loop or polling) corrects the state if the action fails.
|
|
225
|
+
- When a power-on or shutdown attempt fails, the plugin reverts the switch and logs the reason (e.g. WOL failure, SSH failure).
|
|
226
|
+
- Automations may briefly see the optimistic state before verification completes.
|
|
227
|
+
|
|
228
|
+
### WOL verification behavior
|
|
229
|
+
|
|
230
|
+
When power-on is triggered:
|
|
231
|
+
|
|
232
|
+
1. Sends 3 magic packets with 200ms spacing.
|
|
233
|
+
2. Starts a verification window (`wolVerifyDelay` seconds).
|
|
234
|
+
3. **Polling is blocked immediately** — the plugin sets a guard before sending packets to prevent the poll from flickering the switch to OFF during the send window.
|
|
235
|
+
4. Retries `isAlive()` every 5 seconds until:
|
|
236
|
+
- NAS responds → switch stays ON
|
|
237
|
+
- Deadline expires → switch reverts to OFF and polling resumes
|
|
238
|
+
|
|
239
|
+
This means a NAS that takes 45 seconds to boot will be detected correctly as long as `wolVerifyDelay` is set high enough (default 10s — increase for slow hardware).
|
|
240
|
+
|
|
241
|
+
### Shutdown behavior
|
|
242
|
+
|
|
243
|
+
- The shutdown command is sent over SSH.
|
|
244
|
+
- OMV (and most Linux systems) drops the SSH connection mid-shutdown — this is expected and treated as success, not an error.
|
|
245
|
+
- Shutdown success is **not** verified by SSH exit code alone — the plugin relies on subsequent polling to confirm the NAS is offline.
|
|
246
|
+
- Polling is suppressed for `shutdownCooldownDelay` seconds (default 30s) after the command is sent to prevent the switch flickering back to ON while the NAS powers down.
|
|
247
|
+
- If the user toggles the switch during the cooldown window, the cooldown is cancelled immediately and the new action proceeds.
|
|
248
|
+
|
|
249
|
+
### Polling and backoff
|
|
250
|
+
|
|
251
|
+
- Polling checks SSH port reachability every `pollInterval` seconds (default 30s).
|
|
252
|
+
- Polling is **suspended** during WOL verification and shutdown cooldown windows.
|
|
253
|
+
- On consecutive failures, polling uses **exponential backoff** (interval × 2ⁿ) up to a maximum of 5 minutes, reducing network load during extended downtime.
|
|
254
|
+
- On the next successful check or user-initiated action, the backoff resets.
|
|
255
|
+
|
|
256
|
+
### Transition latency
|
|
257
|
+
|
|
258
|
+
The HomeKit switch updates optimistically (immediately on user action). Actual state changes take time — shutdown may take 30s to several minutes; boot typically 30–120s depending on hardware.
|
|
259
|
+
|
|
260
|
+
**HomeKit automation note:** Because `handleSet` returns immediately (to prevent the Home app spinner), HomeKit automations may briefly see a false-positive state before verification corrects it. This is a deliberate UX trade-off — the switch feels instantaneous but HomeKit loses direct transactional feedback. The optimistic update is corrected by WOL verification and polling within seconds.
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Wake-on-LAN Troubleshooting
|
|
265
|
+
|
|
266
|
+
- **Wi-Fi:** Many wireless adapters do not support WOL. Homebridge should be on wired ethernet.
|
|
267
|
+
- **Managed switches:** May require WOL to be explicitly enabled per-port.
|
|
268
|
+
- **Energy Efficient Ethernet (EEE):** Can interfere with WOL. Disable in NAS network adapter settings.
|
|
269
|
+
- **VLAN isolation:** Magic packets won't cross VLAN boundaries. Use `wolBroadcastAddress` with a subnet-directed broadcast (e.g. `192.168.1.255`).
|
|
270
|
+
- **Router blocking broadcasts:** Use a directed broadcast address instead of `255.255.255.255`.
|
|
271
|
+
- **Slow-booting hardware:** Increase `wolVerifyDelay` beyond the default 10s. The plugin retries every 5s until the deadline, so a value of 60–120s covers most hardware.
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Notes
|
|
276
|
+
|
|
277
|
+
- The plugin supports multiple NAS devices — add additional entries to the `devices` array.
|
|
278
|
+
- OMV drops the SSH connection during shutdown — the plugin treats this as expected, not an error.
|
|
279
|
+
- WOL uses IPv4 UDP broadcast only. IPv6-only networks are not supported.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "NasPower",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": false,
|
|
5
|
+
"schema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["name"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"title": "Platform Name",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"default": "NAS Power"
|
|
13
|
+
},
|
|
14
|
+
"devices": {
|
|
15
|
+
"title": "NAS Devices",
|
|
16
|
+
"type": "array",
|
|
17
|
+
"items": {
|
|
18
|
+
"title": "NAS Device",
|
|
19
|
+
"type": "object",
|
|
20
|
+
"required": ["name", "host", "username"],
|
|
21
|
+
"properties": {
|
|
22
|
+
"name": {
|
|
23
|
+
"title": "Display Name",
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"host": {
|
|
27
|
+
"title": "IP Address or Hostname",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"minLength": 1,
|
|
30
|
+
"description": "Local IP address (e.g. 192.168.1.100) or hostname of the NAS."
|
|
31
|
+
},
|
|
32
|
+
"mac": {
|
|
33
|
+
"title": "MAC Address (for WOL)",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"pattern": "^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$",
|
|
36
|
+
"description": "MAC address used for Wake-on-LAN. Optional — if omitted, power-on will not be available.",
|
|
37
|
+
"placeholder": "AA:BB:CC:DD:EE:FF"
|
|
38
|
+
},
|
|
39
|
+
"port": {
|
|
40
|
+
"title": "SSH Port",
|
|
41
|
+
"type": "integer",
|
|
42
|
+
"default": 22,
|
|
43
|
+
"minimum": 1,
|
|
44
|
+
"maximum": 65535
|
|
45
|
+
},
|
|
46
|
+
"username": {
|
|
47
|
+
"title": "SSH Username",
|
|
48
|
+
"type": "string"
|
|
49
|
+
},
|
|
50
|
+
"password": {
|
|
51
|
+
"title": "SSH Password",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"format": "password",
|
|
54
|
+
"minLength": 1,
|
|
55
|
+
"description": "SSH password. Required if privateKeyPath is not set. Both may be supplied; private key takes priority."
|
|
56
|
+
},
|
|
57
|
+
"privateKeyPath": {
|
|
58
|
+
"title": "SSH Private Key Path",
|
|
59
|
+
"type": "string",
|
|
60
|
+
"minLength": 1,
|
|
61
|
+
"description": "Absolute path to an SSH private key file. Recommended over password auth.",
|
|
62
|
+
"placeholder": "/home/homebridge/.ssh/id_ed25519"
|
|
63
|
+
},
|
|
64
|
+
"passphrase": {
|
|
65
|
+
"title": "Private Key Passphrase",
|
|
66
|
+
"type": "string",
|
|
67
|
+
"format": "password",
|
|
68
|
+
"description": "Passphrase for the private key, if encrypted."
|
|
69
|
+
},
|
|
70
|
+
"shutdownCommand": {
|
|
71
|
+
"title": "Shutdown Command",
|
|
72
|
+
"type": "string",
|
|
73
|
+
"default": "sudo shutdown -h now",
|
|
74
|
+
"description": "Command run over SSH to shut down the NAS. Only use trusted values — it is executed directly on the NAS without sanitization."
|
|
75
|
+
},
|
|
76
|
+
"pollInterval": {
|
|
77
|
+
"title": "Poll Interval (seconds)",
|
|
78
|
+
"type": "integer",
|
|
79
|
+
"default": 30,
|
|
80
|
+
"minimum": 5,
|
|
81
|
+
"maximum": 86400,
|
|
82
|
+
"description": "How often to check NAS power state via SSH port check. Min 5s, max 86400s (24h)."
|
|
83
|
+
},
|
|
84
|
+
"wolVerifyDelay": {
|
|
85
|
+
"title": "WOL Verify Delay (seconds)",
|
|
86
|
+
"type": "integer",
|
|
87
|
+
"default": 10,
|
|
88
|
+
"minimum": 1,
|
|
89
|
+
"maximum": 300,
|
|
90
|
+
"description": "How long to wait after sending WOL before checking if the NAS has booted. Increase for slow-booting hardware."
|
|
91
|
+
},
|
|
92
|
+
"shutdownCooldownDelay": {
|
|
93
|
+
"title": "Shutdown Cooldown Delay (seconds)",
|
|
94
|
+
"type": "integer",
|
|
95
|
+
"default": 15,
|
|
96
|
+
"minimum": 1,
|
|
97
|
+
"maximum": 300,
|
|
98
|
+
"description": "How long to suppress polling after a shutdown command. During this window, rapid power-on will not be detected until the cooldown expires. Default 15s covers most NAS shutdown speeds; increase for slower hardware."
|
|
99
|
+
},
|
|
100
|
+
"wolBroadcastAddress": {
|
|
101
|
+
"title": "WOL Broadcast Address",
|
|
102
|
+
"type": "string",
|
|
103
|
+
"default": "255.255.255.255",
|
|
104
|
+
"pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",
|
|
105
|
+
"description": "Broadcast address for WOL magic packet. Change if your NAS is on a different VLAN or subnet.",
|
|
106
|
+
"placeholder": "255.255.255.255"
|
|
107
|
+
},
|
|
108
|
+
"knownHostsPath": {
|
|
109
|
+
"title": "Known Hosts File Path",
|
|
110
|
+
"type": "string",
|
|
111
|
+
"description": "Path to store verified SSH host fingerprints. Defaults to $HOMEBRIDGE_USER_STORAGE_PATH/nas-power-known-hosts.",
|
|
112
|
+
"placeholder": "/home/homebridge/.homebridge/nas-power-known-hosts"
|
|
113
|
+
},
|
|
114
|
+
"execTimeout": {
|
|
115
|
+
"title": "SSH Exec Timeout (seconds)",
|
|
116
|
+
"type": "integer",
|
|
117
|
+
"default": 30,
|
|
118
|
+
"minimum": 5,
|
|
119
|
+
"maximum": 300,
|
|
120
|
+
"description": "How long to wait for the SSH shutdown command to complete before treating it as a timeout. Increase for slow-shutting NAS hardware."
|
|
121
|
+
},
|
|
122
|
+
"uuidOverride": {
|
|
123
|
+
"title": "UUID Override",
|
|
124
|
+
"type": "string",
|
|
125
|
+
"description": "Advanced: manually specify the seed string for this device's HomeKit UUID. Use when two physical devices share the same MAC address and need to coexist in the same config."
|
|
126
|
+
},
|
|
127
|
+
"manufacturer": {
|
|
128
|
+
"title": "Manufacturer",
|
|
129
|
+
"type": "string",
|
|
130
|
+
"description": "Shown in HomeKit accessory info. Defaults to 'OpenMediaVault'."
|
|
131
|
+
},
|
|
132
|
+
"model": {
|
|
133
|
+
"title": "Model",
|
|
134
|
+
"type": "string",
|
|
135
|
+
"description": "Shown in HomeKit accessory info. Defaults to 'NAS'."
|
|
136
|
+
},
|
|
137
|
+
"firmwareRevision": {
|
|
138
|
+
"title": "Firmware Revision",
|
|
139
|
+
"type": "string",
|
|
140
|
+
"description": "Optional firmware version shown in HomeKit accessory info."
|
|
141
|
+
},
|
|
142
|
+
"hardwareRevision": {
|
|
143
|
+
"title": "Hardware Revision",
|
|
144
|
+
"type": "string",
|
|
145
|
+
"description": "Optional hardware version shown in HomeKit accessory info."
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"anyOf": [
|
|
149
|
+
{ "required": ["password"] },
|
|
150
|
+
{ "required": ["privateKeyPath"] }
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
|
+
import { NasPowerPlatform } from './platform';
|
|
3
|
+
import { DeviceConfig } from './types';
|
|
4
|
+
export declare class NasAccessory {
|
|
5
|
+
private readonly platform;
|
|
6
|
+
private readonly accessory;
|
|
7
|
+
private readonly service;
|
|
8
|
+
private readonly ssh;
|
|
9
|
+
private readonly name;
|
|
10
|
+
private readonly mac?;
|
|
11
|
+
private readonly shutdownCommand;
|
|
12
|
+
private readonly wolBroadcastAddress;
|
|
13
|
+
private readonly wolVerifyDelay;
|
|
14
|
+
private readonly pollInterval;
|
|
15
|
+
private readonly shutdownCooldownDelay;
|
|
16
|
+
private pollTimer;
|
|
17
|
+
private wolVerifyTimer;
|
|
18
|
+
private activeWolGeneration;
|
|
19
|
+
private shutdownCooldownTimer;
|
|
20
|
+
private isPolling;
|
|
21
|
+
private currentState;
|
|
22
|
+
private consecutiveFailures;
|
|
23
|
+
private destroyed;
|
|
24
|
+
private wolVerifyGeneration;
|
|
25
|
+
private readonly log;
|
|
26
|
+
private stateQueue;
|
|
27
|
+
constructor(platform: NasPowerPlatform, accessory: PlatformAccessory, config: DeviceConfig);
|
|
28
|
+
private initialise;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
handleGet(): Promise<CharacteristicValue>;
|
|
31
|
+
handleSet(value: CharacteristicValue): Promise<void>;
|
|
32
|
+
private handleSetInternal;
|
|
33
|
+
private handleWakeOnLan;
|
|
34
|
+
private handleShutdown;
|
|
35
|
+
private poll;
|
|
36
|
+
private schedulePoll;
|
|
37
|
+
private revertState;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=accessory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessory.d.ts","sourceRoot":"","sources":["../src/accessory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOvC,qBAAa,YAAY;IA6CrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IA7C5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;IAEjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;IAE/C,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,cAAc,CAA8C;IAIpE,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,qBAAqB,CAA8C;IAC3E,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,mBAAmB,CAAK;IAChC,OAAO,CAAC,SAAS,CAAS;IAK1B,OAAO,CAAC,mBAAmB,CAAK;IAIhC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAIlB;IAOF,OAAO,CAAC,UAAU,CAAoC;gBAGnC,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,iBAAiB,EAC7C,MAAM,EAAE,YAAY;YA2FR,UAAU;IAmBxB,OAAO,IAAI,IAAI;IAUT,SAAS,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAK/C,SAAS,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;YAiBtC,iBAAiB;YA6BjB,eAAe;YA0Ff,cAAc;YAiCd,IAAI;IA8ClB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,WAAW;CAOpB"}
|