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

Uploaded Source

Built Distribution

energymeter2mqtt-0.1.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: energymeter2mqtt-0.1.1.tar.gz
  • Upload date:
  • Size: 43.4 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.1.tar.gz
Algorithm Hash digest
SHA256 402a48f59823b27fcaaf1ba0449f0393a32eb6f8913070eeafd7688b1b7cc06e
MD5 52e4568daad5cf2833466aebbc20af73
BLAKE2b-256 5f6b0f26b651a803190773cc8985f789838b0989d73ac5c546a1362d19341216

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for energymeter2mqtt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cda3e77d8547696f58181ff51f44fd8a304a96db67895da0d2ac18f4cfb703b6
MD5 c7a4719a6cf141b0fecad72eb9aec9ae
BLAKE2b-256 60bac11481a2e633fd2661875c44c697e43380923564bde9bbbae3a31cfcf0d1

See more details on using hashes here.

Provenance

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