Package: pysmartmeter
pysmartmeterCollect data from Hichi Smartmeter akavolkszaehler.org(USB Version) and expose it via MQTT.Discussion:https://www.photovoltaikforum.com/thread/188160-pysmartmeter(de)In the end it can looks like the followingHome Assistantdashboard screenshot, usingMQTT integration:With my "eBZ DD3" energy meter by eBZ GmbH the values update live every second ;)Currently only energy meters that sendOBIS text protocolare supported! (Test this with./cli.py dump)TODO:#37 - Add support for SML (Smart Message Language) binary protocolquickstartInstall minimum requirements, e.g.:~$sudoaptinstallpython3-venvClone sources and install project:~$gitclonehttps://github.com/jedie/pysmartmeter.git
~$cdpysmartmeter
~/pysmartmeter$./cli.py--helpThe output of./cli.py --helplooks like:Usage: ./cli.py [OPTIONS] COMMAND [ARGS]...

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
│ --help      Show this message and exit.                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────╮
│ debug-settings               Display (anonymized) MQTT server username and password              │
│ debug-systemd-service        Just print the systemd service file content                         │
│ detect-serial                Just print the detected serial port instance                        │
│ dump                         Just dump serial output                                             │
│ publish-loop                 Publish current data via MQTT (endless loop)                        │
│ setup-systemd-service        Setup PySmartMeter systemd services and starts it.                  │
│ store-settings               Store MQTT server settings.                                         │
│ systemd-restart              Restart PySmartMeter systemd services                               │
│ systemd-status               Call systemd status of PySmartMeter services                        │
│ systemd-stop                 Stop PySmartMeter systemd services                                  │
│ test-mqtt-connection         Test connection to MQTT Server                                      │
│ version                      Print version and exit                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯Test if you Hichi Smartmeter with CP2102 USB to UART Bridge Controller will be found, e.g.:~/pysmartmeter$./cli.pydetect-serialMaybe you didn't have permissions to access the port, e.g.:~/pysmartmeter$./cli.pydump
...
try:/dev/ttyUSB0CP2102USBtoUARTBridgeController-CP2102USBtoUARTBridgeControllerUSBVID:PID=10C4:EA60
/dev/ttyUSB0filemode:0o20660
/dev/ttyUSB0userID:0/dev/ttyUSB0usergroupID:20/dev/ttyUSB0usergroup:'dialout'ERROR:[Errno13]couldnotopenport/dev/ttyUSB0:[Errno13]Permissiondenied:'/dev/ttyUSB0'...Fix fiy by add the user to the group, e.g.:sudousermod-a-Gdialout$USERpublish smartmeter data via MQTTYou have to store your MQTT settings (host, port, username, password) one time, e.g.:~/pysmartmeter$./cli.pystore-settingsThis will create a JSON file here:~/.pysmartmeterYou can test reading this settings file with:~/pysmartmeter$./cli.pydebug-settingsTest your MQTT settings with:~/pysmartmeter$./cli.pytest-mqtt-connectionSetup systemd service:~/pysmartmeter$sudo./cli.pysetup-systemd-serviceThis will create a systemd service that automaticly starts on every boot.Note: Before you start the systemd service, check if everything works correctly with./cli.py dumpand./cli.py publish-loopOtherwise you may start a services that will just deal wie gabage (e.g.: your energy meters speaks no OBIS text protocol) and restarts on and on again ;)Check if service is running:~/pysmartmeter$sudo./cli.pysystemd-statusIf everything is fine: Go to yourHome Assistant and check the MQTT integrationThe device discovery will be made automaticly.Start hacking~$gitclonehttps://github.com/jedie/pysmartmeter.git
~$cdpysmartmeter
~/pysmartmeter$./dev-cli.py--helpUsage: ./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.                                  │
│ fix-code-style              Fix code style of all pysmartmeter source code files via darker      │
│ install                     Run pip-sync and install 'pysmartmeter' 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                                               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯Backwards-incompatible changesv0.4.x -> v0.5.xWe split the CLI files into:./cli.py- Commands for end users./dev-cli.py- Commands for developersv0.2.x -> v0.3.xPackages changes:We switched frompoetrytopip-toolsMakefilewas removed"Renamed"cli.shtocli.pyTheMakefileis no longer needed, because "Bootstrapping" will be made, just by callcli.pyTo migrate, just remove the existing.venvand create a fresh one, e.g.:~$cdpysmartmeter
~/pysmartmeter$gitpulloriginmain
~/pysmartmeter$rm-Rf.venv
~/pysmartmeter$./cli.py--helpvarious linksDiscussion:https://www.photovoltaikforum.com/thread/188160-pysmartmeter(de)https://github.com/pyserial/pyserialhttps://github.com/eclipse/paho.mqtt.pythonhttps://github.com/eclipse/mosquittohttps://dewiki.de/Lexikon/OBIS-Kennzahlen(de) |https://www.promotic.eu/en/pmdoc/Subsystems/Comm/PmDrivers/IEC62056_OBIS.htm(en)https://www.photovoltaikforum.com/thread/145886-habe-lesk%C3%B6pfe-mit-usb-%C3%BCber/(de)https://www.heise.de/tests/Ausprobiert-Guenstiger-IR-Lesekopf-fuer-Smart-Meter-mit-Tastmota-Firmware-7065559.html(de)https://www.home-assistant.io