Get values from modbus energy meter to MQTT / HomeAssistant
Project description
energymeter2mqtt
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
Note: It's a good idea to use the /dev/serial/by-id/{your-device-id}
path as serial port, instead of /dev/ttyUSB1
Call udevadm info -n /dev/ttyUSB*
to get information about all USB serial devices and ls -l /dev/serial/by-id/
to see the existing links.
~$ 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 │
│ probe-usb-ports Probe through the USB ports and print the values from definition │
│ 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 tests and show coverage report. │
│ create-default-settings Create a default user settings file. (Used by CI pipeline ;) │
│ fix-code-style Fix code style of all cli_base source code files via darker │
│ install Run pip-sync and install 'cli_base' via pip as editable. │
│ mypy Run Mypy (configured in pyproject.toml) │
│ pip-audit Run pip-audit check against current requirements files │
│ publish Build and upload this project to PyPi │
│ 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
Built Distribution
File details
Details for the file energymeter2mqtt-0.4.0.tar.gz
.
File metadata
- Download URL: energymeter2mqtt-0.4.0.tar.gz
- Upload date:
- Size: 53.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8ae868137b86244909689370fb284366e328ea69a41bb717378f78ac24a8d12 |
|
MD5 | 39509e75255d58709c83d8553843583e |
|
BLAKE2b-256 | 9a6a99b3c91e4dfcf2fc1b86bd8be8d30336c95bbb8f5be4976f174bf69cf894 |
File details
Details for the file energymeter2mqtt-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: energymeter2mqtt-0.4.0-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0daec7adc9c2d25c15497bc73f03e04d0f9e8029ca4a651d5637835632d43059 |
|
MD5 | d29524bec320b289e3b4e787ef81c39d |
|
BLAKE2b-256 | 710e2cfabfcce021c6e681a22fd17af7cdb016577fca57c39a93162647e3373e |