Package: tenta
Tenta Python ClientThis is a Python client library forTenta, a sensor network management tool. This library usesPaho MQTTto 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 contactMoritz Makowskiif you have any questions or feedback that goes beyond the scope of a GitHub issue. The documentation for this client library is hosted attenta-python-client.netlify.app.UsageInstall it with Pip orPoetry:pipinstalltenta# orpoetryaddtentaImport and use it in your project:importtenta# connect to the MQTT brokertenta_client=tenta.TentaClient(mqtt_host="test.mosquitto.org",mqtt_port=1884,mqtt_identifier="rw",mqtt_password="readwrite",sensor_identifier="81b...",)# publish log or measurement messagestenta_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 messagestenta_client.wait_for_publish()# check if a new configuration message has arrivedconfig_message:typing.Optional[tenta.ConfigurationMessage]=tenta_client.get_latest_received_config_message()# disconnect from the MQTT brokertenta_client.teardown()AboutWhy 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 version0.X.*will be compatible with the Tenta specification0.X.*. Client library versionsY.*.*will be compatible with Tenta specificationY.*.*.Adhering to semantic versioning:The same function calls will produce the same MQTT messages within non-breaking releases, i.e., the function calltenta_client.function(args)will produce the same MQTT messages in library versions0.1.0and0.1.3even if the Tenta specification provides a new feature in0.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 usingMypy. 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 usingNextraandPydoc-Markdown.