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
Add Attribute Picker as a selector - add to state trigger #11641
Conversation
@@ -81,6 +81,7 @@ export class HaForm extends LitElement implements HaFormElement { | |||
: ""} | |||
${"selector" in item | |||
? html`<ha-selector | |||
.schema=${item} |
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.
Why is this necessary? The selector
value is the schema in this case.
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.
Adding features outside of the selector
definition will break compatibility when selectors are used in services.yaml
or blueprints.
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.
This is needed for the value changed event
I removed it and now all selectors are broken
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.
All selectors work here https://design.home-assistant.io/#components/ha-form
Why does it fix it?
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.
When the value is changed and sent to the ha-form. Ha-form uses schema to find the name of the value
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.
root.addEventListener("value-changed", (ev) => {
ev.stopPropagation();
const schema = (ev.target as HaFormElement).schema as HaFormSchema;
fireEvent(this, "value-changed", {
value: { ...this.data, [schema.name]: ev.detail.value },
});
});
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.
Then how does the selectors card on https://design.home-assistant.io/#components/ha-form work?
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.
Is it the latest dev?
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.
I broke it today
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
@@ -81,12 +92,13 @@ export class HaStateTrigger extends LitElement implements TriggerElement { | |||
const trgFor = createDurationData(this.trigger.for); | |||
|
|||
const data = { ...this.trigger, ...{ for: trgFor } }; |
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.
{ ...this.trigger, for: trgFor }
Breaking change
Proposed change
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: