33 lines
825 B
Python
33 lines
825 B
Python
import time
|
|
import bambulabs_api as bl
|
|
|
|
IP = '192.168.0.24'
|
|
SERIAL = '0309DA542101636'
|
|
ACCESS_CODE = '24679559'
|
|
|
|
if __name__ == '__main__':
|
|
print('Starting bambulabs_api example')
|
|
print('Connecting to BambuLab 3D printer')
|
|
print(f'IP: {IP}')
|
|
print(f'Serial: {SERIAL}')
|
|
print(f'Access Code: {ACCESS_CODE}')
|
|
|
|
# Create a new instance of the API
|
|
printer = bl.Printer(IP, ACCESS_CODE, SERIAL)
|
|
|
|
# Connect to the BambuLab 3D printer
|
|
printer.connect()
|
|
|
|
time.sleep(5)
|
|
|
|
# Get the printer status
|
|
status = printer.get_state()
|
|
print(f'Printer status: {status}')
|
|
rem_time = printer.get_time()
|
|
print(f'Remaining time {rem_time}')
|
|
percent = printer.get_percentage()
|
|
print(f'Percentage : {percent}')
|
|
|
|
# Disconnect from the Bambulabs 3D printer
|
|
printer.disconnect()
|