-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
base: next
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for home-assistant-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this 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
, andtranslation_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
anddescription_key
, but the configuration docs refer tolabel_field
anddescription_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.
📝 WalkthroughWalkthroughThe 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
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
⛔ 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.
{% 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 %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
{% 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.
label_key: name | ||
description_key: percentage | ||
multiple: true | ||
fields: | ||
name: | ||
label: Name | ||
selector: | ||
text: | ||
percentage: | ||
label: Percentage | ||
selector: | ||
number: | ||
unit_of_measurement: "%" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Proposed change
Add fields and multiple support to object selector. The nested items will be editable in a dialog.
Type of change
current
branch).current
branch).next
branch).next
branch).Additional information
Checklist
current
branch.next
branch.Summary by CodeRabbit