Make config flow previews more generic #21382
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
Most of the config flow preview modules seem to be copy-pastes of the same code, as they do the same thing (pass the form data to the backend via a start_preview API call, get a fake entity in response).
Feels like maybe we don't really need to recreate the same logic for every integration that wants to create a preview. It adds a big hurdle for backend integration developers that might want to add previews to get a frontend merged as well.
The modules seem like they could be replaced with a generic module, and then with this backend developers can implement new config flow previews without needing any frontend support. For more complex previews (like template), creating custom modules is still possible.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
Summary by CodeRabbit
domain
parameter to enhance flexibility in preview functionalities.@coderabbitai ignore