flashforge-python-api 1.5.0__py3-none-any.whl → 3.0.0__py3-none-any.whl

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.
Files changed (71) hide show
  1. flashforge/__init__.py +337 -233
  2. flashforge/_removed.py +65 -0
  3. flashforge/api/__init__.py +12 -18
  4. flashforge/api/constants/__init__.py +11 -11
  5. flashforge/api/constants/commands.py +18 -15
  6. flashforge/api/constants/endpoints.py +11 -11
  7. flashforge/api/misc/__init__.py +8 -8
  8. flashforge/api/network/__init__.py +11 -11
  9. flashforge/api/network/utils.py +71 -71
  10. flashforge/backends/__init__.py +80 -0
  11. flashforge/backends/connect.py +275 -0
  12. flashforge/backends/creator5_backend.py +191 -0
  13. flashforge/backends/dual_api_backend.py +170 -0
  14. flashforge/backends/dual_api_models.py +145 -0
  15. flashforge/backends/http_core.py +431 -0
  16. flashforge/backends/http_printer_backend.py +254 -0
  17. flashforge/backends/legacy_backend.py +436 -0
  18. flashforge/backends/printer_backend.py +217 -0
  19. flashforge/backends/types.py +125 -0
  20. flashforge/capabilities/__init__.py +98 -0
  21. flashforge/capabilities/models.py +67 -0
  22. flashforge/capabilities/palettes/__init__.py +28 -0
  23. flashforge/capabilities/palettes/ad5x_palette.py +70 -0
  24. flashforge/capabilities/palettes/creator5_palette.py +78 -0
  25. flashforge/capabilities/palettes/palette.py +54 -0
  26. flashforge/{api/controls/creator5_palette.py → capabilities/palettes/palette_snap.py} +226 -258
  27. flashforge/capabilities/printer_capabilities.py +145 -0
  28. flashforge/capabilities/registry.py +125 -0
  29. flashforge/capabilities/resolve_model.py +61 -0
  30. flashforge/discovery/__init__.py +39 -39
  31. flashforge/discovery/discovery.py +730 -763
  32. flashforge/exceptions.py +90 -51
  33. flashforge/models/__init__.py +52 -55
  34. flashforge/models/machine_info.py +540 -543
  35. flashforge/{api/controls/info.py → models/machine_info_parser.py} +35 -242
  36. flashforge/models/responses.py +119 -254
  37. flashforge/status/__init__.py +43 -0
  38. flashforge/status/printer_snapshot.py +396 -0
  39. flashforge/tcp/__init__.py +55 -54
  40. flashforge/tcp/a3_client.py +427 -427
  41. flashforge/tcp/a4_client.py +304 -304
  42. flashforge/tcp/ff_client.py +609 -590
  43. flashforge/tcp/gcode/__init__.py +15 -13
  44. flashforge/tcp/gcode/a3_gcode_controller.py +109 -109
  45. flashforge/tcp/gcode/gcode_controller.py +292 -308
  46. flashforge/tcp/gcode/gcodes.py +81 -99
  47. flashforge/tcp/gcode/legacy_gcode_controller.py +56 -0
  48. flashforge/tcp/parsers/__init__.py +27 -27
  49. flashforge/tcp/parsers/endstop_status.py +248 -248
  50. flashforge/tcp/parsers/location_info.py +83 -83
  51. flashforge/tcp/parsers/print_status.py +180 -180
  52. flashforge/tcp/parsers/printer_info.py +146 -146
  53. flashforge/tcp/parsers/temp_info.py +218 -218
  54. flashforge/tcp/parsers/thumbnail_info.py +274 -274
  55. flashforge/tcp/tcp_client.py +52 -12
  56. flashforge/threemf/__init__.py +40 -0
  57. flashforge/threemf/parser.py +560 -0
  58. flashforge/threemf/warnings.py +58 -0
  59. flashforge_python_api-3.0.0.dist-info/METADATA +184 -0
  60. flashforge_python_api-3.0.0.dist-info/RECORD +69 -0
  61. {flashforge_python_api-1.5.0.dist-info → flashforge_python_api-3.0.0.dist-info}/WHEEL +1 -1
  62. {flashforge_python_api-1.5.0.dist-info → flashforge_python_api-3.0.0.dist-info}/licenses/LICENSE +21 -21
  63. flashforge/api/controls/__init__.py +0 -17
  64. flashforge/api/controls/control.py +0 -413
  65. flashforge/api/controls/files.py +0 -210
  66. flashforge/api/controls/job_control.py +0 -880
  67. flashforge/api/controls/temp_control.py +0 -309
  68. flashforge/client.py +0 -609
  69. flashforge_python_api-1.5.0.dist-info/METADATA +0 -152
  70. flashforge_python_api-1.5.0.dist-info/RECORD +0 -49
  71. {flashforge_python_api-1.5.0.dist-info → flashforge_python_api-3.0.0.dist-info}/entry_points.txt +0 -0
