Skip to main content

This is a demo for accessing data using MQTT and OpenSTS services

Project description

OpenSTS Python

This Python package provides a simple MQTT client using the paho-mqtt library, with built-in support for subscribing to multiple topics and handling messages. The package supports configuration via environment variables for enhanced security.

Installation

pip install opensts-py

Configuration

This package uses environment variables for credentials. You can configure these by creating a .env file in the project directory:

Environment variables

MQTT_BROKER=your_broker_address
MQTT_PORT=1883
MQTT_USERNAME=your_username
MQTT_SECRET_KEY=your_secret_key

Topics in MQTT

In OpenSTS, MQTT topics follow a specific format to allow for proper identification of devices and applications. This ensures that data published by a device under a particular application can be easily accessed by authorized users or services. The topic format looks like this applications/{Application ID}/devices/{Device ID} e.g applications/23/devices/12.

The topics that you want to subscribe should be in the following format in a file named topic.py.

#List of topics to subscribe
topics = [
        "applications/23/devices/12",
        "applications/24/devices/27"
        ]

Usage

The following is an example script which can be used to check how to subscribe to data topics from OpenSTS Services

from opensts_py import subscriber
from topic import topics # This imports topics list from the topic.py file


# Path to the .env file
env_file_path = "./.env"

# Subscribe to the topics
subscriber(env_file_path, topics)

Project details


Download files

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

Source Distribution

opensts_py-0.1.2.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opensts_py-0.1.2-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

Details for the file opensts_py-0.1.2.tar.gz.

File metadata

  • Download URL: opensts_py-0.1.2.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-45-generic

File hashes

Hashes for opensts_py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f6117eac28e800dcfa82da0bee93a2c1fa3627c411c2468cf323c26ff35a30af
MD5 8c15743678a225d17743d1fe367d520e
BLAKE2b-256 ded0b01b1847db9b3c62f470b13e266d4b0dedccbaefc3a1b4ba2b8cb5bac35a

See more details on using hashes here.

File details

Details for the file opensts_py-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: opensts_py-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-45-generic

File hashes

Hashes for opensts_py-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2e7faeb676fbf82412132ac18da1f0eab5a5593adfe90d2168e64f49f7b700b3
MD5 6c330ff98a343c9e8540b3f9e7d23053
BLAKE2b-256 4d9b737f245965e28915adb46cbf0dfc32b1291523a1ca19c2e905819d12237f

See more details on using hashes here.

Supported by

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