Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions src/layouts/app/connection-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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",
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/elements/hui-service-button-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
>
`;
Expand Down