Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add fields and multiple support to object selector #39655

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 3 commits into
base: next
Choose a base branch
from

Conversation

piitaya
Copy link
Member

@piitaya piitaya commented Jun 20, 2025

Proposed change

Add fields and multiple support to object selector. The nested items will be editable in a dialog.

Type of change

  • Spelling, grammar or other readability improvements (current branch).
  • Adjusted missing or incorrect information in the current documentation (current branch).
  • Added documentation for a new integration I'm adding to Home Assistant (next branch).
  • Added documentation for a new feature I'm adding to Home Assistant (next branch).
  • Removed stale or deprecated documentation.

Additional information

Checklist

  • This PR uses the correct branch, based on one of the following:
    • I made a change to the existing documentation and used the current branch.
    • I made a change that is related to an upcoming version of Home Assistant and used the next branch.
  • The documentation follows the Home Assistant documentation standards.

Summary by CodeRabbit

  • Documentation
    • Expanded and clarified documentation for the "object" selector, including detailed explanations of its usage modes and configuration options.
    • Added a new example demonstrating schema usage with labeled fields and nested selectors.
    • Included a comprehensive configuration schema outlining all available options and their descriptions.

@home-assistant home-assistant bot added has-parent This PR has a parent PR in a other repo next This PR goes into the next branch labels Jun 20, 2025
Copy link

netlify bot commented Jun 20, 2025

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit 7829192
🔍 Latest deploy log https://app.netlify.com/projects/home-assistant-docs/deploys/68555ce222c8c5000822c9f0
😎 Deploy Preview https://deploy-preview-39655--home-assistant-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@piitaya piitaya changed the title dd fields and multiple support to object selector Add fields and multiple support to object selector Jun 20, 2025
@piitaya piitaya marked this pull request as ready for review June 20, 2025 13:07
@Copilot Copilot AI review requested due to automatic review settings June 20, 2025 13:07
Copy link
Contributor

@Copilot Copilot AI left a 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 enhances the object selector by adding structured fields support, multiple selection capability, and corresponding configuration documentation.

  • Introduces free-form and schema-based object selector examples
  • Adds fields, multiple, label_field, description_field, and translation_key configuration options
  • Provides a detailed configuration block for the object selector
Comments suppressed due to low confidence (3)

source/_docs/blueprint/selectors.markdown:1153

  • The example uses label_key and description_key, but the configuration docs refer to label_field and description_field. Rename for consistency or update the docs to match.
  label_key: name

source/_docs/blueprint/selectors.markdown:1170

  • The configuration block is labeled qr_code but documents the object selector. Update the block identifier to reflect the object selector.
{% configuration qr_code %}

source/_docs/blueprint/selectors.markdown:1206

  • The description for multiple mentions a "single string value," but the object selector returns a list of objects. Clarify that it becomes a list of objects.
    Allows selecting multiple options. If set to `true`, the resulting value of this selector will be a list instead of a single string value. This option is only used if `fields` option set.

Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

📝 Walkthrough

Walkthrough

The documentation for the "object" selector was updated to clarify its behavior in both free-form and schema-enforced modes. Detailed configuration schema options were added, and a new example demonstrates schema usage with labeled fields and nested selectors. No code or interface changes occurred; all updates are documentation-only.

Changes

File Change Summary
source/_docs/blueprint/selectors.markdown Expanded "object" selector documentation, added schema options, new example, and detailed config schema

Sequence Diagram(s)

No sequence diagram generated as the changes are documentation-only.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
source/_docs/blueprint/selectors.markdown (2)

1139-1140: Hyphenate “free-form” for clarity
Compound adjectives preceding a noun are typically hyphenated.


1147-1148: Refine phrasing for consistency
Consider using “enforce” instead of “force” to match the terminology used elsewhere (e.g., “enforce the object structure”).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 940045c and 7829192.

