Skip to main content

smart-meter-to-openhab

Pushing 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)

Installation

The 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 in install-poetry.sh

  1. Navigate to the folder where the virtual environment shall be created (e.g. your home dir):
cd ~
  1. Create virtual environment (this will create a new folder smart_meter_py_env):
python3 -m venv smart_meter_py_env
  1. Activate the virtual environment
source smart_meter_py_env/bin/activate
  1. Upgrade pip and setuptools
python3 -m pip install --upgrade pip setuptools
  1. Install smart-meter-to-openhab
pip install smart-meter-to-openhab
  1. Provide 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) (required)
OH_HOST='<http://your_ip:your_port'
#openhab user (or token) for login (optional)
OH_USER=''
#openhab password for login (optional)
OH_PASSWD=''
#current consumption openhab item (required)
OVERALL_CONSUMPTION_WATT_OH_ITEM='smart_meter_overall_consumption'
#other openhab item names (optional)
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'
ELECTRICITY_METER_KWH_OH_ITEM='smart_meter_electricity_meter'

NOTE: certificate verification is turned off, in case OH_HOST refers to an https address (since most openHAB instances do probably use self-signed certificates)

  1. Run smart-meter-to-openhab with e.g.
nohup smart_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.service and copy paste the following contents. Replace User/Group/ExecStart accordingly.

[Unit]
Description=smart_meter_to_openhab
Documentation=https://github.com/die-bauerei/smart-meter-to-openhab
After=network-online.target

[Service]
Type=simple
User=openhab
Group=openhab
UMask=002
Restart=always
RestartSec=5s
ExecStart=/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.target

Now execute the following commands to enable autostart:

sudo systemctl --system daemon-reload
sudo systemctl enable smart_meter_to_openhab.service

It is now possible to start, stop, restart and check the status of smart-meter-to-openhab with:

sudo systemctl start smart_meter_to_openhab.service
sudo systemctl stop smart_meter_to_openhab.service
sudo systemctl restart smart_meter_to_openhab.service
sudo systemctl status smart_meter_to_openhab.service

Development

Development is done in wsl2 on ubuntu 22.04. 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.

Setup

The project is using poetry for managing packaging and resolve dependencies. To install poetry call install-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 in vscode-settings. (Copy them to .vscode folder) Follow these instructions to enable proper linting and type checking.

Metadata

Release files for smart-meter-to-openhab 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smart-meter-to-openhab 0.5.3
File Size Uploaded Provenance Actions
smart_meter_to_openhab-0.5.3.tar.gz 12.2 kB Without provenance Details for smart_meter_to_openhab-0.5.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smart-meter-to-openhab 0.5.3
File Interpreter ABI Platform Actions
smart_meter_to_openhab-0.5.3-py3-none-any.whl Python 3 none any Details for smart_meter_to_openhab-0.5.3-py3-none-any.whl

Total release size: 26.0 kB

Release files / smart_meter_to_openhab-0.5.3.tar.gz

Download URL smart_meter_to_openhab-0.5.3.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5ebee6b0dec431c826a7a10a6fa1e086226012875a5ed356702a581cf459f600
BLAKE2b-256 checksum
How to use checksums
d423ff58dae63ab0a6e9f12f2b1968c95e72cf1184a6f7feedd9d9effe3649d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / smart_meter_to_openhab-0.5.3-py3-none-any.whl

Download URL smart_meter_to_openhab-0.5.3-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e12dc2ec5ae89da0cd496d6c13436b3b23ea59b0cc1567c515a49bd5db2d861
BLAKE2b-256 checksum
How to use checksums
0a5612cd24b78649ece548d1a660eba27cc2d75fb81eb7107d0578cb2dc65044
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Security for smart-meter-to-openhab 0.5.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page