@sdeck/plugin-home-assistant 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ /** A client for Home Assistant's WebSocket API, authenticated with a long-lived access token. */
2
+ import { type Link } from "@sdeck/plugin";
3
+ export interface EntityState {
4
+ state: string;
5
+ /** The friendly name, or the entity id. */
6
+ name: string;
7
+ attributes: Record<string, unknown>;
8
+ }
9
+ /** Entities by domain and object id: `entities.light.kitchen.state`. */
10
+ export type Entities = Record<string, Record<string, EntityState>>;
11
+ export interface HaClient {
12
+ /** Sends a command; resolves with its result. */
13
+ command(message: {
14
+ type: string;
15
+ [key: string]: unknown;
16
+ }): Promise<unknown>;
17
+ /** The entities, kept current. */
18
+ entities(): Entities;
19
+ /** Hears every state change; returns a function that stops. */
20
+ onChange(listener: (change: StateChange) => void): () => void;
21
+ }
22
+ export interface StateChange {
23
+ entity: string;
24
+ /** `undefined` when the entity is gone. */
25
+ state: EntityState | undefined;
26
+ from: string | undefined;
27
+ }
28
+ /** `http://host:8123` → `ws://host:8123/api/websocket`. */
29
+ export declare function socketUrl(address: string): string;
30
+ /** A copy of `entities` with one entity set or removed. */
31
+ export declare function withEntity(entities: Entities, id: string, state: EntityState | undefined): Entities;
32
+ export declare function connectHomeAssistant(address: string, token: string, lost: (error: Error) => void, signal: AbortSignal, pingMs?: number): Promise<Link<HaClient>>;
33
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,OAAO,EAAE,KAAK,IAAI,EAAkB,MAAM,eAAe,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,wEAAwE;AACxE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAEnE,MAAM,WAAW,QAAQ;IACvB,iDAAiD;IACjD,OAAO,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7E,kCAAkC;IAClC,QAAQ,IAAI,QAAQ,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC/D;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CASjD;AAiBD,2DAA2D;AAC3D,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,WAAW,GAAG,SAAS,GAC7B,QAAQ,CASV;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAC5B,MAAM,EAAE,WAAW,EACnB,MAAM,SAAS,GACd,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAwJzB"}
@@ -0,0 +1,14 @@
1
+ export * from "./client.ts";
2
+ /** `light.kitchen` → the entity's domain and object id, or a message for the user. */
3
+ export declare function splitEntity(entity: string): {
4
+ domain: string;
5
+ object: string;
6
+ };
7
+ /** The state path of an entity, for templates and expressions. */
8
+ export declare function entityPath(entity: string): string;
9
+ export declare const domainOf: (entity: string) => string;
10
+ /** The data of a service call: a JSON object, or nothing. */
11
+ export declare function serviceData(text: string): Record<string, unknown>;
12
+ declare const _default: import("@sdeck/plugin").PluginDef;
13
+ export default _default;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAWA,cAAc,aAAa,CAAC;AAoD5B,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAI9E;AAED,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGjD;AA6BD,eAAO,MAAM,QAAQ,WAAY,MAAM,WAAoD,CAAC;AAoF5F,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYjE"}