mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 19:56:42 +00:00
Fix service button element (#2343)
This commit is contained in:
parent
d1a56d6acc
commit
e5bf842801
@ -56,6 +56,10 @@ export default (superClass) =>
|
|||||||
dockedSidebar: false,
|
dockedSidebar: false,
|
||||||
moreInfoEntityId: null,
|
moreInfoEntityId: null,
|
||||||
callService: async (domain, service, serviceData = {}) => {
|
callService: async (domain, service, serviceData = {}) => {
|
||||||
|
if (__DEV__) {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
console.log("Calling service", domain, service, serviceData);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await callService(conn, domain, service, serviceData);
|
await callService(conn, domain, service, serviceData);
|
||||||
|
|
||||||
@ -91,6 +95,15 @@ export default (superClass) =>
|
|||||||
}
|
}
|
||||||
this.fire("hass-notification", { message });
|
this.fire("hass-notification", { message });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (__DEV__) {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
console.error(
|
||||||
|
"Error calling service",
|
||||||
|
domain,
|
||||||
|
service,
|
||||||
|
serviceData
|
||||||
|
);
|
||||||
|
}
|
||||||
const message = this.localize(
|
const message = this.localize(
|
||||||
"ui.notification_toast.service_call_failed",
|
"ui.notification_toast.service_call_failed",
|
||||||
"service",
|
"service",
|
||||||
@ -106,21 +119,25 @@ export default (superClass) =>
|
|||||||
fetchWithAuth(auth, `${auth.data.hassUrl}${path}`, init),
|
fetchWithAuth(auth, `${auth.data.hassUrl}${path}`, init),
|
||||||
// For messages that do not get a response
|
// For messages that do not get a response
|
||||||
sendWS: (msg) => {
|
sendWS: (msg) => {
|
||||||
// eslint-disable-next-line
|
if (__DEV__) {
|
||||||
if (__DEV__) console.log("Sending", msg);
|
// eslint-disable-next-line
|
||||||
|
console.log("Sending", msg);
|
||||||
|
}
|
||||||
conn.sendMessage(msg);
|
conn.sendMessage(msg);
|
||||||
},
|
},
|
||||||
// For messages that expect a response
|
// For messages that expect a response
|
||||||
callWS: (msg) => {
|
callWS: (msg) => {
|
||||||
/* eslint-disable no-console */
|
if (__DEV__) {
|
||||||
if (__DEV__) console.log("Sending", msg);
|
/* eslint-disable no-console */
|
||||||
|
console.log("Sending", msg);
|
||||||
|
}
|
||||||
|
|
||||||
const resp = conn.sendMessagePromise(msg);
|
const resp = conn.sendMessagePromise(msg);
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
resp.then(
|
resp.then(
|
||||||
(result) => console.log("Received", result),
|
(result) => console.log("Received", result),
|
||||||
(err) => console.log("Error", err)
|
(err) => console.error("Error", err)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return resp;
|
return resp;
|
||||||
|
@ -48,7 +48,7 @@ export class HuiServiceButtonElement extends LitElement
|
|||||||
.hass="${this.hass}"
|
.hass="${this.hass}"
|
||||||
.domain="${this._domain}"
|
.domain="${this._domain}"
|
||||||
.service="${this._service}"
|
.service="${this._service}"
|
||||||
.service-data="${this._config.service_data}"
|
.serviceData="${this._config.service_data}"
|
||||||
>${this._config.title}</ha-call-service-button
|
>${this._config.title}</ha-call-service-button
|
||||||
>
|
>
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user