Skip to main content

Simple MQTT client implementation that fits nalkinscloud projects

Project description

nalkinscloud-mqtt-python-client

MQTT Client package for nalkinscloud project usage

Usage

## activate package logging by:
# logging.getLogger('nalkinscloud_mqtt_python_client')

from nalkinscloud_mqtt_python_client.mqtt_handler import MQTTClient

client = MQTTClient(broker_host="mosquitto.alpha.nalkins.cloud",
                    broker_port=8883,
                    broker_cert=None,
                    broker_tls=True,
                    broker_tls_skip=True)


# This is the event handler method that receives the Mosquito messages
def on_message(client, userdata, message):
    print("message received: {}".format(message.payload.decode('UTF-8')))

# this client will have default 'on_connect' function, but a custom 'on_message' function
client.init_device(device_id='some_device_id', device_type='sensor', device_password='none',
                   qos=0, subscription_update="status", on_message_func=on_message)
client.connect()
client.subscribe("test_dht_device_id/dht/temperature", 2)
client.subscribe("test_dht_device_id/dht/humidity", 2)

# Start the MQTT Mosquito process loop
client.do_loop_forever()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page