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

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

sudo systemctl edit balance-subscriber.service

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.

Options

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.

Service control

Start the service

sudo systemctl start balance-subscriber.service

Stop the service

sudo systemctl stop 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"

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.1rc2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

balance_subscriber-0.0.1rc2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: balance_subscriber-0.0.1rc2.tar.gz
  • Upload date:
  • Size: 5.4 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.1rc2.tar.gz
Algorithm Hash digest
SHA256 e8f23fe17db7ce2e148bc8399d155b47bc39195f4aaa96184bc81d01aa0de19b
MD5 1eca751d2b214848deae0f4ce2ca41fb
BLAKE2b-256 528a0b2d8fc7f9479febe9c2a5bc9606f8d80e0bf43b6b8ce121ace5a51e7dd7

See more details on using hashes here.

Provenance

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

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

Attestations:

File details

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

File metadata

File hashes

Hashes for balance_subscriber-0.0.1rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 4b91ac2902c9b933ff9799bdd9cbb0eb33c897892b900ea315c0fab79602bc8f
MD5 125a1387ff9e3c3085a770fc450c5101
BLAKE2b-256 7e8d4c1869f8f92dbc1220398e2e00cff2be671e646213a49c8ba56020a6bbec

See more details on using hashes here.

Provenance

The following attestation bundles were made for balance_subscriber-0.0.1rc2-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