-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add show-automation-editor event for custom cards & panels #26613
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 show-automation-editor event for custom cards & panels #26613
Conversation
I wonder if should just expose this on the |
Thanks a lot for the feedback! |
The frontend team discussed this and we agreed that this should be exposed but as an event similar to Side note: the |
Great! I’ve just updated the PR to expose it as an event. |
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.
Pull Request Overview
This PR adds support for custom cards and panels to open the Home Assistant Automation Editor with prefilled data by introducing a new show-automation-editor
event. Previously, only the core UI could programmatically open the automation editor with initial data, limiting the functionality available to custom integrations and panels.
Key changes:
- Creates a new mixin that handles
show-automation-editor
events and delegates to the existingshowAutomationEditor
function - Adds the mixin to the base
HassElement
class to make the functionality available throughout the application - Defines proper TypeScript interfaces for the event parameters
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/state/hass-element.ts |
Imports and applies the new AutomationEditorMixin to the base HassElement class |
src/state/automation-editor-mixin.ts |
New mixin that listens for show-automation-editor events and handles them |
src/data/automation.ts |
Adds TypeScript interface definitions for the new event and its parameters |
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.
Thank you!
Proposed change
ExposeshowAutomationEditor(data?: Partial<AutomationConfig>, expanded?: boolean)
as a public method on theha-panel-custom
. This allows custom panels (iframes) to open the Automation Editor prefilled with data.Add a new event for
show-automation-editor
. This allows custom cards & panels to open the Automation Editor prefilled with data.Until now, only the core UI could open the automation editor prefilled. Custom panels (iframes) had no way to do this, because the editor initialization (initialAutomationEditorData) was only accessible inside the main app. By exposing showAutomationEditor, embedded panels can now trigger the same flow and hand over prefilled data.
Use case:
For the KNX integration we provide a Telegram Monitor. This tool shows how KNX devices on the network exchange messages with each other (e.g., a wall switch sending a telegram to a light actuator). We want to add a feature that lets the user create an automation directly from such a telegram, like so:
create_automation_from_group_monitor.mov
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: