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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple sections #131393

Draft
wants to merge 13 commits into
base: dev
Choose a base branch
from
Draft

Allow multiple sections #131393

wants to merge 13 commits into from

Conversation

gjohansson-ST
Copy link
Member

@gjohansson-ST gjohansson-ST commented Nov 23, 2024

Proposed change

Allow us to use multiple sections e.g. the user can add/remove sections from the same configuration.
See frontend PR how it would be displayed for the user.

Example of integrations that could use this (some already in UI)

  • bayesian (observations list)
  • filter (as filters)
  • compensation (data points)
  • template (alarm_control_panel/lock define the different arming/lock options).
  • scrape (sensors)

Frontend: home-assistant/frontend#22965
Dev docs: home-assistant/developers.home-assistant#2471

Type of change

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

Additional information

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

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

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

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (kitchen_sink) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of kitchen_sink can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign kitchen_sink Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@gjohansson-ST gjohansson-ST changed the title WIP: Allow multiple sections Allow multiple sections Nov 24, 2024
@gjohansson-ST gjohansson-ST marked this pull request as ready for review November 24, 2024 20:20
@gjohansson-ST gjohansson-ST requested a review from a team as a code owner November 24, 2024 20:20
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Please provide an overview of use cases and existing integrations that can use the new selector config, besides the compensation integration.

@home-assistant home-assistant bot marked this pull request as draft November 25, 2024 14:34
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@gjohansson-ST
Copy link
Member Author

Please provide an overview of use cases and existing integrations that can use the new selector config, besides the compensation integration.

I have updated the PR description with some integrations that could use this. There are probably also quite a few more than could use it, if it was available when it went into UI.

@MartinHjelmare
Copy link
Member

I'd say that of the ones mentioned now, only bayesian, compensation and filter are suitable. Scrape would use sub entries (nuggets), and template alarm control panel I don't see how it would use a multiple section. There's only one action (script) allowed per alarm control panel service action and panel and we use action selectors for that.

@gjohansson-ST
Copy link
Member Author

and template alarm control panel I don't see how it would use a multiple section. There's only one action (script) allowed per alarm control panel service action and panel and we use action selectors for that.

I was more thinking the whole arming definition would go into sections. So instead as currently you need to ask which ones to use and present on a second form. The user could just simply add one after the other and define for which action it is.

So I think that would also be the same for lock, cover etc.

arm_away:
  action: alarm_control_panel.alarm_arm_away
  target:
    entity_id: alarm_control_panel.real_alarm
  data:
    code: !secret alarm_code

@MartinHjelmare
Copy link
Member

What's the second form? Is it really intuitive to use sections when there's a limited set of distinct items to configure?

@gjohansson-ST
Copy link
Member Author

I guess that's a border line case to have the sections in the initial form (and the user need to select the arming types) than presenting the fixed set of options on a second form (or multiple forms).
Even though it's a bit hard to present a lot of integrations that can use this, I'm convinced it would be beneficial also for other integrations to use when there is a list with multiple fields inside.

@MartinHjelmare
Copy link
Member

There's only one form for template alarm control panel.

@gjohansson-ST
Copy link
Member Author

I don't remember but I guessed two. Anyhow template is not the best example here anyhow.
I guess you'll come back with some final verdict later 😅

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.

2 participants