A small example package
Project description
Mqtt common library
Usage
from MqttLibPy.client import MqttClient
# from MqttLibPy.serializer import Serializer
# Both prefix and postfix are optional
client = MqttClient('myhost.com', 1883, prefix="myprefix")
# This function will be called when a message is received in the myprefix/myendpoint topic
@client.endpoint("myendpoint", force_json=True)
def myendpoint(mqtt_client, _, json_body):
print(json_body)
my_field = json_body["some_field"]
# Do stuff with my_field
# ..
# Return a response
my_response = {"another_field": "Ok!"}
# Sends message to topic "myendpoint"
client.send_message_serialized(my_response, "myendpoint", valid_json=True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mqttlibpy-0.0.12.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for mqttlibpy-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c9f37efdfb33b2cb4c5c5a2f44683e348036e859207312cbf2f88ba8f49a226 |
|
MD5 | 20de9570d3aa4fd278ee1890e98244fb |
|
BLAKE2b-256 | 0bf142220b372d15a2418dbb83e96f1a3b82dc1fbe42b48d71d84e757ea79d99 |