homebridge-philips-air-purifier-complete 2.3.0 → 2.4.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.
@@ -0,0 +1,23 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: github-actions
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ open-pull-requests-limit: 5
8
+
9
+ - package-ecosystem: npm
10
+ directory: /
11
+ schedule:
12
+ interval: weekly
13
+ open-pull-requests-limit: 5
14
+ groups:
15
+ dev-dependencies:
16
+ patterns: ["*"]
17
+ update-types: ["minor", "patch"]
18
+
19
+ - package-ecosystem: pip
20
+ directory: /
21
+ schedule:
22
+ interval: weekly
23
+ open-pull-requests-limit: 5
@@ -0,0 +1,23 @@
1
+ name: Dependabot auto-merge
2
+
3
+ on: pull_request
4
+
5
+ permissions:
6
+ contents: write
7
+ pull-requests: write
8
+
9
+ jobs:
10
+ automerge:
11
+ runs-on: ubuntu-latest
12
+ if: github.actor == 'dependabot[bot]'
13
+ steps:
14
+ - name: Fetch Dependabot metadata
15
+ id: metadata
16
+ uses: dependabot/fetch-metadata@v3
17
+
18
+ - name: Auto-merge patch updates
19
+ if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
20
+ run: gh pr merge --auto --squash "$PR_URL"
21
+ env:
22
+ PR_URL: ${{ github.event.pull_request.html_url }}
23
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,26 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ id-token: write # Required for npm OIDC trusted publishing
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: '24'
18
+ registry-url: 'https://registry.npmjs.org'
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: '3.12'
22
+ - run: npm install -g npm@latest # Trusted publishing requires npm >= 11.5.1
23
+ - run: npm ci
24
+ - run: npm test
25
+ - run: npm publish --provenance
26
+ # No NODE_AUTH_TOKEN — OIDC is used instead; any token value (even empty) blocks OIDC
@@ -0,0 +1,44 @@
1
+ name: Security
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ permissions:
10
+ contents: read
11
+ security-events: write
12
+
13
+ jobs:
14
+ security:
15
+ name: security
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v6
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - name: Gitleaks
23
+ uses: gitleaks/gitleaks-action@v3
24
+ env:
25
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26
+
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v6
29
+ with:
30
+ python-version: '3.12'
31
+
32
+ - name: Install audit tools
33
+ run: pip install pip-audit bandit
34
+
35
+ - name: pip-audit
36
+ run: pip-audit || true
37
+
38
+ - name: Bandit SAST
39
+ run: bandit -r . -ll -x ./.git,./node_modules --quiet || true
40
+
41
+ - name: Semgrep
42
+ run: |
43
+ pip install semgrep
44
+ semgrep --config=p/default --config=p/secrets --config=p/owasp-top-ten --error --quiet || true
package/CHANGELOG.md CHANGED
@@ -6,6 +6,26 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
6
6
 
7
7
  ---
8
8
 
9
+ ## [2.4.0] — 14/06/2026
10
+
11
+ ### Added
12
+
13
+ - **Philips Air+ cloud MQTT protocol** (`airplus-cloud`) for devices registered in the
14
+ Philips Air+ app (e.g. AC0650/10, AC1715). Uses OAuth2/PKCE → AWS IoT MQTT over WebSocket.
15
+ State updates push within ~2 seconds via MQTT subscription.
16
+ - `scripts/airplus_setup.py` — interactive CLI to complete the OAuth2/PKCE flow, list registered
17
+ devices, and save tokens to `~/.homebridge/philips-airplus-{uuid}.json`.
18
+ - `scripts/probe_devices.py` — standalone stdlib-only script that tests all three local protocols
19
+ (CoAP port 5683, HTTP DH/AES, HomeID) against a list of device IPs and prints a pass/fail report.
20
+ - New `paho-mqtt>=2.1` Python runtime dependency (installed automatically by `postinstall.sh`).
21
+ - New config options `airplusDeviceUuid` and `airplusTokenFile` for `airplus-cloud` accessories.
22
+ - Air+ MQTT power field `D0310D` is now normalised to `D03102` in `parse_status()` so the same
23
+ IPC shape is produced for all protocols.
24
+ - Homebridge UI wizard for Air+ cloud device setup — no SSH or terminal required. Accessible
25
+ from the plugin's Settings page in the Homebridge web UI.
26
+
27
+ ---
28
+
9
29
  ## [2.3.0] — 2026-05-24
