@varco/client 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.
- package/README.md +52 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +302 -0
- package/dist/client.js.map +1 -0
- package/dist/consumer-client.d.ts +2 -0
- package/dist/consumer-client.js +19 -0
- package/dist/consumer-client.js.map +1 -0
- package/dist/domain-helpers.d.ts +12 -0
- package/dist/domain-helpers.js +83 -0
- package/dist/domain-helpers.js.map +1 -0
- package/dist/encoding.d.ts +4 -0
- package/dist/encoding.js +32 -0
- package/dist/encoding.js.map +1 -0
- package/dist/hass-like.d.ts +7 -0
- package/dist/hass-like.js +13 -0
- package/dist/hass-like.js.map +1 -0
- package/dist/identity.d.ts +11 -0
- package/dist/identity.js +96 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/local-client.d.ts +2 -0
- package/dist/local-client.js +90 -0
- package/dist/local-client.js.map +1 -0
- package/dist/manifest-helpers.d.ts +94 -0
- package/dist/manifest-helpers.js +105 -0
- package/dist/manifest-helpers.js.map +1 -0
- package/dist/memory-storage.d.ts +7 -0
- package/dist/memory-storage.js +7 -0
- package/dist/memory-storage.js.map +1 -0
- package/dist/transport-noble.d.ts +34 -0
- package/dist/transport-noble.js +257 -0
- package/dist/transport-noble.js.map +1 -0
- package/dist/transport.d.ts +29 -0
- package/dist/transport.js +195 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +185 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/varco-client.js +5139 -0
- package/package.json +54 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
export type Json = null | boolean | number | string | Json[] | {
|
|
2
|
+
[key: string]: Json;
|
|
3
|
+
};
|
|
4
|
+
export type VarcoManifest = {
|
|
5
|
+
name: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
version: string;
|
|
8
|
+
read_entities?: string[];
|
|
9
|
+
/** @deprecated Use `read_entities`. Do not set both: the Authority rejects conflicting aliases. */
|
|
10
|
+
readEntities?: string[];
|
|
11
|
+
subscriptions?: string[];
|
|
12
|
+
history?: string[];
|
|
13
|
+
camera_snapshots?: string[];
|
|
14
|
+
/** @deprecated Use `camera_snapshots`. Do not set both: the Authority rejects conflicting aliases. */
|
|
15
|
+
cameraSnapshots?: string[];
|
|
16
|
+
actions?: string[];
|
|
17
|
+
};
|
|
18
|
+
export type HassState = {
|
|
19
|
+
entity_id: string;
|
|
20
|
+
state: string;
|
|
21
|
+
attributes: Record<string, unknown>;
|
|
22
|
+
last_changed?: string;
|
|
23
|
+
};
|
|
24
|
+
export type VarcoTransport = {
|
|
25
|
+
request(message: Record<string, unknown>): Promise<any>;
|
|
26
|
+
close?(): void | Promise<void>;
|
|
27
|
+
onEvent?(handler: (event: any) => void): void;
|
|
28
|
+
onClose?(handler: () => void): void;
|
|
29
|
+
};
|
|
30
|
+
export type StorageLike = {
|
|
31
|
+
getItem(key: string): string | null;
|
|
32
|
+
setItem(key: string, value: string): void;
|
|
33
|
+
removeItem?(key: string): void;
|
|
34
|
+
};
|
|
35
|
+
export type VarcoTransportStatus = {
|
|
36
|
+
mode: "relay" | "p2p";
|
|
37
|
+
detail?: string;
|
|
38
|
+
};
|
|
39
|
+
export type VarcoConsumerTransportStatus = {
|
|
40
|
+
mode: "relay" | "p2p" | "home-assistant";
|
|
41
|
+
detail?: string;
|
|
42
|
+
};
|
|
43
|
+
export type VarcoClientOptions = {
|
|
44
|
+
authorityId: string;
|
|
45
|
+
bridgeUrl: string;
|
|
46
|
+
manifest: VarcoManifest;
|
|
47
|
+
storage?: StorageLike;
|
|
48
|
+
transport?: VarcoTransport;
|
|
49
|
+
warn?: (message: string) => void;
|
|
50
|
+
webrtc?: boolean;
|
|
51
|
+
reconnect?: boolean;
|
|
52
|
+
onTransportStatus?: (status: VarcoTransportStatus) => void;
|
|
53
|
+
};
|
|
54
|
+
export type AccessResult = {
|
|
55
|
+
request_id: string;
|
|
56
|
+
pairing_code: string;
|
|
57
|
+
status: string;
|
|
58
|
+
mode?: "home-assistant";
|
|
59
|
+
};
|
|
60
|
+
export type VarcoDomainHelpers = {
|
|
61
|
+
entity: {
|
|
62
|
+
get(entityId: string): Promise<HassState | null>;
|
|
63
|
+
subscribe(entityId: string, cb: (event: any) => void): Promise<string>;
|
|
64
|
+
history(entityId: string, range?: Record<string, unknown>): Promise<any>;
|
|
65
|
+
call(entityId: string, service: string, data?: Record<string, unknown>): Promise<void>;
|
|
66
|
+
};
|
|
67
|
+
light: {
|
|
68
|
+
turnOn(entityId: string, options?: Record<string, unknown>): Promise<void>;
|
|
69
|
+
turnOff(entityId: string): Promise<void>;
|
|
70
|
+
toggle(entityId: string): Promise<void>;
|
|
71
|
+
setBrightness(entityId: string, brightnessPct: number): Promise<void>;
|
|
72
|
+
setColor(entityId: string, color: Record<string, unknown>): Promise<void>;
|
|
73
|
+
};
|
|
74
|
+
switch: {
|
|
75
|
+
turnOn(entityId: string): Promise<void>;
|
|
76
|
+
turnOff(entityId: string): Promise<void>;
|
|
77
|
+
toggle(entityId: string): Promise<void>;
|
|
78
|
+
};
|
|
79
|
+
climate: {
|
|
80
|
+
setTemperature(entityId: string, temperature: number, options?: Record<string, unknown>): Promise<void>;
|
|
81
|
+
setTemperatureRange(entityId: string, targetTempLow: number, targetTempHigh: number, options?: Record<string, unknown>): Promise<void>;
|
|
82
|
+
setHvacMode(entityId: string, hvacMode: string): Promise<void>;
|
|
83
|
+
setPresetMode(entityId: string, presetMode: string): Promise<void>;
|
|
84
|
+
setFanMode(entityId: string, fanMode: string): Promise<void>;
|
|
85
|
+
setSwingMode(entityId: string, swingMode: string): Promise<void>;
|
|
86
|
+
setHumidity(entityId: string, humidity: number): Promise<void>;
|
|
87
|
+
turnOn(entityId: string): Promise<void>;
|
|
88
|
+
turnOff(entityId: string): Promise<void>;
|
|
89
|
+
};
|
|
90
|
+
cover: {
|
|
91
|
+
open(entityId: string): Promise<void>;
|
|
92
|
+
close(entityId: string): Promise<void>;
|
|
93
|
+
stop(entityId: string): Promise<void>;
|
|
94
|
+
setPosition(entityId: string, position: number): Promise<void>;
|
|
95
|
+
openTilt(entityId: string): Promise<void>;
|
|
96
|
+
closeTilt(entityId: string): Promise<void>;
|
|
97
|
+
stopTilt(entityId: string): Promise<void>;
|
|
98
|
+
setTiltPosition(entityId: string, tiltPosition: number): Promise<void>;
|
|
99
|
+
};
|
|
100
|
+
fan: {
|
|
101
|
+
turnOn(entityId: string): Promise<void>;
|
|
102
|
+
turnOff(entityId: string): Promise<void>;
|
|
103
|
+
toggle(entityId: string): Promise<void>;
|
|
104
|
+
setPercentage(entityId: string, percentage: number): Promise<void>;
|
|
105
|
+
setPresetMode(entityId: string, presetMode: string): Promise<void>;
|
|
106
|
+
setDirection(entityId: string, direction: string): Promise<void>;
|
|
107
|
+
oscillate(entityId: string, oscillating: boolean): Promise<void>;
|
|
108
|
+
};
|
|
109
|
+
lock: {
|
|
110
|
+
lock(entityId: string): Promise<void>;
|
|
111
|
+
unlock(entityId: string): Promise<void>;
|
|
112
|
+
open(entityId: string): Promise<void>;
|
|
113
|
+
};
|
|
114
|
+
mediaPlayer: {
|
|
115
|
+
turnOn(entityId: string): Promise<void>;
|
|
116
|
+
turnOff(entityId: string): Promise<void>;
|
|
117
|
+
volumeUp(entityId: string): Promise<void>;
|
|
118
|
+
volumeDown(entityId: string): Promise<void>;
|
|
119
|
+
setVolume(entityId: string, volumeLevel: number): Promise<void>;
|
|
120
|
+
mute(entityId: string, muted: boolean): Promise<void>;
|
|
121
|
+
play(entityId: string): Promise<void>;
|
|
122
|
+
pause(entityId: string): Promise<void>;
|
|
123
|
+
stop(entityId: string): Promise<void>;
|
|
124
|
+
playPause(entityId: string): Promise<void>;
|
|
125
|
+
nextTrack(entityId: string): Promise<void>;
|
|
126
|
+
previousTrack(entityId: string): Promise<void>;
|
|
127
|
+
seek(entityId: string, seconds: number): Promise<void>;
|
|
128
|
+
selectSource(entityId: string, source: string): Promise<void>;
|
|
129
|
+
playMedia(entityId: string, mediaContentId: string, mediaContentType: string, options?: Record<string, unknown>): Promise<void>;
|
|
130
|
+
};
|
|
131
|
+
button: {
|
|
132
|
+
press(entityId: string): Promise<void>;
|
|
133
|
+
};
|
|
134
|
+
scene: {
|
|
135
|
+
turnOn(entityId: string): Promise<void>;
|
|
136
|
+
};
|
|
137
|
+
number: {
|
|
138
|
+
setValue(entityId: string, value: number): Promise<void>;
|
|
139
|
+
};
|
|
140
|
+
select: {
|
|
141
|
+
selectOption(entityId: string, option: string): Promise<void>;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
export type VarcoClient = VarcoDomainHelpers & {
|
|
145
|
+
readonly consumerPublicKey: string;
|
|
146
|
+
readonly transportStatus: VarcoTransportStatus;
|
|
147
|
+
requestAccess(): Promise<AccessResult>;
|
|
148
|
+
connect(): Promise<void>;
|
|
149
|
+
getStates(entityIds: string[]): Promise<Record<string, HassState | null>>;
|
|
150
|
+
subscribeEntities(entityIds: string[], cb: (event: any) => void): Promise<string>;
|
|
151
|
+
unsubscribe(subscriptionId: string): Promise<void>;
|
|
152
|
+
queryHistory(entityIds: string[], range?: Record<string, unknown>): Promise<any>;
|
|
153
|
+
cameraSnapshot(entityId: string): Promise<{
|
|
154
|
+
contentType: string;
|
|
155
|
+
body: string;
|
|
156
|
+
}>;
|
|
157
|
+
callService(domain: string, service: string, data?: {
|
|
158
|
+
entity_id?: string;
|
|
159
|
+
pin?: string;
|
|
160
|
+
pins?: Record<string, string>;
|
|
161
|
+
[key: string]: unknown;
|
|
162
|
+
}): Promise<void>;
|
|
163
|
+
close(): Promise<void>;
|
|
164
|
+
};
|
|
165
|
+
export type HassFrontend = {
|
|
166
|
+
states: Record<string, HassState>;
|
|
167
|
+
callService?: (domain: string, service: string, serviceData?: Record<string, unknown>, target?: Record<string, unknown>) => Promise<unknown> | unknown;
|
|
168
|
+
callWS?: (message: Record<string, unknown>) => Promise<unknown>;
|
|
169
|
+
connection?: {
|
|
170
|
+
sendMessagePromise?: (message: Record<string, unknown>) => Promise<unknown>;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
export type LocalHomeAssistantOptions = {
|
|
174
|
+
hass: HassFrontend;
|
|
175
|
+
};
|
|
176
|
+
export type RelayConsumerOptions = Omit<VarcoClientOptions, "manifest"> & {
|
|
177
|
+
manifest?: VarcoManifest;
|
|
178
|
+
};
|
|
179
|
+
export type VarcoConsumerClientOptions = LocalHomeAssistantOptions | (RelayConsumerOptions & {
|
|
180
|
+
hass?: HassFrontend;
|
|
181
|
+
});
|
|
182
|
+
export type VarcoConsumerClient = Omit<VarcoClient, "transportStatus"> & {
|
|
183
|
+
readonly transportStatus: VarcoConsumerTransportStatus;
|
|
184
|
+
updateHass(nextHass: HassFrontend): void;
|
|
185
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|