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
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://yoto.dev/api/getdevices/
|
|
3
|
+
* @typedef {Object} YotoDevicesResponse
|
|
4
|
+
* @property {YotoDevice[]} devices
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @see https://yoto.dev/api/getdevices/
|
|
8
|
+
* @typedef {Object} YotoDevice
|
|
9
|
+
* @property {string} deviceId - The unique identifier for the device
|
|
10
|
+
* @property {string} name - The name of the device
|
|
11
|
+
* @property {string} description - A brief description of the device
|
|
12
|
+
* @property {boolean} online - Indicates whether the device is currently online
|
|
13
|
+
* @property {string} releaseChannel - The release channel of the device
|
|
14
|
+
* @property {string} deviceType - The type of the device
|
|
15
|
+
* @property {string} deviceFamily - The family to which the device belongs
|
|
16
|
+
* @property {string} deviceGroup - The group classification of the device
|
|
17
|
+
* @property {string} [generation] - Device generation (e.g., 'gen3')
|
|
18
|
+
* @property {string} [formFactor] - Device form factor (e.g., 'standard', 'mini')
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the list of devices associated with the authenticated user.
|
|
22
|
+
* @see https://yoto.dev/api/getdevices/
|
|
23
|
+
* @param {object} options
|
|
24
|
+
* @param {string} options.accessToken The API token to request with
|
|
25
|
+
* @param {string} [options.userAgent] Optional user agent string
|
|
26
|
+
* @param {RequestOptions} [options.requestOptions] Additional undici request options
|
|
27
|
+
* @return {Promise<YotoDevicesResponse>} The user's devices
|
|
28
|
+
*/
|
|
1
29
|
export function getDevices({ accessToken, userAgent, requestOptions }: {
|
|
2
30
|
accessToken: string;
|
|
3
31
|
userAgent?: string | undefined;
|
|
@@ -5,6 +33,53 @@ export function getDevices({ accessToken, userAgent, requestOptions }: {
|
|
|
5
33
|
dispatcher?: import("undici").Dispatcher;
|
|
6
34
|
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
7
35
|
}): Promise<YotoDevicesResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* @see https://yoto.dev/api/getdevicestatus/
|
|
38
|
+
* @typedef {Object} YotoDeviceStatusResponse
|
|
39
|
+
* @property {string} deviceId - Unique identifier of the device
|
|
40
|
+
* @property {string} activeCard - Active card on the device (can be 'none')
|
|
41
|
+
* @property {number} ambientLightSensorReading - Reading from ambient light sensor
|
|
42
|
+
* @property {number} averageDownloadSpeedBytesSecond - Average download speed in bytes per second
|
|
43
|
+
* @property {number} batteryLevelPercentage - Battery level in percentage
|
|
44
|
+
* @property {number} batteryLevelPercentageRaw - Raw battery level percentage
|
|
45
|
+
* @property {number} buzzErrors - Number of buzz errors
|
|
46
|
+
* @property {0 | 1 | 2} cardInsertionState - Card insertion state from API (0=none, 1=physical, 2=remote) - converted to CardInsertionState string union in YotoDeviceStatus
|
|
47
|
+
* @property {-1 | 0 | 1} dayMode - Day mode status (-1=unknown, 0=night, 1=day)
|
|
48
|
+
* @property {number} errorsLogged - Number of errors logged
|
|
49
|
+
* @property {string} firmwareVersion - Firmware version (e.g., 'v2.23.2')
|
|
50
|
+
* @property {number} freeDiskSpaceBytes - Free disk space in bytes
|
|
51
|
+
* @property {boolean} isAudioDeviceConnected - Whether audio device is connected
|
|
52
|
+
* @property {boolean} isBackgroundDownloadActive - Whether background download is active
|
|
53
|
+
* @property {boolean} isBluetoothAudioConnected - Whether Bluetooth audio is connected
|
|
54
|
+
* @property {boolean} isCharging - Whether device is currently charging
|
|
55
|
+
* @property {number} isNfcLocked - NFC lock status
|
|
56
|
+
* @property {boolean} isOnline - Whether device is currently online
|
|
57
|
+
* @property {string} networkSsid - Network SSID device is connected to
|
|
58
|
+
* @property {string} nightlightMode - Current nightlight color (HTTP returns 'off' or '0x000000'; MQTT provides actual hex color like '0xff5733')
|
|
59
|
+
* @property {number} playingSource - Currently playing source
|
|
60
|
+
* @property {string | null} powerCapabilities - Power capabilities (e.g., '0x02')
|
|
61
|
+
* @property {0 | 1 | 2 | 3} powerSource - Power source (0=battery, 1=V2 dock, 2=USB-C, 3=Qi)
|
|
62
|
+
* @property {number} systemVolumePercentage - System/max volume in percentage (0-100, represents 0-16 hardware scale, maps to volumeMax in events)
|
|
63
|
+
* @property {number} taskWatchdogTimeoutCount - Task watchdog timeout count
|
|
64
|
+
* @property {string | number} temperatureCelcius - Temperature in Celsius (can be number or string like "0" or "notSupported") - Note: API misspells "Celsius"
|
|
65
|
+
* @property {number} totalDiskSpaceBytes - Total disk space in bytes
|
|
66
|
+
* @property {string} updatedAt - Timestamp of last update
|
|
67
|
+
* @property {number} uptime - Uptime of the device in seconds
|
|
68
|
+
* @property {number} userVolumePercentage - User volume in percentage (0-100, represents 0-16 hardware scale, maps to volume in events)
|
|
69
|
+
* @property {number} utcOffsetSeconds - UTC offset in seconds
|
|
70
|
+
* @property {number} utcTime - UTC time as Unix timestamp
|
|
71
|
+
* @property {number} wifiStrength - WiFi connection strength in decibels
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
* Retrieves the current status of a specific device.
|
|
75
|
+
* @see https://yoto.dev/api/getdevicestatus/
|
|
76
|
+
* @param {object} options
|
|
77
|
+
* @param {string} options.accessToken The API token to request with
|
|
78
|
+
* @param {string} options.deviceId The device ID to get status for
|
|
79
|
+
* @param {string} [options.userAgent] Optional user agent string
|
|
80
|
+
* @param {RequestOptions} [options.requestOptions] Additional undici request options
|
|
81
|
+
* @return {Promise<YotoDeviceStatusResponse>} The device status
|
|
82
|
+
*/
|
|
8
83
|
export function getDeviceStatus({ accessToken, userAgent, deviceId, requestOptions }: {
|
|
9
84
|
accessToken: string;
|
|
10
85
|
deviceId: string;
|
|
@@ -13,6 +88,171 @@ export function getDeviceStatus({ accessToken, userAgent, deviceId, requestOptio
|
|
|
13
88
|
dispatcher?: import("undici").Dispatcher;
|
|
14
89
|
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
15
90
|
}): Promise<YotoDeviceStatusResponse>;
|
|
91
|
+
/**
|
|
92
|
+
* @see https://yoto.dev/api/getdeviceconfig/
|
|
93
|
+
* @typedef {Object} YotoDeviceConfigResponse
|
|
94
|
+
* @property {YotoDeviceConfigDevice} device
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* @see https://yoto.dev/api/getdeviceconfig/
|
|
98
|
+
* @typedef {Object} YotoDeviceConfigDevice
|
|
99
|
+
* @property {YotoDeviceConfig} config - Device configuration settings
|
|
100
|
+
* @property {string} deviceFamily - Device family (e.g., 'v2', 'v3', 'mini')
|
|
101
|
+
* @property {string} deviceGroup - Device group classification
|
|
102
|
+
* @property {string} deviceId - Unique identifier for the device
|
|
103
|
+
* @property {string} deviceType - Type of device
|
|
104
|
+
* @property {any} errorCode - Error code (null if no error)
|
|
105
|
+
* @property {string} geoTimezone - Geographic timezone (e.g., 'Europe/London')
|
|
106
|
+
* @property {string} getPosix - POSIX timezone string
|
|
107
|
+
* @property {string} mac - MAC address
|
|
108
|
+
* @property {string} name - Device name (undocumented)
|
|
109
|
+
* @property {boolean} online - Whether device is online
|
|
110
|
+
* @property {string} registrationCode - Device registration code
|
|
111
|
+
* @property {string} activationPopCode - Activation POP code (undocumented)
|
|
112
|
+
* @property {string} popCode - POP code (undocumented)
|
|
113
|
+
* @property {string} releaseChannelId - Release channel identifier
|
|
114
|
+
* @property {string} releaseChannelVersion - Release channel version
|
|
115
|
+
* @property {string} fwVersion - Firmware version (undocumented)
|
|
116
|
+
* @property {YotoDeviceFullStatus} status - Comprehensive device status object (undocumented)
|
|
117
|
+
* @property {YotoDeviceShortcuts} shortcuts - Button shortcuts configuration (beta feature)
|
|
118
|
+
*/
|
|
119
|
+
/**
|
|
120
|
+
* Comprehensive device status from HTTP config endpoint (undocumented)
|
|
121
|
+
* Contains both user-facing fields and low-level hardware/diagnostic data
|
|
122
|
+
* Note: Many fields are nullable when device hasn't synced settings yet
|
|
123
|
+
* @typedef {Object} YotoDeviceFullStatus
|
|
124
|
+
* @property {string} activeCard - Active card ID or 'none'
|
|
125
|
+
* @property {number | null} aliveTime - Total time device has been alive
|
|
126
|
+
* @property {number} als - Ambient light sensor reading
|
|
127
|
+
* @property {number | null} battery - Raw battery voltage
|
|
128
|
+
* @property {number} batteryLevel - Battery level percentage
|
|
129
|
+
* @property {number} batteryLevelRaw - Raw battery level percentage
|
|
130
|
+
* @property {number | null} batteryRemaining - Battery remaining time estimate
|
|
131
|
+
* @property {0 | 1} bgDownload - Background download status (0 or 1)
|
|
132
|
+
* @property {0 | 1} bluetoothHp - Bluetooth headphones enabled (0 or 1)
|
|
133
|
+
* @property {number} buzzErrors - Number of buzz errors
|
|
134
|
+
* @property {number} bytesPS - Bytes per second transfer rate
|
|
135
|
+
* @property {0 | 1 | 2} cardInserted - Card insertion state (0=none, 1=physical, 2=remote)
|
|
136
|
+
* @property {number | null} chgStatLevel - Charge state level
|
|
137
|
+
* @property {0 | 1} charging - Charging state (0 or 1)
|
|
138
|
+
* @property {-1 | 0 | 1} day - Day mode (0=night, 1=day, -1=unknown)
|
|
139
|
+
* @property {number | null} dayBright - Day brightness setting
|
|
140
|
+
* @property {number | null} dbatTimeout - DBAT timeout value
|
|
141
|
+
* @property {string} deviceId - Device unique identifier
|
|
142
|
+
* @property {number | null} dnowBrightness - Current display brightness
|
|
143
|
+
* @property {number} errorsLogged - Number of errors logged
|
|
144
|
+
* @property {any} failData - Failure data (null if none)
|
|
145
|
+
* @property {any} failReason - Failure reason (null if none)
|
|
146
|
+
* @property {number | null} free - Free memory in bytes
|
|
147
|
+
* @property {number | null} free32 - Free 32-bit memory pool
|
|
148
|
+
* @property {number} freeDisk - Free disk space in bytes
|
|
149
|
+
* @property {number | null} freeDMA - Free DMA memory
|
|
150
|
+
* @property {string} fwVersion - Firmware version
|
|
151
|
+
* @property {0 | 1} headphones - Headphones connected (0 or 1)
|
|
152
|
+
* @property {string | null} lastSeenAt - Last seen timestamp
|
|
153
|
+
* @property {number | null} missedLogs - Number of missed log entries
|
|
154
|
+
* @property {string} nfcErrs - NFC errors (e.g., 'n/a')
|
|
155
|
+
* @property {number} nfcLock - NFC lock status
|
|
156
|
+
* @property {number | null} nightBright - Night brightness setting
|
|
157
|
+
* @property {string} nightlightMode - Current nightlight color (hex color like '0xff5733' or 'off')
|
|
158
|
+
* @property {number} playingStatus - Playing status code
|
|
159
|
+
* @property {string | null} powerCaps - Power capabilities
|
|
160
|
+
* @property {0 | 1 | 2 | 3} powerSrc - Power source (0=battery, 1=V2 dock, 2=USB-C, 3=Qi)
|
|
161
|
+
* @property {number | null} qiOtp - Qi OTP value
|
|
162
|
+
* @property {string | null} sd_info - SD card information
|
|
163
|
+
* @property {string | null} shutDown - Shutdown reason ('nA' = running, 'userShutdown' = powered off, etc.)
|
|
164
|
+
* @property {number | null} shutdownTimeout - Shutdown timeout in seconds
|
|
165
|
+
* @property {string} ssid - WiFi SSID
|
|
166
|
+
* @property {number | null} statusVersion - Status version number
|
|
167
|
+
* @property {string} temp - Temperature readings (format: 'value1:value2' or 'value1:notSupported')
|
|
168
|
+
* @property {'12' | '24' | null} timeFormat - Time format ('12' or '24')
|
|
169
|
+
* @property {number} totalDisk - Total disk space in bytes
|
|
170
|
+
* @property {number} twdt - Task watchdog timeout count
|
|
171
|
+
* @property {string} updatedAt - Last update timestamp (ISO 8601)
|
|
172
|
+
* @property {number} upTime - Uptime in seconds
|
|
173
|
+
* @property {number} userVolume - User volume setting (0-100 percentage, represents 0-16 hardware scale, maps to volume in events)
|
|
174
|
+
* @property {number} utcOffset - UTC offset in seconds
|
|
175
|
+
* @property {number} utcTime - UTC time as Unix timestamp
|
|
176
|
+
* @property {number} volume - System/max volume level (0-100 percentage, represents 0-16 hardware scale, maps to volumeMax in events)
|
|
177
|
+
* @property {number | null} wifiRestarts - Number of WiFi restarts
|
|
178
|
+
* @property {number} wifiStrength - WiFi signal strength in dBm
|
|
179
|
+
*/
|
|
180
|
+
/**
|
|
181
|
+
* @see https://yoto.dev/api/getdeviceconfig/
|
|
182
|
+
* @typedef {Object} YotoDeviceConfig
|
|
183
|
+
* @property {string[]} alarms - Array of alarm strings in comma-separated format (e.g., '1111111,1100,5WsQg,,,8')
|
|
184
|
+
* @property {string} ambientColour - Ambient light color (hex code)
|
|
185
|
+
* @property {string} bluetoothEnabled - Bluetooth enabled state ('0' or '1')
|
|
186
|
+
* @property {boolean} btHeadphonesEnabled - Bluetooth headphones enabled
|
|
187
|
+
* @property {string} clockFace - Clock face style (e.g., 'digital-sun')
|
|
188
|
+
* @property {string} dayDisplayBrightness - Day display brightness (e.g., 'auto', '100')
|
|
189
|
+
* @property {string} dayTime - Day mode start time (e.g., '07:00')
|
|
190
|
+
* @property {string} dayYotoDaily - Day mode Yoto Daily card path
|
|
191
|
+
* @property {string} dayYotoRadio - Day mode Yoto Radio card path
|
|
192
|
+
* @property {string} daySoundsOff - Day sounds off setting ('0' or '1') (undocumented)
|
|
193
|
+
* @property {string} displayDimBrightness - Display dim brightness level (undocumented)
|
|
194
|
+
* @property {string} displayDimTimeout - Display dim timeout in seconds
|
|
195
|
+
* @property {boolean} headphonesVolumeLimited - Whether headphones volume is limited
|
|
196
|
+
* @property {string} hourFormat - Hour format ('12' or '24') (undocumented)
|
|
197
|
+
* @property {string} logLevel - Log level (e.g., 'none') (undocumented)
|
|
198
|
+
* @property {string} locale - Device locale (e.g., 'en') (undocumented)
|
|
199
|
+
* @property {string} maxVolumeLimit - Maximum volume limit
|
|
200
|
+
* @property {string} nightAmbientColour - Night ambient light color (hex code)
|
|
201
|
+
* @property {string} nightDisplayBrightness - Night display brightness
|
|
202
|
+
* @property {string} nightMaxVolumeLimit - Night maximum volume limit
|
|
203
|
+
* @property {string} nightTime - Night mode start time (e.g., '19:20')
|
|
204
|
+
* @property {string} nightYotoDaily - Night mode Yoto Daily card path
|
|
205
|
+
* @property {string} nightYotoRadio - Night mode Yoto Radio card path (can be '0' for none)
|
|
206
|
+
* @property {string} nightSoundsOff - Night sounds off setting ('0' or '1') (undocumented)
|
|
207
|
+
* @property {boolean} pausePowerButton - Pause on power button press (undocumented)
|
|
208
|
+
* @property {boolean} pauseVolumeDown - Pause on volume down (undocumented)
|
|
209
|
+
* @property {boolean} repeatAll - Whether repeat all is enabled
|
|
210
|
+
* @property {boolean} showDiagnostics - Show diagnostics (undocumented)
|
|
211
|
+
* @property {string} shutdownTimeout - Shutdown timeout in seconds
|
|
212
|
+
* @property {string} systemVolume - System volume level (e.g., '100') (undocumented)
|
|
213
|
+
* @property {string} timezone - Timezone setting (empty string if not set) (undocumented)
|
|
214
|
+
* @property {string} volumeLevel - Volume level preset (e.g., 'safe') (undocumented)
|
|
215
|
+
*/
|
|
216
|
+
/**
|
|
217
|
+
* @see https://yoto.dev/api/getdeviceconfig/
|
|
218
|
+
* @typedef {Object} YotoDeviceShortcuts
|
|
219
|
+
* @property {YotoShortcutModes} modes - Shortcut modes for day and night
|
|
220
|
+
* @property {string} versionId - Shortcuts configuration version ID
|
|
221
|
+
*/
|
|
222
|
+
/**
|
|
223
|
+
* @see https://yoto.dev/api/getdeviceconfig/
|
|
224
|
+
* @typedef {Object} YotoShortcutModes
|
|
225
|
+
* @property {YotoShortcutMode} day - Day mode shortcuts
|
|
226
|
+
* @property {YotoShortcutMode} night - Night mode shortcuts
|
|
227
|
+
*/
|
|
228
|
+
/**
|
|
229
|
+
* @see https://yoto.dev/api/getdeviceconfig/
|
|
230
|
+
* @typedef {Object} YotoShortcutMode
|
|
231
|
+
* @property {YotoShortcutContent[]} content - Array of shortcut content commands
|
|
232
|
+
*/
|
|
233
|
+
/**
|
|
234
|
+
* @see https://yoto.dev/api/getdeviceconfig/
|
|
235
|
+
* @typedef {Object} YotoShortcutContent
|
|
236
|
+
* @property {string} cmd - Command type (e.g., 'track-play')
|
|
237
|
+
* @property {YotoShortcutParams} params - Command parameters
|
|
238
|
+
*/
|
|
239
|
+
/**
|
|
240
|
+
* @see https://yoto.dev/api/getdeviceconfig/
|
|
241
|
+
* @typedef {Object} YotoShortcutParams
|
|
242
|
+
* @property {string} card - Card ID
|
|
243
|
+
* @property {string} chapter - Chapter identifier
|
|
244
|
+
* @property {string} track - Track identifier
|
|
245
|
+
*/
|
|
246
|
+
/**
|
|
247
|
+
* Retrieves the configuration details for a specific device.
|
|
248
|
+
* @see https://yoto.dev/api/getdeviceconfig/
|
|
249
|
+
* @param {object} options
|
|
250
|
+
* @param {string} options.accessToken The API token to request with
|
|
251
|
+
* @param {string} options.deviceId The device ID to get config for
|
|
252
|
+
* @param {string} [options.userAgent] Optional user agent string
|
|
253
|
+
* @param {RequestOptions} [options.requestOptions] Additional undici request options
|
|
254
|
+
* @return {Promise<YotoDeviceConfigResponse>} The device configuration
|
|
255
|
+
*/
|
|
16
256
|
export function getDeviceConfig({ accessToken, userAgent, deviceId, requestOptions }: {
|
|
17
257
|
accessToken: string;
|
|
18
258
|
deviceId: string;
|
|
@@ -21,6 +261,28 @@ export function getDeviceConfig({ accessToken, userAgent, deviceId, requestOptio
|
|
|
21
261
|
dispatcher?: import("undici").Dispatcher;
|
|
22
262
|
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
23
263
|
}): Promise<YotoDeviceConfigResponse>;
|
|
264
|
+
/**
|
|
265
|
+
* @see https://yoto.dev/api/updatedeviceconfig/
|
|
266
|
+
* @typedef {Object} YotoUpdateDeviceConfigRequest
|
|
267
|
+
* @property {string} [name] - Device name
|
|
268
|
+
* @property {Partial<YotoDeviceConfig>} config - Configuration settings to update (all fields optional)
|
|
269
|
+
*/
|
|
270
|
+
/**
|
|
271
|
+
* @see https://yoto.dev/api/updatedeviceconfig/
|
|
272
|
+
* @typedef {Object} YotoUpdateDeviceConfigResponse
|
|
273
|
+
* @property {string} status - Status of the update operation (e.g., 'ok')
|
|
274
|
+
*/
|
|
275
|
+
/**
|
|
276
|
+
* Updates the configuration settings for a specific device.
|
|
277
|
+
* @see https://yoto.dev/api/updatedeviceconfig/
|
|
278
|
+
* @param {object} options
|
|
279
|
+
* @param {string} options.accessToken The API token to request with
|
|
280
|
+
* @param {string} options.deviceId The device ID to update config for
|
|
281
|
+
* @param {YotoUpdateDeviceConfigRequest} options.configUpdate The configuration updates to apply (all config fields are optional)
|
|
282
|
+
* @param {string} [options.userAgent] Optional user agent string
|
|
283
|
+
* @param {RequestOptions} [options.requestOptions] Additional undici request options
|
|
284
|
+
* @return {Promise<YotoUpdateDeviceConfigResponse>} The update response
|
|
285
|
+
*/
|
|
24
286
|
export function updateDeviceConfig({ accessToken, userAgent, deviceId, configUpdate, requestOptions }: {
|
|
25
287
|
accessToken: string;
|
|
26
288
|
deviceId: string;
|
|
@@ -30,6 +292,27 @@ export function updateDeviceConfig({ accessToken, userAgent, deviceId, configUpd
|
|
|
30
292
|
dispatcher?: import("undici").Dispatcher;
|
|
31
293
|
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
32
294
|
}): Promise<YotoUpdateDeviceConfigResponse>;
|
|
295
|
+
/**
|
|
296
|
+
* @see https://yoto.dev/api/updateshortcutsbeta/
|
|
297
|
+
* @typedef {Object} YotoUpdateShortcutsRequest
|
|
298
|
+
* @property {YotoDeviceShortcuts} shortcuts - Shortcuts configuration to update
|
|
299
|
+
*/
|
|
300
|
+
/**
|
|
301
|
+
* @see https://yoto.dev/api/updateshortcutsbeta/
|
|
302
|
+
* @typedef {Object} YotoUpdateShortcutsResponse
|
|
303
|
+
* @property {string} status - Status of the update operation (e.g., 'ok')
|
|
304
|
+
*/
|
|
305
|
+
/**
|
|
306
|
+
* Updates the shortcuts configuration for a specific device (beta feature).
|
|
307
|
+
* @see https://yoto.dev/api/updateshortcutsbeta/
|
|
308
|
+
* @param {object} options
|
|
309
|
+
* @param {string} options.accessToken The API token to request with
|
|
310
|
+
* @param {string} options.deviceId The device ID to update shortcuts for
|
|
311
|
+
* @param {YotoUpdateShortcutsRequest} options.shortcutsUpdate The shortcuts configuration to update
|
|
312
|
+
* @param {string} [options.userAgent] Optional user agent string
|
|
313
|
+
* @param {RequestOptions} [options.requestOptions] Additional undici request options
|
|
314
|
+
* @return {Promise<YotoUpdateShortcutsResponse>} The update response
|
|
315
|
+
*/
|
|
33
316
|
export function updateDeviceShortcuts({ accessToken, userAgent, deviceId, shortcutsUpdate, requestOptions }: {
|
|
34
317
|
accessToken: string;
|
|
35
318
|
deviceId: string;
|
|
@@ -39,6 +322,31 @@ export function updateDeviceShortcuts({ accessToken, userAgent, deviceId, shortc
|
|
|
39
322
|
dispatcher?: import("undici").Dispatcher;
|
|
40
323
|
} & Omit<import("undici").Dispatcher.RequestOptions<unknown>, "origin" | "path" | "method"> & Partial<Pick<import("undici").Dispatcher.RequestOptions<null>, "method">>) | undefined;
|
|
41
324
|
}): Promise<YotoUpdateShortcutsResponse>;
|
|
325
|
+
/**
|
|
326
|
+
* @see https://yoto.dev/api/senddevicecommand/
|
|
327
|
+
* @see https://yoto.dev/players-mqtt/mqtt-docs/
|
|
328
|
+
* @typedef {Object} YotoDeviceCommandResponse
|
|
329
|
+
* @property {string} status - Status of the command (e.g., 'ok')
|
|
330
|
+
*/
|
|
331
|
+
/**
|
|
332
|
+
* MQTT command types that can be sent to a device.
|
|
333
|
+
* Uses command types from the mqtt module.
|
|
334
|
+
* @see https://yoto.dev/players-mqtt/mqtt-docs/
|
|
335
|
+
* @typedef {YotoVolumeCommand | YotoAmbientCommand | YotoSleepTimerCommand | YotoCardStartCommand | YotoBluetoothCommand | YotoDisplayPreviewCommand | {}} YotoDeviceCommand
|
|
336
|
+
*/
|
|
337
|
+
/**
|
|
338
|
+
* Sends an MQTT command to a device.
|
|
339
|
+
* This is a mutation endpoint that controls device behavior.
|
|
340
|
+
* @see https://yoto.dev/api/senddevicecommand/
|
|
341
|
+
* @see https://yoto.dev/players-mqtt/mqtt-docs/
|
|
342
|
+
* @param {object} options
|
|
343
|
+
* @param {string} options.accessToken The API token to request with
|
|
344
|
+
* @param {string} options.deviceId The device ID to send command to
|
|
345
|
+
* @param {YotoDeviceCommand} options.command The MQTT command payload to send
|
|
346
|
+
* @param {string} [options.userAgent] Optional user agent string
|
|
347
|
+
* @param {RequestOptions} [options.requestOptions] Additional undici request options
|
|
348
|
+
* @return {Promise<YotoDeviceCommandResponse>} The command response
|
|
349
|
+
*/
|
|
42
350
|
export function sendDeviceCommand({ accessToken, userAgent, deviceId, command, requestOptions }: {
|
|
43
351
|
accessToken: string;
|
|
44
352
|
deviceId: string;
|
|
@@ -52,146 +360,707 @@ export type YotoDevicesResponse = {
|
|
|
52
360
|
devices: YotoDevice[];
|
|
53
361
|
};
|
|
54
362
|
export type YotoDevice = {
|
|
363
|
+
/**
|
|
364
|
+
* - The unique identifier for the device
|
|
365
|
+
*/
|
|
55
366
|
deviceId: string;
|
|
367
|
+
/**
|
|
368
|
+
* - The name of the device
|
|
369
|
+
*/
|
|
56
370
|
name: string;
|
|
371
|
+
/**
|
|
372
|
+
* - A brief description of the device
|
|
373
|
+
*/
|
|
57
374
|
description: string;
|
|
375
|
+
/**
|
|
376
|
+
* - Indicates whether the device is currently online
|
|
377
|
+
*/
|
|
58
378
|
online: boolean;
|
|
379
|
+
/**
|
|
380
|
+
* - The release channel of the device
|
|
381
|
+
*/
|
|
59
382
|
releaseChannel: string;
|
|
383
|
+
/**
|
|
384
|
+
* - The type of the device
|
|
385
|
+
*/
|
|
60
386
|
deviceType: string;
|
|
387
|
+
/**
|
|
388
|
+
* - The family to which the device belongs
|
|
389
|
+
*/
|
|
61
390
|
deviceFamily: string;
|
|
391
|
+
/**
|
|
392
|
+
* - The group classification of the device
|
|
393
|
+
*/
|
|
62
394
|
deviceGroup: string;
|
|
395
|
+
/**
|
|
396
|
+
* - Device generation (e.g., 'gen3')
|
|
397
|
+
*/
|
|
63
398
|
generation?: string;
|
|
399
|
+
/**
|
|
400
|
+
* - Device form factor (e.g., 'standard', 'mini')
|
|
401
|
+
*/
|
|
64
402
|
formFactor?: string;
|
|
65
403
|
};
|
|
66
404
|
export type YotoDeviceStatusResponse = {
|
|
405
|
+
/**
|
|
406
|
+
* - Unique identifier of the device
|
|
407
|
+
*/
|
|
67
408
|
deviceId: string;
|
|
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
|
-
|
|
409
|
+
/**
|
|
410
|
+
* - Active card on the device (can be 'none')
|
|
411
|
+
*/
|
|
412
|
+
activeCard: string;
|
|
413
|
+
/**
|
|
414
|
+
* - Reading from ambient light sensor
|
|
415
|
+
*/
|
|
416
|
+
ambientLightSensorReading: number;
|
|
417
|
+
/**
|
|
418
|
+
* - Average download speed in bytes per second
|
|
419
|
+
*/
|
|
420
|
+
averageDownloadSpeedBytesSecond: number;
|
|
421
|
+
/**
|
|
422
|
+
* - Battery level in percentage
|
|
423
|
+
*/
|
|
424
|
+
batteryLevelPercentage: number;
|
|
425
|
+
/**
|
|
426
|
+
* - Raw battery level percentage
|
|
427
|
+
*/
|
|
428
|
+
batteryLevelPercentageRaw: number;
|
|
429
|
+
/**
|
|
430
|
+
* - Number of buzz errors
|
|
431
|
+
*/
|
|
432
|
+
buzzErrors: number;
|
|
433
|
+
/**
|
|
434
|
+
* - Card insertion state from API (0=none, 1=physical, 2=remote) - converted to CardInsertionState string union in YotoDeviceStatus
|
|
435
|
+
*/
|
|
436
|
+
cardInsertionState: 0 | 1 | 2;
|
|
437
|
+
/**
|
|
438
|
+
* - Day mode status (-1=unknown, 0=night, 1=day)
|
|
439
|
+
*/
|
|
440
|
+
dayMode: -1 | 0 | 1;
|
|
441
|
+
/**
|
|
442
|
+
* - Number of errors logged
|
|
443
|
+
*/
|
|
444
|
+
errorsLogged: number;
|
|
445
|
+
/**
|
|
446
|
+
* - Firmware version (e.g., 'v2.23.2')
|
|
447
|
+
*/
|
|
448
|
+
firmwareVersion: string;
|
|
449
|
+
/**
|
|
450
|
+
* - Free disk space in bytes
|
|
451
|
+
*/
|
|
452
|
+
freeDiskSpaceBytes: number;
|
|
453
|
+
/**
|
|
454
|
+
* - Whether audio device is connected
|
|
455
|
+
*/
|
|
456
|
+
isAudioDeviceConnected: boolean;
|
|
457
|
+
/**
|
|
458
|
+
* - Whether background download is active
|
|
459
|
+
*/
|
|
460
|
+
isBackgroundDownloadActive: boolean;
|
|
461
|
+
/**
|
|
462
|
+
* - Whether Bluetooth audio is connected
|
|
463
|
+
*/
|
|
464
|
+
isBluetoothAudioConnected: boolean;
|
|
465
|
+
/**
|
|
466
|
+
* - Whether device is currently charging
|
|
467
|
+
*/
|
|
468
|
+
isCharging: boolean;
|
|
469
|
+
/**
|
|
470
|
+
* - NFC lock status
|
|
471
|
+
*/
|
|
472
|
+
isNfcLocked: number;
|
|
473
|
+
/**
|
|
474
|
+
* - Whether device is currently online
|
|
475
|
+
*/
|
|
476
|
+
isOnline: boolean;
|
|
477
|
+
/**
|
|
478
|
+
* - Network SSID device is connected to
|
|
479
|
+
*/
|
|
480
|
+
networkSsid: string;
|
|
481
|
+
/**
|
|
482
|
+
* - Current nightlight color (HTTP returns 'off' or '0x000000'; MQTT provides actual hex color like '0xff5733')
|
|
483
|
+
*/
|
|
484
|
+
nightlightMode: string;
|
|
485
|
+
/**
|
|
486
|
+
* - Currently playing source
|
|
487
|
+
*/
|
|
488
|
+
playingSource: number;
|
|
489
|
+
/**
|
|
490
|
+
* - Power capabilities (e.g., '0x02')
|
|
491
|
+
*/
|
|
492
|
+
powerCapabilities: string | null;
|
|
493
|
+
/**
|
|
494
|
+
* - Power source (0=battery, 1=V2 dock, 2=USB-C, 3=Qi)
|
|
495
|
+
*/
|
|
496
|
+
powerSource: 0 | 1 | 2 | 3;
|
|
497
|
+
/**
|
|
498
|
+
* - System/max volume in percentage (0-100, represents 0-16 hardware scale, maps to volumeMax in events)
|
|
499
|
+
*/
|
|
500
|
+
systemVolumePercentage: number;
|
|
501
|
+
/**
|
|
502
|
+
* - Task watchdog timeout count
|
|
503
|
+
*/
|
|
504
|
+
taskWatchdogTimeoutCount: number;
|
|
505
|
+
/**
|
|
506
|
+
* - Temperature in Celsius (can be number or string like "0" or "notSupported") - Note: API misspells "Celsius"
|
|
507
|
+
*/
|
|
508
|
+
temperatureCelcius: string | number;
|
|
509
|
+
/**
|
|
510
|
+
* - Total disk space in bytes
|
|
511
|
+
*/
|
|
512
|
+
totalDiskSpaceBytes: number;
|
|
513
|
+
/**
|
|
514
|
+
* - Timestamp of last update
|
|
515
|
+
*/
|
|
516
|
+
updatedAt: string;
|
|
517
|
+
/**
|
|
518
|
+
* - Uptime of the device in seconds
|
|
519
|
+
*/
|
|
520
|
+
uptime: number;
|
|
521
|
+
/**
|
|
522
|
+
* - User volume in percentage (0-100, represents 0-16 hardware scale, maps to volume in events)
|
|
523
|
+
*/
|
|
524
|
+
userVolumePercentage: number;
|
|
525
|
+
/**
|
|
526
|
+
* - UTC offset in seconds
|
|
527
|
+
*/
|
|
528
|
+
utcOffsetSeconds: number;
|
|
529
|
+
/**
|
|
530
|
+
* - UTC time as Unix timestamp
|
|
531
|
+
*/
|
|
532
|
+
utcTime: number;
|
|
533
|
+
/**
|
|
534
|
+
* - WiFi connection strength in decibels
|
|
535
|
+
*/
|
|
536
|
+
wifiStrength: number;
|
|
100
537
|
};
|
|
101
538
|
export type YotoDeviceConfigResponse = {
|
|
102
539
|
device: YotoDeviceConfigDevice;
|
|
103
540
|
};
|
|
104
541
|
export type YotoDeviceConfigDevice = {
|
|
542
|
+
/**
|
|
543
|
+
* - Device configuration settings
|
|
544
|
+
*/
|
|
105
545
|
config: YotoDeviceConfig;
|
|
546
|
+
/**
|
|
547
|
+
* - Device family (e.g., 'v2', 'v3', 'mini')
|
|
548
|
+
*/
|
|
106
549
|
deviceFamily: string;
|
|
550
|
+
/**
|
|
551
|
+
* - Device group classification
|
|
552
|
+
*/
|
|
107
553
|
deviceGroup: string;
|
|
554
|
+
/**
|
|
555
|
+
* - Unique identifier for the device
|
|
556
|
+
*/
|
|
108
557
|
deviceId: string;
|
|
558
|
+
/**
|
|
559
|
+
* - Type of device
|
|
560
|
+
*/
|
|
109
561
|
deviceType: string;
|
|
562
|
+
/**
|
|
563
|
+
* - Error code (null if no error)
|
|
564
|
+
*/
|
|
110
565
|
errorCode: any;
|
|
566
|
+
/**
|
|
567
|
+
* - Geographic timezone (e.g., 'Europe/London')
|
|
568
|
+
*/
|
|
111
569
|
geoTimezone: string;
|
|
570
|
+
/**
|
|
571
|
+
* - POSIX timezone string
|
|
572
|
+
*/
|
|
112
573
|
getPosix: string;
|
|
574
|
+
/**
|
|
575
|
+
* - MAC address
|
|
576
|
+
*/
|
|
113
577
|
mac: string;
|
|
578
|
+
/**
|
|
579
|
+
* - Device name (undocumented)
|
|
580
|
+
*/
|
|
114
581
|
name: string;
|
|
582
|
+
/**
|
|
583
|
+
* - Whether device is online
|
|
584
|
+
*/
|
|
115
585
|
online: boolean;
|
|
586
|
+
/**
|
|
587
|
+
* - Device registration code
|
|
588
|
+
*/
|
|
116
589
|
registrationCode: string;
|
|
590
|
+
/**
|
|
591
|
+
* - Activation POP code (undocumented)
|
|
592
|
+
*/
|
|
117
593
|
activationPopCode: string;
|
|
594
|
+
/**
|
|
595
|
+
* - POP code (undocumented)
|
|
596
|
+
*/
|
|
118
597
|
popCode: string;
|
|
598
|
+
/**
|
|
599
|
+
* - Release channel identifier
|
|
600
|
+
*/
|
|
119
601
|
releaseChannelId: string;
|
|
602
|
+
/**
|
|
603
|
+
* - Release channel version
|
|
604
|
+
*/
|
|
120
605
|
releaseChannelVersion: string;
|
|
606
|
+
/**
|
|
607
|
+
* - Firmware version (undocumented)
|
|
608
|
+
*/
|
|
121
609
|
fwVersion: string;
|
|
122
|
-
|
|
123
|
-
|
|
610
|
+
/**
|
|
611
|
+
* - Comprehensive device status object (undocumented)
|
|
612
|
+
*/
|
|
613
|
+
status: YotoDeviceFullStatus;
|
|
614
|
+
/**
|
|
615
|
+
* - Button shortcuts configuration (beta feature)
|
|
616
|
+
*/
|
|
617
|
+
shortcuts: YotoDeviceShortcuts;
|
|
618
|
+
};
|
|
619
|
+
/**
|
|
620
|
+
* Comprehensive device status from HTTP config endpoint (undocumented)
|
|
621
|
+
* Contains both user-facing fields and low-level hardware/diagnostic data
|
|
622
|
+
* Note: Many fields are nullable when device hasn't synced settings yet
|
|
623
|
+
*/
|
|
624
|
+
export type YotoDeviceFullStatus = {
|
|
625
|
+
/**
|
|
626
|
+
* - Active card ID or 'none'
|
|
627
|
+
*/
|
|
628
|
+
activeCard: string;
|
|
629
|
+
/**
|
|
630
|
+
* - Total time device has been alive
|
|
631
|
+
*/
|
|
632
|
+
aliveTime: number | null;
|
|
633
|
+
/**
|
|
634
|
+
* - Ambient light sensor reading
|
|
635
|
+
*/
|
|
636
|
+
als: number;
|
|
637
|
+
/**
|
|
638
|
+
* - Raw battery voltage
|
|
639
|
+
*/
|
|
640
|
+
battery: number | null;
|
|
641
|
+
/**
|
|
642
|
+
* - Battery level percentage
|
|
643
|
+
*/
|
|
644
|
+
batteryLevel: number;
|
|
645
|
+
/**
|
|
646
|
+
* - Raw battery level percentage
|
|
647
|
+
*/
|
|
648
|
+
batteryLevelRaw: number;
|
|
649
|
+
/**
|
|
650
|
+
* - Battery remaining time estimate
|
|
651
|
+
*/
|
|
652
|
+
batteryRemaining: number | null;
|
|
653
|
+
/**
|
|
654
|
+
* - Background download status (0 or 1)
|
|
655
|
+
*/
|
|
656
|
+
bgDownload: 0 | 1;
|
|
657
|
+
/**
|
|
658
|
+
* - Bluetooth headphones enabled (0 or 1)
|
|
659
|
+
*/
|
|
660
|
+
bluetoothHp: 0 | 1;
|
|
661
|
+
/**
|
|
662
|
+
* - Number of buzz errors
|
|
663
|
+
*/
|
|
664
|
+
buzzErrors: number;
|
|
665
|
+
/**
|
|
666
|
+
* - Bytes per second transfer rate
|
|
667
|
+
*/
|
|
668
|
+
bytesPS: number;
|
|
669
|
+
/**
|
|
670
|
+
* - Card insertion state (0=none, 1=physical, 2=remote)
|
|
671
|
+
*/
|
|
672
|
+
cardInserted: 0 | 1 | 2;
|
|
673
|
+
/**
|
|
674
|
+
* - Charge state level
|
|
675
|
+
*/
|
|
676
|
+
chgStatLevel: number | null;
|
|
677
|
+
/**
|
|
678
|
+
* - Charging state (0 or 1)
|
|
679
|
+
*/
|
|
680
|
+
charging: 0 | 1;
|
|
681
|
+
/**
|
|
682
|
+
* - Day mode (0=night, 1=day, -1=unknown)
|
|
683
|
+
*/
|
|
684
|
+
day: -1 | 0 | 1;
|
|
685
|
+
/**
|
|
686
|
+
* - Day brightness setting
|
|
687
|
+
*/
|
|
688
|
+
dayBright: number | null;
|
|
689
|
+
/**
|
|
690
|
+
* - DBAT timeout value
|
|
691
|
+
*/
|
|
692
|
+
dbatTimeout: number | null;
|
|
693
|
+
/**
|
|
694
|
+
* - Device unique identifier
|
|
695
|
+
*/
|
|
696
|
+
deviceId: string;
|
|
697
|
+
/**
|
|
698
|
+
* - Current display brightness
|
|
699
|
+
*/
|
|
700
|
+
dnowBrightness: number | null;
|
|
701
|
+
/**
|
|
702
|
+
* - Number of errors logged
|
|
703
|
+
*/
|
|
704
|
+
errorsLogged: number;
|
|
705
|
+
/**
|
|
706
|
+
* - Failure data (null if none)
|
|
707
|
+
*/
|
|
708
|
+
failData: any;
|
|
709
|
+
/**
|
|
710
|
+
* - Failure reason (null if none)
|
|
711
|
+
*/
|
|
712
|
+
failReason: any;
|
|
713
|
+
/**
|
|
714
|
+
* - Free memory in bytes
|
|
715
|
+
*/
|
|
716
|
+
free: number | null;
|
|
717
|
+
/**
|
|
718
|
+
* - Free 32-bit memory pool
|
|
719
|
+
*/
|
|
720
|
+
free32: number | null;
|
|
721
|
+
/**
|
|
722
|
+
* - Free disk space in bytes
|
|
723
|
+
*/
|
|
724
|
+
freeDisk: number;
|
|
725
|
+
/**
|
|
726
|
+
* - Free DMA memory
|
|
727
|
+
*/
|
|
728
|
+
freeDMA: number | null;
|
|
729
|
+
/**
|
|
730
|
+
* - Firmware version
|
|
731
|
+
*/
|
|
732
|
+
fwVersion: string;
|
|
733
|
+
/**
|
|
734
|
+
* - Headphones connected (0 or 1)
|
|
735
|
+
*/
|
|
736
|
+
headphones: 0 | 1;
|
|
737
|
+
/**
|
|
738
|
+
* - Last seen timestamp
|
|
739
|
+
*/
|
|
740
|
+
lastSeenAt: string | null;
|
|
741
|
+
/**
|
|
742
|
+
* - Number of missed log entries
|
|
743
|
+
*/
|
|
744
|
+
missedLogs: number | null;
|
|
745
|
+
/**
|
|
746
|
+
* - NFC errors (e.g., 'n/a')
|
|
747
|
+
*/
|
|
748
|
+
nfcErrs: string;
|
|
749
|
+
/**
|
|
750
|
+
* - NFC lock status
|
|
751
|
+
*/
|
|
752
|
+
nfcLock: number;
|
|
753
|
+
/**
|
|
754
|
+
* - Night brightness setting
|
|
755
|
+
*/
|
|
756
|
+
nightBright: number | null;
|
|
757
|
+
/**
|
|
758
|
+
* - Current nightlight color (hex color like '0xff5733' or 'off')
|
|
759
|
+
*/
|
|
760
|
+
nightlightMode: string;
|
|
761
|
+
/**
|
|
762
|
+
* - Playing status code
|
|
763
|
+
*/
|
|
764
|
+
playingStatus: number;
|
|
765
|
+
/**
|
|
766
|
+
* - Power capabilities
|
|
767
|
+
*/
|
|
768
|
+
powerCaps: string | null;
|
|
769
|
+
/**
|
|
770
|
+
* - Power source (0=battery, 1=V2 dock, 2=USB-C, 3=Qi)
|
|
771
|
+
*/
|
|
772
|
+
powerSrc: 0 | 1 | 2 | 3;
|
|
773
|
+
/**
|
|
774
|
+
* - Qi OTP value
|
|
775
|
+
*/
|
|
776
|
+
qiOtp: number | null;
|
|
777
|
+
/**
|
|
778
|
+
* - SD card information
|
|
779
|
+
*/
|
|
780
|
+
sd_info: string | null;
|
|
781
|
+
/**
|
|
782
|
+
* - Shutdown reason ('nA' = running, 'userShutdown' = powered off, etc.)
|
|
783
|
+
*/
|
|
784
|
+
shutDown: string | null;
|
|
785
|
+
/**
|
|
786
|
+
* - Shutdown timeout in seconds
|
|
787
|
+
*/
|
|
788
|
+
shutdownTimeout: number | null;
|
|
789
|
+
/**
|
|
790
|
+
* - WiFi SSID
|
|
791
|
+
*/
|
|
792
|
+
ssid: string;
|
|
793
|
+
/**
|
|
794
|
+
* - Status version number
|
|
795
|
+
*/
|
|
796
|
+
statusVersion: number | null;
|
|
797
|
+
/**
|
|
798
|
+
* - Temperature readings (format: 'value1:value2' or 'value1:notSupported')
|
|
799
|
+
*/
|
|
800
|
+
temp: string;
|
|
801
|
+
/**
|
|
802
|
+
* - Time format ('12' or '24')
|
|
803
|
+
*/
|
|
804
|
+
timeFormat: "12" | "24" | null;
|
|
805
|
+
/**
|
|
806
|
+
* - Total disk space in bytes
|
|
807
|
+
*/
|
|
808
|
+
totalDisk: number;
|
|
809
|
+
/**
|
|
810
|
+
* - Task watchdog timeout count
|
|
811
|
+
*/
|
|
812
|
+
twdt: number;
|
|
813
|
+
/**
|
|
814
|
+
* - Last update timestamp (ISO 8601)
|
|
815
|
+
*/
|
|
816
|
+
updatedAt: string;
|
|
817
|
+
/**
|
|
818
|
+
* - Uptime in seconds
|
|
819
|
+
*/
|
|
820
|
+
upTime: number;
|
|
821
|
+
/**
|
|
822
|
+
* - User volume setting (0-100 percentage, represents 0-16 hardware scale, maps to volume in events)
|
|
823
|
+
*/
|
|
824
|
+
userVolume: number;
|
|
825
|
+
/**
|
|
826
|
+
* - UTC offset in seconds
|
|
827
|
+
*/
|
|
828
|
+
utcOffset: number;
|
|
829
|
+
/**
|
|
830
|
+
* - UTC time as Unix timestamp
|
|
831
|
+
*/
|
|
832
|
+
utcTime: number;
|
|
833
|
+
/**
|
|
834
|
+
* - System/max volume level (0-100 percentage, represents 0-16 hardware scale, maps to volumeMax in events)
|
|
835
|
+
*/
|
|
836
|
+
volume: number;
|
|
837
|
+
/**
|
|
838
|
+
* - Number of WiFi restarts
|
|
839
|
+
*/
|
|
840
|
+
wifiRestarts: number | null;
|
|
841
|
+
/**
|
|
842
|
+
* - WiFi signal strength in dBm
|
|
843
|
+
*/
|
|
844
|
+
wifiStrength: number;
|
|
124
845
|
};
|
|
125
846
|
export type YotoDeviceConfig = {
|
|
126
|
-
|
|
847
|
+
/**
|
|
848
|
+
* - Array of alarm strings in comma-separated format (e.g., '1111111,1100,5WsQg,,,8')
|
|
849
|
+
*/
|
|
850
|
+
alarms: string[];
|
|
851
|
+
/**
|
|
852
|
+
* - Ambient light color (hex code)
|
|
853
|
+
*/
|
|
127
854
|
ambientColour: string;
|
|
855
|
+
/**
|
|
856
|
+
* - Bluetooth enabled state ('0' or '1')
|
|
857
|
+
*/
|
|
128
858
|
bluetoothEnabled: string;
|
|
859
|
+
/**
|
|
860
|
+
* - Bluetooth headphones enabled
|
|
861
|
+
*/
|
|
129
862
|
btHeadphonesEnabled: boolean;
|
|
130
|
-
|
|
863
|
+
/**
|
|
864
|
+
* - Clock face style (e.g., 'digital-sun')
|
|
865
|
+
*/
|
|
866
|
+
clockFace: string;
|
|
867
|
+
/**
|
|
868
|
+
* - Day display brightness (e.g., 'auto', '100')
|
|
869
|
+
*/
|
|
131
870
|
dayDisplayBrightness: string;
|
|
871
|
+
/**
|
|
872
|
+
* - Day mode start time (e.g., '07:00')
|
|
873
|
+
*/
|
|
132
874
|
dayTime: string;
|
|
875
|
+
/**
|
|
876
|
+
* - Day mode Yoto Daily card path
|
|
877
|
+
*/
|
|
133
878
|
dayYotoDaily: string;
|
|
879
|
+
/**
|
|
880
|
+
* - Day mode Yoto Radio card path
|
|
881
|
+
*/
|
|
134
882
|
dayYotoRadio: string;
|
|
135
|
-
|
|
136
|
-
|
|
883
|
+
/**
|
|
884
|
+
* - Day sounds off setting ('0' or '1') (undocumented)
|
|
885
|
+
*/
|
|
886
|
+
daySoundsOff: string;
|
|
887
|
+
/**
|
|
888
|
+
* - Display dim brightness level (undocumented)
|
|
889
|
+
*/
|
|
890
|
+
displayDimBrightness: string;
|
|
891
|
+
/**
|
|
892
|
+
* - Display dim timeout in seconds
|
|
893
|
+
*/
|
|
137
894
|
displayDimTimeout: string;
|
|
895
|
+
/**
|
|
896
|
+
* - Whether headphones volume is limited
|
|
897
|
+
*/
|
|
138
898
|
headphonesVolumeLimited: boolean;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
899
|
+
/**
|
|
900
|
+
* - Hour format ('12' or '24') (undocumented)
|
|
901
|
+
*/
|
|
902
|
+
hourFormat: string;
|
|
903
|
+
/**
|
|
904
|
+
* - Log level (e.g., 'none') (undocumented)
|
|
905
|
+
*/
|
|
906
|
+
logLevel: string;
|
|
907
|
+
/**
|
|
908
|
+
* - Device locale (e.g., 'en') (undocumented)
|
|
909
|
+
*/
|
|
910
|
+
locale: string;
|
|
911
|
+
/**
|
|
912
|
+
* - Maximum volume limit
|
|
913
|
+
*/
|
|
142
914
|
maxVolumeLimit: string;
|
|
915
|
+
/**
|
|
916
|
+
* - Night ambient light color (hex code)
|
|
917
|
+
*/
|
|
143
918
|
nightAmbientColour: string;
|
|
919
|
+
/**
|
|
920
|
+
* - Night display brightness
|
|
921
|
+
*/
|
|
144
922
|
nightDisplayBrightness: string;
|
|
923
|
+
/**
|
|
924
|
+
* - Night maximum volume limit
|
|
925
|
+
*/
|
|
145
926
|
nightMaxVolumeLimit: string;
|
|
927
|
+
/**
|
|
928
|
+
* - Night mode start time (e.g., '19:20')
|
|
929
|
+
*/
|
|
146
930
|
nightTime: string;
|
|
931
|
+
/**
|
|
932
|
+
* - Night mode Yoto Daily card path
|
|
933
|
+
*/
|
|
147
934
|
nightYotoDaily: string;
|
|
935
|
+
/**
|
|
936
|
+
* - Night mode Yoto Radio card path (can be '0' for none)
|
|
937
|
+
*/
|
|
148
938
|
nightYotoRadio: string;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
939
|
+
/**
|
|
940
|
+
* - Night sounds off setting ('0' or '1') (undocumented)
|
|
941
|
+
*/
|
|
942
|
+
nightSoundsOff: string;
|
|
943
|
+
/**
|
|
944
|
+
* - Pause on power button press (undocumented)
|
|
945
|
+
*/
|
|
946
|
+
pausePowerButton: boolean;
|
|
947
|
+
/**
|
|
948
|
+
* - Pause on volume down (undocumented)
|
|
949
|
+
*/
|
|
950
|
+
pauseVolumeDown: boolean;
|
|
951
|
+
/**
|
|
952
|
+
* - Whether repeat all is enabled
|
|
953
|
+
*/
|
|
152
954
|
repeatAll: boolean;
|
|
153
|
-
|
|
955
|
+
/**
|
|
956
|
+
* - Show diagnostics (undocumented)
|
|
957
|
+
*/
|
|
958
|
+
showDiagnostics: boolean;
|
|
959
|
+
/**
|
|
960
|
+
* - Shutdown timeout in seconds
|
|
961
|
+
*/
|
|
154
962
|
shutdownTimeout: string;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
963
|
+
/**
|
|
964
|
+
* - System volume level (e.g., '100') (undocumented)
|
|
965
|
+
*/
|
|
966
|
+
systemVolume: string;
|
|
967
|
+
/**
|
|
968
|
+
* - Timezone setting (empty string if not set) (undocumented)
|
|
969
|
+
*/
|
|
970
|
+
timezone: string;
|
|
971
|
+
/**
|
|
972
|
+
* - Volume level preset (e.g., 'safe') (undocumented)
|
|
973
|
+
*/
|
|
974
|
+
volumeLevel: string;
|
|
158
975
|
};
|
|
159
976
|
export type YotoDeviceShortcuts = {
|
|
977
|
+
/**
|
|
978
|
+
* - Shortcut modes for day and night
|
|
979
|
+
*/
|
|
160
980
|
modes: YotoShortcutModes;
|
|
981
|
+
/**
|
|
982
|
+
* - Shortcuts configuration version ID
|
|
983
|
+
*/
|
|
161
984
|
versionId: string;
|
|
162
985
|
};
|
|
163
986
|
export type YotoShortcutModes = {
|
|
987
|
+
/**
|
|
988
|
+
* - Day mode shortcuts
|
|
989
|
+
*/
|
|
164
990
|
day: YotoShortcutMode;
|
|
991
|
+
/**
|
|
992
|
+
* - Night mode shortcuts
|
|
993
|
+
*/
|
|
165
994
|
night: YotoShortcutMode;
|
|
166
995
|
};
|
|
167
996
|
export type YotoShortcutMode = {
|
|
997
|
+
/**
|
|
998
|
+
* - Array of shortcut content commands
|
|
999
|
+
*/
|
|
168
1000
|
content: YotoShortcutContent[];
|
|
169
1001
|
};
|
|
170
1002
|
export type YotoShortcutContent = {
|
|
1003
|
+
/**
|
|
1004
|
+
* - Command type (e.g., 'track-play')
|
|
1005
|
+
*/
|
|
171
1006
|
cmd: string;
|
|
1007
|
+
/**
|
|
1008
|
+
* - Command parameters
|
|
1009
|
+
*/
|
|
172
1010
|
params: YotoShortcutParams;
|
|
173
1011
|
};
|
|
174
1012
|
export type YotoShortcutParams = {
|
|
1013
|
+
/**
|
|
1014
|
+
* - Card ID
|
|
1015
|
+
*/
|
|
175
1016
|
card: string;
|
|
1017
|
+
/**
|
|
1018
|
+
* - Chapter identifier
|
|
1019
|
+
*/
|
|
176
1020
|
chapter: string;
|
|
1021
|
+
/**
|
|
1022
|
+
* - Track identifier
|
|
1023
|
+
*/
|
|
177
1024
|
track: string;
|
|
178
1025
|
};
|
|
179
1026
|
export type YotoUpdateDeviceConfigRequest = {
|
|
1027
|
+
/**
|
|
1028
|
+
* - Device name
|
|
1029
|
+
*/
|
|
180
1030
|
name?: string;
|
|
1031
|
+
/**
|
|
1032
|
+
* - Configuration settings to update (all fields optional)
|
|
1033
|
+
*/
|
|
181
1034
|
config: Partial<YotoDeviceConfig>;
|
|
182
1035
|
};
|
|
183
1036
|
export type YotoUpdateDeviceConfigResponse = {
|
|
1037
|
+
/**
|
|
1038
|
+
* - Status of the update operation (e.g., 'ok')
|
|
1039
|
+
*/
|
|
184
1040
|
status: string;
|
|
185
1041
|
};
|
|
186
1042
|
export type YotoUpdateShortcutsRequest = {
|
|
1043
|
+
/**
|
|
1044
|
+
* - Shortcuts configuration to update
|
|
1045
|
+
*/
|
|
187
1046
|
shortcuts: YotoDeviceShortcuts;
|
|
188
1047
|
};
|
|
189
1048
|
export type YotoUpdateShortcutsResponse = {
|
|
1049
|
+
/**
|
|
1050
|
+
* - Status of the update operation (e.g., 'ok')
|
|
1051
|
+
*/
|
|
190
1052
|
status: string;
|
|
191
1053
|
};
|
|
192
1054
|
export type YotoDeviceCommandResponse = {
|
|
1055
|
+
/**
|
|
1056
|
+
* - Status of the command (e.g., 'ok')
|
|
1057
|
+
*/
|
|
193
1058
|
status: string;
|
|
194
1059
|
};
|
|
1060
|
+
/**
|
|
1061
|
+
* MQTT command types that can be sent to a device.
|
|
1062
|
+
* Uses command types from the mqtt module.
|
|
1063
|
+
*/
|
|
195
1064
|
export type YotoDeviceCommand = YotoVolumeCommand | YotoAmbientCommand | YotoSleepTimerCommand | YotoCardStartCommand | YotoBluetoothCommand | YotoDisplayPreviewCommand | {};
|
|
196
1065
|
import type { YotoVolumeCommand } from '../mqtt/commands.js';
|
|
197
1066
|
import type { YotoAmbientCommand } from '../mqtt/commands.js';
|