Package: smart-meter-to-openhab
smart-meter-to-openhabPushing data of ISKRA MT175 smart meter to openhab.
For a connection to the Smart meter you need a USB infrared adapter. There are several adapters on the market (e.g.https://weidmann-elektronik.de/Produkt_IR-Kopf.html) that just need to be pluged in. They are usually detected as a casual serial port (/dev/ttyUSB0)InstallationThe python package can be installed from PyPi (https://pypi.org/project/smart-meter-to-openhab/)
It as advisable to use the same python version as specfied in the pyproject.toml.
Follow the process ininstall-poetry.shNavigate to the folder where the virtual environment shall be created (e.g. your home dir):cd~Create virtual environment (this will create a new foldersmart_meter_py_env):python3-mvenvsmart_meter_py_envActivate the virtual environmentsourcesmart_meter_py_env/bin/activateUpgrade pip and setuptoolspython3-mpipinstall--upgradepipsetuptoolsInstall smart-meter-to-openhabpipinstallsmart-meter-to-openhabProvide environment variables. You can e.g. pass a .env file to smart-meter-to-openhab via the option--dotenv_path. Or provide them by any other means (e.g. in your ~/.profile).# Hostname incl. http(s)OH_HOST='<http://your_ip:your_port'#openhab user (or token) for login (optional)OH_USER=''#openhab password for login (optional)OH_PASSWD=''#openhab item names. Optional, but recommended :)PHASE_1_CONSUMPTION_WATT_OH_ITEM='smart_meter_phase_1_consumption'PHASE_2_CONSUMPTION_WATT_OH_ITEM='smart_meter_phase_2_consumption'PHASE_3_CONSUMPTION_WATT_OH_ITEM='smart_meter_phase_3_consumption'OVERALL_CONSUMPTION_WATT_OH_ITEM='smart_meter_overall_consumption'OVERALL_CONSUMPTION_WH_OH_ITEM='smart_meter_overall_consumption_wh'ELECTRICITY_METER_KWH_OH_ITEM='smart_meter_electricity_meter'NOTE: certificate verification is turned off, in caseOH_HOSTrefers to an https address (since most openHAB instances do probably use self-signed certificates)Run smart-meter-to-openhab with e.g.nohupsmart_meter_to_openhab--logfile~/smart_meter.log--verbose&Autostart after reboot and on failure##Create a systemd service by opening the file/etc/systemd/system/smart_meter_to_openhab.serviceand copy paste the following contents. Replace User/Group/ExecStart accordingly.[Unit]Description=smart_meter_to_openhabDocumentation=https://github.com/die-bauerei/smart-meter-to-openhabAfter=network-online.target[Service]Type=simpleUser=openhabGroup=openhabUMask=002Restart=on-failureRestartSec=5sExecStart=/usr/bin/bash-lc"/home/openhab/smart_meter_py_env/bin/smart_meter_to_openhab --logfile /home/openhab/smart_meter.log --verbose"[Install]WantedBy=multi-user.targetNow execute the following commands to enable autostart:sudosystemctl--systemdaemon-reload
sudosystemctlenablesmart_meter_to_openhab.serviceIt is now possible to start, stop, restart and check the status of smart-meter-to-openhab with:sudosystemctlstartsmart_meter_to_openhab.service
sudosystemctlstopsmart_meter_to_openhab.service
sudosystemctlrestartsmart_meter_to_openhab.service
sudosystemctlstatussmart_meter_to_openhab.serviceuhubctlThe USB infrared adapter sometimes seems to lose its connection. It helps to just unplug and again plug the adapter. The same can be achieved if you Power off and on usb ports. This can be configured by the argumentuhubctl. The current implementation powers off and on all usb ports on a raspberry pi (change it to your needs). The package uhubctl (https://github.com/mvp/uhubctl) can be installed viasudo apt install uhubctlon a debian based system.DevelopmentDevelopment is done in wsl2 on ubuntu 20.4.
Setting up the development environment on Windows is not supported. But in principal it could be setup as well since no OS specific functionalities are used.SetupThe project is usingpoetryfor managing packaging and resolve dependencies.
To install poetry callinstall-poetry.sh. This will install poetry itself as well as python and the required packages as a virtual environment in.venv.
Example settings for development in VS Code are provided invscode-settings. (Copy them to.vscodefolder)
Follow theseinstructionsto enable proper linting and type checking.