@mp-consulting/homebridge-daikin-cloud 1.6.2 → 1.7.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 CHANGED
@@ -29,6 +29,7 @@ A [Homebridge](https://homebridge.io) plugin that integrates Daikin air conditio
29
29
  - Fan only mode (`showFanOnlyMode`)
30
30
  - Holiday (away) mode (`showHolidayMode`)
31
31
  - **Separate Fan Tile** (`showSeparateFanControl`): Expose fan speed and oscillation as a standalone Fan tile, so both stay visible even when the accessory is grouped into a single tile in the Home app
32
+ - **Assistant (optional)**: Explains connection, login and offline-unit problems in the settings UI and suggests config changes, using the AI provider you set up in Homebridge AI Kit
32
33
  - **Firmware Updates** (`showFirmwareUpdateSwitch`): Manage gateway firmware updates from HomeKit instead of the Onecta app. The plugin logs when Daikin stages an update for your unit and exposes a "Firmware Update" switch — turn it on to install; it stays on while the update runs and the plugin logs the outcome. Not part of `showExtraFeatures`: it must be enabled explicitly, so an "all switches on" scene can never trigger an install. The unit is unavailable (and rejects commands) while it updates. The current firmware version is also shown in each accessory's HomeKit details.
33
34
 
34
35
  > **Note**: HomeKit doesn't natively support all Daikin operation modes. Extra features appear as switches in the Home app. Enable them individually in the plugin settings UI.
@@ -233,6 +234,33 @@ These errors indicate temporary issues with the Daikin Cloud servers:
233
234
  - If errors persist, the Daikin API may be experiencing extended downtime
234
235
  - Check [Daikin's status page](https://www.daikin.eu/) or try again later
235
236
 
237
+ ## Assistant
238
+
239
+ The settings UI can explain problems and suggest configuration changes with the
240
+ **Assistant**. It is off until you set up an AI provider once for all MP Consulting
241
+ plugins in [Homebridge AI Kit](https://github.com/mp-consulting/homebridge-ai-kit)
242
+ (or the Homebridge Glass UI): the plugin reads the shared `HomebridgeAiKit` platform
243
+ block from `config.json` and has no AI settings of its own. When it is not set up,
244
+ the UI looks exactly as before, with a small tip in the Settings tab.
245
+
246
+ When it is enabled:
247
+
248
+ - **Explain** buttons appear next to a failed connection test, a failed Mobile App
249
+ login, a Developer Portal login that cannot start or complete, a failed device list,
250
+ and every unit the Onecta cloud reports as offline. The answer streams into an
251
+ Assistant panel below.
252
+ - **Describe Your Setup** (Settings tab) turns a request such as *"show the Powerful and
253
+ Econo switches and poll every 10 minutes"* into a configuration change, shown as a diff
254
+ to apply or reject. Like every other change in the Settings tab, an applied change is
255
+ saved straight away; restart Homebridge to use it.
256
+
257
+ What is sent to the provider: the error message, the authentication method, the update
258
+ interval, the WebSocket and HTTP transport settings, and for a unit its name, Daikin
259
+ device ID, model, type, online flag and enabled feature switches. Your Daikin email and
260
+ password, Client ID and Client Secret, tokens, and the callback and bind addresses are
261
+ never sent (e-mail and IP addresses are also masked in error messages), and the
262
+ provider's API key stays on the Homebridge server.
263
+
236
264
  ## Supported Devices
237
265
 
238
266
  Any device compatible with the [Daikin Onecta app](https://www.daikin.eu/en_us/product-group/control-systems/onecta/connectable-units.html), including:
@@ -266,6 +294,12 @@ npm run test:coverage
266
294
  npm run schema:check
267
295
  ```
268
296
 
297
+ The build copies `@mp-consulting/homebridge-ui-kit` and Bootstrap Icons into
298
+ `homebridge-ui/public/lib/` with `mp-ui-kit-copy --vendor`.
299
+ The Assistant routes come from `@mp-consulting/homebridge-ai-core`, the slim core of
300
+ Homebridge AI Kit (its only runtime dependency is `ajv`), so the plugin does not pull in
301
+ the MCP SDK or socket.io.
302
+
269
303
  ### Code Quality
270
304
 
271
305
  This plugin uses:
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Assistant routes for the custom settings UI (/ai/status, /ai/explain, /ai/ask,
3
+ * /ai/config), from @mp-consulting/homebridge-ai-core/plugin. The provider is set up
4
+ * once in the shared `HomebridgeAiKit` block of config.json; its key never reaches
5
+ * the browser.
6
+ *
7
+ * ai-core is ESM-only and this UI server is CommonJS, so it is loaded lazily with
8
+ * import(). When it cannot be loaded the routes are simply missing: the UI calls
9
+ * /ai/status, gets an error and hides everything Assistant-related.
10
+ */
11
+
12
+ const ASSISTANT_PLUGIN_NAME = '@mp-consulting/homebridge-daikin-cloud';
13
+
14
+ /**
15
+ * Daikin background the Assistant gets with every request from this plugin's
16
+ * settings UI. Keep it short: it is sent with each prompt.
17
+ */
18
+ const DAIKIN_AI_CONTEXT = [
19
+ 'The plugin bridges Daikin air conditioners and Altherma heat pumps (climateControl and domesticHotWaterTank',
20
+ 'management points) from the Daikin Onecta cloud to HomeKit; it never talks to the units on the LAN.',
21
+ 'Authentication methods ("authMode"): "developer_portal" uses OAuth 2.0 with a Client ID and Client Secret from',
22
+ 'the Daikin Developer Portal and allows 200 API calls per day; "mobile_app" logs in with the Onecta app email and',
23
+ 'password (Gigya login at id.daikin.eu), allows 3000 calls per day and adds real-time WebSocket updates',
24
+ '("enableWebSocket"). Developer Portal login needs a temporary HTTPS callback server with a self-signed certificate',
25
+ '(the browser warns about it): the redirect URI registered in the portal must be exactly',
26
+ 'https://<callbackServerExternalAddress>:<callbackServerPort> (default port 8582), the port must be reachable from',
27
+ 'the browser, the bind address ("oidcCallbackServerBindAddr", default 0.0.0.0) may only be loopback when the browser',
28
+ 'runs on the Homebridge host, and the callback server stops after 10 minutes. Tokens are stored in',
29
+ '.daikin-controller-cloud-tokenset (Developer Portal) or .daikin-mobile-tokenset (Mobile App) in the Homebridge',
30
+ 'storage path. Common errors: "Unauthorized (401): Token refresh failed. Please re-authenticate." or "invalid_grant"',
31
+ 'means the refresh token expired or was revoked, so authenticate again; "Rate limited. Retry after N seconds." (HTTP',
32
+ '429) means the daily or per-minute quota is used up, so raise "updateIntervalInMinutes" (15+ for Developer Portal)',
33
+ 'or switch to Mobile App; "Bad Gateway (502)", "Service Unavailable (503)" or "Gateway Timeout (504)" with "The',
34
+ 'Daikin API is temporarily unavailable" is a Daikin-side outage (polls back off on their own); "Device <id> is',
35
+ 'offline (cloud connection down)" or a device shown Offline means its Wi-Fi adapter lost the Onecta cloud',
36
+ 'connection (check power, Wi-Fi and the Onecta app); "Request to <host> failed after N attempts" (ETIMEDOUT,',
37
+ 'ECONNRESET, ECONNREFUSED) points at the Homebridge host network: DNS, firewall, broken IPv6 or a low MTU; "returned',
38
+ 'a non-JSON response" usually means a proxy or WAF answered instead of Daikin, and some WAFs drop Node\'s TLS',
39
+ 'fingerprint, which "httpTransport": "curl" works around. Mobile App login errors carry the Gigya error code in',
40
+ 'parentheses. Hidden devices are listed in "excludedDevicesByDeviceId". Never ask the user for their password,',
41
+ 'Client Secret, tokens or API keys.',
42
+ ].join(' ');
43
+
44
+ /**
45
+ * Adds the Assistant routes to the plugin UI server. Resolves once they are
46
+ * registered (or immediately when ai-core cannot be loaded).
47
+ *
48
+ * `options` is passed through to `registerAiRoutes` (tests inject a provider).
49
+ */
50
+ function registerAssistant(server, options = {}) {
51
+ return import('@mp-consulting/homebridge-ai-core/plugin')
52
+ .then(({ registerAiRoutes }) => registerAiRoutes(server, {
53
+ pluginName: ASSISTANT_PLUGIN_NAME,
54
+ systemContext: DAIKIN_AI_CONTEXT,
55
+ ...options,
56
+ }))
57
+ .catch((error) => {
58
+ console.warn('[DaikinCloud] Assistant unavailable:', error.message);
59
+ });
60
+ }
61
+
62
+ module.exports = { ASSISTANT_PLUGIN_NAME, DAIKIN_AI_CONTEXT, registerAssistant };
@@ -82,6 +82,8 @@
82
82
  <p class="text-muted small">Make sure you're authenticated and your Daikin devices are set up in the Onecta app.</p>
83
83
  </div>
84
84
  <div id="devices-error" class="alert alert-danger d-none"></div>
85
+ <!-- Assistant: explain the device list error (filled by script.js) -->
86
+ <div id="devices-problem" class="mb-3 d-none"></div>
85
87
  </div>
86
88
 
87
89
  <!-- Settings Tab -->
@@ -297,6 +299,27 @@
297
299
  </div>
298
300
  </div>
299
301
  </div>
302
+
303
+ <!-- Assistant: describe your setup (shown only when the Assistant is enabled) -->
304
+ <div class="card mt-3 d-none" id="assistant-config-card">
305
+ <div class="card-header d-flex align-items-center gap-2">
306
+ <span>Describe Your Setup</span>
307
+ <span id="assistant-config-badge"></span>
308
+ </div>
309
+ <div class="card-body">
310
+ <label class="form-label" for="assistant-config-request">What should change?</label>
311
+ <textarea class="form-control mb-2" id="assistant-config-request" rows="2"
312
+ placeholder="e.g. Show Powerful and Econo mode switches and poll every 10 minutes"></textarea>
313
+ <div class="form-text mb-3">The Assistant suggests a configuration change for you to review. Your Daikin credentials and network addresses are never sent.</div>
314
+ <div id="assistant-config-action"></div>
315
+ <div id="assistant-config-result" class="mt-3"></div>
316
+ </div>
317
+ </div>
318
+
319
+ <p id="assistant-hint" class="small text-muted mt-3 mb-0 d-none">
320
+ <i class="bi bi-info-circle me-1"></i>Tip: install and enable <strong>Homebridge AI Kit</strong> to get the Assistant,
321
+ which explains connection and device errors here.
322
+ </p>
300
323
  </div>
301
324
 
302
325
  <!-- Authentication Tab -->
@@ -347,6 +370,8 @@
347
370
  </button>
348
371
  </div>
349
372
  <div id="test-result" class="alert mt-3 mb-0 d-none"></div>
373
+ <!-- Assistant: explain a failed connection test (filled by script.js) -->
374
+ <div id="test-problem" class="mt-2 d-none"></div>
350
375
  </div>
351
376
  </div>
352
377
 
@@ -371,6 +396,8 @@
371
396
  </div>
372
397
 
373
398
  <div id="mobile-auth-errors" class="alert alert-danger d-none"></div>
399
+ <!-- Assistant: explain a failed Mobile App login (filled by script.js) -->
400
+ <div id="mobile-auth-problem" class="mb-3 d-none"></div>
374
401
  <div id="mobile-auth-success" class="alert alert-success d-none"></div>
375
402
 
376
403
  <div class="d-flex gap-2 justify-content-end">
@@ -433,6 +460,8 @@
433
460
  </div>
434
461
 
435
462
  <div id="validation-errors" class="alert alert-danger d-none"></div>
463
+ <!-- Assistant: explain why the login cannot start (filled by script.js) -->
464
+ <div id="wizard-start-problem" class="mb-3 d-none"></div>
436
465
 
437
466
  <div class="d-flex gap-2 justify-content-end">
438
467
  <button class="btn btn-outline-secondary" onclick="hideWizard()">Cancel</button>
@@ -459,6 +488,9 @@
459
488
  </button>
460
489
  </div>
461
490
 
491
+ <!-- Assistant: failed authorization + explanation (filled by script.js) -->
492
+ <div id="wizard-auth-problem" class="mb-3 d-none"></div>
493
+
462
494
  <!-- Automatic callback status -->
463
495
  <div id="callback-server-status" class="d-none">
464
496
  <div class="alert alert-success">