homebridge-philips-air-purifier-complete 2.2.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,55 @@ 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
+
29
+ ## [2.3.0] — 2026-05-24
30
+
31
+ ### Added
32
+
33
+ - Added explicit `homeid-http` protocol support for HomeID/Condor local HTTP devices.
34
+ This path supports HTTP or HTTPS, PhilipsCondor 401 challenge authentication, optional
35
+ HomeID AES payload encryption, and merged polling of `status`, `air`, and `fltsts`.
36
+ - Added HomeID configuration fields: `useHttps`, `clientId`, `clientSecret`, and
37
+ `encryptionKey`. HomeID secrets are passed to the Python daemon via environment
38
+ variables rather than command-line arguments.
39
+ - Added `probe-homeid` CLI diagnostic command to probe HomeID HTTP/HTTPS endpoints
40
+ without changing device state.
41
+ - Added focused Python unit tests for CoAP/HTTP/HomeID status normalisation,
42
+ HomeID AES encryption, and PhilipsCondor authentication response generation.
43
+
44
+ ### Fixed
45
+
46
+ - Restored the normalised `mode_name` field in Python sensor output while keeping
47
+ `mode` compatible with the JavaScript HomeKit mapping.
48
+ - Added clearer HTTP diagnostics for endpoint status and decrypt failures without
49
+ logging secrets or encrypted payloads.
50
+ - Replaced private `ssl._create_unverified_context()` with `ssl.create_default_context()`
51
+ (`check_hostname=False`, `verify_mode=CERT_NONE`) for HomeID HTTPS devices with
52
+ self-signed certificates.
53
+ - Removed duplicated HomeID mode mapping; both HTTP and HomeID control paths now share
54
+ `HTTP_MODE_VALUES`.
55
+
56
+ ---
57
+
9
58
  ## [2.2.0] — 2026-05-23
10
59
 
11
60
  ### 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
@@ -26,8 +26,8 @@ This plugin bundles the [aioairctrl](https://github.com/betaboon/aioairctrl) CoA
26
26
  - **Child Lock** — Lock or unlock physical controls on the device
27
27
  - **HEPA Filter Status** — Filter life percentage and change alert
28
28
  - **Pre-Filter Status** — Cleanup cycle percentage and change alert
29
- - **HTTP Protocol Support** — Supports AC1xxx-series models (e.g. AC1715) that use HTTP instead of CoAP
30
- - **Real-time Updates** — CoAP Observe push updates (AC2xxx+) or 10-second HTTP polling (AC1xxx)
29
+ - **HTTP Protocol Support** — Supports AC1xxx-series DH/AES HTTP models (e.g. AC1715) and HomeID/Condor local HTTP devices
30
+ - **Real-time Updates** — CoAP Observe push updates (AC2xxx+) or 10-second HTTP polling (HTTP/HomeID)
31
31
  - **Auto-reconnect** — Daemon restarts automatically with exponential backoff if the device drops off
32
32
 
33
33
  ---
@@ -136,7 +136,25 @@ For AC1xxx models that use HTTP:
136
136
  }
