Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/panda-official/driftmqtt
A wrapper around Python Paho Mqtt library
https://github.com/panda-official/driftmqtt
Last synced: about 1 month ago
JSON representation
A wrapper around Python Paho Mqtt library
- Host: GitHub
- URL: https://github.com/panda-official/driftmqtt
- Owner: panda-official
- License: mpl-2.0
- Created: 2022-09-23T14:29:20.000Z (about 2 years ago)
- Default Branch: develop
- Last Pushed: 2023-10-10T09:56:56.000Z (about 1 year ago)
- Last Synced: 2024-11-06T20:08:15.588Z (about 2 months ago)
- Language: Python
- Size: 43.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Drift MQTT tools
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/panda-official/DriftMqtt/ci.yml?branch=develop)](https://github.com/panda-official/DriftMqtt/actions)
![PyPI](https://img.shields.io/pypi/v/drift-mqtt)
![PyPI - Downloads](https://img.shields.io/pypi/dm/drift-mqtt)A collection of helpers to work with MQTT:
* `Client` - wrapper around `paho.mqtt.Client` that correctly handles subscriptions after reconnect## Installation
```bash
pip install drift-mqtt
```Or get the latest version from GitHub:
```bash
pip install git+https://github.com/panda-official/DriftMqtt.git
```## Usage
Producer
```python
from drift_mqtt import Clientclient = Client('tcp://127.0.0.1:8000', 'client_id')
client.connect()
client.loop_start()
...
client.publish('topic', 'some message')
```
Consumer
```python
from drift_mqtt import Clientdef message_handler(message):
print('Got message ', message.payload, message.topic)client = Client('tcp://127.0.0.1:8000', client_id='test_subscriber')
client.subscribe('test_topic', message_handler)
client.connect()
client.loop_forever()
```For more details please check `examples/` folder