Add response UI to stop action (#17045)

This commit is contained in:
Bram Kragten 2023-06-27 19:02:05 +02:00 committed by GitHub
parent c3c062cc29
commit 6b4300950d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -19,7 +19,7 @@ export class HaStopAction extends LitElement implements ActionElement {
}
protected render() {
const { error, stop } = this.action;
const { error, stop, response_variable } = this.action;
return html`
<ha-textfield
@ -30,6 +30,14 @@ export class HaStopAction extends LitElement implements ActionElement {
.disabled=${this.disabled}
@change=${this._stopChanged}
></ha-textfield>
<ha-textfield
.label=${this.hass.localize(
"ui.panel.config.automation.editor.actions.type.stop.response_variable"
)}
.value=${response_variable || ""}
.disabled=${this.disabled}
@change=${this._responseChanged}
></ha-textfield>
<ha-formfield
.disabled=${this.disabled}
.label=${this.hass.localize(
@ -45,14 +53,21 @@ export class HaStopAction extends LitElement implements ActionElement {
`;
}
private _stopChanged(ev: CustomEvent) {
private _stopChanged(ev: Event) {
ev.stopPropagation();
fireEvent(this, "value-changed", {
value: { ...this.action, stop: (ev.target as any).value },
});
}
private _errorChanged(ev: CustomEvent) {
private _responseChanged(ev: Event) {
ev.stopPropagation();
fireEvent(this, "value-changed", {
value: { ...this.action, response_variable: (ev.target as any).value },
});
}
private _errorChanged(ev: Event) {
ev.stopPropagation();
fireEvent(this, "value-changed", {
value: { ...this.action, error: (ev.target as any).checked },

View File

@ -2652,6 +2652,7 @@
"stop": {
"label": "Stop",
"stop": "Reason for stopping",
"response_variable": "The name of the variable to use as response",
"error": "Stop because of an unexpected error"
},
"parallel": {