Allow multiple states in state condition editor

This commit is contained in:
Thomas Lovén 2020-11-08 22:06:40 +01:00
parent 4dcf26236e
commit c448bbc3b4
2 changed files with 24 additions and 8 deletions

View File

@ -30,6 +30,9 @@ export const handleChangeEvent = (
ev: CustomEvent ev: CustomEvent
) => { ) => {
ev.stopPropagation(); ev.stopPropagation();
if (ev.detail.isValid === false) {
return;
}
const name = (ev.target as any)?.name; const name = (ev.target as any)?.name;
if (!name) { if (!name) {
return; return;

View File

@ -41,14 +41,27 @@ export class HaStateCondition extends LitElement implements ConditionElement {
@value-changed=${this._valueChanged} @value-changed=${this._valueChanged}
allow-custom-value allow-custom-value
></ha-entity-attribute-picker> ></ha-entity-attribute-picker>
<paper-input ${Array.isArray(state)
.label=${this.hass.localize( ? html`
"ui.panel.config.automation.editor.conditions.type.state.state" <ha-yaml-editor
)} .label=${this.hass.localize(
.name=${"state"} "ui.panel.config.automation.editor.conditions.type.state.state"
.value=${state} ) + " (YAML)"}
@value-changed=${this._valueChanged} .defaultValue=${state}
></paper-input> .name=${"state"}
@value-changed=${this._valueChanged}
></ha-yaml-editor>
`
: html`
<paper-input
.label=${this.hass.localize(
"ui.panel.config.automation.editor.conditions.type.state.state"
)}
.name=${"state"}
.value=${state}
@value-changed=${this._valueChanged}
></paper-input>
`}
`; `;
} }