Skip to main content

Tests

MQTT subscriber

A service to listen for messages and save the data.

flowchart LR
publisher --> broker
broker --> subscriber
subscriber --> storage[(Storage)]

Installation

There is a Bash script to install this service: install.sh. There are further details below.

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

Reload all systemd unit files

sudo systemctl daemon-reload

Enable the service

sudo systemctl enable balance-subscriber.service

Configuration

Configure the service using the systemd configuration editor.

sudo systemctl edit balance-subscriber.service

This will create or edit 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. Each row defines an environment variable containing a configuration setting for the service.

[Service]
Environment="DATA_DIR=/tmp"

Then, restart the service as described in the service control section.

Options

The following options are available.

Setting Required Description Default
DATA_DIR Required The path of the target directory to serialise MQTT messages to.
HOST Optional MQTT broker host name localhost
PORT Optional MQTT broker port 1883
USERNAME Optional MQTT broker username
PASSWORD Optional MQTT broker password
TOPICS Optional MQTT topics #
QOS Optional Quality of service (0, 1, 2) 0
KEEP_ALIVE Optional MQTT broker keep-alive interval (time in seconds) 60
LOG_LEVEL Optional Logging verbosity WARNING
EXT Optional File extension for saved messages .bin

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

Usage

The app will run as a service in the background.

Service control

Start the service

sudo systemctl start balance-subscriber.service

Stop the service

sudo systemctl stop balance-subscriber.service

Restart the service

sudo systemctl restart balance-subscriber.service

Monitoring

View service status

sudo systemctl status balance-subscriber.service

View logs

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

Metadata

Release files for balance-subscriber 1.0.1

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

Source distribution (sdist)

Source distribution for balance-subscriber 1.0.1
File Size Uploaded
balance_subscriber-1.0.1.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for balance-subscriber 1.0.1
File Interpreter ABI Platform
balance_subscriber-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.8 kB

Release files / balance_subscriber-1.0.1.tar.gz

Download URL balance_subscriber-1.0.1.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1a13b4a979da6f0acba72a3438688770808708cdfe13867ddf5af01ee94cc532
BLAKE2b-256 checksum
How to use checksums
26f928e68fd6cc5112d6be4e08472bd07098ca83e46840874b337791bedd0013
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 15, 2025.

Transparency log

Release files / balance_subscriber-1.0.1-py3-none-any.whl

Download URL balance_subscriber-1.0.1-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23e215e336d38876d9b5d831db3f5f4a68d35d7df77c18699bb816228fac16ab
BLAKE2b-256 checksum
How to use checksums
b7b54920a07ec7a09ce0b026a54d908bc89dcd1f7096eef54f3b9432e2f6fa0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 15, 2025.

Transparency log
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