⛔ Files ignored due to path filters (2)
  • source/images/blueprints/selector-object-schema.png is excluded by !**/*.png
  • source/images/blueprints/selector-object.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • source/_docs/blueprint/selectors.markdown (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - home-assistant-docs
  • GitHub Check: Header rules - home-assistant-docs
  • GitHub Check: Pages changed - home-assistant-docs
🔇 Additional comments (1)
source/_docs/blueprint/selectors.markdown (1)

1143-1146: Code snippet looks good
The YAML example is valid and consistent with other selector docs.

Comment on lines +1170 to +1210
{% configuration qr_code %}
fields:
description: >
List of fields of the object.
type: map
required: false
keys:
label:
description: The label of the field
required: false
type: string
selector:
description: The selector to use for this field. It can be any available selector.
required: true
type: string
label_field:
description: >
The field to use as a label. By default, it will be the first field defined. This option is only used if `fields` option set.
type: string
required: false
description_field:
description: >
The field to use as a description. This option is only used if `fields` option set.
type: string
required: false
translation_key:
description: >
Allows translations provided by an integration where `translation_key`
is the translation key that is providing the selector option strings
translation. See the documentation on
[Backend Localization](https://developers.home-assistant.io/docs/internationalization/core/#selectors)
for more information.
type: string
required: false
multiple:
description: >
Allows selecting multiple options. If set to `true`, the resulting value of this selector will be a list instead of a single string value. This option is only used if `fields` option set.
type: boolean
required: false
default: false
{% endconfiguration %}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the configuration directive name
The block is mistakenly tagged as qr_code; it should be scoped to object to render correctly.

Apply this diff:

-{% configuration qr_code %}
+{% configuration object %}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{% configuration qr_code %}
fields:
description: >
List of fields of the object.
type: map
required: false
keys:
label:
description: The label of the field
required: false
type: string
selector:
description: The selector to use for this field. It can be any available selector.
required: true
type: string
label_field:
description: >
The field to use as a label. By default, it will be the first field defined. This option is only used if `fields` option set.
type: string
required: false
description_field:
description: >
The field to use as a description. This option is only used if `fields` option set.
type: string
required: false
translation_key:
description: >
Allows translations provided by an integration where `translation_key`
is the translation key that is providing the selector option strings
translation. See the documentation on
[Backend Localization](https://developers.home-assistant.io/docs/internationalization/core/#selectors)
for more information.
type: string
required: false
multiple:
description: >
Allows selecting multiple options. If set to `true`, the resulting value of this selector will be a list instead of a single string value. This option is only used if `fields` option set.
type: boolean
required: false
default: false
{% endconfiguration %}
{% configuration object %}
fields:
description: >
List of fields of the object.
type: map
required: false
keys:
label:
description: The label of the field
required: false
type: string
selector:
description: The selector to use for this field. It can be any available selector.
required: true
type: string
label_field:
description: >
The field to use as a label. By default, it will be the first field defined. This option is only used if `fields` option set.
type: string
required: false
description_field:
description: >
The field to use as a description. This option is only used if `fields` option set.
type: string
required: false
translation_key:
description: >
Allows translations provided by an integration where `translation_key`
is the translation key that is providing the selector option strings
translation. See the documentation on
[Backend Localization](https://developers.home-assistant.io/docs/internationalization/core/#selectors)
for more information.
type: string
required: false
multiple:
description: >
Allows selecting multiple options. If set to `true`, the resulting value of this selector will be a list instead of a single string value. This option is only used if `fields` option set.
type: boolean
required: false
default: false
{% endconfiguration %}
🤖 Prompt for AI Agents
In source/_docs/blueprint/selectors.markdown between lines 1170 and 1210, the
configuration block is incorrectly tagged as qr_code instead of object. Change
the configuration directive name from qr_code to object to ensure the block
renders correctly.

Comment on lines +1153 to 1166
label_key: name
description_key: percentage
multiple: true
fields:
name:
label: Name
selector:
text:
percentage:
label: Percentage
selector:
number:
unit_of_measurement: "%"
```
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix mismatched key names in example
The snippet uses label_key and description_key, but the configuration schema below defines label_field and description_field. These must match.

Apply this diff:

- object:
-   label_key: name
-   description_key: percentage
+ object:
+   label_field: name
+   description_field: percentage

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In source/_docs/blueprint/selectors.markdown around lines 1153 to 1166, the
example uses the keys label_key and description_key, but the configuration
schema expects label_field and description_field. To fix this, rename label_key
to label_field and description_key to description_field in the snippet so the
keys match the schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-parent This PR has a parent PR in a other repo next This PR goes into the next branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant