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)
Changelog
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-1.0.0.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for mqttlibpy-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 354899dc55c14491ede31ca01c4de8d4ae1a5624c91a4f1bcb750f5d40b6c0a0 |
|
MD5 | 3ea454e1f3bd19d41bf05592fad3799a |
|
BLAKE2b-256 | d95d82d550fb83b2c0fc48a8fcace6ba63902443ef861afaa3ce5ae4a9ca0d58 |