homebridge-philips-air-purifier-complete 2.2.0 → 2.3.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/AGENTS.md +63 -0
- package/CHANGELOG.md +29 -0
- package/CLAUDE.md +16 -8
- package/README.md +38 -8
- package/config.schema.json +45 -2
- package/index.js +25 -8
- package/issues.md +23 -0
- package/package.json +2 -1
- package/philips_air_api.py +421 -12
- package/tests/test_philips_air_api.py +106 -0
- package/IMG_0301.jpeg +0 -0
- package/codex-plan.md +0 -326
package/AGENTS.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# AGENTS.md — homebridge-philips-air-purifier-complete
|
|
2
|
+
|
|
3
|
+
Homebridge plugin for Philips Air Purifiers → Apple HomeKit via CoAP or HTTP. Merges a prior Homebridge plugin with the bundled [aioairctrl](https://github.com/betaboon/aioairctrl) Python CoAP library.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
Node.js >=24, Homebridge >=2.0, Python >=3.12, aiocoap >=0.4.17,<0.5, pycryptodomex >=3.23,<4
|
|
7
|
+
|
|
8
|
+
## Architecture
|
|
9
|
+
```
|
|
10
|
+
index.js (DaemonHandler) → spawn philips_air_api.py --daemon [--protocol http] → device
|
|
11
|
+
```
|
|
12
|
+
- **CoAP path:** `aioairctrl/coap/client.py` → CoAP UDP:5683 → device
|
|
13
|
+
- **HTTP path:** `PhilipsAirHTTPClient` → HTTP TCP:80 → device
|
|
14
|
+
- **Updates:** CoAP Observe push or HTTP polling every 10 seconds (device → Python stdout JSON → JS readline)
|
|
15
|
+
- **Commands:** JS writes JSON to Python stdin; Python sends CoAP or HTTP control and replies
|
|
16
|
+
- **State:** Cached from observe updates or HTTP polls; reads avoid an extra device request
|
|
17
|
+
|
|
18
|
+
## Key Files
|
|
19
|
+
| File | Role |
|
|
20
|
+
|------|------|
|
|
21
|
+
| `index.js` | Plugin entry; DaemonHandler + PhilipsAirPurifierAccessory |
|
|
22
|
+
| `philips_air_api.py` | Python daemon (`ObserveDaemon` / `HTTPPollingDaemon`) + CLI client |
|
|
23
|
+
| `aioairctrl/coap/client.py` | CoAP get/observe/set; handles encryption |
|
|
24
|
+
| `aioairctrl/coap/encryption.py` | AES-CBC + SHA256 integrity (key: "JiangPan" — protocol constant) |
|
|
25
|
+
| `aioairctrl/coap/aiocoap_monkeypatch.py` | Patches aiocoap deduplication and iterator cleanup — do not remove |
|
|
26
|
+
| `preinstall.sh` | Warns (not fails) if Node 24+ or Python 3.12+ absent; supports `PHILIPS_AIR_PYTHON` and `PHILIPS_AIR_SKIP_PYTHON_PREINSTALL=1` |
|
|
27
|
+
| `postinstall.sh` | Creates `.venv/`, installs Python deps, verifies setup |
|
|
28
|
+
|
|
29
|
+
## Device Protocol
|
|
30
|
+
CoAP paths: `/sys/dev/sync` (POST key exchange), `/sys/dev/status` (GET+Observe), `/sys/dev/control` (POST set).
|
|
31
|
+
|
|
32
|
+
HTTP paths: `/di/v1/products/0/security` (PUT DH key exchange), `/di/v1/products/1/air` (GET/PUT encrypted status/control). HTTP uses AES-128-CBC with zero IV, PKCS7 padding, and base64 payloads after the session key exchange.
|
|
33
|
+
|
|
34
|
+
Mode values: `0`=auto, `17`=sleep, `18`=turbo, `19`=medium. Light values: `0`=off, `115`=dim, `123`=bright.
|
|
35
|
+
|
|
36
|
+
HTTP field names differ from the current CoAP payloads: power `pwr`, mode `mode`, fan speed `om`, display brightness `aqil`, child lock `cl`, PM2.5 `pm25`, allergen index `iaql`. `parse_status()` normalises both protocol families into the same Homebridge IPC shape.
|
|
37
|
+
|
|
38
|
+
HomeKit RotationSpeed → mode: 0%=off, 1–33%=sleep, 34–66%=medium, 67–100%=turbo. Sleep Mode is a dedicated Switch service (HomeKit AirPurifier only has Auto/Manual).
|
|
39
|
+
|
|
40
|
+
## Design Decisions
|
|
41
|
+
- **Optimistic state:** Commands update `this.state` immediately; observe updates correct on next push.
|
|
42
|
+
- **Command lock (`_commandCount`):** Blocks observe updates for 500ms after a command to avoid overwriting optimistic state.
|
|
43
|
+
- **Daemon backoff:** `[5s, 10s, 30s, 60s]` restart delays on crash.
|
|
44
|
+
- **Python finder:** Checks `.venv/bin/python3` first, then system Python 3.12 paths; all candidates validated with `PYTHON_RUNTIME_CHECK` (version + import check).
|
|
45
|
+
- **aiocoap monkeypatches:** Required for Observe to work correctly. Pinned to `<0.5` — do not bump aiocoap without re-validating patches.
|
|
46
|
+
- **`PYTHON_MIN_VERSION` is the single source of truth** for the minimum Python version across `index.js`, `preinstall.sh`, and `postinstall.sh`. All three derive the version tuple from this string — only one value to update when the minimum changes.
|
|
47
|
+
- **preinstall warns, not fails:** If Python 3.12+ is not in the PATH npm sees, install continues with a warning. Set `PHILIPS_AIR_PYTHON=/path/to/python3.12` or `PHILIPS_AIR_SKIP_PYTHON_PREINSTALL=1` for Docker/NAS setups.
|
|
48
|
+
- **Protocol selection:** `protocol` is explicit per accessory (`coap` default, `http` for AC1xxx such as AC1715). No auto-detection; mixed households work because each accessory owns its config.
|
|
49
|
+
- **HTTP polling:** `HTTPPollingDaemon.POLL_INTERVAL` is 10 seconds. Physical button changes on HTTP devices may be stale in HomeKit for up to one poll interval.
|
|
50
|
+
|
|
51
|
+
## Release Process
|
|
52
|
+
1. Update `CHANGELOG.md` and bump `version` in `package.json`
|
|
53
|
+
2. `git commit`, `git tag vX.Y.Z`, `git push origin main vX.Y.Z`
|
|
54
|
+
3. `gh release create vX.Y.Z --title "vX.Y.Z" --notes "..."`
|
|
55
|
+
4. `npm publish --access public`
|
|
56
|
+
|
|
57
|
+
## Dev Commands
|
|
58
|
+
```bash
|
|
59
|
+
npm run lint # ESLint v9 flat config
|
|
60
|
+
npm run format # Prettier
|
|
61
|
+
bash postinstall.sh # Rebuild .venv manually
|
|
62
|
+
source .venv/bin/activate && python philips_air_api.py <ip> sensors
|
|
63
|
+
```
|
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,35 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [2.3.0] — 2026-05-24
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Added explicit `homeid-http` protocol support for HomeID/Condor local HTTP devices.
|
|
14
|
+
This path supports HTTP or HTTPS, PhilipsCondor 401 challenge authentication, optional
|
|
15
|
+
HomeID AES payload encryption, and merged polling of `status`, `air`, and `fltsts`.
|
|
16
|
+
- Added HomeID configuration fields: `useHttps`, `clientId`, `clientSecret`, and
|
|
17
|
+
`encryptionKey`. HomeID secrets are passed to the Python daemon via environment
|
|
18
|
+
variables rather than command-line arguments.
|
|
19
|
+
- Added `probe-homeid` CLI diagnostic command to probe HomeID HTTP/HTTPS endpoints
|
|
20
|
+
without changing device state.
|
|
21
|
+
- Added focused Python unit tests for CoAP/HTTP/HomeID status normalisation,
|
|
22
|
+
HomeID AES encryption, and PhilipsCondor authentication response generation.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Restored the normalised `mode_name` field in Python sensor output while keeping
|
|
27
|
+
`mode` compatible with the JavaScript HomeKit mapping.
|
|
28
|
+
- Added clearer HTTP diagnostics for endpoint status and decrypt failures without
|
|
29
|
+
logging secrets or encrypted payloads.
|
|
30
|
+
- Replaced private `ssl._create_unverified_context()` with `ssl.create_default_context()`
|
|
31
|
+
(`check_hostname=False`, `verify_mode=CERT_NONE`) for HomeID HTTPS devices with
|
|
32
|
+
self-signed certificates.
|
|
33
|
+
- Removed duplicated HomeID mode mapping; both HTTP and HomeID control paths now share
|
|
34
|
+
`HTTP_MODE_VALUES`.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
9
38
|
## [2.2.0] — 2026-05-23
|
|
10
39
|
|
|
11
40
|
### Added
|
package/CLAUDE.md
CHANGED
|
@@ -7,33 +7,39 @@ Node.js >=24, Homebridge >=2.0, Python >=3.12, aiocoap >=0.4.17,<0.5, pycryptodo
|
|
|
7
7
|
|
|
8
8
|
## Architecture
|
|
9
9
|
```
|
|
10
|
-
index.js (DaemonHandler) → spawn philips_air_api.py --daemon [--protocol
|
|
10
|
+
index.js (DaemonHandler) → spawn philips_air_api.py --daemon [--protocol <proto>] → device
|
|
11
11
|
```
|
|
12
12
|
- **CoAP path:** `aioairctrl/coap/client.py` → CoAP UDP:5683 → device
|
|
13
|
-
- **HTTP path:** `PhilipsAirHTTPClient` → HTTP TCP:80 → device
|
|
14
|
-
- **
|
|
13
|
+
- **HTTP path:** `PhilipsAirHTTPClient` → HTTP TCP:80 → device (DH/AES, AC1xxx)
|
|
14
|
+
- **HomeID path:** `PhilipsHomeIDHTTPClient` → HTTP/HTTPS TCP:80/443 → device (PhilipsCondor auth + optional AES)
|
|
15
|
+
- **Updates:** CoAP Observe push or HTTP/HomeID polling every 10 seconds (device → Python stdout JSON → JS readline)
|
|
15
16
|
- **Commands:** JS writes JSON to Python stdin; Python sends CoAP or HTTP control and replies
|
|
16
17
|
- **State:** Cached from observe updates or HTTP polls; reads avoid an extra device request
|
|
18
|
+
- **Secrets:** HomeID clientId/clientSecret/encryptionKey passed to Python via environment variables, not CLI args
|
|
17
19
|
|
|
18
20
|
## Key Files
|
|
19
21
|
| File | Role |
|
|
20
22
|
|------|------|
|
|
21
23
|
| `index.js` | Plugin entry; DaemonHandler + PhilipsAirPurifierAccessory |
|
|
22
|
-
| `philips_air_api.py` | Python daemon (`ObserveDaemon` / `HTTPPollingDaemon`) + CLI client |
|
|
24
|
+
| `philips_air_api.py` | Python daemon (`ObserveDaemon` / `HTTPPollingDaemon` / `HomeIDHTTPPollingDaemon`) + CLI client |
|
|
23
25
|
| `aioairctrl/coap/client.py` | CoAP get/observe/set; handles encryption |
|
|
24
26
|
| `aioairctrl/coap/encryption.py` | AES-CBC + SHA256 integrity (key: "JiangPan" — protocol constant) |
|
|
25
27
|
| `aioairctrl/coap/aiocoap_monkeypatch.py` | Patches aiocoap deduplication and iterator cleanup — do not remove |
|
|
26
28
|
| `preinstall.sh` | Warns (not fails) if Node 24+ or Python 3.12+ absent; supports `PHILIPS_AIR_PYTHON` and `PHILIPS_AIR_SKIP_PYTHON_PREINSTALL=1` |
|
|
27
29
|
| `postinstall.sh` | Creates `.venv/`, installs Python deps, verifies setup |
|
|
30
|
+
| `issues.md` | Known issues pending live-device verification |
|
|
31
|
+
| `tests/test_philips_air_api.py` | Unit tests for status parsing, HomeID AES crypto, PhilipsCondor auth |
|
|
28
32
|
|
|
29
33
|
## Device Protocol
|
|
30
34
|
CoAP paths: `/sys/dev/sync` (POST key exchange), `/sys/dev/status` (GET+Observe), `/sys/dev/control` (POST set).
|
|
31
35
|
|
|
32
|
-
HTTP paths: `/di/v1/products/0/security` (PUT DH key exchange), `/di/v1/products/1/air` (GET/PUT encrypted status/control).
|
|
36
|
+
HTTP (DH/AES) paths: `/di/v1/products/0/security` (PUT DH key exchange), `/di/v1/products/1/air` (GET/PUT encrypted status/control). Uses AES-128-CBC with zero IV, PKCS7 padding, and base64 payloads after DH session key exchange.
|
|
37
|
+
|
|
38
|
+
HomeID paths: `/di/v1/products/{id}/device`, `/di/v1/products/{id}/status`, `/di/v1/products/{id}/air`, `/di/v1/products/{id}/fltsts`, `/di/v1/products/0/security` (optional AES key fetch). Uses PhilipsCondor challenge/response auth (401 → SHA256(challenge+clientId+clientSecret)) and optional AES-CBC encryption with a persistent hex key.
|
|
33
39
|
|
|
34
40
|
Mode values: `0`=auto, `17`=sleep, `18`=turbo, `19`=medium. Light values: `0`=off, `115`=dim, `123`=bright.
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
Field names (HTTP/HomeID): power `pwr`, mode `mode`, fan speed `om`, display brightness `aqil`, child lock `cl`, PM2.5 `pm25`, allergen index `iaql`. `parse_status()` normalises CoAP, HTTP, and HomeID payloads into the same Homebridge IPC shape.
|
|
37
43
|
|
|
38
44
|
HomeKit RotationSpeed → mode: 0%=off, 1–33%=sleep, 34–66%=medium, 67–100%=turbo. Sleep Mode is a dedicated Switch service (HomeKit AirPurifier only has Auto/Manual).
|
|
39
45
|
|
|
@@ -45,8 +51,10 @@ HomeKit RotationSpeed → mode: 0%=off, 1–33%=sleep, 34–66%=medium, 67–100
|
|
|
45
51
|
- **aiocoap monkeypatches:** Required for Observe to work correctly. Pinned to `<0.5` — do not bump aiocoap without re-validating patches.
|
|
46
52
|
- **`PYTHON_MIN_VERSION` is the single source of truth** for the minimum Python version across `index.js`, `preinstall.sh`, and `postinstall.sh`. All three derive the version tuple from this string — only one value to update when the minimum changes.
|
|
47
53
|
- **preinstall warns, not fails:** If Python 3.12+ is not in the PATH npm sees, install continues with a warning. Set `PHILIPS_AIR_PYTHON=/path/to/python3.12` or `PHILIPS_AIR_SKIP_PYTHON_PREINSTALL=1` for Docker/NAS setups.
|
|
48
|
-
- **Protocol selection:** `protocol` is explicit per accessory (`coap` default, `http` for AC1xxx
|
|
49
|
-
- **HTTP polling:** `HTTPPollingDaemon.POLL_INTERVAL` is 10 seconds. Physical button changes
|
|
54
|
+
- **Protocol selection:** `protocol` is explicit per accessory (`coap` default, `http` for AC1xxx, `homeid-http` for HomeID/Condor devices). No auto-detection; mixed households work because each accessory owns its config.
|
|
55
|
+
- **HTTP/HomeID polling:** `HTTPPollingDaemon.POLL_INTERVAL` is 10 seconds. Physical button changes may be stale in HomeKit for up to one poll interval.
|
|
56
|
+
- **HomeID HTTPS:** Uses `ssl.create_default_context()` with `check_hostname=False` and `verify_mode=CERT_NONE` — required for devices with self-signed certificates on the local network.
|
|
57
|
+
- **HomeID secrets:** `clientId`, `clientSecret`, `encryptionKey` are passed to the Python daemon via environment variables (`PHILIPS_HOMEID_CLIENT_ID`, etc.) not CLI args (CLI args are visible in `ps aux`).
|
|
50
58
|
|
|
51
59
|
## Release Process
|
|
52
60
|
1. Update `CHANGELOG.md` and bump `version` in `package.json`
|
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)
|
|
30
|
-
- **Real-time Updates** — CoAP Observe push updates (AC2xxx+) or 10-second HTTP polling (
|
|
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
|
-
|
|
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.
|
|
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,7 +174,8 @@ 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
|
|
|
@@ -168,6 +191,10 @@ source $(npm root -g)/homebridge-philips-air-purifier-complete/.venv/bin/activat
|
|
|
168
191
|
|
|
169
192
|
# Run a sensor query
|
|
170
193
|
python $(npm root -g)/homebridge-philips-air-purifier-complete/philips_air_api.py 192.168.1.100 sensors
|
|
194
|
+
|
|
195
|
+
# Probe HomeID local HTTP endpoints without changing device state
|
|
196
|
+
python $(npm root -g)/homebridge-philips-air-purifier-complete/philips_air_api.py 192.168.1.100 probe-homeid
|
|
197
|
+
python $(npm root -g)/homebridge-philips-air-purifier-complete/philips_air_api.py 192.168.1.100 probe-homeid --use-https
|
|
171
198
|
```
|
|
172
199
|
|
|
173
200
|
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 +227,9 @@ Homebridge (Node.js)
|
|
|
200
227
|
▼
|
|
201
228
|
philips_air_api.py ─── aioairctrl/ (bundled) ──► aiocoap ──► Philips device (CoAP)
|
|
202
229
|
│
|
|
203
|
-
|
|
230
|
+
├──────────────────── DH/AES HTTP polling ──────────────► Philips device (HTTP)
|
|
231
|
+
│
|
|
232
|
+
└──────────────────── HomeID HTTP/HTTPS polling ────────► Philips device (HomeID)
|
|
204
233
|
│
|
|
205
234
|
│ CoAP Observe (push)
|
|
206
235
|
│ ≈ every 30s or on change
|
|
@@ -211,6 +240,7 @@ State cache ──► HomeKit characteristics
|
|
|
211
240
|
|
|
212
241
|
- The Python daemon maintains a **CoAP Observe** subscription to the device
|
|
213
242
|
- For HTTP models, the Python daemon polls the local API every 10 seconds
|
|
243
|
+
- HomeID mode polls `status`, `air`, and `fltsts`, and supports PhilipsCondor challenge authentication
|
|
214
244
|
- Commands (power, mode, light) are sent directly and complete in ~100–300ms
|
|
215
245
|
- The Node.js plugin communicates with the daemon over stdin/stdout JSON
|
|
216
246
|
- If the daemon exits for any reason, Homebridge restarts it with exponential backoff (5s → 10s → 30s → 60s)
|
|
@@ -260,8 +290,8 @@ python3.12 philips_air_api.py 192.168.1.100 childlock off
|
|
|
260
290
|
- Assign a static IP to the device in your router's DHCP settings
|
|
261
291
|
|
|
262
292
|
**`Network error: NetworkError` on every command**
|
|
263
|
-
- Your device may use HTTP instead of CoAP. Set `"protocol": "http"`
|
|
264
|
-
-
|
|
293
|
+
- Your device may use HTTP instead of CoAP. Set `"protocol": "http"` for AC1xxx DH/AES models such as AC1715.
|
|
294
|
+
- If your device responds to HomeID local HTTP endpoints or PhilipsCondor authentication challenges, use `"protocol": "homeid-http"` and configure `clientId` / `clientSecret` if required.
|
|
265
295
|
|
|
266
296
|
---
|
|
267
297
|
|
package/config.schema.json
CHANGED
|
@@ -24,9 +24,36 @@
|
|
|
24
24
|
"protocol": {
|
|
25
25
|
"title": "Protocol",
|
|
26
26
|
"type": "string",
|
|
27
|
-
"enum": ["coap", "http"],
|
|
27
|
+
"enum": ["coap", "http", "homeid-http"],
|
|
28
28
|
"default": "coap",
|
|
29
|
-
"description": "Communication protocol. Use 'http' for AC1xxx models (AC1715, etc.)
|
|
29
|
+
"description": "Communication protocol. Use 'http' for AC1xxx DH/AES models (AC1715, etc.) or 'homeid-http' for HomeID/Condor local HTTP devices."
|
|
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."
|
|
30
57
|
},
|
|
31
58
|
"pythonPath": {
|
|
32
59
|
"title": "Python Path (Optional)",
|
|
@@ -50,6 +77,22 @@
|
|
|
50
77
|
"expandable": true,
|
|
51
78
|
"expanded": false,
|
|
52
79
|
"items": [
|
|
80
|
+
{
|
|
81
|
+
"key": "useHttps",
|
|
82
|
+
"description": "Only applies to the homeid-http protocol"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"key": "clientId",
|
|
86
|
+
"description": "Only applies to HomeID/Condor devices"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"key": "clientSecret",
|
|
90
|
+
"description": "Only applies to HomeID/Condor devices"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"key": "encryptionKey",
|
|
94
|
+
"description": "Optional HomeID AES key; leave blank unless needed"
|
|
95
|
+
},
|
|
53
96
|
{
|
|
54
97
|
"key": "pythonPath",
|
|
55
98
|
"description": "Only needed if the auto-detected Python does not have the required dependencies"
|
package/index.js
CHANGED
|
@@ -93,11 +93,15 @@ class DaemonHandler {
|
|
|
93
93
|
this.commandTimeout = 15000;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
async start(pythonPath, scriptPath, host,
|
|
96
|
+
async start(pythonPath, scriptPath, host, options = {}) {
|
|
97
97
|
return new Promise((resolve, reject) => {
|
|
98
|
+
const protocol = options.protocol || 'coap';
|
|
98
99
|
const args = [scriptPath, host, '--daemon'];
|
|
99
|
-
if (protocol
|
|
100
|
-
args.push('--protocol',
|
|
100
|
+
if (protocol !== 'coap') {
|
|
101
|
+
args.push('--protocol', protocol);
|
|
102
|
+
}
|
|
103
|
+
if (protocol === 'homeid-http' && options.useHttps) {
|
|
104
|
+
args.push('--use-https');
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
this.log.info(`Starting ${protocol} daemon: ${pythonPath} ${args.join(' ')}`);
|
|
@@ -109,6 +113,9 @@ class DaemonHandler {
|
|
|
109
113
|
HOME: process.env.HOME,
|
|
110
114
|
LANG: process.env.LANG || 'en_US.UTF-8',
|
|
111
115
|
PYTHONUNBUFFERED: '1',
|
|
116
|
+
PHILIPS_HOMEID_CLIENT_ID: options.homeIdClientId || '',
|
|
117
|
+
PHILIPS_HOMEID_CLIENT_SECRET: options.homeIdClientSecret || '',
|
|
118
|
+
PHILIPS_HOMEID_ENCRYPTION_KEY: options.homeIdEncryptionKey || '',
|
|
112
119
|
// Ensure the bundled aioairctrl package is always importable
|
|
113
120
|
PYTHONPATH: path.dirname(scriptPath),
|
|
114
121
|
},
|
|
@@ -154,7 +161,7 @@ class DaemonHandler {
|
|
|
154
161
|
this.rl.removeListener('line', readyHandler);
|
|
155
162
|
this.connected = response.connected;
|
|
156
163
|
if (response.connected) {
|
|
157
|
-
this.log.info(`Daemon ready, waiting for first ${protocol === '
|
|
164
|
+
this.log.info(`Daemon ready, waiting for first ${protocol === 'coap' ? 'observe' : 'poll'} update...`);
|
|
158
165
|
} else {
|
|
159
166
|
this.log.warn(`Daemon ready but not connected: ${response.error}`);
|
|
160
167
|
}
|
|
@@ -253,6 +260,10 @@ class PhilipsAirPurifierAccessory {
|
|
|
253
260
|
this.name = config.name || 'Air Purifier';
|
|
254
261
|
this.host = config.host;
|
|
255
262
|
this.protocol = config.protocol || 'coap';
|
|
263
|
+
this.homeIdClientId = config.clientId || '';
|
|
264
|
+
this.homeIdClientSecret = config.clientSecret || '';
|
|
265
|
+
this.homeIdEncryptionKey = config.encryptionKey || '';
|
|
266
|
+
this.useHttps = Boolean(config.useHttps);
|
|
256
267
|
|
|
257
268
|
if (!this.host) {
|
|
258
269
|
throw new Error('host is required in config');
|
|
@@ -362,8 +373,8 @@ class PhilipsAirPurifierAccessory {
|
|
|
362
373
|
}
|
|
363
374
|
|
|
364
375
|
validateProtocol(protocol) {
|
|
365
|
-
if (!['coap', 'http'].includes(protocol)) {
|
|
366
|
-
throw new Error(`protocol must be "coap" or "http", got: "${protocol}"`);
|
|
376
|
+
if (!['coap', 'http', 'homeid-http'].includes(protocol)) {
|
|
377
|
+
throw new Error(`protocol must be "coap", "http", or "homeid-http", got: "${protocol}"`);
|
|
367
378
|
}
|
|
368
379
|
}
|
|
369
380
|
|
|
@@ -383,10 +394,16 @@ class PhilipsAirPurifierAccessory {
|
|
|
383
394
|
|
|
384
395
|
async startDaemon() {
|
|
385
396
|
try {
|
|
386
|
-
const connected = await this.daemon.start(this.pythonPath, this.apiScriptPath, this.host,
|
|
397
|
+
const connected = await this.daemon.start(this.pythonPath, this.apiScriptPath, this.host, {
|
|
398
|
+
protocol: this.protocol,
|
|
399
|
+
useHttps: this.useHttps,
|
|
400
|
+
homeIdClientId: this.homeIdClientId,
|
|
401
|
+
homeIdClientSecret: this.homeIdClientSecret,
|
|
402
|
+
homeIdEncryptionKey: this.homeIdEncryptionKey,
|
|
403
|
+
});
|
|
387
404
|
this.deviceReachable = connected;
|
|
388
405
|
this._restartAttempt = 0;
|
|
389
|
-
this.log.info(`Daemon started, waiting for ${this.protocol === '
|
|
406
|
+
this.log.info(`Daemon started, waiting for ${this.protocol === 'coap' ? 'CoAP observe' : 'HTTP poll'} updates...`);
|
|
390
407
|
} catch (error) {
|
|
391
408
|
this.log.error(`Failed to start daemon: ${error.message}`);
|
|
392
409
|
this.deviceReachable = false;
|
package/issues.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Known Issues
|
|
2
|
+
|
|
3
|
+
## HomeID childlock field type
|
|
4
|
+
|
|
5
|
+
**Affects:** `homeid-http` protocol only
|
|
6
|
+
**Status:** Unverified — needs a live HomeID device to test
|
|
7
|
+
|
|
8
|
+
`HomeIDHTTPPollingDaemon._execute_command` sends `{"cl": True/False}` (Python boolean) for child lock commands. The DH/AES HTTP path sends `{"cl": "1"/"0"}` (strings). It is unknown which representation HomeID firmware expects. If child lock commands have no effect on a HomeID device, try changing the `set_values` call to use `"1"`/`"0"` strings instead.
|
|
9
|
+
|
|
10
|
+
**Location:** [philips_air_api.py](philips_air_api.py) — `HomeIDHTTPPollingDaemon._execute_command`, childlock branch (around line 1053)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## HomeID filter life always shows 100%
|
|
15
|
+
|
|
16
|
+
**Affects:** `homeid-http` protocol only
|
|
17
|
+
**Status:** Needs live device `fltsts` response to map field names
|
|
18
|
+
|
|
19
|
+
`parse_status()` reads filter life from CoAP-specific keys (`D05408`, `D0540E`) which are absent in HomeID `fltsts` responses. Until the actual HomeID field names are known, filter life and pre-filter life always default to 100%.
|
|
20
|
+
|
|
21
|
+
To fix: capture a raw `fltsts` response from a HomeID device (`probe-homeid` or direct `curl`), identify the field names, and add them to `parse_status()` alongside the existing CoAP keys.
|
|
22
|
+
|
|
23
|
+
**Location:** [philips_air_api.py](philips_air_api.py) — `parse_status()` filter section (around line 174)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-philips-air-purifier-complete",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Homebridge plugin for Philips Air Purifier with bundled CoAP control library and Python 3.12+/Node.js 24 support",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"preinstall": "bash preinstall.sh",
|
|
42
42
|
"postinstall": "bash postinstall.sh",
|
|
43
|
+
"test": "python3 -m unittest discover -s tests",
|
|
43
44
|
"lint": "eslint .",
|
|
44
45
|
"format": "prettier -w ."
|
|
45
46
|
}
|