Graphs

Show graphs in OpenHAB

Some graphs, showing how different items change in function of the time, are pre-configred in the SD card supplied.

Using the Grafana dashboard manager at cm3-home.local:3000 the way the graph is displayed can be modified changing time period, refresh, item to show, math functions to apply and many other more:

How to plot graphs on a Habpanel

OpenHAB items can automatically be stored in the time series database InfluxDB. Grafana ships with very feature rich data source plugin for InfluxDB. Supporting a feature rich query editor, annotation and templating queries. For these reasons their installation scripts are included in the standard Openhabian distribution.

Both Grafana and InfluxDB can be easily installed using openhabian-config tool

  • 20 | Optional Components Choose from a set of optional software components
    • 24 | InfluxDB+Grafana A powerful persistence and graphing solution
InfluxDB

After adding DB and graphs components, the persistance service can be installed.

persistence-influxdb - 1.10.0

This is the link between OpenHAB items and InfluxDB.

Then create the table and set the InfluxDB permissions

openhabian@cm3-home:~$ influx
Connected to http://localhost:8086 version 1.5.0
InfluxDB shell version: 1.5.0
> CREATE DATABASE openhab_db
> CREATE USER admin WITH PASSWORD 'admin' WITH ALL PRIVILEGES
> CREATE USER openhab WITH PASSWORD 'openhab'
> CREATE USER grafana WITH PASSWORD 'grafana'
> GRANT ALL ON openhab_db TO openhab
> GRANT READ ON openhab_db TO grafana
> exit

Enable the authentication in the HTTP section

sudo nano /etc/influxdb/influxdb.conf

[http]
# Determines whether HTTP endpoint is enabled.
enabled = true

# The bind address used by the HTTP service.
bind-address = ":8086"

# Determines whether user authentication is enabled over HTTP/HTTPS.
auth-enabled = true


Restart InfluxDB service

 

sudo systemctl restart influxdb.service

GRAFANA

Grafana panel is accessible at address: cm3-home.local:3000
with default login admin:admin

Disable registration and enable anonymous users to access Grafana

sudo nano /etc/grafana/grafana.ini
[users]
# disable user signup / registration
allow_sign_up = false
...
[auth.anonymous]
# enable anonymous access
enabled = true

Link Grafana with InfuxDB

using the already defined accesses:

 

Link OpenHab with InfluxDB

Edit the services/influxdb.cfg file

Add the following lines:

# The database URL, e.g. http://127.0.0.1:8086 or https://127.0.0.1:8084 .
# Defaults to: http://127.0.0.1:8086
url=http://127.0.0.1:8086

# The name of the database user, e.g. openhab.
# Defaults to: openhab
user=openhab

# The password of the database user.
password=openhab

# The name of the database, e.g. openhab.
# Defaults to: openhab
db=openhab_db

# The retention policy to be used, needs to configured in InfluxDB
# Till v0.13: 'default', since v1.0: 'autogen'
retentionPolicy=autogen

 

Configure the item to be stored in InfluxDB and the update strategies
Edit the persistence/influxdb.persist file 

Strategies
{
everyMinute : "0 * * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"

default = everyChange
}

Items
{
L1P, L1V, L1C, L1F : strategy = everyMinute, everyChange, restoreOnStartup
Sonoff1Temp, Sonoff1Hum, Netatmo_Indoor_Co2, TempIntValue, Netatmo_Indoor_Humidity, Netatmo_Indoor_Temperature, Netatmo_Outdoor_Temperature, Netatmo_Outdoor_Humidity, Netatmo_Indoor_Pressure : strategy = everyMinute, everyChange, restoreOnStartup
SpeedtestResultPing, SpeedtestResultDown, SpeedtestResultUp : strategy = everyChange
}
Add the item to plot

Many different graphs can be created adding new dashboards and configuring stored items to plot

Using the sharing option it creates the link to be used in a frame widget to show the graph on the Habpanel


Links

 

Share