Closed bmedicke closed 3 years ago
So far I can't get %matplotlib widget
to work, it fails with: Error displaying widget: model not found
So far I can't get
%matplotlib widget
to work, it fails with:Error displaying widget: model not found
fixed by: jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib
samples for AMQP and MQTT with docker: https://github.com/bmedicke?tab=repositories&q=mqtt+OR+amqp
receive in JupyterLab notebook via paho:
cell 1 (setup & connection)
server = "broker.emqx.io"
import paho.mqtt.client as mqtt
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe("test")
# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(server, 1883, 60)
# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.
cell 2 (keeps running)
client.loop_forever()
send via mosquitto:
mosquitto_pub -h broker.emqx.io --topic 'test' --message 'test'
works great
alias sub="mosquitto_sub -u admin -P admin -v --topic 'lights/light1/lumen'"
alias pub="mosquitto_pub -u admin -P admin --topic 'lights/light1/lumen'"
alias long="mosquitto_pub -u admin -P admin -l --topic 'lights/light1/lumen'"
alias retain="mosquitto_pub -u admin -P admin -l --topic 'lights/light1/lumen' --retain"
alias will="mosquitto_pub -u admin -P admin --will-retain --will-topic 'lights/light1/lumen' --will-payload '0' -l --topic 'lights/light1/lumen'"
alias cl="mosquitto_pub -u admin -P admin --topic lights/light1/lumen --message '' --retain"
test AMQT (pika)requirements.txt