Add Attribute Picker as a selector - add to state trigger#11641
Conversation
| : ""} | ||
| ${"selector" in item | ||
| ? html`<ha-selector | ||
| .schema=${item} |
There was a problem hiding this comment.
Why is this necessary? The selector value is the schema in this case.
There was a problem hiding this comment.
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.
This is needed for the value changed event
I removed it and now all selectors are broken
There was a problem hiding this comment.
All selectors work here https://design.home-assistant.io/#components/ha-form
Why does it fix it?
There was a problem hiding this comment.
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.
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.
Then how does the selectors card on https://design.home-assistant.io/#components/ha-form work?
There was a problem hiding this comment.
Is it the latest dev?
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.
{ ...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: