Created
November 14, 2024 11:06
-
-
Save lin-ycv/14a8b091ed5d16ed9d519fa3ebc0caf7 to your computer and use it in GitHub Desktop.
Simple python script that sends a pause command to a Bambu printer over local MQTT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ssl | |
import paho.mqtt.client as mqtt | |
user = 'bblp' | |
printer={'ip': '<LAN-IP>', 'sn': '<SERIAL-NUMBER>', 'ac': '<ACCESS-CODE>'} | |
} | |
port = 8883 | |
command = '{"print": {"sequence_id": "0", "command": "pause"}}' | |
def topic(sn): | |
return f'device/{sn}/request' | |
client = mqtt.Client(client_id='ThisCanBeAnything',transport='tcp',protocol=mqtt.MQTTv311,clean_session=True) | |
client.username_pw_set(user,printer['ac']) | |
client.tls_set(tls_version=ssl.PROTOCOL_TLS, cert_reqs=ssl.CERT_NONE) | |
client.tls_insecure_set(True) | |
client.connect(printer['ip'],port) | |
client.publish(topic(printer['sn']), command) | |
client.disconnect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment