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.stopPropagation();
if (ev.detail.isValid === false) {
return;
}
const name = (ev.target as any)?.name;
if (!name) {
return;

View File

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