137
137
  ```
138
138
 
139
- Or configure via the Homebridge UI — fill in **Name** and **IP Address**, and set **Protocol** to `http` if your device is an AC1xxx model.
139
+ For HomeID/Condor local HTTP devices:
140
+
141
+ ```json
142
+ {
143
+ "accessories": [
144
+ {
145
+ "accessory": "PhilipsAirPurifier",
146
+ "name": "Study Air Purifier",
147
+ "host": "192.168.1.102",
148
+ "protocol": "homeid-http",
149
+ "useHttps": true,
150
+ "clientId": "BASE64_CLIENT_ID",
151
+ "clientSecret": "BASE64_CLIENT_SECRET"
152
+ }
153
+ ]
154
+ }
155
+ ```
156
+
157
+ Or configure via the Homebridge UI — fill in **Name** and **IP Address**, and set **Protocol** to `http` for AC1xxx DH/AES models or `homeid-http` for HomeID/Condor local HTTP devices.
140
158
 
141
159
  ### Configuration Options
142
160
 
@@ -144,7 +162,11 @@ Or configure via the Homebridge UI — fill in **Name** and **IP Address**, and
144
162
  |--------|----------|---------|-------------|
145
163
  | `name` | Yes | — | Name shown in HomeKit |
146
164
  | `host` | Yes | — | IPv4 address of your air purifier |
147
- | `protocol` | No | `coap` | Communication protocol. Set to `http` for AC1xxx models (AC1715, etc.) that do not support CoAP. |
165
+ | `protocol` | No | `coap` | Communication protocol. Use `http` for AC1xxx DH/AES models or `homeid-http` for HomeID/Condor local HTTP devices. |
166
+ | `useHttps` | No | `false` | Use HTTPS for `homeid-http` devices with self-signed certificates. Ignored for `coap` and `http`. |
167
+ | `clientId` | No | — | Base64 HomeID local API client ID for PhilipsCondor challenge authentication. |
168
+ | `clientSecret` | No | — | Base64 HomeID local API client secret for PhilipsCondor challenge authentication. |
169
+ | `encryptionKey` | No | Auto-fetched when possible | Optional hex AES key for HomeID encrypted payloads. Leave blank unless you already know it. |
148
170
  | `pythonPath` | No | Auto-detected | Path to Python 3.12 or newer with `aiocoap` and `pycryptodomex` installed. Leave blank to use the plugin's bundled virtual environment. |
149
171
 
150
172
  ### Model Compatibility
@@ -152,12 +174,43 @@ Or configure via the Homebridge UI — fill in **Name** and **IP Address**, and
152
174
  | Protocol | Models | Notes |
153
175
  |----------|--------|-------|
154
176
  | `coap` (default) | AC2xxx, AC3xxx, AC4xxx | CoAP Observe push updates |
155
- | `http` | AC1xxx (e.g. AC1715) | HTTP polling every 10 seconds |
177
+ | `http` | AC1xxx DH/AES models (e.g. AC1715) | HTTP polling every 10 seconds via `/air` |
178
+ | `homeid-http` | HomeID/Condor local HTTP devices | HTTP/HTTPS polling every 10 seconds via `/status`, `/air`, and `/fltsts` |
156
179
 
157
180
  If your device shows `Network error: NetworkError` on every command, try setting `"protocol": "http"` in your accessory config.
158
181
 
159
182
  ---
160
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
+
161
214
  ## Connectivity Check (optional)
162
215
 
163
216
  Before configuring Homebridge, you can verify the plugin can reach your device:
@@ -168,6 +221,10 @@ source $(npm root -g)/homebridge-philips-air-purifier-complete/.venv/bin/activat
168
221
 
169
222
  # Run a sensor query
170
223
  python $(npm root -g)/homebridge-philips-air-purifier-complete/philips_air_api.py 192.168.1.100 sensors
224
+
225
+ # Probe HomeID local HTTP endpoints without changing device state
226
+ python $(npm root -g)/homebridge-philips-air-purifier-complete/philips_air_api.py 192.168.1.100 probe-homeid
227
+ python $(npm root -g)/homebridge-philips-air-purifier-complete/philips_air_api.py 192.168.1.100 probe-homeid --use-https
171
228
  ```
172
229
 
173
230
  You should see a JSON payload with PM2.5, filter life, temperature, and so on. CoAP can be flaky on the first connection — re-run if you get a timeout.
@@ -200,7 +257,9 @@ Homebridge (Node.js)
200
257
  ▼
201
258
  philips_air_api.py ─── aioairctrl/ (bundled) ──► aiocoap ──► Philips device (CoAP)
202
259
  │
203
- └──────────────────── HTTP encrypted polling ───────────► Philips device (HTTP)
260
+ ├──────────────────── DH/AES HTTP polling ──────────────► Philips device (HTTP)
261
+ │
262
+ └──────────────────── HomeID HTTP/HTTPS polling ────────► Philips device (HomeID)
204
263
  │
205
264
  │ CoAP Observe (push)
206
265
  │ ≈ every 30s or on change
@@ -211,6 +270,7 @@ State cache ──► HomeKit characteristics
211
270
 
212
271
  - The Python daemon maintains a **CoAP Observe** subscription to the device
213
272
  - For HTTP models, the Python daemon polls the local API every 10 seconds
273
+ - HomeID mode polls `status`, `air`, and `fltsts`, and supports PhilipsCondor challenge authentication
214
274
  - Commands (power, mode, light) are sent directly and complete in ~100–300ms
215
275
  - The Node.js plugin communicates with the daemon over stdin/stdout JSON
216
276
  - If the daemon exits for any reason, Homebridge restarts it with exponential backoff (5s → 10s → 30s → 60s)
@@ -260,8 +320,8 @@ python3.12 philips_air_api.py 192.168.1.100 childlock off
260
320
  - Assign a static IP to the device in your router's DHCP settings
261
321
 
262
322
  **`Network error: NetworkError` on every command**
263
- - Your device may use HTTP instead of CoAP. Set `"protocol": "http"` in your Homebridge accessory configuration.
264
- - This affects AC1xxx models (e.g. AC1715) which do not expose a CoAP server on UDP port 5683.
323
+ - Your device may use HTTP instead of CoAP. Set `"protocol": "http"` for AC1xxx DH/AES models such as AC1715.
324
+ - If your device responds to HomeID local HTTP endpoints or PhilipsCondor authentication challenges, use `"protocol": "homeid-http"` and configure `clientId` / `clientSecret` if required.
265
325
 
266
326
  ---
267
327
 
@@ -24,9 +24,48 @@
24
24
  "protocol": {
25
25
  "title": "Protocol",
26
26
  "type": "string",
27
- "enum": ["coap", "http"],
27
+ "enum": ["coap", "http", "homeid-http", "airplus-cloud"],
28
28
  "default": "coap",
29
- "description": "Communication protocol. Use 'http' for AC1xxx models (AC1715, etc.) that do not support CoAP."
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
+ },
31
+ "useHttps": {
32
+ "title": "Use HTTPS for HomeID",
33
+ "type": "boolean",
34
+ "default": false,
35
+ "description": "Use HTTPS for the HomeID local API. Only applies when Protocol is 'homeid-http'."
36
+ },
37
+ "clientId": {
38
+ "title": "HomeID Client ID",
39
+ "type": "string",
40
+ "required": false,
41
+ "x-schema-form": { "type": "password" },
42
+ "description": "Base64 HomeID local API client ID. Only required for HomeID devices that return a PhilipsCondor authentication challenge."
43
+ },
44
+ "clientSecret": {
45
+ "title": "HomeID Client Secret",
46
+ "type": "string",
47
+ "required": false,
48
+ "x-schema-form": { "type": "password" },
49
+ "description": "Base64 HomeID local API client secret. Only required for HomeID devices that return a PhilipsCondor authentication challenge."
50
+ },
51
+ "encryptionKey": {
52
+ "title": "HomeID Encryption Key",
53
+ "type": "string",
54
+ "required": false,
55
+ "x-schema-form": { "type": "password" },
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
+ },
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."
30
69
  },
31
70
  "pythonPath": {
32
71
  "title": "Python Path (Optional)",
@@ -50,6 +89,30 @@
50
89
  "expandable": true,
51
90
  "expanded": false,
52
91
  "items": [
92
+ {
93
+ "key": "useHttps",
94
+ "description": "Only applies to the homeid-http protocol"
95
+ },
96
+ {
97
+ "key": "clientId",
98
+ "description": "Only applies to HomeID/Condor devices"
99
+ },
100
+ {
101
+ "key": "clientSecret",
102
+ "description": "Only applies to HomeID/Condor devices"
103
+ },
104
+ {
105
+ "key": "encryptionKey",
106
+ "description": "Optional HomeID AES key; leave blank unless needed"
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
+ },
53
116
  {
54
117
  "key": "pythonPath",
55
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,