yoto-nodejs-client 0.0.1 → 0.0.3
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 +523 -30
- package/bin/auth.js +36 -46
- package/bin/content.js +0 -0
- package/bin/device-model.d.ts +3 -0
- package/bin/device-model.d.ts.map +1 -0
- package/bin/device-model.js +360 -0
- package/bin/device-tui.TODO.md +125 -0
- package/bin/device-tui.d.ts +31 -0
- package/bin/device-tui.d.ts.map +1 -0
- package/bin/device-tui.js +1123 -0
- package/bin/devices.js +166 -28
- package/bin/groups.js +0 -0
- package/bin/icons.js +0 -0
- package/bin/lib/cli-helpers.d.ts +33 -1
- package/bin/lib/cli-helpers.d.ts.map +1 -1
- package/bin/lib/cli-helpers.js +5 -5
- package/bin/lib/token-helpers.d.ts +32 -0
- package/bin/lib/token-helpers.d.ts.map +1 -1
- package/bin/refresh-token.js +6 -6
- package/bin/token-info.js +3 -3
- package/index.d.ts +4 -217
- package/index.d.ts.map +1 -1
- package/index.js +11 -689
- package/lib/api-client.d.ts +576 -0
- package/lib/api-client.d.ts.map +1 -0
- package/lib/api-client.js +681 -0
- package/lib/api-endpoints/auth.d.ts +280 -4
- package/lib/api-endpoints/auth.d.ts.map +1 -1
- package/lib/api-endpoints/auth.js +224 -7
- package/lib/api-endpoints/auth.test.js +54 -2
- package/lib/api-endpoints/constants.d.ts +30 -2
- package/lib/api-endpoints/constants.d.ts.map +1 -1
- package/lib/api-endpoints/constants.js +17 -10
- package/lib/api-endpoints/content.d.ts +760 -0
- package/lib/api-endpoints/content.d.ts.map +1 -1
- package/lib/api-endpoints/content.test.js +1 -1
- package/lib/api-endpoints/devices.d.ts +917 -48
- package/lib/api-endpoints/devices.d.ts.map +1 -1
- package/lib/api-endpoints/devices.js +114 -52
- package/lib/api-endpoints/devices.test.js +1 -1
- package/lib/api-endpoints/endpoint-test-helpers.d.ts +28 -0
- package/lib/api-endpoints/endpoint-test-helpers.d.ts.map +1 -0
- package/lib/api-endpoints/family-library-groups.d.ts +187 -0
- package/lib/api-endpoints/family-library-groups.d.ts.map +1 -1
- package/lib/api-endpoints/family-library-groups.test.js +1 -1
- package/lib/api-endpoints/family.d.ts +88 -0
- package/lib/api-endpoints/family.d.ts.map +1 -1
- package/lib/api-endpoints/family.test.js +1 -1
- package/lib/api-endpoints/helpers.d.ts +37 -3
- package/lib/api-endpoints/helpers.d.ts.map +1 -1
- package/lib/api-endpoints/icons.d.ts +196 -0
- package/lib/api-endpoints/icons.d.ts.map +1 -1
- package/lib/api-endpoints/icons.test.js +1 -1
- package/lib/api-endpoints/media.d.ts +83 -0
- package/lib/api-endpoints/media.d.ts.map +1 -1
- package/lib/helpers/power-state.d.ts +53 -0
- package/lib/helpers/power-state.d.ts.map +1 -0
- package/lib/helpers/power-state.js +73 -0
- package/lib/helpers/power-state.test.js +100 -0
- package/lib/helpers/temperature.d.ts +24 -0
- package/lib/helpers/temperature.d.ts.map +1 -0
- package/lib/helpers/temperature.js +61 -0
- package/lib/helpers/temperature.test.js +58 -0
- package/lib/helpers/typed-keys.d.ts +7 -0
- package/lib/helpers/typed-keys.d.ts.map +1 -0
- package/lib/helpers/typed-keys.js +8 -0
- package/lib/mqtt/client.d.ts +610 -7
- package/lib/mqtt/client.d.ts.map +1 -1
- package/lib/mqtt/client.js +213 -31
- package/lib/mqtt/commands.d.ts +195 -0
- package/lib/mqtt/commands.d.ts.map +1 -1
- package/lib/mqtt/factory.d.ts +62 -1
- package/lib/mqtt/factory.d.ts.map +1 -1
- package/lib/mqtt/factory.js +27 -5
- package/lib/mqtt/mqtt.test.js +85 -28
- package/lib/mqtt/topics.d.ts +186 -1
- package/lib/mqtt/topics.d.ts.map +1 -1
- package/lib/mqtt/topics.js +54 -20
- package/lib/pkg.d.cts +9 -0
- package/lib/token.d.ts +106 -3
- package/lib/token.d.ts.map +1 -1
- package/lib/token.js +30 -23
- package/lib/yoto-account.d.ts +163 -0
- package/lib/yoto-account.d.ts.map +1 -0
- package/lib/yoto-account.js +340 -0
- package/lib/yoto-device.d.ts +656 -0
- package/lib/yoto-device.d.ts.map +1 -0
- package/lib/yoto-device.js +2850 -0
- package/package.json +22 -15
- package/lib/api-endpoints/test-helpers.d.ts +0 -7
- package/lib/api-endpoints/test-helpers.d.ts.map +0 -1
- /package/lib/api-endpoints/{test-helpers.js → endpoint-test-helpers.js} +0 -0
package/lib/mqtt/client.d.ts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yoto MQTT Client class
|
|
3
|
+
* @extends EventEmitter
|
|
4
|
+
*
|
|
5
|
+
* Device automatically publishes status updates every 5 minutes when connected.
|
|
6
|
+
* Status can also be requested on-demand via requestStatus() and requestEvents().
|
|
7
|
+
*
|
|
8
|
+
* @fires YotoMqttClient#events - Emits (topic, payload) when device sends events
|
|
9
|
+
* @fires YotoMqttClient#status - Emits (topic, payload) when device sends status (automatic every 5 min, or on-demand)
|
|
10
|
+
* @fires YotoMqttClient#status-legacy - Emits (topic, payload) when device sends legacy status with lifecycle events
|
|
11
|
+
* @fires YotoMqttClient#response - Emits (topic, payload) when device responds to commands
|
|
12
|
+
* @fires YotoMqttClient#unknown - Emits (topic, payload) when receiving unknown message type
|
|
13
|
+
* @fires YotoMqttClient#connected
|
|
14
|
+
* @fires YotoMqttClient#disconnected
|
|
15
|
+
* @fires YotoMqttClient#reconnecting
|
|
16
|
+
* @fires YotoMqttClient#error
|
|
17
|
+
*/
|
|
1
18
|
export class YotoMqttClient extends EventEmitter<any> {
|
|
19
|
+
/**
|
|
20
|
+
* Create a Yoto MQTT client
|
|
21
|
+
* @param {MqttClient} mqttClient - Underlying MQTT client
|
|
22
|
+
* @param {string} deviceId - Device ID
|
|
23
|
+
* @param {Object} [options] - Client options
|
|
24
|
+
* @param {boolean} [options.autoSubscribe=true] - Auto-subscribe to device topics on connect
|
|
25
|
+
*/
|
|
2
26
|
constructor(mqttClient: MqttClient, deviceId: string, options?: {
|
|
3
27
|
autoSubscribe?: boolean | undefined;
|
|
4
28
|
});
|
|
@@ -16,17 +40,94 @@ export class YotoMqttClient extends EventEmitter<any> {
|
|
|
16
40
|
bluetoothAudioSource: typeof import("./commands.js").createBluetoothAudioSourceCommand;
|
|
17
41
|
displayPreview: typeof import("./commands.js").createDisplayPreviewCommand;
|
|
18
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Get current connection state
|
|
45
|
+
* @returns {YotoMqttConnectionState}
|
|
46
|
+
*/
|
|
19
47
|
get state(): YotoMqttConnectionState;
|
|
48
|
+
/**
|
|
49
|
+
* Check if client is connected
|
|
50
|
+
* @returns {boolean}
|
|
51
|
+
*/
|
|
20
52
|
get connected(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Subscribe to device topics
|
|
55
|
+
* @param {Array<'events' | 'status' | 'response'> | 'all'} [types='all'] - Topic types to subscribe to, or 'all' for all topics
|
|
56
|
+
* @returns {Promise<void>}
|
|
57
|
+
* @example
|
|
58
|
+
* // Subscribe to all topics (default)
|
|
59
|
+
* await client.subscribe()
|
|
60
|
+
* await client.subscribe('all')
|
|
61
|
+
*
|
|
62
|
+
* // Subscribe to specific topics
|
|
63
|
+
* await client.subscribe(['events', 'status'])
|
|
64
|
+
* await client.subscribe(['response'])
|
|
65
|
+
*/
|
|
66
|
+
subscribe(types?: Array<"events" | "status" | "response"> | "all"): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Connect to MQTT broker
|
|
69
|
+
* @returns {Promise<void>}
|
|
70
|
+
*/
|
|
21
71
|
connect(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Disconnect from MQTT broker
|
|
74
|
+
* @returns {Promise<void>}
|
|
75
|
+
*/
|
|
22
76
|
disconnect(): Promise<void>;
|
|
23
|
-
|
|
24
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Request current events from device
|
|
79
|
+
* @param {string} [body=''] - Optional request body for tracking/identification
|
|
80
|
+
* @returns {Promise<void>}
|
|
81
|
+
*/
|
|
82
|
+
requestEvents(body?: string): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Request current status from device
|
|
85
|
+
* @param {string} [body=''] - Optional request body for tracking/identification
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
requestStatus(body?: string): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Set device volume
|
|
91
|
+
* @param {number} volume - Volume level [0-100]
|
|
92
|
+
* @returns {Promise<void>}
|
|
93
|
+
*/
|
|
25
94
|
setVolume(volume: number): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Set ambient light color
|
|
97
|
+
* @param {number} r - Red intensity [0-255]
|
|
98
|
+
* @param {number} g - Green intensity [0-255]
|
|
99
|
+
* @param {number} b - Blue intensity [0-255]
|
|
100
|
+
* @returns {Promise<void>}
|
|
101
|
+
*/
|
|
26
102
|
setAmbient(r: number, g: number, b: number): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Set ambient light color from hex
|
|
105
|
+
* @param {string} hexColor - Hex color string (e.g., "#FF0000")
|
|
106
|
+
* @returns {Promise<void>}
|
|
107
|
+
*/
|
|
27
108
|
setAmbientHex(hexColor: string): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Set sleep timer
|
|
111
|
+
* @param {number} seconds - Timer duration in seconds (0 to disable)
|
|
112
|
+
* @returns {Promise<void>}
|
|
113
|
+
*/
|
|
28
114
|
setSleepTimer(seconds: number): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Reboot device
|
|
117
|
+
* @returns {Promise<void>}
|
|
118
|
+
*/
|
|
29
119
|
reboot(): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Start card playback
|
|
122
|
+
* @param {Object} options - Card start options
|
|
123
|
+
* @param {string} options.uri - Card URI (e.g., "https://yoto.io/<cardID>")
|
|
124
|
+
* @param {string} [options.chapterKey] - Chapter to start from
|
|
125
|
+
* @param {string} [options.trackKey] - Track to start from
|
|
126
|
+
* @param {number} [options.secondsIn] - Playback start offset in seconds
|
|
127
|
+
* @param {number} [options.cutOff] - Playback stop offset in seconds
|
|
128
|
+
* @param {boolean} [options.anyButtonStop] - Whether button press stops playback
|
|
129
|
+
* @returns {Promise<void>}
|
|
130
|
+
*/
|
|
30
131
|
startCard(options: {
|
|
31
132
|
uri: string;
|
|
32
133
|
chapterKey?: string | undefined;
|
|
@@ -35,9 +136,31 @@ export class YotoMqttClient extends EventEmitter<any> {
|
|
|
35
136
|
cutOff?: number | undefined;
|
|
36
137
|
anyButtonStop?: boolean | undefined;
|
|
37
138
|
}): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Stop card playback
|
|
141
|
+
* @returns {Promise<void>}
|
|
142
|
+
*/
|
|
38
143
|
stopCard(): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Pause card playback
|
|
146
|
+
* @returns {Promise<void>}
|
|
147
|
+
*/
|
|
39
148
|
pauseCard(): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Resume card playback
|
|
151
|
+
* @returns {Promise<void>}
|
|
152
|
+
*/
|
|
40
153
|
resumeCard(): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Turn Bluetooth on
|
|
156
|
+
* @param {Object} [options] - Bluetooth options
|
|
157
|
+
* @param {string} [options.action] - Bluetooth action
|
|
158
|
+
* @param {boolean | string} [options.mode] - Bluetooth mode
|
|
159
|
+
* @param {number} [options.rssi] - RSSI threshold
|
|
160
|
+
* @param {string} [options.name] - Target device name
|
|
161
|
+
* @param {string} [options.mac] - Target device MAC
|
|
162
|
+
* @returns {Promise<void>}
|
|
163
|
+
*/
|
|
41
164
|
bluetoothOn(options?: {
|
|
42
165
|
action?: string | undefined;
|
|
43
166
|
mode?: string | boolean | undefined;
|
|
@@ -45,13 +168,49 @@ export class YotoMqttClient extends EventEmitter<any> {
|
|
|
45
168
|
name?: string | undefined;
|
|
46
169
|
mac?: string | undefined;
|
|
47
170
|
}): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Turn Bluetooth off
|
|
173
|
+
* @returns {Promise<void>}
|
|
174
|
+
*/
|
|
48
175
|
bluetoothOff(): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Enable Bluetooth speaker mode
|
|
178
|
+
* @returns {Promise<void>}
|
|
179
|
+
*/
|
|
49
180
|
bluetoothSpeakerMode(): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Enable Bluetooth audio source mode
|
|
183
|
+
* @returns {Promise<void>}
|
|
184
|
+
*/
|
|
50
185
|
bluetoothAudioSourceMode(): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Delete all Bluetooth bonds
|
|
188
|
+
* @returns {Promise<void>}
|
|
189
|
+
*/
|
|
51
190
|
bluetoothDeleteBonds(): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* Connect to Bluetooth device
|
|
193
|
+
* @returns {Promise<void>}
|
|
194
|
+
*/
|
|
52
195
|
bluetoothConnect(): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Disconnect Bluetooth device
|
|
198
|
+
* @returns {Promise<void>}
|
|
199
|
+
*/
|
|
53
200
|
bluetoothDisconnect(): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Get Bluetooth state
|
|
203
|
+
* @returns {Promise<void>}
|
|
204
|
+
*/
|
|
54
205
|
bluetoothGetState(): Promise<void>;
|
|
206
|
+
/**
|
|
207
|
+
* Preview display icon
|
|
208
|
+
* @param {Object} options - Display preview options
|
|
209
|
+
* @param {string} options.uri - Icon URI
|
|
210
|
+
* @param {number} options.timeout - Display duration in seconds
|
|
211
|
+
* @param {boolean} options.animated - Whether icon is animated
|
|
212
|
+
* @returns {Promise<void>}
|
|
213
|
+
*/
|
|
55
214
|
displayPreview(options: {
|
|
56
215
|
uri: string;
|
|
57
216
|
timeout: number;
|
|
@@ -59,52 +218,205 @@ export class YotoMqttClient extends EventEmitter<any> {
|
|
|
59
218
|
}): Promise<void>;
|
|
60
219
|
#private;
|
|
61
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Events message from device
|
|
223
|
+
* Note: Messages are partial - only changed fields are included
|
|
224
|
+
*/
|
|
62
225
|
export type YotoEventsMessage = {
|
|
226
|
+
/**
|
|
227
|
+
* - Repeat all tracks
|
|
228
|
+
*/
|
|
63
229
|
repeatAll?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* - Whether streaming
|
|
232
|
+
*/
|
|
64
233
|
streaming?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* - Current user volume level (0-16 scale, maps to userVolumePercentage in status)
|
|
236
|
+
*/
|
|
65
237
|
volume?: number;
|
|
238
|
+
/**
|
|
239
|
+
* - Maximum volume limit (0-16 scale, maps to systemVolumePercentage in status)
|
|
240
|
+
*/
|
|
66
241
|
volumeMax?: number;
|
|
242
|
+
/**
|
|
243
|
+
* - Playback waiting
|
|
244
|
+
*/
|
|
67
245
|
playbackWait?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* - Sleep timer active
|
|
248
|
+
*/
|
|
68
249
|
sleepTimerActive?: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* - Unix timestamp
|
|
252
|
+
*/
|
|
69
253
|
eventUtc?: number;
|
|
254
|
+
/**
|
|
255
|
+
* - Track duration in seconds
|
|
256
|
+
*/
|
|
70
257
|
trackLength?: number;
|
|
258
|
+
/**
|
|
259
|
+
* - Current position in seconds
|
|
260
|
+
*/
|
|
71
261
|
position?: number;
|
|
262
|
+
/**
|
|
263
|
+
* - Currently playing card ID
|
|
264
|
+
*/
|
|
72
265
|
cardId?: string;
|
|
266
|
+
/**
|
|
267
|
+
* - Source of playback (e.g., "card", "remote", "MQTT")
|
|
268
|
+
*/
|
|
73
269
|
source?: string;
|
|
270
|
+
/**
|
|
271
|
+
* - ISO8601 format timestamp
|
|
272
|
+
*/
|
|
74
273
|
cardUpdatedAt?: string;
|
|
274
|
+
/**
|
|
275
|
+
* - Current chapter title
|
|
276
|
+
*/
|
|
75
277
|
chapterTitle?: string;
|
|
278
|
+
/**
|
|
279
|
+
* - Current chapter key
|
|
280
|
+
*/
|
|
76
281
|
chapterKey?: string;
|
|
282
|
+
/**
|
|
283
|
+
* - Current track title
|
|
284
|
+
*/
|
|
77
285
|
trackTitle?: string;
|
|
286
|
+
/**
|
|
287
|
+
* - Current track key
|
|
288
|
+
*/
|
|
78
289
|
trackKey?: string;
|
|
79
|
-
|
|
290
|
+
/**
|
|
291
|
+
* - Playback status
|
|
292
|
+
*/
|
|
293
|
+
playbackStatus?: "playing" | "paused" | "stopped" | "loading" | string;
|
|
294
|
+
/**
|
|
295
|
+
* - Seconds remaining on sleep timer
|
|
296
|
+
*/
|
|
80
297
|
sleepTimerSeconds?: number;
|
|
81
298
|
};
|
|
299
|
+
/**
|
|
300
|
+
* Status message from device (MQTT /data/status)
|
|
301
|
+
*
|
|
302
|
+
* Device automatically publishes status updates every 5 minutes (matching keepalive interval).
|
|
303
|
+
* Can also be requested on-demand via requestStatus().
|
|
304
|
+
*
|
|
305
|
+
* Note: MQTT types differ from HTTP - uses booleans, non-nullable fields
|
|
306
|
+
*/
|
|
82
307
|
export type YotoStatusMessage = {
|
|
308
|
+
/**
|
|
309
|
+
* - Status object
|
|
310
|
+
*/
|
|
311
|
+
status: YotoMqttStatus;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* MQTT status payload structure (documented spec)
|
|
315
|
+
*
|
|
316
|
+
* Automatic updates (every 5 minutes): 21 fields (excludes nightlightMode and temp)
|
|
317
|
+
* Requested status: All 23 fields including nightlightMode and temp
|
|
318
|
+
*/
|
|
319
|
+
export type YotoMqttStatus = {
|
|
320
|
+
/**
|
|
321
|
+
* - Status message version
|
|
322
|
+
*/
|
|
83
323
|
statusVersion: number;
|
|
324
|
+
/**
|
|
325
|
+
* - Firmware version
|
|
326
|
+
*/
|
|
84
327
|
fwVersion: string;
|
|
328
|
+
/**
|
|
329
|
+
* - Product type identifier
|
|
330
|
+
*/
|
|
85
331
|
productType: string;
|
|
332
|
+
/**
|
|
333
|
+
* - Battery level percentage
|
|
334
|
+
*/
|
|
86
335
|
batteryLevel: number;
|
|
336
|
+
/**
|
|
337
|
+
* - Ambient light sensor reading
|
|
338
|
+
*/
|
|
87
339
|
als: number;
|
|
340
|
+
/**
|
|
341
|
+
* - Free disk space in bytes
|
|
342
|
+
*/
|
|
88
343
|
freeDisk: number;
|
|
344
|
+
/**
|
|
345
|
+
* - Shutdown timeout in seconds
|
|
346
|
+
*/
|
|
89
347
|
shutdownTimeout: number;
|
|
348
|
+
/**
|
|
349
|
+
* - DBAT timeout
|
|
350
|
+
*/
|
|
90
351
|
dbatTimeout: number;
|
|
352
|
+
/**
|
|
353
|
+
* - Charging state (0 or 1)
|
|
354
|
+
*/
|
|
91
355
|
charging: number;
|
|
356
|
+
/**
|
|
357
|
+
* - Active card ID or 'none'
|
|
358
|
+
*/
|
|
92
359
|
activeCard: string;
|
|
93
|
-
|
|
360
|
+
/**
|
|
361
|
+
* - Card insertion state (0=none, 1=physical, 2=remote)
|
|
362
|
+
*/
|
|
363
|
+
cardInserted: 0 | 1 | 2;
|
|
364
|
+
/**
|
|
365
|
+
* - Playing status code
|
|
366
|
+
*/
|
|
94
367
|
playingStatus: number;
|
|
368
|
+
/**
|
|
369
|
+
* - Headphones connected
|
|
370
|
+
*/
|
|
95
371
|
headphones: boolean;
|
|
372
|
+
/**
|
|
373
|
+
* - Current display brightness
|
|
374
|
+
*/
|
|
96
375
|
dnowBrightness: number;
|
|
376
|
+
/**
|
|
377
|
+
* - Day brightness setting
|
|
378
|
+
*/
|
|
97
379
|
dayBright: number;
|
|
380
|
+
/**
|
|
381
|
+
* - Night brightness setting
|
|
382
|
+
*/
|
|
98
383
|
nightBright: number;
|
|
384
|
+
/**
|
|
385
|
+
* - Bluetooth headphones enabled
|
|
386
|
+
*/
|
|
99
387
|
bluetoothHp: boolean;
|
|
388
|
+
/**
|
|
389
|
+
* - System/max volume level (0-100 percentage, represents 0-16 hardware scale, maps to volumeMax in events)
|
|
390
|
+
*/
|
|
100
391
|
volume: number;
|
|
392
|
+
/**
|
|
393
|
+
* - User volume setting (0-100 percentage, represents 0-16 hardware scale, maps to volume in events)
|
|
394
|
+
*/
|
|
101
395
|
userVolume: number;
|
|
396
|
+
/**
|
|
397
|
+
* - Time format preference
|
|
398
|
+
*/
|
|
102
399
|
timeFormat: "12" | "24";
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
400
|
+
/**
|
|
401
|
+
* - Current nightlight color (actual hex color like '0xff5733' or 'off') - only in requested status, most accurate source
|
|
402
|
+
*/
|
|
403
|
+
nightlightMode?: string;
|
|
404
|
+
/**
|
|
405
|
+
* - Temperature reading (format varies: 'value1:value2:value3' or 'value1:notSupported') - only in requested status
|
|
406
|
+
*/
|
|
407
|
+
temp?: string;
|
|
408
|
+
/**
|
|
409
|
+
* - Day mode (0=night, 1=day, -1=unknown)
|
|
410
|
+
*/
|
|
411
|
+
day: -1 | 0 | 1;
|
|
106
412
|
};
|
|
413
|
+
/**
|
|
414
|
+
* Response message from device
|
|
415
|
+
*/
|
|
107
416
|
export type YotoResponseMessage = {
|
|
417
|
+
/**
|
|
418
|
+
* - Status object with dynamic resource keys
|
|
419
|
+
*/
|
|
108
420
|
status: {
|
|
109
421
|
volume?: "OK" | "FAIL" | undefined;
|
|
110
422
|
ambients?: "OK" | "FAIL" | undefined;
|
|
@@ -118,7 +430,298 @@ export type YotoResponseMessage = {
|
|
|
118
430
|
sleepTimer: "OK" | "FAIL";
|
|
119
431
|
};
|
|
120
432
|
};
|
|
433
|
+
/**
|
|
434
|
+
* Legacy status message from device (MQTT /status)
|
|
435
|
+
*
|
|
436
|
+
* This is the older undocumented status topic that contains critical lifecycle information
|
|
437
|
+
* not available in the documented /data/status topic, including:
|
|
438
|
+
* - shutDown field: Indicates device power state changes ('userShutdown', 'nA', etc.)
|
|
439
|
+
* - Startup detection: Low upTime values, utcTime: 0 after power on
|
|
440
|
+
* - Full hardware diagnostics: battery voltage, memory stats, temperatures
|
|
441
|
+
*
|
|
442
|
+
* Both documented and legacy status topics are necessary for complete device monitoring.
|
|
443
|
+
*/
|
|
444
|
+
export type YotoStatusLegacyMessage = {
|
|
445
|
+
/**
|
|
446
|
+
* - Legacy status object with full hardware details
|
|
447
|
+
*/
|
|
448
|
+
status: YotoLegacyStatus;
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* Legacy MQTT status payload structure (undocumented)
|
|
452
|
+
*
|
|
453
|
+
* Contains all fields from documented status plus additional lifecycle and diagnostic fields.
|
|
454
|
+
*/
|
|
455
|
+
export type YotoLegacyStatus = {
|
|
456
|
+
/**
|
|
457
|
+
* - Status message version
|
|
458
|
+
*/
|
|
459
|
+
statusVersion: number;
|
|
460
|
+
/**
|
|
461
|
+
* - Firmware version
|
|
462
|
+
*/
|
|
463
|
+
fwVersion: string;
|
|
464
|
+
/**
|
|
465
|
+
* - Power state: 'nA' = device running, any other value = shutting down/shut down (e.g., 'userShutdown') - ONLY in legacy topic
|
|
466
|
+
*/
|
|
467
|
+
shutDown: string;
|
|
468
|
+
/**
|
|
469
|
+
* - Total disk space in bytes
|
|
470
|
+
*/
|
|
471
|
+
totalDisk: number;
|
|
472
|
+
/**
|
|
473
|
+
* - Product type identifier
|
|
474
|
+
*/
|
|
475
|
+
productType: string;
|
|
476
|
+
/**
|
|
477
|
+
* - WiFi signal strength in dBm
|
|
478
|
+
*/
|
|
479
|
+
wifiStrength: number;
|
|
480
|
+
/**
|
|
481
|
+
* - WiFi SSID
|
|
482
|
+
*/
|
|
483
|
+
ssid: string;
|
|
484
|
+
/**
|
|
485
|
+
* - RTC reset reason (PRO)
|
|
486
|
+
*/
|
|
487
|
+
rtcResetReasonPRO: number;
|
|
488
|
+
/**
|
|
489
|
+
* - RTC reset reason (APP)
|
|
490
|
+
*/
|
|
491
|
+
rtcResetReasonAPP: number;
|
|
492
|
+
/**
|
|
493
|
+
* - RTC wakeup cause code
|
|
494
|
+
*/
|
|
495
|
+
rtcWakeupCause: number;
|
|
496
|
+
/**
|
|
497
|
+
* - ESP reset reason code
|
|
498
|
+
*/
|
|
499
|
+
espResetReason: number;
|
|
500
|
+
/**
|
|
501
|
+
* - SD card information string
|
|
502
|
+
*/
|
|
503
|
+
sd_info: string;
|
|
504
|
+
/**
|
|
505
|
+
* - Raw battery voltage in millivolts
|
|
506
|
+
*/
|
|
507
|
+
battery: number;
|
|
508
|
+
/**
|
|
509
|
+
* - Power capabilities
|
|
510
|
+
*/
|
|
511
|
+
powerCaps: string;
|
|
512
|
+
/**
|
|
513
|
+
* - Battery level percentage
|
|
514
|
+
*/
|
|
515
|
+
batteryLevel: number;
|
|
516
|
+
/**
|
|
517
|
+
* - Battery temperature
|
|
518
|
+
*/
|
|
519
|
+
batteryTemp: number;
|
|
520
|
+
/**
|
|
521
|
+
* - Battery data string (format: 'val1:val2:val3')
|
|
522
|
+
*/
|
|
523
|
+
batteryData: string;
|
|
524
|
+
/**
|
|
525
|
+
* - Raw battery level reading
|
|
526
|
+
*/
|
|
527
|
+
batteryLevelRaw: number;
|
|
528
|
+
/**
|
|
529
|
+
* - Free memory in bytes
|
|
530
|
+
*/
|
|
531
|
+
free: number;
|
|
532
|
+
/**
|
|
533
|
+
* - Free DMA memory in bytes
|
|
534
|
+
*/
|
|
535
|
+
freeDMA: number;
|
|
536
|
+
/**
|
|
537
|
+
* - Free 32-bit memory in bytes
|
|
538
|
+
*/
|
|
539
|
+
free32: number;
|
|
540
|
+
/**
|
|
541
|
+
* - Device uptime in seconds (low values indicate recent startup)
|
|
542
|
+
*/
|
|
543
|
+
upTime: number;
|
|
544
|
+
/**
|
|
545
|
+
* - UTC timestamp (0 indicates fresh startup before time sync)
|
|
546
|
+
*/
|
|
547
|
+
utcTime: number;
|
|
548
|
+
/**
|
|
549
|
+
* - Total alive time in seconds
|
|
550
|
+
*/
|
|
551
|
+
aliveTime: number;
|
|
552
|
+
/**
|
|
553
|
+
* - Accelerometer temperature in Celsius
|
|
554
|
+
*/
|
|
555
|
+
accelTemp: number;
|
|
556
|
+
/**
|
|
557
|
+
* - Battery profile identifier
|
|
558
|
+
*/
|
|
559
|
+
batteryProfile: string;
|
|
560
|
+
/**
|
|
561
|
+
* - Free disk space in bytes
|
|
562
|
+
*/
|
|
563
|
+
freeDisk: number;
|
|
564
|
+
/**
|
|
565
|
+
* - Failure reason code
|
|
566
|
+
*/
|
|
567
|
+
failReason: number;
|
|
568
|
+
/**
|
|
569
|
+
* - Failure data
|
|
570
|
+
*/
|
|
571
|
+
failData: number;
|
|
572
|
+
/**
|
|
573
|
+
* - Shutdown timeout in seconds
|
|
574
|
+
*/
|
|
575
|
+
shutdownTimeout: number;
|
|
576
|
+
/**
|
|
577
|
+
* - UTC offset in seconds
|
|
578
|
+
*/
|
|
579
|
+
utcOffset: number;
|
|
580
|
+
/**
|
|
581
|
+
* - NFC error rates (format: 'xx.xx%-xx.xx%')
|
|
582
|
+
*/
|
|
583
|
+
nfcErrs: string;
|
|
584
|
+
/**
|
|
585
|
+
* - DBAT timeout in seconds
|
|
586
|
+
*/
|
|
587
|
+
dbatTimeout: number;
|
|
588
|
+
/**
|
|
589
|
+
* - Charging state (0 or 1)
|
|
590
|
+
*/
|
|
591
|
+
charging: number;
|
|
592
|
+
/**
|
|
593
|
+
* - Power source (0=battery, 1=V2 dock, 2=USB-C, 3=Qi)
|
|
594
|
+
*/
|
|
595
|
+
powerSrc: 0 | 1 | 2 | 3;
|
|
596
|
+
/**
|
|
597
|
+
* - Active card ID or 'none'
|
|
598
|
+
*/
|
|
599
|
+
activeCard: string;
|
|
600
|
+
/**
|
|
601
|
+
* - Card insertion state (0=none, 1=physical, 2=remote)
|
|
602
|
+
*/
|
|
603
|
+
cardInserted: 0 | 1 | 2;
|
|
604
|
+
/**
|
|
605
|
+
* - Playing status code
|
|
606
|
+
*/
|
|
607
|
+
playingStatus: number;
|
|
608
|
+
/**
|
|
609
|
+
* - Headphones connected (0 or 1)
|
|
610
|
+
*/
|
|
611
|
+
headphones: number;
|
|
612
|
+
/**
|
|
613
|
+
* - WiFi restart count
|
|
614
|
+
*/
|
|
615
|
+
wifiRestarts: number;
|
|
616
|
+
/**
|
|
617
|
+
* - Qi OTP value
|
|
618
|
+
*/
|
|
619
|
+
qiOtp: number;
|
|
620
|
+
/**
|
|
621
|
+
* - Buzzer error count
|
|
622
|
+
*/
|
|
623
|
+
buzzErrors: number;
|
|
624
|
+
/**
|
|
625
|
+
* - Current display brightness
|
|
626
|
+
*/
|
|
627
|
+
dnowBrightness: number;
|
|
628
|
+
/**
|
|
629
|
+
* - Day brightness setting
|
|
630
|
+
*/
|
|
631
|
+
dayBright: number;
|
|
632
|
+
/**
|
|
633
|
+
* - Night brightness setting
|
|
634
|
+
*/
|
|
635
|
+
nightBright: number;
|
|
636
|
+
/**
|
|
637
|
+
* - Number of errors logged
|
|
638
|
+
*/
|
|
639
|
+
errorsLogged: number;
|
|
640
|
+
/**
|
|
641
|
+
* - Task watchdog timer value
|
|
642
|
+
*/
|
|
643
|
+
twdt: number;
|
|
644
|
+
/**
|
|
645
|
+
* - Bluetooth headphones state (0 or 1)
|
|
646
|
+
*/
|
|
647
|
+
bluetoothHp: number;
|
|
648
|
+
/**
|
|
649
|
+
* - Current nightlight color (hex color like '0xff5733' or 'off')
|
|
650
|
+
*/
|
|
651
|
+
nightlightMode: string;
|
|
652
|
+
/**
|
|
653
|
+
* - Background download state
|
|
654
|
+
*/
|
|
655
|
+
bgDownload: number;
|
|
656
|
+
/**
|
|
657
|
+
* - Bytes per second
|
|
658
|
+
*/
|
|
659
|
+
bytesPS: number;
|
|
660
|
+
/**
|
|
661
|
+
* - Day mode (0=night, 1=day, -1=unknown)
|
|
662
|
+
*/
|
|
663
|
+
day: -1 | 0 | 1;
|
|
664
|
+
/**
|
|
665
|
+
* - Temperature readings (format: 'val1:val2:val3')
|
|
666
|
+
*/
|
|
667
|
+
temp: string;
|
|
668
|
+
/**
|
|
669
|
+
* - Ambient light sensor reading
|
|
670
|
+
*/
|
|
671
|
+
als: number;
|
|
672
|
+
/**
|
|
673
|
+
* - System/max volume level (0-100 percentage, represents 0-16 hardware scale, maps to volumeMax in events)
|
|
674
|
+
*/
|
|
675
|
+
volume: number;
|
|
676
|
+
/**
|
|
677
|
+
* - User volume setting (0-100 percentage, represents 0-16 hardware scale, maps to volume in events)
|
|
678
|
+
*/
|
|
679
|
+
userVolume: number;
|
|
680
|
+
/**
|
|
681
|
+
* - Time format preference
|
|
682
|
+
*/
|
|
683
|
+
timeFormat: "12" | "24";
|
|
684
|
+
/**
|
|
685
|
+
* - Charge state level
|
|
686
|
+
*/
|
|
687
|
+
chgStatLevel: number;
|
|
688
|
+
/**
|
|
689
|
+
* - Missed log count
|
|
690
|
+
*/
|
|
691
|
+
missedLogs: number;
|
|
692
|
+
/**
|
|
693
|
+
* - NFC lock state
|
|
694
|
+
*/
|
|
695
|
+
nfcLock: number;
|
|
696
|
+
/**
|
|
697
|
+
* - Battery full percentage threshold
|
|
698
|
+
*/
|
|
699
|
+
batteryFullPct: number;
|
|
700
|
+
};
|
|
701
|
+
/**
|
|
702
|
+
* MQTT connection state
|
|
703
|
+
*/
|
|
121
704
|
export type YotoMqttConnectionState = "disconnected" | "connected" | "reconnecting";
|
|
705
|
+
/**
|
|
706
|
+
* Events message callback
|
|
707
|
+
*/
|
|
708
|
+
export type EventsCallback = (topic: string, payload: YotoEventsMessage) => any;
|
|
709
|
+
/**
|
|
710
|
+
* Status message callback
|
|
711
|
+
*/
|
|
712
|
+
export type StatusCallback = (topic: string, payload: YotoStatusMessage) => any;
|
|
713
|
+
/**
|
|
714
|
+
* Legacy status message callback
|
|
715
|
+
*/
|
|
716
|
+
export type StatusLegacyCallback = (topic: string, payload: YotoStatusLegacyMessage) => any;
|
|
717
|
+
/**
|
|
718
|
+
* Response message callback
|
|
719
|
+
*/
|
|
720
|
+
export type ResponseCallback = (topic: string, payload: YotoResponseMessage) => any;
|
|
721
|
+
/**
|
|
722
|
+
* Unknown message callback
|
|
723
|
+
*/
|
|
724
|
+
export type UnknownCallback = (topic: string, payload: any) => any;
|
|
122
725
|
import { EventEmitter } from 'events';
|
|
123
726
|
import type { MqttClient } from 'mqtt';
|
|
124
727
|
//# sourceMappingURL=client.d.ts.map
|