Skip to content

Commit

Permalink
Add service response support (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Apr 24, 2024
1 parent 0993e90 commit 0260066
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const callService = (
service: string,
serviceData?: object,
target?: HassServiceTarget,
returnResponse?: boolean,
) =>
connection.sendMessagePromise(
messages.callService(domain, service, serviceData, target),
messages.callService(domain, service, serviceData, target, returnResponse),
);
3 changes: 3 additions & 0 deletions lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,22 @@ type ServiceCallMessage = {
service: string;
service_data?: object;
target?: HassServiceTarget;
return_response?: boolean;
};

export function callService(
domain: string,
service: string,
serviceData?: object,
target?: HassServiceTarget,
returnResponse?: boolean,
) {
const message: ServiceCallMessage = {
type: "call_service",
domain,
service,
target,
return_response: returnResponse,
};

if (serviceData) {
Expand Down

0 comments on commit 0260066

Please sign in to comment.