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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: balance_subscriber-0.0.1rc3.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.1rc3.tar.gz
Algorithm Hash digest
SHA256 dbd64a0f416b10b537922ee13f9ebd58805daac5e14b9cccd8874cd867f76732
MD5 82849c9c1d55204bb00667b0820efb10
BLAKE2b-256 f39e66ba9706d3ea165884ff961e41cdb379cc2af60904b81fcf5ddc9278d86b

See more details on using hashes here.

Provenance

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

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

Attestations:

File details

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

File metadata

File hashes

Hashes for balance_subscriber-0.0.1rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 a268fbb8bd6adc38b153ac0d38ba6583776e7fd5e80a34ad9da6c59944b04a25
MD5 498826c6c8f15f468a5084963d1e9176
BLAKE2b-256 c8164d11747b3be38749d0ab7298e5787c90945cf4749c8d9a7f6eb10f1bda30

See more details on using hashes here.

Provenance

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