flashforge/client.py DELETED
@@ -1,609 +0,0 @@
1
- """
2
- FlashForge Python API - Main Unified Client
3
-
4
- This module provides the main FlashForgeClient class that orchestrates both HTTP and TCP
5
- communication layers for controlling FlashForge 3D printers.
6
- """
7
-
8
- import asyncio
9
- import logging
10
- from dataclasses import dataclass
11
-
12
- import aiohttp
13
- from pydantic import ValidationError
14
-
15
- from .api.constants.endpoints import CAMERA_STREAM_PORT, Endpoints
16
- from .api.controls import Control, Files, Info, JobControl, TempControl
17
- from .api.controls.info import MachineInfoParser
18
- from .api.network.utils import NetworkUtils, json_from_response
19
- from .models import FFMachineInfo, Product, ProductResponse
20
- from .tcp import FlashForgeClient as TcpClient
21
- from .tcp import FlashForgeTcpClientOptions, PrinterInfo
22
- from .tcp.parsers.temp_info import TempInfo
23
-
24
- logger = logging.getLogger(__name__)
25
-
26
-
27
- @dataclass(slots=True)
28
- class FiveMClientConnectionOptions:
29
- """Optional connection and feature overrides for FiveMClient-compatible clients."""
30
-
31
- http_port: int | None = None
32
- tcp_port: int | None = None
33
- led_control_override: bool | None = None
34
- # Force HTTP-only transport (skip the TCP/8899 handshake). Set this for a
35
- # Creator 5 / Creator 5 Pro, which exposes no TCP service; otherwise it is
36
- # auto-detected from the firmware-reported model after `verify_connection`.
37
- http_only: bool | None = None
38
-
39
-
40
- class FlashForgeClient:
41
- """
42
- Main client for interacting with a FlashForge 3D printer.
43
-
44
- This class provides methods for controlling the printer, managing print jobs,
45
- retrieving information, and handling file operations. It orchestrates both
46
- HTTP and TCP communication layers to provide a unified interface.
47
- """
48
-
49
- def __init__(
50
- self,
51
- ip_address: str,
52
- serial_number: str,
53
- check_code: str,
54
- options: FiveMClientConnectionOptions | None = None,
55
- ):
56
- """
57
- Creates an instance of FlashForgeClient.
58
-
59
- Args:
60
- ip_address: The IP address of the printer
61
- serial_number: The serial number of the printer
62
- check_code: The check code for the printer
63
- """
64
- # Connection parameters
65
- self.ip_address = ip_address
66
- self.serial_number = serial_number
67
- self.check_code = check_code
68
-
69
- # Constants
70
- self._PORT = options.http_port if options and options.http_port is not None else 8898
71
- self._HTTP_TIMEOUT = 15.0
72
-
73
- # HTTP client state
74
- self._http_session: aiohttp.ClientSession | None = None
75
- self._http_client_event = asyncio.Event()
76
- self._http_client_event.set() # Not busy initially
77
-
78
- # FIFO mutex for command submission. asyncio.Lock hands the lock to
79
- # waiters in the order they asked for it. So command POSTs run one at
80
- # a time, in submission order. Scope: command POSTs only (/control,
81
- # /product, /printGcode). File uploads (/uploadGcode) and read/poll
82
- # POSTs (/detail, /gcodeList, /gcodeThumb) stay outside the lock. An
83
- # upload can run for minutes; pause and stop must never queue behind
84
- # one.
85
- self._command_lock = asyncio.Lock()
86
-
87
- # TCP client setup
88
- tcp_options = None
89
- if options and options.tcp_port is not None:
90
- tcp_options = FlashForgeTcpClientOptions(port=options.tcp_port)
91
- self.tcp_client = TcpClient(ip_address, tcp_options)
92
-
93
- # Control instances
94
- self.control = Control(self)
95
- self.job_control = JobControl(self)
96
- self.info = Info(self)
97
- self.files = Files(self)
98
- self.temp_control = TempControl(self)
99
-
100
- # Printer information cache
101
- self.printer_name: str = ""
102
- self.is_pro: bool = False
103
- self._is_ad5x: bool = False
104
- self.is_creator5: bool = False
105
- self.is_creator5_pro: bool = False
106
- self.firmware_version: str = ""
107
- self.firmware_ver: str = ""
108
- self.mac_address: str = ""
109
- self.flash_cloud_code: str = ""
110
- self.polar_cloud_code: str = ""
111
- self.camera_stream_url: str = ""
112
- self.lifetime_print_time: str = ""
113
- self.lifetime_filament_meters: str = ""
114
- self.product_info: Product | None = None
115
-
116
- # Control states
117
- self.led_control: bool = False
118
- self.filtration_control: bool = False
119
- self._detected_led_control: bool = False
120
- self._detected_filtration_control: bool = False
121
- self._led_control_override = (
122
- options.led_control_override
123
- if options and options.led_control_override is not None
124
- else None
125
- )
126
- self._apply_feature_overrides()
127
-
128
- # Transport selection. Creator 5 / Creator 5 Pro have no TCP/8899
129
- # service, so they must run HTTP-only. An explicit override wins;
130
- # otherwise http_only is auto-set from the detected model in
131
- # `verify_connection` / `cache_details`.
132
- self._http_only_override: bool | None = (
133
- options.http_only if options and options.http_only is not None else None
134
- )
135
- self._http_only: bool = bool(self._http_only_override)
136
-
137
- @property
138
- def is_ad5x(self) -> bool:
139
- """
140
- Indicates if the printer is an AD5X model.
141
-
142
- Returns:
143
- True if the printer is AD5X, False otherwise
144
- """
145
- return self._is_ad5x
146
-
147
- @property
148
- def http_only(self) -> bool:
149
- """
150
- Indicates whether the client should avoid the TCP transport.
151
-
152
- True for Creator 5 / Creator 5 Pro (no TCP/8899 service) or when an
153
- explicit ``http_only`` override was supplied at construction. When True,
154
- TCP-only operations are unavailable (see :meth:`can_use_tcp`).
155
-
156
- Returns:
157
- True if the client must operate over HTTP only
158
- """
159
- return self._http_only
160
-
161
- def can_use_tcp(self, op: str = "") -> bool:
162
- """
163
- Report whether a TCP-backed operation may be attempted.
164
-
165
- Returns False whenever this client is HTTP-only (e.g. a Creator 5 with
166
- no TCP/8899 service). TCP-delegating control/temperature methods check
167
- this and no-op (return False) instead of hanging on a dead socket.
168
-
169
- Args:
170
- op: Optional operation name, included in the warning log.
171
-
172
- Returns:
173
- True if TCP operations are permitted, False otherwise
174
- """
175
- if self._http_only:
176
- logger.debug("%s() unavailable: printer has no TCP control channel (HTTP-only).", op)
177
- return False
178
- return True
179
-
180
- def _update_http_only_from_model(self) -> None:
181
- """Recompute ``http_only`` from the detected model unless overridden."""
182
- if self._http_only_override is not None:
183
- self._http_only = bool(self._http_only_override)
184
- else:
185
- self._http_only = self.is_creator5 or self.is_creator5_pro
186
-
187
- async def __aenter__(self) -> "FlashForgeClient":
188
- """Async context manager entry."""
189
- await self._ensure_http_session()
190
- await self.initialize()
191
- return self
192
-
193
- async def __aexit__(
194
- self,
195
- exc_type: type[BaseException] | None,
196
- exc_val: BaseException | None,
197
- exc_tb: object,
198
- ) -> None:
199
- """Async context manager exit."""
200
- await self.dispose()
201
-
202
- async def _ensure_http_session(self) -> aiohttp.ClientSession:
203
- """
204
- Ensures that an HTTP session is available.
205
-
206
- Returns:
207
- The HTTP session instance
208
- """
209
- if self._http_session is None or self._http_session.closed:
210
- timeout = aiohttp.ClientTimeout(total=self._HTTP_TIMEOUT)
211
- self._http_session = aiohttp.ClientSession(timeout=timeout, headers={"Accept": "*/*"})
212
- return self._http_session
213
-
214
- @property
215
- def command_lock(self) -> asyncio.Lock:
216
- """
217
- The FIFO lock that serializes command-submission HTTP POSTs.
218
-
219
- Command POSTs (/control, /product, /printGcode) hold this lock while
220
- the request is in flight. asyncio.Lock serves waiters in arrival order,
221
- so concurrent commands run one at a time, first come first served.
222
- Uploads and read/poll requests never take this lock. So a long upload
223
- cannot delay a pause or stop command.
224
- """
225
- return self._command_lock
226
-
227
- async def initialize(self) -> bool:
228
- """
229
- Initializes the FlashForgeClient and verifies the connection to the printer.
230
-
231
- Returns:
232
- True if initialization is successful, False otherwise
233
- """
234
- connected = await self.verify_connection()
235
- if connected:
236
- return True
237
- logger.warning("Failed to connect to the printer.")
238
- return False
239
-
240
- @property
241
- def _http_client_busy(self) -> bool:
242
- """
243
- Legacy property to maintain internal API compatibility.
244
- Returns True if the client is busy (event is not set), False otherwise.
245
- """
246
- return not self._http_client_event.is_set()
247
-
248
- @_http_client_busy.setter
249
- def _http_client_busy(self, value: bool) -> None:
250
- """
251
- Sets the busy state using the event.
252
- True means busy (clear event), False means not busy (set event).
253
- """
254
- if value:
255
- self._http_client_event.clear()
256
- else:
257
- self._http_client_event.set()
258
-
259
- async def is_http_client_busy(self) -> bool:
260
- """
261
- Checks if the HTTP client is currently busy.
262
- Waits until the client is not busy before returning.
263
-
264
- Returns:
265
- False (always returns False after waiting, for compatibility)
266
- """
267
- await self._http_client_event.wait()
268
- return False
269
-
270
- def release_http_client(self) -> None:
271
- """Releases the HTTP client, allowing it to be used for new requests."""
272
- self._http_client_busy = False
273
-
274
- async def init_control(self) -> bool:
275
- """
276
- Initializes the control interface with the printer.
277
-
278
- This involves sending a product command and initializing TCP control.
279
-
280
- Returns:
281
- True if control initialization is successful, False otherwise
282
- """
283
- if await self.send_product_command():
284
- return await self.tcp_client.init_control()
285
- logger.warning("New API control failed; the product command was rejected.")
286
- return False
287
-
288
- async def dispose(self) -> None:
289
- """
290
- Disposes of the FlashForgeClient instance, stopping keep-alive messages
291
- and cleaning up resources.
292
- """
293
- # Stop TCP keep-alive and dispose. An HTTP-only client (e.g. Creator 5,
294
- # which has no TCP/8899 service) never opened a TCP socket, so skip the
295
- # cleanup handshake -- otherwise the logout send would attempt (and time
296
- # out on) a connection that was never established.
297
- if not self._http_only:
298
- if hasattr(self.tcp_client, "stop_keep_alive"):
299
- await self.tcp_client.stop_keep_alive(True)
300
- if hasattr(self.tcp_client, "dispose"):
301
- await self.tcp_client.dispose()
302
-
303
- # Close HTTP session
304
- if self._http_session and not self._http_session.closed:
305
- await self._http_session.close()
306
-
307
- self.camera_stream_url = ""
308
-
309
- async def detect_camera_stream(self, timeout_ms: int = 3000) -> str:
310
- """
311
- Probes the printer's known OEM camera endpoint.
312
-
313
- Falls back to a short GET when HEAD is unsupported so MJPEG servers
314
- that reject HEAD requests are still detected.
315
-
316
- Args:
317
- timeout_ms: Timeout for each probe attempt in milliseconds.
318
-
319
- Returns:
320
- The working camera stream URL, or an empty string if not detected.
321
- """
322
- probe_url = f"http://{self.ip_address}:{CAMERA_STREAM_PORT}/?action=stream"
323
- timeout = aiohttp.ClientTimeout(total=timeout_ms / 1000)
324
-
325
- if await self._probe_camera_stream_with_method("head", probe_url, timeout):
326
- return probe_url
327
-
328
- if await self._probe_camera_stream_with_method("get", probe_url, timeout):
329
- return probe_url
330
-
331
- return ""
332
-
333
- async def _probe_camera_stream_with_method(
334
- self,
335
- method: str,
336
- probe_url: str,
337
- timeout: aiohttp.ClientTimeout,
338
- ) -> bool:
339
- try:
340
- session = await self._ensure_http_session()
341
- request = session.head if method == "head" else session.get
342
-
343
- async with request(probe_url, timeout=timeout) as response:
344
- return self._is_valid_camera_probe_response(
345
- response.status, response.headers.get("Content-Type", "")
346
- )
347
- except Exception:
348
- return False
349
-
350
- @staticmethod
351
- def _is_valid_camera_probe_response(status: int, content_type: str | None) -> bool:
352
- if status != 200:
353
- return False
354
-
355
- normalized_content_type = (content_type or "").lower()
356
- return (
357
- normalized_content_type == ""
358
- or "multipart" in normalized_content_type
359
- or "video/x-mjpeg" in normalized_content_type
360
- )
361
-
362
- def cache_details(self, info: FFMachineInfo | None) -> bool:
363
- """
364
- Caches machine details from the provided FFMachineInfo object.
365
-
366
- Args:
367
- info: The FFMachineInfo object containing printer details
368
-
369
- Returns:
370
- True if caching is successful, False otherwise
371
- """
372
- if not info:
373
- return False
374
-
375
- # Cache all printer information
376
- self.printer_name = info.name or ""
377
- self.is_pro = info.is_pro
378
- self.firmware_version = info.firmware_version or ""
379
- self.firmware_ver = info.firmware_version.split("-")[0] if info.firmware_version else ""
380
- self.mac_address = info.mac_address or ""
381
- self.flash_cloud_code = info.flash_cloud_register_code or ""
382
- self.polar_cloud_code = info.polar_cloud_register_code or ""
383
- self.camera_stream_url = info.camera_stream_url or ""
384
- self.lifetime_print_time = info.formatted_total_run_time or ""
385
- self._is_ad5x = info.is_ad5x
386
- self.is_creator5 = info.is_creator5
387
- self.is_creator5_pro = info.is_creator5_pro
388
- # Refresh transport selection now that the model flags are cached.
389
- self._update_http_only_from_model()
390
-
391
- # Format filament usage
392
- filament_value = info.cumulative_filament if info.cumulative_filament is not None else 0.0
393
- self.lifetime_filament_meters = f"{filament_value:.2f}m"
394
- self._apply_feature_overrides()
395
-
396
- return True
397
-
398
- def get_endpoint(self, endpoint: str) -> str:
399
- """
400
- Constructs the full API endpoint URL.
401
-
402
- Args:
403
- endpoint: The specific API endpoint path
404
-
405
- Returns:
406
- The full URL for the API endpoint
407
- """
408
- return f"http://{self.ip_address}:{self._PORT}{endpoint}"
409
-
410
- async def verify_connection(self) -> bool:
411
- """
412
- Verifies the connection to the printer by retrieving machine details and TCP information.
413
-
414
- Returns:
415
- True if the connection is verified, False otherwise
416
- """
417
- try:
418
- # Get HTTP API response
419
- response = await self.info.get_detail_response()
420
- if not response or not NetworkUtils.is_ok(response):
421
- logger.warning("Failed to get a valid response from the printer API.")
422
- return False
423
-
424
- # Parse machine info from detail response
425
- machine_info = MachineInfoParser.from_detail(response.detail)
426
- if not machine_info:
427
- logger.warning("Failed to parse machine info from the /detail response.")
428
- return False
429
-
430
- # Detect http_only from the parsed model BEFORE touching TCP. The
431
- # Creator 5 / Creator 5 Pro expose no TCP/8899 service, so the M115
432
- # handshake would hang until the connect timeout. An explicit
433
- # override always wins.
434
- if self._http_only_override is not None:
435
- self._http_only = bool(self._http_only_override)
436
- else:
437
- self._http_only = machine_info.is_creator5
438
-
439
- # Get TCP printer information to check for Pro model
440
- tcp_info: PrinterInfo | None = None
441
- if not self._http_only:
442
- tcp_info = await self.tcp_client.get_printer_info()
443
- if tcp_info:
444
- if (
445
- "Pro" in tcp_info.type_name
446
- and not machine_info.is_pro
447
- and not machine_info.is_ad5x
448
- ):
449
- self.is_pro = True
450
- else:
451
- logger.warning(
452
- "Unable to get PrinterInfo from the TCP API; some features might "
453
- "not work."
454
- )
455
-
456
- # Cache the details
457
- return self.cache_details(machine_info)
458
-
459
- except Exception as error:
460
- logger.warning("Error in verify_connection: %s", error)
461
- return False
462
-
463
- async def send_product_command(self) -> bool:
464
- """
465
- Sends a product command to the printer to retrieve control states.
466
-
467
- This method holds the command lock while the request is in progress.
468
-
469
- Returns:
470
- True if the product command is sent successfully and valid data is received,
471
- False otherwise
472
- """
473
- payload = {"serialNumber": self.serial_number, "checkCode": self.check_code}
474
-
475
- try:
476
- session = await self._ensure_http_session()
477
- async with self._command_lock:
478
- async with session.post(
479
- self.get_endpoint(Endpoints.PRODUCT),
480
- json=payload,
481
- headers={"Content-Type": "application/json"},
482
- ) as response:
483
- if response.status != 200:
484
- return False
485
-
486
- data = await json_from_response(response)
487
-
488
- # Validate response structure
489
- if not NetworkUtils.is_ok(data):
490
- return False
491
-
492
- # Parse product response and set control states
493
- product_response = ProductResponse(**data)
494
- if product_response and product_response.product:
495
- product = product_response.product
496
- self.product_info = product
497
- self._detected_led_control = product.lightCtrlState != 0
498
- self._detected_filtration_control = not (
499
- product.internalFanCtrlState == 0 or product.externalFanCtrlState == 0
500
- )
501
- self._apply_feature_overrides()
502
- return True
503
-
504
- except ValidationError as error:
505
- # Distinct from a rejected check code, and it must not read as one:
506
- # the printer answered 200 with code 0, we simply could not parse
507
- # what it said. Callers treat a False return as bad credentials
508
- # (ff-5mp-hass surfaces it as "check code incorrect"), so the log
509
- # line is the only place the real cause can surface.
510
- logger.warning(
511
- "Could not parse the /product response; reporting the printer as "
512
- "unavailable rather than the credentials as rejected. This usually "
513
- "means the firmware added a field this library has not seen. %s",
514
- error,
515
- )
516
- return False
517
- except Exception as error:
518
- logger.warning("Error in send_product_command: %s", error)
519
- return False
520
-
521
- return False
522
-
523
- async def get_http_session(self) -> aiohttp.ClientSession:
524
- """
525
- Gets the HTTP session for making requests.
526
-
527
- Returns:
528
- The HTTP session instance
529
- """
530
- return await self._ensure_http_session()
531
-
532
- # Additional convenience methods for direct access to common operations
533
-
534
- async def get_printer_status(self) -> FFMachineInfo | None:
535
- """
536
- Gets the current printer status and information.
537
-
538
- Returns:
539
- FFMachineInfo object with current printer status, or None if failed
540
- """
541
- return await self.info.get()
542
-
543
- async def get_temperatures(self) -> TempInfo | None:
544
- """
545
- Gets current temperature readings from the printer.
546
-
547
- Returns:
548
- Temperature information from the TCP client
549
- """
550
- return await self.tcp_client.get_temp_info()
551
-
552
- async def home_all_axes(self) -> bool:
553
- """
554
- Homes all axes (X, Y, Z) of the printer.
555
-
556
- Returns:
557
- True if successful, False otherwise
558
- """
559
- return await self.control.home_axes()
560
-
561
- async def emergency_stop(self) -> bool:
562
- """
563
- Performs an emergency stop of the printer.
564
-
565
- Returns:
566
- True if successful, False otherwise
567
- """
568
- return await self.job_control.cancel_print_job()
569
-
570
- async def pause_print(self) -> bool:
571
- """
572
- Pauses the current print job.
573
-
574
- Returns:
575
- True if successful, False otherwise
576
- """
577
- return await self.job_control.pause_print_job()
578
-
579
- async def resume_print(self) -> bool:
580
- """
581
- Resumes a paused print job.
582
-
583
- Returns:
584
- True if successful, False otherwise
585
- """
586
- return await self.job_control.resume_print_job()
587
-
588
- def set_feature_overrides(self, *, led_control: bool | None = None) -> None:
589
- """Apply manual feature overrides for integrations that need UI-level capability control."""
590
- self._led_control_override = led_control
591
- self._apply_feature_overrides()
592
-
593
- def _apply_feature_overrides(self) -> None:
594
- """Apply any configured manual capability overrides to the cached client state."""
595
- self.led_control = (
596
- self._led_control_override
597
- if self._led_control_override is not None
598
- else self._detected_led_control
599
- )
600
- self.filtration_control = self._detected_filtration_control
601
-
602
- def __repr__(self) -> str:
603
- """String representation of the client."""
604
- return (
605
- f"FlashForgeClient(ip={self.ip_address}, "
606
- f"printer='{self.printer_name}', "
607
- f"pro={self.is_pro}, "
608
- f"firmware='{self.firmware_ver}')"
609
- )