API reference¶
mister_fpga.MisterClient ¶
Async REST client for the MiSTer FPGA mrext Remote API.
Wraps every endpoint exposed by the mrext Remote service under
http://host:port/api. All network I/O is non-blocking; methods raise
:class:MisterConnectionError on any network or HTTP error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
IP address or hostname of the MiSTer device. |
required |
port
|
int
|
mrext Remote port (default |
8182
|
session
|
ClientSession | None
|
Optional shared |
None
|
timeout
|
int
|
Per-request timeout in seconds (default |
10
|
Source code in src/mister_fpga/client.py
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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
async_close
async
¶
async_close() -> None
Close the underlying HTTP session if this client created it.
Source code in src/mister_fpga/client.py
141 142 143 144 145 | |
async_get_status
async
¶
async_get_status() -> MisterStatus
Fetch a combined sysinfo + playing snapshot.
Returns:
| Name | Type | Description |
|---|---|---|
A |
MisterStatus
|
class: |
Raises:
| Type | Description |
|---|---|
MisterConnectionError
|
If either underlying request fails. |
Source code in src/mister_fpga/client.py
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 | |
async_get_systems
async
¶
async_get_systems() -> list[dict]
Return the list of systems known to mrext.
Source code in src/mister_fpga/client.py
212 213 214 | |
async_launch_system
async
¶
async_launch_system(system_id: str) -> None
Launch the default game/core for system_id.
Source code in src/mister_fpga/client.py
216 217 218 | |
async_launch_game
async
¶
async_launch_game(path: str) -> None
Launch a game by its absolute path on the MiSTer SD card.
Source code in src/mister_fpga/client.py
220 221 222 | |
async_launch_menu
async
¶
async_launch_menu() -> None
Return to the MiSTer main menu.
Source code in src/mister_fpga/client.py
224 225 226 | |
async_search_games
async
¶
async_search_games(query: str, system: str = 'all') -> dict
Search the game index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Free-text search string. |
required |
system
|
str
|
Limit results to a system slug, or |
'all'
|
Returns:
| Type | Description |
|---|---|
dict
|
A dict with a |
Source code in src/mister_fpga/client.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
async_index_games
async
¶
async_index_games() -> None
Trigger a background re-index of the game library.
Source code in src/mister_fpga/client.py
245 246 247 | |
async_send_keyboard
async
¶
async_send_keyboard(name: str) -> None
Send a named virtual-keyboard event (see KEYBOARD_NAMES).
Source code in src/mister_fpga/client.py
249 250 251 | |
async_reboot
async
¶
async_reboot() -> None
Reboot the MiSTer device.
Source code in src/mister_fpga/client.py
253 254 255 | |
async_restart_remote
async
¶
async_restart_remote() -> None
Restart the mrext Remote service on the MiSTer.
Source code in src/mister_fpga/client.py
257 258 259 | |
async_take_screenshot
async
¶
async_take_screenshot() -> None
Capture a screenshot on the MiSTer and save it server-side.
Source code in src/mister_fpga/client.py
261 262 263 | |
async_get_screenshots
async
¶
async_get_screenshots() -> list[dict]
Return metadata for all saved screenshots.
Source code in src/mister_fpga/client.py
265 266 267 | |
async_get_screenshot_image
async
¶
async_get_screenshot_image(core: str, filename: str) -> bytes
Download a screenshot image as raw bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core
|
str
|
Core name sub-directory (e.g. |
required |
filename
|
str
|
Screenshot filename within that sub-directory. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Raw image bytes (typically PNG). |
Raises:
| Type | Description |
|---|---|
MisterConnectionError
|
If the image cannot be retrieved. |
Source code in src/mister_fpga/client.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
async_get_music_status
async
¶
async_get_music_status() -> dict
Return the current music-player status dict.
Source code in src/mister_fpga/client.py
286 287 288 | |
async_music_play
async
¶
async_music_play() -> None
Start or resume music playback.
Source code in src/mister_fpga/client.py
290 291 292 | |
async_music_stop
async
¶
async_music_stop() -> None
Stop music playback.
Source code in src/mister_fpga/client.py
294 295 296 | |
async_music_next
async
¶
async_music_next() -> None
Skip to the next track.
Source code in src/mister_fpga/client.py
298 299 300 | |
async_get_wallpapers
async
¶
async_get_wallpapers() -> dict
Return available wallpapers and the currently active one.
Source code in src/mister_fpga/client.py
303 304 305 | |
async_set_wallpaper
async
¶
async_set_wallpaper(filename: str) -> None
Set the active wallpaper by filename.
Source code in src/mister_fpga/client.py
307 308 309 | |
async_clear_wallpaper
async
¶
async_clear_wallpaper() -> None
Remove the active wallpaper (revert to default).
Source code in src/mister_fpga/client.py
311 312 313 | |
async_get_inis
async
¶
async_get_inis() -> dict
Return a list of MiSTer.ini profiles and the active index.
Source code in src/mister_fpga/client.py
316 317 318 | |
async_get_ini_values
async
¶
async_get_ini_values(ini_id: int) -> dict
Return all key/value pairs for INI profile ini_id.
Source code in src/mister_fpga/client.py
320 321 322 | |
async_set_active_ini
async
¶
async_set_active_ini(ini_id: int) -> None
Switch the active MiSTer.ini profile to ini_id.
Source code in src/mister_fpga/client.py
324 325 326 | |
async_set_ini_values
async
¶
async_set_ini_values(ini_id: int, values: dict) -> None
Update key/value pairs in INI profile ini_id.
Source code in src/mister_fpga/client.py
328 329 330 | |
async_set_background_mode
async
¶
async_set_background_mode(mode: int) -> None
Set the core/menu background display mode (0 = off, 1 = wallpaper, …).
Source code in src/mister_fpga/client.py
332 333 334 | |
async_get_music_playlists
async
¶
async_get_music_playlists() -> list[str]
Return the list of available music playlist names.
Source code in src/mister_fpga/client.py
337 338 339 | |
async_set_music_playlist
async
¶
async_set_music_playlist(name: str) -> None
Activate the music playlist identified by name.
Source code in src/mister_fpga/client.py
341 342 343 | |
async_set_music_playback
async
¶
async_set_music_playback(mode: str) -> None
Set playback mode (e.g. "random", "loop").
Source code in src/mister_fpga/client.py
345 346 347 | |
async_get_scripts
async
¶
async_get_scripts() -> dict
Return the list of user scripts available on the MiSTer.
Source code in src/mister_fpga/client.py
350 351 352 | |
async_launch_script
async
¶
async_launch_script(filename: str) -> None
Launch a user script by its filename.
Source code in src/mister_fpga/client.py
354 355 356 | |
async_open_console
async
¶
async_open_console() -> None
Open the MiSTer console (script terminal).
Source code in src/mister_fpga/client.py
358 359 360 | |
async_kill_script
async
¶
async_kill_script() -> None
Kill the currently running user script.
Source code in src/mister_fpga/client.py
362 363 364 | |
async_get_peers
async
¶
async_get_peers() -> list[dict]
Return the list of mrext Remote peers on the local network.
Source code in src/mister_fpga/client.py
367 368 369 370 | |
async_launch_path
async
¶
async_launch_path(path: str) -> None
Launch a file (ROM, core, script) by its absolute SD-card path.
Source code in src/mister_fpga/client.py
373 374 375 | |
async_launch_token
async
¶
async_launch_token(data: str) -> None
Launch using a short-link token (mrext /l/<data> endpoint).
Source code in src/mister_fpga/client.py
377 378 379 | |
async_create_shortcut
async
¶
async_create_shortcut(game_path: str, folder: str, name: str) -> dict
Create a game shortcut in the Favourites/Recents folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game_path
|
str
|
Absolute path to the game ROM on the SD card. |
required |
folder
|
str
|
Target folder name (e.g. |
required |
name
|
str
|
Display name for the shortcut. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dict describing the created shortcut entry. |
Source code in src/mister_fpga/client.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
async_send_keyboard_raw
async
¶
async_send_keyboard_raw(code: int) -> None
Send a raw HID keyboard scan-code integer.
Source code in src/mister_fpga/client.py
401 402 403 | |
mister_fpga.MisterStatus
dataclass
¶
Snapshot of the MiSTer device state at a point in time.
Returned by :meth:MisterClient.async_get_status and mutated in-place by
:func:~mister_fpga.apply_ws_message.
Attributes:
| Name | Type | Description |
|---|---|---|
online |
bool
|
|
core |
str | None
|
Short core identifier (e.g. |
system |
str | None
|
System slug used by mrext (e.g. |
system_name |
str | None
|
Human-readable system name (e.g. |
game |
str | None
|
Full path of the running game ROM, or |
game_name |
str | None
|
Basename of the game without extension, or |
hostname |
str | None
|
MiSTer hostname as reported by the Remote API. |
version |
str | None
|
mrext Remote version string. |
ip |
str | None
|
Primary IP address of the MiSTer device. |
ips |
list[str]
|
All IP addresses reported by the device. |
updated |
str | None
|
ISO-8601 timestamp of the last sysinfo update. |
dns |
str | None
|
DNS server address reported by the device. |
disk_total |
int | None
|
Total SD-card space in bytes (first disk). |
disk_used |
int | None
|
Used SD-card space in bytes (first disk). |
disk_free |
int | None
|
Free SD-card space in bytes (first disk). |
Source code in src/mister_fpga/client.py
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 | |
is_running_game
property
¶
is_running_game: bool
True when a real core/game (not the menu) is running.
mister_fpga.MisterWebSocketClient ¶
Reconnecting WebSocket client for real-time MiSTer Remote events.
Connects to the mrext Remote WebSocket endpoint and invokes a callback for every TEXT frame received. If the connection drops the client waits reconnect_delay seconds and reconnects automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
IP address or hostname of the MiSTer device. |
required |
port
|
int
|
mrext Remote port (default |
8182
|
session
|
ClientSession | None
|
Optional shared |
None
|
reconnect_delay
|
int
|
Seconds to wait before reconnecting after a
connection loss (default |
5
|
Source code in src/mister_fpga/websocket.py
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 | |
listen
async
¶
listen(on_message: Callable[[str], None | Awaitable[None]]) -> None
Run the reconnect loop, calling on_message for each TEXT frame.
Blocks until :meth:stop is called or the task is cancelled.
on_message may be a plain function or a coroutine function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_message
|
Callable[[str], None | Awaitable[None]]
|
Callable |
required |
Source code in src/mister_fpga/websocket.py
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 | |
stop ¶
stop() -> None
Signal the :meth:listen loop to exit after the current iteration.
Source code in src/mister_fpga/websocket.py
149 150 151 | |
mister_fpga.apply_ws_message ¶
apply_ws_message(message: str, status: MisterStatus, menu_path: str | None, index_state: tuple[bool, bool]) -> tuple[MisterStatus, str | None, tuple[bool, bool]]
Apply one WebSocket text frame to the current state triple.
This is a pure reducer — it never mutates its arguments. Pass it every
raw text frame received from :class:MisterWebSocketClient to keep a
local :class:~mister_fpga.MisterStatus in sync without polling the REST
API.
Understood prefixes (prefix:rest):
coreRunning— updates :attr:~mister_fpga.MisterStatus.core.gameRunning— updates :attr:~mister_fpga.MisterStatus.gameand :attr:~mister_fpga.MisterStatus.game_name.menuNavigation— updates menu_path.indexStatus— updates index_state(exists, in_progress).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Raw text frame received from the WebSocket. |
required |
status
|
MisterStatus
|
Current device-state snapshot. |
required |
menu_path
|
str | None
|
Current menu navigation path, or |
required |
index_state
|
tuple[bool, bool]
|
Tuple |
required |
Returns:
| Type | Description |
|---|---|
MisterStatus
|
A new |
str | None
|
change encoded in message. Unrecognised prefixes are passed through |
tuple[bool, bool]
|
unchanged. |
Source code in src/mister_fpga/websocket.py
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 | |
mister_fpga.MisterSSH ¶
Persistent asyncssh connection for MiSTer telemetry probes.
Maintains a single SSH connection that is re-established transparently on
failure. SSH telemetry is strictly best-effort: :meth:async_probe
always returns a dict (possibly empty) and never raises.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
IP address or hostname of the MiSTer device. |
required |
port
|
int
|
SSH port (default |
required |
username
|
str
|
SSH username (default |
required |
password
|
str
|
SSH password (often |
required |
Source code in src/mister_fpga/ssh.py
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 | |
async_probe
async
¶
async_probe() -> dict
Run the SSH probe command and return parsed telemetry.
Returns:
| Type | Description |
|---|---|
dict
|
Telemetry dict as returned by :func: |
dict
|
if the SSH connection or command fails. |
Source code in src/mister_fpga/ssh.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
async_close
async
¶
async_close() -> None
Close the underlying SSH connection if open.
Source code in src/mister_fpga/ssh.py
119 120 121 122 123 | |
mister_fpga.parse_ssh_probe ¶
parse_ssh_probe(raw: str) -> dict
Parse the batched SSH probe output into a telemetry dict.
The probe command (SSH_PROBE_CMD) concatenates five fields separated by
|||: active core name, uptime, load average, memory info, and firmware
timestamp. Any missing or malformed field is silently coerced to None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
str
|
Raw stdout string returned by running |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dict with the following keys: |
dict
|
|
dict
|
|
dict
|
|
dict
|
|
dict
|
|
Source code in src/mister_fpga/ssh.py
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 | |
mister_fpga.MisterConnectionError ¶
Bases: Exception
Raised when the MiSTer Remote API is unreachable or returns an error.
This exception wraps aiohttp.ClientError, TimeoutError, and
invalid-JSON responses so callers have a single exception type to catch.
Source code in src/mister_fpga/client.py
46 47 48 49 50 51 | |