MQTT listener to save data
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8f23fe17db7ce2e148bc8399d155b47bc39195f4aaa96184bc81d01aa0de19b |
|
MD5 | 1eca751d2b214848deae0f4ce2ca41fb |
|
BLAKE2b-256 | 528a0b2d8fc7f9479febe9c2a5bc9606f8d80e0bf43b6b8ce121ace5a51e7dd7 |
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
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
balance_subscriber-0.0.1rc2.tar.gz
- Subject digest:
e8f23fe17db7ce2e148bc8399d155b47bc39195f4aaa96184bc81d01aa0de19b
- Sigstore transparency entry: 150830804
- Sigstore integration time:
- Predicate type:
File details
Details for the file balance_subscriber-0.0.1rc2-py3-none-any.whl
.
File metadata
- Download URL: balance_subscriber-0.0.1rc2-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b91ac2902c9b933ff9799bdd9cbb0eb33c897892b900ea315c0fab79602bc8f |
|
MD5 | 125a1387ff9e3c3085a770fc450c5101 |
|
BLAKE2b-256 | 7e8d4c1869f8f92dbc1220398e2e00cff2be671e646213a49c8ba56020a6bbec |
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
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
balance_subscriber-0.0.1rc2-py3-none-any.whl
- Subject digest:
4b91ac2902c9b933ff9799bdd9cbb0eb33c897892b900ea315c0fab79602bc8f
- Sigstore transparency entry: 150830807
- Sigstore integration time:
- Predicate type: