Skip to main content

Tenta Python Client

GitHub Workflow Status (with event) GitHub PyPI - Version PyPI - Python Version

This is a Python client library for Tenta, a sensor network management tool. This library uses Paho MQTT to communicate with a Tenta server connected to the same broker. The library provides type-safe interfaces to create an MQTT client, send messages (logs, measurements, and acknowledgments) to the server, and receive parameters (configuration messages) from the server.

Please contact Moritz Makowski if you have any questions or feedback that goes beyond the scope of a GitHub issue. The documentation for this client library is hosted at tenta-python-client.netlify.app.


Usage

Install it with Pip or Poetry:

pip install tenta
# or
poetry add tenta

Import and use it in your project:

import tenta

# connect to the MQTT broker

tenta_client = tenta.TentaClient(
    mqtt_host="test.mosquitto.org",
    mqtt_port=1884,
    mqtt_identifier="rw",
    mqtt_password="readwrite",
    sensor_identifier="81b...",
)

# publish log or measurement messages

tenta_client.publish(
    tenta.LogMessage(severity="info", message="Hello, to you!")
)
tenta_client.publish(
    tenta.MeasurementMessage(
        value={
            "temperature": 20.0, "humidity": 50.0,
            "pressure": 1013.25, "voltage": 3.3,
        },
    )
)

# wait for the client to publish all messages

tenta_client.wait_for_publish()

# check if a new configuration message has arrived

config_message: typing.Optional[
    tenta.ConfigurationMessage
] = tenta_client.get_latest_received_config_message()

# disconnect from the MQTT broker

tenta_client.teardown()

About

Why does this client exist? The Tenta specification of how a sensor should publish its data is simple, but to actually use Tenta in a project, one needs to write code that sends out these messages via a Python MQTT library, like Paho. This implementation code is relatively simple but needs to be written, documented, and tested in every single project that wants to use Tenta. This client library is thoroughly tested and documented. Hence, it makes onboarding to Tenta significantly easier.

Compatibility: Client library version 0.X.* will be compatible with the Tenta specification 0.X.*. Client library versions Y.*.* will be compatible with Tenta specification Y.*.*.

Adhering to semantic versioning: The same function calls will produce the same MQTT messages within non-breaking releases, i.e., the function call tenta_client.function(args) will produce the same MQTT messages in library versions 0.1.0 and 0.1.3 even if the Tenta specification provides a new feature in 0.1.3. New non-breaking features in Tenta will always be opt-in, i.e., tenta_client.function(args, enable_new_feature=True) will opt into that new feature. This way, the behavior of sensors does not change with the same code even if they upgrade to non-breaking client library releases (automatically).

Open-Source: Issues and Pull Requests are welcome! Every PR undergoes a review process to ensure quality and semantic versioning.

Testing: The library is statically typed and is strictly checked using Mypy. The tests cover publishing all message types, receiving configuration messages, and connecting to the MQTT broker with and without TLS encryption with valid and invalid connection details. The tests run for all supported Python versions (3.8, 3.9, 3.10, 3.11).

Documentation: The documentation is built using Nextra and Pydoc-Markdown.

Metadata

Release files for tenta 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tenta 0.1.5
File Size Uploaded
tenta-0.1.5.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tenta 0.1.5
File Interpreter ABI Platform
tenta-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 18.8 kB

Release files / tenta-0.1.5.tar.gz

Download URL tenta-0.1.5.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
04886c1dee70c93f80829f2caf3d706928d7c905f69f14c410741a6e7fc345d7
BLAKE2b-256 checksum
How to use checksums
8f6549c45955c7b02f9aba9ff38e7106f4ecfabdf40b835bee9296fc4c8ec0d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.17.3 CPython/3.12.3 Darwin/23.5.0

Release files / tenta-0.1.5-py3-none-any.whl

Download URL tenta-0.1.5-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a6d7ebf77b022c438beb54e842f8479a0fb0ff62744802247efe9bf9d37edb9
BLAKE2b-256 checksum
How to use checksums
2d1ebd895b1555cd2be448c850c477df8a6308e0217f9db767d5cfdbabc7fd63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.17.3 CPython/3.12.3 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page