-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add API to allow HA-aware add-ons to interact with HA #28213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API to allow HA-aware add-ons to interact with HA #28213
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
8ae205c to
e72d326
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| }, 60000); | ||
|
|
||
| this._addon = addon; | ||
| this._setupHassIngress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Stale state persists when switching between add-ons
When switching between add-ons, _setupHassIngress is called without first cleaning up the previous state. The _propertyCallback and _hideToolbar values from the old add-on persist because _cleanupHassIngress() is only called in disconnectedCallback(). This causes the previous add-on's hideToolbar setting to incorrectly affect the new add-on's toolbar visibility, and the old callback may still be invoked in updated() when properties change.
Additional Locations (1)
|
Marked as draft as I want to add the feature to #28214 |
Implements secure communication between Home Assistant and ingress
add-ons using postMessage instead of direct window access.
Changes to ingress-view:
- Added postMessage listener to handle messages from iframe
- Added sandbox attribute to iframe for improved security
- Support for subscribe/unsubscribe, navigate, and toggleMenu
- Automatically sends property updates (narrow/route) to subscribed add-ons
- hideToolbar option to let add-ons manage their own toolbar
New client library (hass-app-integrate.js):
- Standalone JavaScript library for add-on developers
- Simple API: subscribe(), navigate(), toggleMenu()
- Handles all postMessage communication automatically
- Can be included via <script> tag in add-on UIs
Example usage:
const hassApp = new HassAppIntegrate();
hassApp.subscribe(({ narrow, route }) => {
// Handle layout changes
}, { hideToolbar: true });
hassApp.navigate('/lovelace/dashboard');
hassApp.toggleMenu();
e72d326 to
fe912d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking change
Proposed change
This adds an API for add-ons served via Ingress similar to how we offer one for custom panels inside their iframe.
Add-ons can do the following things:
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
Note
Adds
window.hassIngressAPI (navigate, toggleMenu, subscribe) and optional toolbar hiding for ingress add-ons, with lifecycle integration and reactive updates.window.hassIngresswith:navigate(path, options?),toggleMenu()narrowandroutepropertiessubscribe(({ narrow, route }, { hideToolbar? }) => unsubscribe)with immediate emit and unsubscribe handlingnarrow/routechanges and clean up on disconnect(narrow || sidebar always_hidden)and add-on setshideToolbar=true; add-ons can render their own menu button_hideToolbarand_propertyCallbackstate, setup/cleanup helpers for API lifecycleNavigateOptions)Written by Cursor Bugbot for commit e72d326. This will update automatically on new commits. Configure here.