Skip to main content

Get values from modbus energy meter to MQTT / HomeAssistant

Project description

energymeter2mqtt

tests codecov energymeter2mqtt @ PyPi Python Versions License GPL-3.0-or-later

Get values from modbus energy meter to MQTT / HomeAssistant

Energy Meter -> modbus -> RS485-USB-Adapter -> energymeter2mqtt -> MQTT -> Home Assistant

The current focus is on the energy meter "Saia PCD ALD1D5FD" However, the code is kept flexible, so that similar meters can be quickly put into operation.

Quick start

Overview:

  • Clone the sources
  • Create your config: ./cli.py edit-settings
  • Test: ./cli.py print-values
  • Setup and start MQTT publishing: sudo ./cli.py systemd-setup
~$ git clone https://github.com/jedie/energymeter2mqtt.git
~$ cd energymeter2mqtt
~/energymeter2mqtt$ ./dev-cli.py --help
Usage: ./cli.py [OPTIONS] COMMAND [ARGS]...

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
│ --help      Show this message and exit.                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────╮
│ debug-settings   Display (anonymized) MQTT server username and password                          │
│ edit-settings    Edit the settings file. On first call: Create the default one.                  │
│ print-registers  Print RAW modbus register data                                                  │
│ print-values     Print all values from the definition in endless loop                            │
│ publish-loop     Publish all values via MQTT to Home Assistant in a endless loop.                │
│ systemd-debug    Print Systemd service template + context + rendered file content.               │
│ systemd-remove   Stops the systemd service and removed the service file. (May need sudo)         │
│ systemd-setup    Write Systemd service file, enable it and (re-)start the service. (May need     │
│                  sudo)                                                                           │
│ systemd-status   Display status of systemd service. (May need sudo)                              │
│ systemd-stop     Stops the systemd service. (May need sudo)                                      │
│ version          Print version and exit                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

start development

~$ git clone https://github.com/jedie/energymeter2mqtt.git
~$ cd energymeter2mqtt
~/energymeter2mqtt$ ./dev-cli.py --help

dev CLI

Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]...

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
│ --help      Show this message and exit.                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────╮
│ check-code-style            Check code style by calling darker + flake8                          │
│ coverage                    Run and show coverage.                                               │
│ create-default-settings     Create a default user settings file. (Used by CI pipeline ;)         │
│ fix-code-style              Fix code style of all inverter source code files via darker          │
│ install                     Run pip-sync and install 'inverter' via pip as editable.             │
│ mypy                        Run Mypy (configured in pyproject.toml)                              │
│ publish                     Build and upload this project to PyPi                                │
│ safety                      Run safety check against current requirements files                  │
│ test                        Run unittests                                                        │
│ tox                         Run tox                                                              │
│ update                      Update "requirements*.txt" dependencies files                        │
│ update-test-snapshot-files  Update all test snapshot files (by remove and recreate all snapshot  │
│                             files)                                                               │
│ version                     Print version and exit                                               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

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

energymeter2mqtt-0.1.2.tar.gz (43.9 kB view details)

Uploaded Source

Built Distribution

energymeter2mqtt-0.1.2-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file energymeter2mqtt-0.1.2.tar.gz.

File metadata

  • Download URL: energymeter2mqtt-0.1.2.tar.gz
  • Upload date:
  • Size: 43.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for energymeter2mqtt-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b484f1b48006d0adfb5006005f640aee608e97875b03e26f968cb74ce80c8568
MD5 a4d4aef8715e4e3ae4d26c1b5ccbc995
BLAKE2b-256 b2a03b6084a0f3ed8866550e3b90f991842d6b5ea2e6d039a95d1660f23ef833

See more details on using hashes here.

File details

Details for the file energymeter2mqtt-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for energymeter2mqtt-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 16ecc359309c86dd8378ba6e44f0bf29863c81e183d49a16d7f51dcd19fa9853
MD5 8663a68d3991fcb43d8b2ad7fa25fc6b
BLAKE2b-256 3df95b9eae3f8314e11b16e0edde9256103a9f14542d37ab6f26ad2d71e49dc5

See more details on using hashes here.

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