Show toast with call service error (#8904)

This commit is contained in:
Bram Kragten 2021-04-13 02:10:25 +02:00 committed by GitHub
parent ea60f7005b
commit 56fe4b07f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,7 @@ import { haStyle } from "../../../resources/styles";
import "../../../styles/polymer-ha-style"; import "../../../styles/polymer-ha-style";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import "../../../util/app-localstorage-document"; import "../../../util/app-localstorage-document";
import { showToast } from "../../../util/toast";
class HaPanelDevService extends LitElement { class HaPanelDevService extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@ -267,11 +268,22 @@ class HaPanelDevService extends LitElement {
} }
); );
private _callService() { private async _callService() {
if (!this._serviceData?.service) { if (!this._serviceData?.service) {
return; return;
} }
callExecuteScript(this.hass, [this._serviceData]); try {
await callExecuteScript(this.hass, [this._serviceData]);
} catch (err) {
showToast(this, {
message:
this.hass.localize(
"ui.notification_toast.service_call_failed",
"service",
this._serviceData.service
) + ` ${err.message}`,
});
}
} }
private _toggleYaml() { private _toggleYaml() {