-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimpletest.py
More file actions
46 lines (41 loc) · 1.77 KB
/
Copy pathsimpletest.py
File metadata and controls
46 lines (41 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import json
import os
import wifi
import bambulabs as bl
# Set up networking
print("Connecting to AP...")
wifi.radio.connect(
os.getenv("CIRCUITPY_WIFI_SSID"), os.getenv("CIRCUITPY_WIFI_PASSWORD")
)
print(f"Connected to {os.getenv('CIRCUITPY_WIFI_SSID')}")
print(f"My IP address: {wifi.radio.ipv4_address}")
device_id = os.getenv("DEVICE_ID")
printer = bl.BambuPrinter(device_id)
printer.connect()
status = printer.pushall()
if status is None:
print("Timed out waiting for pushall response.")
else:
print("--- Printer Status ---")
print(f"State: {status.gcode_state}")
print(f"File: {status.gcode_file}")
print(f"Job: {status.subtask_name}")
print(f"Progress: {status.print_percentage}%")
print(f"Remaining: {status.remaining_time} min")
print(f"Layer: {status.current_layer} / {status.total_layers}")
print(f"Print speed: {status.print_speed}")
print(f"Print error: {status.print_error_code}")
print(f"Nozzle temp: {status.nozzle_temperature} / {status.nozzle_temperature_target} C")
print(f"Bed temp: {status.bed_temperature} / {status.bed_temperature_target} C")
print(f"Chamber temp: {status.chamber_temperature} C")
print(f"Part fan: {status.part_fan_speed}")
print(f"Aux fan: {status.aux_fan_speed}")
print(f"Chamber fan: {status.chamber_fan_speed}")
print(f"Nozzle type: {status.nozzle_type}")
print(f"Nozzle diameter: {status.nozzle_diameter} mm")
print(f"WiFi signal: {status.wifi_signal}")
print(f"Light state: {status.light_state}")
print(f"Firmware version: {status.firmware_version}")
print()
print("--- Raw JSON ---")
print(json.dumps(status.raw))