-
Notifications
You must be signed in to change notification settings - Fork 108
/
index.d.ts
223 lines (203 loc) · 4.92 KB
/
index.d.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// Type definitions for ewelink-api
// Definitions by: Alexander Méhes https://github.com/BMXsanko
declare module 'ewelink-api' {
export default eWelink;
class eWelink {
constructor({ }: { email: string; password: string; } | { at: string; } | { at: string; apiKey: string; });
/**
* Login into eWeLink API and get auth credentials.
*/
login(): Promise<LoginInfo>
/**
* Opens a socket connection to eWeLink and listen for real-time events.
*/
openWebSocket(callback: (data: {}) => void): Promise<any>
/**
* Returns a list of devices associated to logged account.
*/
getDevices(): Promise<Device[]>
/**
* Return information for specified device.
*/
getDevice(deviceId: string): Promise<Device>
/**
* Query for specified device power status.
*/
getDevicePowerState(deviceId: string, channel?: number): Promise<DeviceState>
/**
* Change specified device power state.
*/
setDevicePowerState(deviceId: string, state?: string, channel?: number): Promise<DeviceState>
/**
* Switch specified device current power state.
*/
toggleDevice(deviceId: string, channel?: number): Promise<DeviceState>
/**
* Returns current month power usage on device who supports electricity records, like Sonoff POW.
*/
getDevicePowerUsage(deviceId: string): Promise<PowerUsage>
/**
* Return current temperature and humidity for specified device.
*/
getDeviceCurrentTH(deviceId: string): Promise<TemperatureHumidity>
/**
* Return current temperature for specified device.
*/
getDeviceCurrentTemperature(deviceId: string): Promise<TemperatureHumidity>
/**
* Return current temperature for specified device.
*/
getDeviceCurrentHumidity(deviceId: string): Promise<TemperatureHumidity>
/**
* Return total channels for specified device.
*/
getDeviceChannelCount(deviceId: string): Promise<SwitchCount>
/**
* Return firmware version for specified device.
*/
getFirmwareVersion(deviceId: string): Promise<FirmwareVersion>
}
export interface Device {
_id: string;
name: string;
type: string;
deviceid: string;
apikey: string;
extra: Extra2;
__v: number;
onlineTime: string;
ip: string;
location: string;
offlineTime: string;
deviceStatus: string;
tags: Tags;
settings: Settings;
devGroups: any[];
groups: any[];
params: Params;
online: boolean;
createdAt: string;
group: string;
sharedTo: any[];
devicekey: string;
deviceUrl: string;
brandName: string;
showBrand: boolean;
brandLogoUrl: string;
productModel: string;
devConfig: DevConfig;
uiid: number;
}
export interface DevConfig {
}
export interface Params {
pulseWidth: number;
pulse: string;
init: number;
sledOnline: string;
version: number;
timers: any[];
controlType: string;
partnerApikey: string;
bindInfos: BindInfos;
rssi: number;
staMac: string;
startup: string;
fwVersion: string;
switch: string;
}
export interface BindInfos {
gaction: string[];
}
export interface Settings {
alarmNotify: number;
opsHistory: number;
opsNotify: number;
}
export interface Tags {
m_4434_sany: string;
}
export interface Extra2 {
_id: string;
extra: Extra;
}
export interface Extra {
description: string;
brandId: string;
apmac: string;
mac: string;
ui: string;
modelInfo: string;
model: string;
manufacturer: string;
uiid: number;
staMac: string;
chipid: string;
}
export interface DeviceState {
status?: string;
state?: string;
error?: number;
msg?: string;
}
export interface SwitchCount {
status?: string;
switchesAmount?: number;
error?: number;
msg?: string;
}
export interface TemperatureHumidity {
status?: string;
temperature?: number;
humidity?: number;
error?: number;
msg?: string;
}
export interface PowerUsage {
status?: string;
monthly?: number;
daily?: Daily[];
error?: number;
msg?: string;
}
export interface FirmwareVersion {
status?: string;
fwVersion?: string;
error?: number;
msg?: string;
}
export interface LoginInfo {
at: string;
rt: string;
user: User;
region: string;
}
export interface User {
_id: string;
email: string;
appId: string;
lang: string;
online: boolean;
onlineTime: string;
ip: string;
location: string;
offlineTime: string;
userStatus: string;
appInfos: AppInfo[];
isAccepEmailAd: boolean;
bindInfos: LoginBindInfos;
createdAt: string;
apikey: string;
}
export interface LoginBindInfos {
gaction: string[];
}
export interface AppInfo {
appVersion: string;
os: string;
}
export interface Daily {
day: number;
usage: number;
}
}