10
30
 
11
31
  ### Added
package/CODEOWNERS ADDED
@@ -0,0 +1,5 @@
1
+ # Default owner — review required on all changes
2
+ * @MaddogWarner
3
+
4
+ # CI/CD and security configs require explicit sign-off
5
+ .github/ @MaddogWarner
package/README.md CHANGED
@@ -181,6 +181,36 @@ If your device shows `Network error: NetworkError` on every command, try setting
181
181
 
182
182
  ---
183
183
 
184
+ ## Air+ Cloud Setup (AC0650, AC1715)
185
+
186
+ ### Quick Setup (Homebridge UI — recommended)
187
+
188
+ 1. Install the plugin via the Homebridge UI
189
+ 2. Go to **Plugins → Philips Air Purifier → Settings**
190
+ 3. Click **"Add Air+ Device"**
191
+ 4. Click **"Open Philips login →"** — log in with your Philips account
192
+ 5. Your browser shows an error page — **copy the full URL from the address bar**
193
+ 6. Paste it into the setup page and click **Continue**
194
+ 7. Click **"Save & Connect"** next to your device
195
+ 8. Restart Homebridge
196
+
197
+ Each device needs its own setup run. Run through the wizard once per purifier.
198
+
199
+ ### Advanced / Headless Setup (SSH)
200
+
201
+ If your Homebridge host has no browser access (Docker, NAS, headless Raspberry Pi):
202
+
203
+ ```bash
204
+ cd /path/to/homebridge-philips-air-purifier-complete
205
+ source .venv/bin/activate
206
+ python scripts/airplus_setup.py
207
+ ```
208
+
209
+ Follow the on-screen instructions. The script saves a token file to
210
+ `~/.homebridge/philips-airplus-{uuid}.json` and prints the Homebridge config to add.
211
+
212
+ ---
213
+
184
214
  ## Connectivity Check (optional)
185
215
 
186
216
  Before configuring Homebridge, you can verify the plugin can reach your device:
@@ -24,9 +24,9 @@
24
24
  "protocol": {
25
25
  "title": "Protocol",
26
26
  "type": "string",
27
- "enum": ["coap", "http", "homeid-http"],
27
+ "enum": ["coap", "http", "homeid-http", "airplus-cloud"],
28
28
  "default": "coap",
29
- "description": "Communication protocol. Use 'http' for AC1xxx DH/AES models (AC1715, etc.) or 'homeid-http' for HomeID/Condor local HTTP devices."
29
+ "description": "Communication protocol. Use 'http' for AC1xxx DH/AES models, 'homeid-http' for HomeID/Condor local HTTP devices, or 'airplus-cloud' for devices registered in the Philips Air+ app (cloud MQTT)."
30
30
  },
31
31
  "useHttps": {
32
32
  "title": "Use HTTPS for HomeID",
@@ -55,6 +55,18 @@
55
55
  "x-schema-form": { "type": "password" },
56
56
  "description": "Optional hex AES key for HomeID local HTTP payload encryption. If omitted and credentials are provided, the plugin attempts to fetch it from the device security endpoint."
57
57
  },
58
+ "airplusDeviceUuid": {
59
+ "title": "Air+ Device UUID",
60
+ "type": "string",
61
+ "required": false,
62
+ "description": "UUID from running 'python scripts/airplus_setup.py'. Required for airplus-cloud protocol."
63
+ },
64
+ "airplusTokenFile": {
65
+ "title": "Air+ Token File Path",
66
+ "type": "string",
67
+ "required": false,
68
+ "description": "Path to tokens JSON from airplus_setup.py. Defaults to ~/.homebridge/philips-airplus-{uuid}.json if omitted."
69
+ },
58
70
  "pythonPath": {
59
71
  "title": "Python Path (Optional)",
60
72
  "type": "string",
@@ -93,6 +105,14 @@
93
105
  "key": "encryptionKey",
94
106
  "description": "Optional HomeID AES key; leave blank unless needed"
95
107
  },
