Python script to read power meter data from Easymeter meters and publish them via mqtt and/or into a sqlite database.
I'm using this script on a Raspberry Pi 4 with rasbian buster and the "IR Schreib/Lesekopf USB (Optokopf)" USB IR reader from Weidmann with an EASYMETER Q3DA. Maybe you have to change something for other setups.
- You need an optical interface e.g. https://shop.weidmann-elektronik.de/index.php?page=product&info=24 with serial output.
- Python3 is required (developed with 3.8.1)
- If you want to use the sqlite export, it is a little bit more complex, because the compiled python3 packages from apt-get have no sqlite support and you have to compile python on our own (see below)
With sqlite support
- run
compile_python_sqlite.sh
to compile python with sqlite support (takes long time!)
Without sqlite support
sudo apt-get install python3
Setup a virtual environment
- I recommend to create and use a virtual python environment for this script
- Open the easymeter-py path
python3.8 -m venv py-env
to create a virtual envsource py-env/bin/activate
to use virtual envpip3 install -r requirements.txt
to install python modules
Setup without virtual environment
pip3 install -r requirements.txt
to install python modules
- Edit
config.py
, set your device path ("dev"), mqtt settings, sqlite path... - Possible loglevels are: ERROR, DEBUG (others are currently not in use). Set loglevel to "DEBUG" for testing
- Set the loglevel in config.py to "DEBUG" and run
./easymeter-py.sh
- You should see a lot debug informations, but no Exceptions
- Check if the sqlite database has been created in the specified path (config.py)
- Check if the mqtt messages will be published correctly
- Exit with CTRL+C
- Remind to set loglevel back to "ERROR" (in config.py) to avoid huge log files
- Set the correct path for easymeter-py.sh in
easymeter-py.service
sudo cp easymeter-py.service /etc/systemd/system
to copy the service to your systemd pathsudo systemctl enable easymeter-py
to start easymeter-py automaticallysudo systemctl start easymeter-py
to start easymeter-py nowsudo systemctl status easymeter-py
to check if there are erorrs (1 error "reading failed" at the begining is ok)
For bugs or feature requests, please create an issue on github. "Star" or "Watch" the github repo if you like my work.
Regards, Arne Drees