Skip to content

Fix device actions in step-flow-form #24539

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

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

karwosts
Copy link
Contributor

@karwosts karwosts commented Mar 7, 2025

Proposed change

The action selector has some issues when used in a dialog (like a config flow), as device actions implictly rely on consuming the fullEntitiesContext provided by ha-panel-config.

When in a step flow dialog, the dialog is not under the DOM of that ha-panel-config, so the expected entity registry is undefined, leading to significant problems with device actions/conditions/triggers. The frontend just throws exceptions and gets bugged out if you try to use them.

To workaround this, in the action selector I check if the expected entityRegistry is not provided, and create a new producer for it in the action selector if missing, so that the child elements that expect it to exist can function.

Sadly, after making these fixes, using device actions in config flows still does not actually work 😅 . The frontend parts seem to work, but anytime you save and actually trigger the device actions via this method (like with a Template Button), core throws backend errors and says it can't understand the entity_id. But I think that's likely a core bug; so we can fix this first, and then move the investigation there. (Assuming we want device actions to work here).

This could also be an issue if any config flows use Trigger selectors or Condition selectors, though I'm not aware of any that do, so far I've only seen Action selectors used on templates, so I am limiting the fix to that.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@@ -103,6 +104,7 @@ export abstract class HaDeviceAutomationPicker<
.label=${this.label}
.value=${value}
@selected=${this._automationChanged}
@closed=${stopPropagation}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An unrelated bug that causes the config flow form to close every time you select a device action in the action selector.

@bramkragten bramkragten added the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Mar 10, 2025
@bramkragten
Copy link
Member

I think we should add lazy loaded context provides, so that the context provider can be on the home-assistant level and dialogs can also use it.

I'll look in to that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed second-opinion-wanted Add this label when a reviewer needs a second opinion from another member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants