homebridge-philips-air-purifier-complete 3.2.3 → 3.2.5
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 +33 -0
- package/homebridge-ui/public/index.html +7 -2
- package/homebridge-ui/server.js +66 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,39 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [3.2.5] — 15/06/2026
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Air+ Cloud login: extract the authorisation code directly from the URL the user pastes —
|
|
14
|
+
whether it is the `com.philips.air://loginredirect?code=…` deep link or the `accounts.home.id`
|
|
15
|
+
consent/proxy page — by parsing the query string, then the URL fragment, then a regex fallback.
|
|
16
|
+
The v3.2.4 approach refetched the proxy page server-side, which could never succeed because the
|
|
17
|
+
authorisation code is bound to the user's authenticated browser session; that refetch is now only
|
|
18
|
+
a last resort. This is the fix for testers who reported the proxy page error after approving access.
|
|
19
|
+
- Air+ Cloud login: reworded the on-screen steps so the `accounts.home.id` URL is presented as an
|
|
20
|
+
equally valid thing to paste, not a fallback, since many desktop browsers never leave the
|
|
21
|
+
`com.philips.air://` URL in the address bar.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## [3.2.4] — 15/06/2026
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- Air+ Cloud login: detect and handle the Philips consent proxy page URL
|
|
30
|
+
(`accounts.home.id/authui/client/proxy?mode=afterConsent&…`) that some browsers navigate to
|
|
31
|
+
instead of the `com.philips.air://loginredirect?code=…` deep-link redirect. The server now
|
|
32
|
+
fetches the proxy page server-side and attempts to extract the authorisation code automatically.
|
|
33
|
+
If the code cannot be extracted, a clear error explains exactly where to find the correct URL.
|
|
34
|
+
- Air+ Cloud login: rewrote the step-by-step instructions to explain that the browser will try to
|
|
35
|
+
open the Philips Air app, that the address bar will show the `com.philips.air://` URL at that
|
|
36
|
+
moment, and that both the deep-link URL and the Philips proxy page URL can be pasted.
|
|
37
|
+
- Air+ Cloud login: improved the generic "No authorisation code found" error to include specific
|
|
38
|
+
guidance on what URL to look for and where.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
9
42
|
## [3.2.3] — 15/06/2026
|
|
10
43
|
|
|
11
44
|
### Changed
|
|
@@ -262,9 +262,14 @@
|
|
|
262
262
|
|
|
263
263
|
<div id="airplus-flow" hidden>
|
|
264
264
|
<div id="airplus-step-1" class="airplus-step">
|
|
265
|
-
<
|
|
265
|
+
<ol style="color: var(--muted); font-size: 13px; padding-left: 20px; margin: 0 0 14px; line-height: 1.7;">
|
|
266
|
+
<li><a id="auth-link" href="#" target="_blank" rel="noopener">Open the Philips login page</a> (a new tab will open automatically — click the link if it didn't).</li>
|
|
267
|
+
<li>Log in to your Philips account and approve access when prompted.</li>
|
|
268
|
+
<li>After approving, your browser will try to open the Philips Air app and will land on either an error page or a Philips page (<em>accounts.home.id</em>) — this is expected.</li>
|
|
269
|
+
<li>Copy the <strong style="color: var(--text);">full URL from your browser's address bar</strong> and paste it below. It works whether it starts with <code style="background:#1a1a1a; padding: 1px 4px; border-radius: 3px; font-size: 12px;">com.philips.air://loginredirect?code=…</code> or is an <em>accounts.home.id</em> address — as long as it contains <code style="background:#1a1a1a; padding: 1px 4px; border-radius: 3px; font-size: 12px;">code=…</code>.</li>
|
|
270
|
+
</ol>
|
|
266
271
|
<div class="field">
|
|
267
|
-
<label for="redirect-url">Redirect URL</label>
|
|
272
|
+
<label for="redirect-url">Redirect URL (from your browser's address bar)</label>
|
|
268
273
|
<textarea id="redirect-url" placeholder="com.philips.air://loginredirect?code=..."></textarea>
|
|
269
274
|
</div>
|
|
270
275
|
<div class="toolbar">
|
package/homebridge-ui/server.js
CHANGED
|
@@ -59,12 +59,37 @@ class AirPlusSetupServer extends HomebridgePluginUiServer {
|
|
|
59
59
|
throw new Error('Redirect URL is required');
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
// The authorisation code lives in the URL the user copied — whether that is the
|
|
63
|
+
// com.philips.air:// deep link or the accounts.home.id consent/proxy page that
|
|
64
|
+
// many desktop browsers land on instead. Parse it directly (query → fragment →
|
|
65
|
+
// regex), mirroring scripts/airplus_setup.py.
|
|
66
|
+
let code = this._extractCode(redirectUrl);
|
|
67
|
+
|
|
68
|
+
// Last resort: the user pasted a Philips consent page that did not carry the
|
|
69
|
+
// code in its own URL. Fetch it and scan for an embedded deep link. This only
|
|
70
|
+
// works if the page is reachable unauthenticated, so treat failure as benign.
|
|
71
|
+
if (!code && redirectUrl.includes('accounts.home.id')) {
|
|
72
|
+
try {
|
|
73
|
+
const proxyUrl = new URL(redirectUrl);
|
|
74
|
+
const html = await this._httpsGetRaw({
|
|
75
|
+
hostname: proxyUrl.hostname,
|
|
76
|
+
path: proxyUrl.pathname + proxyUrl.search,
|
|
77
|
+
headers: { 'User-Agent': USER_AGENT, Accept: 'text/html' },
|
|
78
|
+
});
|
|
79
|
+
const m = html.match(/com\.philips\.air:\/\/loginredirect[^\s"'\\]*code=([^&\s"'\\]+)/);
|
|
80
|
+
if (m) code = decodeURIComponent(m[1]);
|
|
81
|
+
} catch (_) { /* fall through to descriptive error */ }
|
|
82
|
+
}
|
|
83
|
+
|
|
66
84
|
if (!code) {
|
|
67
|
-
throw new Error(
|
|
85
|
+
throw new Error(
|
|
86
|
+
'No authorisation code found in that URL. After approving access, copy the ' +
|
|
87
|
+
'full URL from your browser’s address bar and paste it here — it will start ' +
|
|
88
|
+
'with either "com.philips.air://loginredirect?code=…" or an "accounts.home.id" ' +
|
|
89
|
+
'address containing "code=…". If you only see a Philips confirmation page with ' +
|
|
90
|
+
'no "code=" in its address, log in again and copy the URL the moment the page ' +
|
|
91
|
+
'finishes loading.'
|
|
92
|
+
);
|
|
68
93
|
}
|
|
69
94
|
|
|
70
95
|
const tokenBody = new URLSearchParams({
|
|
@@ -152,6 +177,30 @@ class AirPlusSetupServer extends HomebridgePluginUiServer {
|
|
|
152
177
|
return { success: true, uuid, name: name || 'Philips Air Purifier', tokenFile: tokenPath };
|
|
153
178
|
}
|
|
154
179
|
|
|
180
|
+
_extractCode(redirectUrl) {
|
|
181
|
+
const trimmed = String(redirectUrl || '').trim();
|
|
182
|
+
if (!trimmed) return null;
|
|
183
|
+
|
|
184
|
+
// Normalise the custom scheme so the URL parser accepts it.
|
|
185
|
+
const normalised = trimmed.replace(/^com\.philips\.air:\/\//i, 'https://airplus.local/');
|
|
186
|
+
let parsed = null;
|
|
187
|
+
try { parsed = new URL(normalised); } catch (_) { parsed = null; }
|
|
188
|
+
|
|
189
|
+
if (parsed) {
|
|
190
|
+
const fromQuery = parsed.searchParams.get('code');
|
|
191
|
+
if (fromQuery) return fromQuery;
|
|
192
|
+
// OIDC may return the response in the URL fragment (#code=…&state=…).
|
|
193
|
+
if (parsed.hash && parsed.hash.length > 1) {
|
|
194
|
+
const fromFragment = new URLSearchParams(parsed.hash.slice(1)).get('code');
|
|
195
|
+
if (fromFragment) return fromFragment;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Fallback for unusual encodings the URL parser may not split cleanly.
|
|
200
|
+
const m = trimmed.match(/[?&#]code=([^&\s"'\\]+)/);
|
|
201
|
+
return m ? decodeURIComponent(m[1]) : null;
|
|
202
|
+
}
|
|
203
|
+
|
|
155
204
|
_httpsRequest(options, postBody) {
|
|
156
205
|
return new Promise((resolve, reject) => {
|
|
157
206
|
const req = https.request(options, (res) => {
|
|
@@ -178,6 +227,18 @@ class AirPlusSetupServer extends HomebridgePluginUiServer {
|
|
|
178
227
|
req.end();
|
|
179
228
|
});
|
|
180
229
|
}
|
|
230
|
+
|
|
231
|
+
_httpsGetRaw(options) {
|
|
232
|
+
return new Promise((resolve, reject) => {
|
|
233
|
+
const req = https.request(options, (res) => {
|
|
234
|
+
const chunks = [];
|
|
235
|
+
res.on('data', (chunk) => chunks.push(chunk));
|
|
236
|
+
res.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
237
|
+
});
|
|
238
|
+
req.on('error', reject);
|
|
239
|
+
req.end();
|
|
240
|
+
});
|
|
241
|
+
}
|
|
181
242
|
}
|
|
182
243
|
|
|
183
244
|
new AirPlusSetupServer();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-philips-air-purifier-complete",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"customUi": true,
|
|
5
5
|
"description": "Homebridge plugin for Philips Air Purifier with bundled CoAP control library and Python 3.12+/Node.js 24 support",
|
|
6
6
|
"main": "index.js",
|