Hi,
I’m running Openhab on a RaspberryPi3 and im logging temperature and humidity using a DHT11 sensor. Reading the sensor data using a python script and displaying it in the BasicUI works fine but no I also want to generate charts using rrd4j persistence.
What I already did:
- Installing RRD4j persistence
- Setting RRD4j as the default persistence in configuration - system
- Configured the rrd4j.cfg and rrd4j.persist file
This is my items-file: balcony.items
Group gTemperatur
Number Weatherstation_Temperature "Temperatur [%.1f °C]" <temperature> (gTemperature)
Number Weatherstation_Humidity "Luftfeuchtigkeit [%.1f %%]" <humidity> (gTemperature)
String temperature_out { channel="exec:command:weatherstation_temperature:output" }
String humidity_out { channel="exec:command:weatherstation_humidity:output" }
This is my persist-file: rrd4j.persist
Strategies {
// for rrd charts, we need a cron strategy, every Minute is a must have.
everyMinute : "0 * * * * ?"
// get the data reduced for older values to keep database small
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
default = everyChange
}
Items {
// additionally persist Items
gTemperature : strategy = everyMinute
}
This is my rules-file: balcony.rules
rule "Weatherstation Temperature"
when
Item temperature_out received update
then
Weatherstation_Temperature.postUpdate(
( ( Float::parseFloat(temperature_out.state.toString) as Number ) * 10 ) / 10
)
end
rule "Weatherstation Humidity"
when
Item humidity_out received update
then
Weatherstation_Humidity.postUpdate(
( ( Float::parseFloat(humidity_out.state.toString) as Number ) * 10 ) / 10
)
end
This is the rrd4j.cfg file:
# configure specific rrd properties for given items in this file.
# please refer to the documentation available at
# https://www.openhab.org/addons/persistence/rrd4j/
#
# default_numeric and default_other are internally defined defnames and are used as
# defaults when no other defname applies
#<defname>.def=[ABSOLUTE|COUNTER|DERIVE|GAUGE],<heartbeat>,[<min>|U],[<max>|U],<step>
#<defname>.archives=[AVERAGE|MIN|MAX|LAST|FIRST|TOTAL],<xff>,<steps>,<rows>
<defname>.items=weatherstation_temperature, weatherstation_humidity
This is the sitemap-file: balcony.sitemap
// Name of file and name of sitemap has to be the same
sitemap weatherstation label="Raspberry Pi Wetterstation"
{
Frame label="Temp+RH" {
Text item=Weatherstation_Temperature
Text item=Weatherstation_Humidity
}
Frame label="Chart" {
Chart item=gTemperature label="test" period=W refresh=1000
}
}
And finally this is the things -file: balcony.things
Thing exec:command:weatherstation_temperature "Temperatur" [command="python
/etc/openhab2/scripts/dht11-raspberrypi/dht11_example.py temperature", transform="REGEX((.*?))",
interval=60, timeout=10, autorun=true]
Thing exec:command:weatherstation_humidity "Luftfeuchtigkeit" [command="python
/etc/openhab2/scripts/dht11-raspberrypi/dht11_example.py humidity", transform="REGEX((.*?))",
interval=10, timeout=10, autorun=true]
So the question is what I am doing wrong? Did I set the wrong items in the rrd4j.persist and rrd4j.cfg file? Do I have do create the graph in the .sitemap file in another way?
Any help and suggestions is highly appreciated!