Skip to content

Update the implementation details of the external bus for the apps#3049

Open
TimoPtr wants to merge 3 commits intomasterfrom
update/external_bus_details
Open

Update the implementation details of the external bus for the apps#3049
TimoPtr wants to merge 3 commits intomasterfrom
update/external_bus_details

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented Apr 14, 2026

Proposed change

Update the documentation regarding the external bus messages and how to set it up properly.

Type of change

  • Document existing features within Home Assistant
  • Document new or changing features for which there is an existing pull request elsewhere
  • Spelling or grammatical corrections, or rewording for improved clarity
  • Changes to the backend of this documentation
  • Remove stale or deprecated documentation

Checklist

  • I have read and followed the documentation guidelines.
  • I have verified that my changes render correctly in the documentation.

Additional information

Summary by CodeRabbit

  • Documentation
    • Updated external authentication docs to add a new Android V2 messaging path with V1/iOS fallbacks, simplified examples, and a note about WebView support availability.
    • Reorganized external bus docs by message direction and response expectation.
    • Expanded the command catalog and clarified payload/response schemas with many new commands and formats.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@TimoPtr has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 52 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 24 minutes and 52 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d682af21-baa5-4cb7-ad7c-cc0b706673e8

📥 Commits

Reviewing files that changed from the base of the PR and between 2c399bf and 7eb0bc7.

📒 Files selected for processing (2)
  • docs/frontend/external-authentication.md
  • docs/frontend/external-bus.md
📝 Walkthrough

Walkthrough

Adds Android WebView V2 messaging (JSON {type,payload} via window.externalAppV2.postMessage) with V1 and iOS fallbacks, and substantially expands the external bus message catalog with grouped directions, response expectations, and detailed payload/response schemas.

Changes

