Skip to main content

MQTT listener to save data

Project description

Tests

MQTT subscriber

A service to listen for messages and save the data.

Installation

Install Python package

Create a virtual environment

sudo mkdir -p /opt/balance-subscriber
sudo python3 -m venv /opt/balance-subscriber/venv

Activate the virtual environment

source /opt/balance-subscriber/venv/bin/activate

Install this package

pip install --upgrade balance-subscriber

Set up service

Create a service account called balance-subscriber.

sudo useradd --system balance-subscriber

This user must have permissions to write to the target data directory.

Install the systemd service.

cp --verbose ./systemd/balance-subscriber.service /etc/systemd/system/balance-subscriber.service

Configure the service

systemctl edit myservice

This will create an override configuration file in the directory /etc/systemd/system/balance-subscriber.service.d. Edit this file to set the options for the service, such as the target data directory.

[Service]
Environment="DATA_DIR=/tmp"
Environment="HOST=localhost"

The available options are listed in the configuration section.

Configuration

The following options are available.

Setting Description
DATA_DIR The target directory to serialise MQTT messages to.
HOST MQTT broker host name
PORT MQTT broker port
TOPICS MQTT topics

These settings are specified in the configuration file for the systemd service as described in the installation section.

Usage

The app will run as a service in the background.

Monitoring

View service status

sudo systemctl status balance-subscriber.service

View logs

sudo journalctl -u balance-subscriber.service --since "1 hour ago"

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

balance_subscriber-0.0.1rc1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

balance_subscriber-0.0.1rc1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file balance_subscriber-0.0.1rc1.tar.gz.

File metadata

  • Download URL: balance_subscriber-0.0.1rc1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for balance_subscriber-0.0.1rc1.tar.gz
Algorithm Hash digest
SHA256 62ece4040c58a9b4790daa8f4152dff06fc28eea70fae0e8aac5b55afb6f05e5
MD5 77b33cc7256d70cca3c16b211ea9504b
BLAKE2b-256 d640835cf520a255cde10eb4027538ad60c890d0c93af42bf9f72cfb7d754696

See more details on using hashes here.

Provenance

The following attestation bundles were made for balance_subscriber-0.0.1rc1.tar.gz:

Publisher: publish.yaml on IoT-balance-project/balance-mqtt-subscriber

Attestations:

File details

Details for the file balance_subscriber-0.0.1rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for balance_subscriber-0.0.1rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b28bc2c8cceedf736b0900a03cd1667921995236b7f1aae46f2b0e69f3e50d3
MD5 8dde669f1e73e24dffc140e764b2c9bc
BLAKE2b-256 54ba340b387ded585734ce5caf396d4136311920cad6ec456aa2d305eef196d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for balance_subscriber-0.0.1rc1-py3-none-any.whl:

Publisher: publish.yaml on IoT-balance-project/balance-mqtt-subscriber

Attestations:

Supported by

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