Pushing data of ISKRA MT175 smart meter to openhab
Project description
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
- Navigate to the folder where the virtual environment shall be created (e.g. your home dir):
cd ~
- Create virtual environment (this will create a new folder smart_meter_py_env):
python3 -m venv smart_meter_py_env
- Activate the virtual environment
source smart_meter_py_env/bin/activate
- Upgrade pip and setuptools
python3 -m pip install --upgrade pip setuptools
- Install smart-meter-to-openhab
pip install smart-meter-to-openhab
- Provide needed 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 or ip (https is not supported at the moment)
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
PHASE_1_CONSUMPTION_OH_ITEM='smart_meter_phase_1_consumption'
PHASE_2_CONSUMPTION_OH_ITEM='smart_meter_phase_2_consumption'
PHASE_3_CONSUMPTION_OH_ITEM='smart_meter_phase_3_consumption'
OVERALL_CONSUMPTION_OH_ITEM='smart_meter_overall_consumption'
ELECTRICITY_METER_OH_ITEM='smart_meter_electricity_meter'
- Run smart-meter-to-openhab with e.g.
nohup smart_meter_to_openhab --logfile ~/smart_meter.log --verbose &
Autostart after reboot
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
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 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.
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.
Project details
Release history Release notifications | RSS feed
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
Hashes for smart_meter_to_openhab-0.1.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b991577de43f6c69c5ba61d739601452d12d95030f4e5a1302cd1cb1dfd75889 |
|
MD5 | dab20b42c5c5ef146b6f8a71825eacf6 |
|
BLAKE2b-256 | 768b4b30f9a66a748cef3591e77c750535a9782738bcc21f889a7c2b59d220d9 |
Hashes for smart_meter_to_openhab-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dedc45095ebdfe97be3e1ba357df5636d167c2adb760dc8d7c3eec89539d9758 |
|
MD5 | 18d71a522adef2fcd368ee1d15b0e8af |
|
BLAKE2b-256 | 246ab9480348cbe90987b8327e2a7edeac50b36b2d0569087f29066daa351b77 |