108
+ {
109
+ "key": "airplusDeviceUuid",
110
+ "description": "Only required for airplus-cloud protocol. Run python scripts/airplus_setup.py to obtain."
111
+ },
112
+ {
113
+ "key": "airplusTokenFile",
114
+ "description": "Only required for airplus-cloud protocol. Leave blank to use the default ~/.homebridge path."
115
+ },
96
116
  {
97
117
  "key": "pythonPath",
98
118
  "description": "Only needed if the auto-detected Python does not have the required dependencies"
package/eslint.config.js CHANGED
@@ -7,6 +7,8 @@ module.exports = [
7
7
  '.venv/**',
8
8
  'venv/**',
9
9
  'node_modules/**',
10
+ '.claude/**',
11
+ 'homebridge-ui/**',
10
12
  ],
11
13
  },
12
14
  js.configs.recommended,
@@ -0,0 +1,375 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Philips Air+ Setup</title>
7
+ <style>
8
+ * { box-sizing: border-box; margin: 0; padding: 0; }
9
+
10
+ body {
11
+ background: #1a1a1a;
12
+ color: #e0e0e0;
13
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
14
+ font-size: 15px;
15
+ line-height: 1.5;
16
+ padding: 24px;
17
+ }
18
+
19
+ h1 {
20
+ font-size: 22px;
21
+ font-weight: 600;
22
+ margin-bottom: 20px;
23
+ color: #ffffff;
24
+ }
25
+
26
+ h2 {
27
+ font-size: 16px;
28
+ font-weight: 600;
29
+ margin-bottom: 12px;
30
+ color: #ffffff;
31
+ }
32
+
33
+ .card {
34
+ background: #2a2a2a;
35
+ border-radius: 8px;
36
+ padding: 16px 20px;
37
+ margin-bottom: 12px;
38
+ }
39
+
40
+ .card-label {
41
+ font-weight: 500;
42
+ margin-bottom: 4px;
43
+ }
44
+
45
+ .card-sub {
46
+ font-size: 13px;
47
+ color: #9e9e9e;
48
+ }
49
+
50
+ .device-card {
51
+ background: #2a2a2a;
52
+ border-radius: 8px;
53
+ padding: 16px 20px;
54
+ margin-bottom: 12px;
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: space-between;
58
+ gap: 12px;
59
+ flex-wrap: wrap;
60
+ }
61
+
62
+ .device-info {
63
+ flex: 1;
64
+ min-width: 0;
65
+ }
66
+
67
+ .device-name-input {
68
+ background: #1a1a1a;
69
+ border: 1px solid #444;
70
+ border-radius: 4px;
71
+ color: #e0e0e0;
72
+ font-size: 14px;
73
+ padding: 6px 10px;
74
+ width: 200px;
75
+ }
76
+
77
+ .device-name-input:focus {
78
+ border-color: #e88122;
79
+ outline: none;
80
+ }
81
+
82
+ button {
83
+ background: #e88122;
84
+ border: none;
85
+ border-radius: 6px;
86
+ color: #ffffff;
87
+ cursor: pointer;
88
+ font-size: 14px;
89
+ font-weight: 600;
90
+ padding: 9px 18px;
91
+ transition: background 0.15s;
92
+ }
93
+
94
+ button:hover {
95
+ background: #cf7320;
96
+ }
97
+
98
+ button.secondary {
99
+ background: #3a3a3a;
100
+ color: #e0e0e0;
101
+ }
102
+
103
+ button.secondary:hover {
104
+ background: #4a4a4a;
105
+ }
106
+
107
+ .btn-row {
108
+ display: flex;
109
+ gap: 10px;
110
+ margin-top: 16px;
111
+ flex-wrap: wrap;
112
+ }
113
+
114
+ textarea {
115
+ background: #1a1a1a;
116
+ border: 1px solid #444;
117
+ border-radius: 6px;
118
+ color: #e0e0e0;
119
+ font-family: monospace;
120
+ font-size: 13px;
121
+ padding: 10px;
122
+ resize: vertical;
123
+ width: 100%;
124
+ margin-top: 10px;
125
+ }
126
+
127
+ textarea:focus {
128
+ border-color: #e88122;
129
+ outline: none;
130
+ }
131
+
132
+ .instructions {
133
+ color: #9e9e9e;
134
+ font-size: 13px;
135
+ margin-top: 8px;
136
+ }
137
+
138
+ .note {
139
+ color: #9e9e9e;
140
+ font-size: 13px;
141
+ margin-top: 20px;
142
+ padding-top: 16px;
143
+ border-top: 1px solid #333;
144
+ }
145
+
146
+ a {
147
+ color: #e88122;
148
+ text-decoration: none;
149
+ }
150
+
151
+ a:hover {
152
+ text-decoration: underline;
153
+ }
154
+
155
+ #error-box {
156
+ display: none;
157
+ background: #2a1a1a;
158
+ border: 1px solid #e53935;
159
+ border-radius: 6px;
160
+ color: #e53935;
161
+ margin-bottom: 16px;
162
+ padding: 12px 16px;
163
+ }
164
+
165
+ .success-title {
166
+ color: #43a047;
167
+ font-size: 20px;
168
+ font-weight: 600;
169
+ margin-bottom: 8px;
170
+ }
171
+
172
+ .token-path {
173
+ color: #9e9e9e;
174
+ font-family: monospace;
175
+ font-size: 12px;
176
+ margin-top: 8px;
177
+ word-break: break-all;
178
+ }
179
+
180
+ .spinner {
181
+ color: #9e9e9e;
182
+ font-size: 14px;
183
+ padding: 20px 0;
184
+ }
185
+
186
+ .existing-device {
187
+ color: #43a047;
188
+ font-size: 13px;
189
+ }
190
+
191
+ .step { display: none; }
192
+ .step.active { display: block; }
193
+ </style>
194
+ </head>
195
+ <body>
196
+
197
+ <h1>Philips Air+ Setup</h1>
198
+
199
+ <div id="error-box">
200
+ <span id="error-msg"></span>
201
+ <div class="btn-row">
202
+ <button onclick="goToStep(1)">Try again</button>
203
+ </div>
204
+ </div>
205
+
206
+ <!-- Step 0: Landing -->
207
+ <div id="step-0" class="step active">
208
+ <div id="existing-devices"></div>
209
+ <button onclick="startSetup()">Add Air+ Device</button>
210
+ <p class="note">For CoAP / HTTP / HomeID devices, use the JSON tab to edit config directly.</p>
211
+ </div>
212
+
213
+ <!-- Step 1: Log in -->
214
+ <div id="step-1" class="step">
215
+ <div class="card">
216
+ <h2>Log in with your Philips account</h2>
217
+ <p>
218
+ <a id="auth-link" href="#" target="_blank">Open Philips login &rarr;</a>
219
+ </p>
220
+ <p class="instructions">
221
+ After logging in, your browser will show an error page &mdash; that's expected.
222
+ Copy the entire URL from your browser's address bar and paste it below.
223
+ </p>
224
+ <textarea id="redirect-url" rows="4" placeholder="com.philips.air://loginredirect?code=..."></textarea>
225
+ </div>
226
+ <div class="btn-row">
227
+ <button onclick="doExchange()">Continue &rarr;</button>
228
+ <button class="secondary" onclick="goToStep(0)">Cancel</button>
229
+ </div>
230
+ </div>
231
+
232
+ <!-- Step 2: Device selection -->
233
+ <div id="step-2" class="step">
234
+ <div id="device-list"><div class="spinner">Connecting...</div></div>
235
+ </div>
236
+
237
+ <!-- Step 3: Success -->
238
+ <div id="step-3" class="step">
239
+ <div class="card">
240
+ <div class="success-title" id="success-title"></div>
241
+ <div class="token-path" id="token-path"></div>
242
+ </div>
243
+ <div class="btn-row">
244
+ <button onclick="startSetup()">Add Another Device</button>
245
+ <button class="secondary" onclick="location.reload()">Done</button>
246
+ </div>
247
+ </div>
248
+
249
+ <script>
250
+ let _authUrl = '';
251
+ let _pastedUrl = '';
252
+
253
+ function goToStep(n) {
254
+ document.querySelectorAll('.step').forEach(el => el.classList.remove('active'));
255
+ document.getElementById('step-' + n).classList.add('active');
256
+ hideError();
257
+ }
258
+
259
+ function showError(msg) {
260
+ const box = document.getElementById('error-box');
261
+ document.getElementById('error-msg').textContent = msg;
262
+ box.style.display = 'block';
263
+ }
264
+
265
+ function hideError() {
266
+ document.getElementById('error-box').style.display = 'none';
267
+ }
268
+
269
+ async function req(path, body) {
270
+ try {
271
+ return await homebridge.request(path, body || {});
272
+ } catch (e) {
273
+ showError(e.message || String(e));
274
+ throw e;
275
+ }
276
+ }
277
+
278
+ async function loadExistingDevices() {
279
+ try {
280
+ const configs = await homebridge.getPluginConfig();
281
+ const airplus = configs.filter(c => c.protocol === 'airplus-cloud');
282
+ const container = document.getElementById('existing-devices');
283
+ if (airplus.length === 0) {
284
+ container.innerHTML = '';
285
+ return;
286
+ }
287
+ container.innerHTML = airplus.map(c => {
288
+ const short = c.airplusDeviceUuid ? c.airplusDeviceUuid.slice(0, 8) + '...' : 'unknown';
289
+ return '<div class="card"><span class="existing-device">&#10003; ' +
290
+ escHtml(c.name || 'Philips Air Purifier') + ' (' + escHtml(short) + ')</span></div>';
291
+ }).join('');
292
+ } catch (_e) {
293
+ // not critical — ignore
294
+ }
295
+ }
296
+
297
+ async function startSetup() {
298
+ hideError();
299
+ try {
300
+ const result = await req('/auth/init');
301
+ _authUrl = result.url;
302
+ document.getElementById('auth-link').href = _authUrl;
303
+ window.open(_authUrl, '_blank');
304
+ goToStep(1);
305
+ } catch (_e) {
306
+ // error already shown
307
+ }
308
+ }
309
+
310
+ async function doExchange() {
311
+ const ta = document.getElementById('redirect-url');
312
+ const url = ta.value.trim();
313
+ if (!url) {
314
+ showError('Please paste the redirect URL from your browser.');
315
+ return;
316
+ }
317
+ _pastedUrl = url;
318
+ goToStep(2);
319
+ await loadDevices();
320
+ }
321
+
322
+ async function loadDevices() {
323
+ const container = document.getElementById('device-list');
324
+ container.innerHTML = '<div class="spinner">Connecting...</div>';
325
+ try {
326
+ const result = await req('/auth/exchange', { redirectUrl: _pastedUrl });
327
+ if (!result.devices || result.devices.length === 0) {
328
+ container.innerHTML = '<div class="card">No devices found on this account.</div>';
329
+ return;
330
+ }
331
+ container.innerHTML = '<h2>Select a device</h2>' + result.devices.map((d, i) => {
332
+ return '<div class="device-card">' +
333
+ '<div class="device-info">' +
334
+ '<div class="card-label">' + escHtml(d.name || 'Air Purifier') + '</div>' +
335
+ '<div class="card-sub">' + escHtml(d.modelName || d.uuid) + '</div>' +
336
+ '</div>' +
337
+ '<input class="device-name-input" id="name-' + i + '" type="text" value="' + escAttr(d.name || 'Philips Air Purifier') + '">' +
338
+ '<button onclick="saveDevice(' + escHtml(JSON.stringify(d.uuid)) + ', ' + i + ')">Save &amp; Connect</button>' +
339
+ '</div>';
340
+ }).join('');
341
+ } catch (_e) {
342
+ container.innerHTML = '<div class="card">Failed to load devices. <button onclick="goToStep(1)">Try again</button></div>';
343
+ }
344
+ }
345
+
346
+ async function saveDevice(uuid, idx) {
347
+ const nameInput = document.getElementById('name-' + idx);
348
+ const name = nameInput ? nameInput.value.trim() : '';
349
+ try {
350
+ const result = await req('/auth/save', { uuid, name });
351
+ document.getElementById('success-title').textContent = '✓ ' + (name || 'Device') + ' connected!';
352
+ document.getElementById('token-path').textContent = 'Token file: ' + result.tokenPath;
353
+ goToStep(3);
354
+ } catch (_e) {
355
+ // error already shown
356
+ }
357
+ }
358
+
359
+ function escHtml(str) {
360
+ return String(str)
361
+ .replace(/&/g, '&amp;')
362
+ .replace(/</g, '&lt;')
363
+ .replace(/>/g, '&gt;')
364
+ .replace(/"/g, '&quot;');
365
+ }
366
+
367
+ function escAttr(str) {
368
+ return String(str).replace(/"/g, '&quot;').replace(/'/g, '&#39;');
369
+ }
370
+
371
+ // Initialise
372
+ loadExistingDevices();
373
+ </script>
374
+ </body>
375
+ </html>