Cohort / File(s) Summary
External Authentication Bridge
docs/frontend/external-authentication.md
Documented Android V2 API using window.externalAppV2.postMessage(JSON.stringify({type,payload})); retained Android V1 and iOS fallbacks; removed legacy "introduced in Home Assistant 0.78" notes; adjusted JavaScript examples and added web-message-listener reference.
External Bus Messaging
docs/frontend/external-bus.md
Documented dual messaging paths (V2 via WebViewFeature.WEB_MESSAGE_LISTENER and V1 fallback) and app auto-selection note. Reorganized supported messages by direction and response expectation and added many new command identifiers and explicit TypeScript-like payload/response schemas (e.g., theme-update, assist/*, sidebar/*, bar_code/*, matter/commission, thread/*, improv/*, exoplayer/*, focus_element).

Sequence Diagram(s)

sequenceDiagram
    participant FE as Frontend (Web)
    participant WV as WebView (injected bridge)
    participant App as Native App
    rect rgba(200,220,255,0.5)
        FE->>WV: check WebViewFeature.WEB_MESSAGE_LISTENER
        alt V2 supported
            FE->>WV: postMessage(JSON.stringify({type,payload}))
            WV->>App: deliver message object
            App-->>WV: response (if expected)
            WV-->>FE: deliver response
        else V2 not supported
            FE->>App: call `window.externalApp.*` (V1) or `window.webkit.messageHandlers.*` (iOS)
            App-->>FE: callback/response (if expected)
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating documentation about external bus implementation details for apps, which aligns with the file changes in external-authentication.md and external-bus.md.
Description check ✅ Passed The PR description follows the template with all required sections completed: proposed change, type of change selected, checklist items confirmed, and relevant pull request link provided.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update/external_bus_details

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/frontend/external-authentication.md`:
- Around line 22-40: Docs show inconsistent iOS postMessage formats; update the
iOS examples in external-authentication.md so they match the string parameter
style used in external-bus.md by JSON-stringifying the message before calling
window.webkit.messageHandlers.getExternalAuth.postMessage(...) (and likewise for
revokeExternalAuth or any other window.webkit.messageHandlers.* usages), i.e.,
pass a single string via JSON.stringify({ callback: "...", force: true, type:
"..." }) to align with the externalBus signature.

In `@docs/frontend/external-bus.md`:
- Around line 444-448: The "Messages from app to frontend" section currently
uses h3 for the section title and then jumps to h5 for each message heading,
violating markdown heading order; update every message heading in that section
(all instances between the "Messages from app to frontend" heading and the end
of that block, roughly lines 448-569) by changing the h5 markers (`#####`) to h4
markers (`####`) so headings flow h3 → h4 consistently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 51958ac0-c7fc-4596-b9a1-a38bbaedea9d

📥 Commits

Reviewing files that changed from the base of the PR and between a07ecbc and 09d0754.

📒 Files selected for processing (2)
  • docs/frontend/external-authentication.md
  • docs/frontend/external-bus.md

Comment thread docs/frontend/external-authentication.md Outdated
Comment thread docs/frontend/external-bus.md Outdated
bgoncal
bgoncal previously approved these changes Apr 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the frontend developer documentation for embedded apps by clarifying Android WebView integration (V2 vs V1) and expanding/organizing the external-bus message catalog.

Changes:

  • Document Android V2 vs V1 setup for the external bus, including WebViewFeature-based behavior.
  • Reorganize and substantially expand the “Supported messages” section for external bus (direction-based grouping + additional commands/payloads).
  • Update external authentication docs to describe/use the Android V2 postMessage approach with a V1 fallback.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
docs/frontend/external-bus.md Adds Android V2/V1 guidance and reorganizes/extends the external-bus message reference.
docs/frontend/external-authentication.md Updates Android integration docs to include V2 (externalAppV2) messaging with V1 fallback and iOS examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/frontend/external-bus.md Outdated
Comment thread docs/frontend/external-bus.md
Comment thread docs/frontend/external-authentication.md Outdated
Comment thread docs/frontend/external-authentication.md
Copy link
Copy Markdown
Member

@jpelgrom jpelgrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning behind some of my earlier comments is: the mobile_app integration and frontend support for native apps is supposed to be for any native app, the official Home Assistant companion apps are just one of the users.

(Out of scope for this PR, but I feel like it would be nice to have a flowchart for the Improv Wi-Fi and bar code scanner flows.)

Comment thread docs/frontend/external-authentication.md Outdated
Comment thread docs/frontend/external-authentication.md Outdated
Comment thread docs/frontend/external-authentication.md Outdated
Comment thread docs/frontend/external-authentication.md Outdated
Comment thread docs/frontend/external-authentication.md Outdated
Comment thread docs/frontend/external-bus.md
Comment thread docs/frontend/external-bus.md Outdated
Comment thread docs/frontend/external-bus.md Outdated
Comment thread docs/frontend/external-bus.md Outdated
Comment thread docs/frontend/external-bus.md Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
docs/frontend/external-bus.md (1)

454-467: ⚠️ Potential issue | 🟡 Minor

Document the navigate payload parameters.

The path and options.replace parameters lack descriptions. Users need to know:

  • Is path relative to the frontend root or absolute?
  • What does the replace option do (e.g., does it replace the current history entry)?
📝 Suggested documentation additions
 ```ts
 {
   path: string;
   options?: {
     replace: boolean;
   };
 }

+- path: The path to navigate to (e.g., "/lovelace/0" or "/config/dashboard")
+- options.replace: If true, replaces the current history entry instead of adding a new one

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @docs/frontend/external-bus.md around lines 454 - 467, The documentation for
the navigate payload is missing parameter descriptions; update the navigate
payload block to document path and options.replace by stating that path is
the URL path to navigate to (examples like "/lovelace/0" or "/config/dashboard"
and whether it should be treated as absolute from the frontend root) and that
options.replace is a boolean which, when true, replaces the current browser
history entry instead of pushing a new one; keep the existing type signature for
navigate and add those two concise bullet descriptions next to path and
options.replace.


</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against the current code and only fix it if needed.

Inline comments:
In @docs/frontend/external-bus.md:

  • Line 17: Replace the empty fenced code block with a concrete V2 message
    example (or remove it if unnecessary): add a fenced block with a language tag
    (e.g., ```json) and a representative V2 message showing fields like version
    (e.g., "v2"), id/messageId, type/event, timestamp, and payload/body to
    illustrate the V2 message format; ensure the example matches the repo's V2
    schema naming (referenced as "V2 message format") and is realistic enough for
    documentation readers.

Duplicate comments:
In @docs/frontend/external-bus.md:

  • Around line 454-467: The documentation for the navigate payload is missing
    parameter descriptions; update the navigate payload block to document path
    and options.replace by stating that path is the URL path to navigate to
    (examples like "/lovelace/0" or "/config/dashboard" and whether it should be
    treated as absolute from the frontend root) and that options.replace is a
    boolean which, when true, replaces the current browser history entry instead of
    pushing a new one; keep the existing type signature for navigate and add those
    two concise bullet descriptions next to path and options.replace.

</details>

<details>
<summary>🪄 Autofix (Beta)</summary>

Fix all unresolved CodeRabbit comments on this PR:

- [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)
- [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes

</details>

---

<details>
<summary>ℹ️ Review info</summary>

<details>
<summary>⚙️ Run configuration</summary>

**Configuration used**: Organization UI

**Review profile**: CHILL

**Plan**: Pro

**Run ID**: `86bad38b-dbc7-4e27-9e95-46ef7ea7bfe6`

</details>

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 09d07540d4b216ae6470a05763e0c8ced793271b and 2c399bfd52b733300811865ec81de815e64988df.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `docs/frontend/external-authentication.md`
* `docs/frontend/external-bus.md`

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* docs/frontend/external-authentication.md

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread docs/frontend/external-bus.md Outdated

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

```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix incomplete code block.

The code block is empty and has no language identifier. This appears to be an error. Based on the context, this should likely demonstrate the V2 message format or be removed if not needed.

🧰 Tools
🪛 markdownlint-cli2 (0.22.0)

[warning] 17-17: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/frontend/external-bus.md` at line 17, Replace the empty fenced code
block with a concrete V2 message example (or remove it if unnecessary): add a
fenced block with a language tag (e.g., ```json) and a representative V2 message
showing fields like version (e.g., "v2"), id/messageId, type/event, timestamp,
and payload/body to illustrate the V2 message format; ensure the example matches
the repo's V2 schema naming (referenced as "V2 message format") and is realistic
enough for documentation readers.

@TimoPtr TimoPtr requested a review from jpelgrom April 16, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants