pyHM is a Python 3.5 implementation of simple home metering application based on SML (Smart Message Language), OBIS (Object Identification System) and SQLite. It receives SML telegrams from USB IR Write/Read interfaces, extracts OBIS informations from SML_GetListRes messages contained in a telegram, stores these informations in a SQLite database and logs all events.
- install Python 3.5.x
- install Python modules colorama, colorlog, pyserial and pyyaml, e.g. via pip
- clone the repository pyHM into any directory
- create a PEM key and certificate file into this directory, e.g. via
openssl req -new -newkey rsa:4096 -x509 -subj "/C=us/ST=florida/L=orlando/O= /OU= /CN= " -days 365 -nodes -keyout your_own_key.pem -out your_own_cert.pem
- edit pyHM.cfg to your needs
- start data acquisition
- open a command line and change dir into
- type
./pyHM_dattrc.sh start
orpyHM_dattrc.bat
whether you're on Linux or Windows
- start web server
- open a command line and change dir into
- type
./pyHM_websrv.sh start
orpyHM_websrv.bat
whether you're on Linux or Windows
- enjoy pyHM
- close web server
- set focus on the command line running web server and press
STRG+C
or - run
./pyHM_websrv.sh stop
in another terminal
- set focus on the command line running web server and press
- close data acquisition
- set focus on the command line running data acquisition and press
STRG+C
or - run
./pyHM_dattrc.sh stop
in another terminal
- set focus on the command line running data acquisition and press
- download Fedberry 27.1-beta1
- write image on a SD Memory Card
- place SD Memory Card in Raspberry 3
- start up Raspberry 3 and follow the instructions, e.g. configuring a root password, creating a user , ...
- login as user
- install Python 3.5.x modules colorama, colorlog, pyserial and pyyaml, e.g. via dnfdragora
- install Linux application screen, e.g. via dnfdragora
- configure a static IP address
- copy or checkout pyHM and all submodules into a directory in the home directory of
- create a PEM key and certificate file into this directory, e.g. via
openssl req -new -newkey rsa:4096 -x509 -subj "/C=us/ST=florida/L=orlando/O= /OU= /CN= " -days 365 -nodes -keyout your_own_key.pem -out your_own_cert.pem
- edit pyHM.cfg to your needs
- add the port configured in pyHM.cfg for the web server to the permanent configuration of the firewall
- create a file /usr/lib/udev/rules.d/97-hm.rules with following content
with , and relating to the USB parameters of your specific USB IR adaptor
# Meter01 SUBSYSTEMS=="usb", ATTRS{idVendor}=="<VID>", ATTRS{idProduct}=="<PID>", ATTRS{serial}=="<SERIAL>", MODE="0666", SYMLINK+="hm_<SERIAL>" # Meter02 SUBSYSTEMS=="usb", ATTRS{idVendor}=="<VID>", ATTRS{idProduct}=="<PID>", ATTRS{serial}=="<SERIAL>", MODE="0666", SYMLINK+="hm_<SERIAL>" # ...
- create a file /etc/systemd/system/pyHM_websrv.service with following content (as root)
[Unit] Description=pyHM web server Requires=network-online.target pyHM_dattrc.service After=network-online.target pyHM_dattrc.service [Service] Type=forking ExecStart=/usr/bin/screen -dmS pyHM_websrv /home/<USER>/<PYHM>/pyHM_websrv.sh start ExecStop=/home/<USER>/<PYHM>/pyHM_websrv.sh stop User=<USER> WorkingDirectory=/home/<USER>/<PYHM> [Install] WantedBy=multi-user.target
- create a file /etc/systemd/system/pyHM_dattrc.service with following content (as root)
[Unit] Description=pyHM data trace [Service] Type=forking ExecStart=/usr/bin/screen -dmS pyHM_dattrc /home/<USER>/<PYHM>/pyHM_dattrc.sh start ExecStop=/home/<USER>/<PYHM>/pyHM_dattrc.sh stop User=<USER> WorkingDirectory=/home/<USER>/<PYHM> [Install] WantedBy=multi-user.target
- edit in file /etc/selinux/config the value of key SELINUX to disabled (as root)
- call
systemctl enable pyHM_websrv.service
- call
systemctl enable pyHM_dattrc.service
- restart the Raspberry 3
- login as and start a shell or connect from the shell of another PC via
ssh <USER>@<IPADDR>
- call
screen -r pyHM_websrv
to attach the virtual shell wherepyHM_websrv
is running to the real shell; detach viaCtrl+a,d
- call
screen -r pyHM_dattrc
to attach the virtual shell wherepyHM_dattrc
is running to the real shell; detach viaCtrl+a,d
- logout or call
systemctl poweroff
orsystemctl reboot