A small example package
Project description
Mqtt common library
Usage
from MqttLibPy import MqttClient, 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.9.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for mqttlibpy-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4baf58250c0e3e059cf7ebed0e916f2866aaf825051aec778574bb43b6665a89 |
|
MD5 | dcd6051b1e9ff0394e57acc80a3ff027 |
|
BLAKE2b-256 | 923872373c56918a4a823cd3584d6f838d2b36f4dd4e9161fad87d728c874e7b |