-
Notifications
You must be signed in to change notification settings - Fork 77
/
commands.ts
33 lines (28 loc) · 968 Bytes
/
commands.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Connection } from "./connection.js";
import * as messages from "./messages.js";
import {
HassEntity,
HassServices,
HassConfig,
HassUser,
HassServiceTarget,
} from "./types.js";
export const getStates = (connection: Connection) =>
connection.sendMessagePromise<HassEntity[]>(messages.states());
export const getServices = (connection: Connection) =>
connection.sendMessagePromise<HassServices>(messages.services());
export const getConfig = (connection: Connection) =>
connection.sendMessagePromise<HassConfig>(messages.config());
export const getUser = (connection: Connection) =>
connection.sendMessagePromise<HassUser>(messages.user());
export const callService = (
connection: Connection,
domain: string,
service: string,
serviceData?: object,
target?: HassServiceTarget,
returnResponse?: boolean,
) =>
connection.sendMessagePromise(
messages.callService(domain, service, serviceData, target, returnResponse),
);