Skip to content

brupje/Pyohc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Openhab Chart (Pyohc) module

This module generates charts based on OpenHab items data using Mysql and Python. This allows you far more advanced charts then OpenHAB will allow. You can have multi-series, bar graphs, etc. Charts are generated by PyGal http://pygal.org, so you can see all options there. The output is a SVG file that can be shown in a sitemap using a Image Element Type. By generating the images in the background, there is also no delay in the App while waiting for a graph to render.

Tested with OpenHAB 2.4 on Openhabian

Multi-series power production

Multi-series power production with month average

Requirements

  1. An OpenHAB installation with Mysql Persistence enabled
  2. Python 3.5 with numpy, math, time
  3. pygal http://pygal.org,
pip3 install pygal cairosvg
  1. Mysql connector for Python
apt-get install python3-mysql.connector
  1. Cairo for rendering SVG to PNG
apt-get install libcairo2 libopenjp2
  1. You probably want to load timezones into the MySQL database:
mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root mysql

Installation

Extract this library onto the filesystem of the OpenHAB installation, for example in the userdata folder. Write a python file that generates the charts and execute using

/usr/bin/python3 /srv/openhab2-userdata/example.py

You can create a cronjob to generate charts regularly:

0 * * * * /usr/bin/python3 /srv/openhab2-userdata/charts_hourly.py
0 0 * * * /usr/bin/python3 /srv/openhab2-userdata/charts_daily.py

The images should be stored in the static files folder of OpenHAB, /etc/openhab2/html/ on Openhabian. To use the images in a sitemap add this to the sitemap:

Image url="http://<>/static/output.png"

Documentation

Find examples in the examples folder. These should teach you the basics. For information on the chart modules go to http://pygal.org/en/stable/documentation/index.html

About

Python chart module for Openhab smart home

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages