Skip to content

Commit 2c399bf

Browse files
TimoPtrCopilotjpelgrom
authored
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
1 parent 09d0754 commit 2c399bf

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

docs/frontend/external-authentication.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ If you want to embed the Home Assistant frontend in an external app, you will wa
99
To activate this API, load the frontend with `?external_auth=1` appended to the URL. If this is passed in, Home Assistant will expect either `window.externalAppV2` (Android V2, recommended), `window.externalApp` (Android V1, fallback) or `window.webkit.messageHandlers` (iOS) to be defined containing the methods described below.
1010

1111
:::note
12-
V2 (`window.externalAppV2`) is only available when the WebView supports [`WebViewFeature.WEB_MESSAGE_LISTENER`][web-message-listener]. The app should fall back to V1 otherwise.
12+
V2 (`window.externalAppV2`) requires the WebView to support [`WebViewFeature.WEB_MESSAGE_LISTENER`][web-message-listener]. The app should fall back to V1 otherwise.
1313
:::
1414

1515
## Get access token
@@ -19,15 +19,15 @@ When the frontend loads, it will request an access token from the external authe
1919
The `force` boolean has been introduced in Home Assistant 0.104 and might not always be available.
2020

2121
```js
22-
// V2 (recommended)
22+
// Android V2 (recommended)
2323
window.externalAppV2.postMessage(
2424
JSON.stringify({
2525
type: "getExternalAuth",
2626
payload: { callback: "externalAuthSetToken", force: true },
2727
})
2828
);
2929

30-
// V1 (fallback)
30+
// Android V1 (fallback)
3131
window.externalApp.getExternalAuth(
3232
JSON.stringify({ callback: "externalAuthSetToken", force: true })
3333
);
@@ -59,15 +59,15 @@ The frontend will call this method when the page first loads and whenever it nee
5959
When the user presses the logout button on the profile page, the external app will have to [revoke the refresh token](auth_api.md#revoking-a-refresh-token), and log the user out.
6060

6161
```js
62-
// V2 (recommended)
62+
// Android V2 (recommended)
6363
window.externalAppV2.postMessage(
6464
JSON.stringify({
6565
type: "revokeExternalAuth",
6666
payload: { callback: "externalAuthRevokeToken" },
6767
})
6868
);
6969

70-
// V1 (fallback)
70+
// Android V1 (fallback)
7171
window.externalApp.revokeExternalAuth(
7272
JSON.stringify({ callback: "externalAuthRevokeToken" })
7373
);

docs/frontend/external-bus.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ Messages are passed to the external app as serialized JSON objects. The function
1212

1313
On Android, the implementation depends on the WebView features:
1414

15-
**V2 (recommended)**: Uses [`WebViewFeature.WEB_MESSAGE_LISTENER`][web-message-listener] for secure origin validation. The frontend sends messages using:
15+
**V2 (recommended)**: Uses [`WebViewFeature.WEB_MESSAGE_LISTENER`][web-message-listener] for secure origin validation. The frontend sends messages using the injected V2 object:
1616

17-
```ts
18-
postMessage(JSON.stringify({ type: "externalBus", payload: msg }))
1917
```
2018
2119
**V1 (fallback)**: Used when the WebView doesn't support [`WebViewFeature.WEB_MESSAGE_LISTENER`][web-message-listener]. Your app needs to define:
@@ -139,9 +137,9 @@ Expected response:
139137
- `canCommissionMatter`: Set to true if the app can commission Matter devices
140138
- `canImportThreadCredentials`: Set to true if the app can import Thread credentials
141139
- `canTransferThreadCredentialsToKeychain`: Set to true if the app can transfer Thread credentials to the keychain (Apple only)
142-
- `hasAssist`: Set to true if the app supports the Assist voice assistant interface
143-
- `hasBarCodeScanner`: Set to 1 if the app has barcode scanning capability, 0 otherwise
144-
- `canSetupImprov`: Set to true if the app can set up Improv-enabled devices
140+
- `hasAssist`: Set to true if the app has a native Assist interface, replacing the frontend implementation
141+
- `hasBarCodeScanner`: Set to `1` if the app has bar code scanning capability, `0` otherwise
142+
- `canSetupImprov`: Set to true if the app can set up Improv Wi-Fi devices
145143
- `appVersion`: The version string of the native app
146144
- `hasEntityAddTo`: Set to true if the app supports adding entities to platform-specific locations (e.g., homescreen widget)
147145
- `hasAssistSettings`: Set to true if the app has an Assist settings screen
@@ -241,7 +239,7 @@ Payload:
241239

242240
##### `assist/show`
243241

244-
Show the Assist interface.
242+
Show the native Assist interface.
245243

246244
Payload (optional):
247245

@@ -269,7 +267,7 @@ Payload: None
269267

270268
##### `bar_code/scan`
271269

272-
Start scanning a barcode.
270+
Start scanning a bar code.
273271

274272
Payload:
275273

@@ -283,17 +281,17 @@ Payload:
283281

284282
- `title`: Title to show in the scanner UI (required)
285283
- `description`: Description text to show in the scanner UI (required)
286-
- `alternative_option_label`: Optional label for an alternative action button
284+
- `alternative_option_label`: Optional label for an alternative action button, if not included the alternative action button should be hidden
287285

288286
##### `bar_code/close`
289287

290-
Close the barcode scanner.
288+
Close the bar code scanner.
291289

292290
Payload: None
293291

294292
##### `bar_code/notify`
295293

296-
Show a notification message in the barcode scanner.
294+
Show a notification message in the bar code scanner.
297295

298296
Payload:
299297

@@ -318,26 +316,28 @@ Payload (optional):
318316
}
319317
```
320318

321-
- `mac_extended_address`: The MAC extended address of the device
322-
- `extended_pan_id`: The extended PAN ID of the Thread network
319+
All payload properties describe the preferred Thread network which should be used when commissioning a Matter over Thread device.
320+
321+
- `mac_extended_address`: The MAC extended address
322+
- `extended_pan_id`: The extended PAN ID
323323
- `border_agent_id`: The border agent ID
324-
- `active_operational_dataset`: The active operational dataset
324+
- `active_operational_dataset`: The active operational dataset (TLV)
325325

326326
##### `thread/import_credentials`
327327

328-
Import Thread network credentials.
328+
Import Thread network credentials from the device. Credentials should be sent using the [WebSocket API](/docs/api/websocket)
329329

330330
Payload: None
331331

332332
##### `improv/scan`
333333

334-
Start scanning for Improv-enabled devices.
334+
Start scanning for Improv Wi-Fi devices.
335335

336336
Payload: None
337337

338338
##### `improv/configure_device`
339339

340-
Configure a discovered Improv device.
340+
Configure a discovered Improv Wi-Fi device.
341341

342342
Payload:
343343

@@ -422,10 +422,10 @@ Payload:
422422
}
423423
```
424424

425-
- `mac_extended_address`: The MAC extended address of the device
425+
- `mac_extended_address`: The MAC extended address
426426
- `border_agent_id`: The border agent ID
427-
- `active_operational_dataset`: The active operational dataset
428-
- `extended_pan_id`: The extended PAN ID of the Thread network
427+
- `active_operational_dataset`: The active operational dataset (TLV)
428+
- `extended_pan_id`: The extended PAN ID
429429

430430
##### `focus_element`
431431

@@ -498,7 +498,7 @@ Payload (optional):
498498

499499
##### `bar_code/scan_result`
500500

501-
Send a barcode scan result to the frontend.
501+
Send a bar code scanner result to the frontend.
502502

503503
Payload:
504504

@@ -540,7 +540,7 @@ Payload:
540540

541541
##### `improv/discovered_device`
542542

543-
Notify that an Improv device was discovered.
543+
Notify that an Improv Wi-Fi device was discovered.
544544

545545
Payload:
546546

@@ -552,7 +552,7 @@ Payload:
552552

553553
##### `improv/device_setup_done`
554554

555-
Notify that Improv device setup is complete.
555+
Notify that Improv Wi-Fi device setup is complete.
556556

557557
Payload: None
558558

0 commit comments

Comments
 (0)