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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion source/_docs/blueprint/selectors.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1136,16 +1136,79 @@ number:

The object selector can be used to input arbitrary data in YAML form. This is useful for e.g. lists and dictionaries containing data for actions. The value of the input will contain the provided data.

When used without options, the selector will accept a free form object.

![Screenshot of an object selector](/images/blueprints/selector-object.png)

This selector does not have any other options; therefore, it only has its key.
```yaml
object:
```

When used with a `schema`, the selector will force the object to be in this format by displaying a form.

![Screenshot of an object selector](/images/blueprints/selector-object-schema.png)

```yaml
object:
label_key: name
description_key: percentage
multiple: true
fields:
name:
label: Name
selector:
text:
percentage:
label: Percentage
selector:
number:
unit_of_measurement: "%"
```
Comment on lines +1153 to 1166
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.


The output of this selector is a YAML object.

{% 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 %}
Comment on lines +1170 to +1210
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.


## QR code selector

The QR code selector shows a QR code. It has no return value.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified source/images/blueprints/selector-object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.