Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device trigger - sync value with initialHaFormData #20810

Merged
merged 1 commit into from
May 24, 2024

Conversation

karwosts
Copy link
Contributor

@karwosts karwosts commented May 16, 2024

Proposed change

When computeInitialHaFormData sets up the form for the first time in device triggers, we need to actually push those selections to the value as well, or else the trigger can be broken. Consider this trigger:

550e1c16f162ccfb704581315cf79652066273af

computeInitialHaFormData sees the trigger contains a required select selector with 1 item, and defaults to selecting the first item. But until user interacts with the form there is no actual zone key published to the trigger value. Since it is already selected, clicking it again does nothing. Therefore this trigger is broken and there's no way to make the visual editor accept this trigger (without dropping into yaml mode), as seen by the error that there is a required zone, but it is already selected.

I might have thought we needed something similar for device conditions or device actions, but those don't use computeInitialHaFormData 馃し

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

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:

@karwosts karwosts changed the title Device trigger - sync yaml with initialHaFormData Device trigger - sync value with initialHaFormData May 16, 2024
@piitaya
Copy link
Member

piitaya commented May 22, 2024

The device trigger is the only automation block using computeInitialHaFormData. Not sure why...

@piitaya piitaya merged commit d52641b into home-assistant:dev May 24, 2024
14 checks passed
@karwosts karwosts deleted the device-trigger-initial-form branch May 24, 2024 13:08
@farmio
Copy link
Contributor

farmio commented May 29, 2024

Maybe because I didn't think of the others (since I never implemented them 馃槵). See #20555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants