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