mqttsensor
A Python package for sending sensor data over MQTT with message persistence and reconnection support.
Features
- MQTT client with TLS support
- Automatic message storage and resend on connection loss
- Configurable via TOML file
- Logging with loguru
Installation
pip install .
Configuration
Create a config.toml file in your project directory:
[mqtt]
broker = "localhost"
port = 1883
client_id = "your_client_id"
ca_certs = "ca.pem"
certfile = "cert.pem"
key = "key.pem"
max_times = 3
Usage
from mqttsensor.main import init_client
config, mqtt_client = init_client("config.toml")
mqtt_client.start()
# Send sensor data
mqtt_client.send_sensor_data(
measurement="temperature",
location="office",
sensor_id="sensor01",
unit="C",
value=23.5
)
mqtt_client.stop()
Testing
Run all tests with:
pytest
License
MIT License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mqttsensor-0.2.1.tar.gz
(23.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mqttsensor-0.2.1.tar.gz.
File metadata
- Download URL: mqttsensor-0.2.1.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19e3a326ba5242ca44061fb023dfbc68b968750e78e1fb1a8d14f2c2b38189e6
|
|
| MD5 |
c0c2a7e45f463e210372be5836f322e0
|
|
| BLAKE2b-256 |
39a6a4f906989605d79f2d82f3546d01cbd1d23f50e7ac51068d5983f340ac9f
|
File details
Details for the file mqttsensor-0.2.1-py3-none-any.whl.
File metadata
- Download URL: mqttsensor-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
530f04cea2166151e941472f0294bf9d71571119c6a19ca775e9d4cafd806976
|
|
| MD5 |
372aa3bc580305527d47a10342ab37f9
|
|
| BLAKE2b-256 |
5e4e53c29a9fcb7cacb2c9dca3c9cdeb9c7b9a46219845f595e318d4c79ca455
|