Hello,
I have a problem saving number items calculated by a rule into a rrd4j persistence
The raw number item “GoogleMaps_duration_in_traffic_value” is stored correctly and can be shown in the chart of the Habpanel. The current converted number “GoogleMaps_duration_in_traffic_value_minutes” can be shown in Habpanel (Dummy Widget) but is not stored into the rrd4j.
So conversion works but storing or reading rrd4j does not work.
What am I doing wrong?
Here my configuration:
OpenHAB 2.3
Item to get Google Maps traffic duration in seconds
Number GoogleMaps_duration_in_traffic_value "Duration [%s]" (gGoogleMaps) { http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=Amsterdam&destinations=Rotterdam&language=NL&departure_time=now&traffic_model=best_guess&mode=driving&key=YOUR_API_KEY:300000:JSONPATH($.rows[0].elements[0].duration_in_traffic.value)]" }
Number GoogleMaps_duration_in_traffic_value_minutes "Duration [%f]" (gGoogleMaps)
Rule to convert seconds to minutes
rule "Calculate GoogleMaps_duration_in_traffic_value_minutes"
when
Item GoogleMaps_duration_in_traffic_value received update
then
val v = GoogleMaps_duration_in_traffic_value.state as DecimalType
GoogleMaps_duration_in_traffic_value_minutes.postUpdate(v / 60.0)
end
services/rrd4j.cfg
ctr5min.def=COUNTER,900,0,U,300
ctr5min.archives=AVERAGE,0.5,1,365:AVERAGE,0.5,7,300
ctr5min.items=GoogleMaps_duration_in_traffic_value,GoogleMaps_duration_in_traffic_value_minutes
persistence/rrd4j.persist
Strategies {
everyMinute : "0 * * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
}
Items {
GoogleMaps_duration_in_traffic_value : strategy = everyMinute, restoreOnStartup
GoogleMaps_duration_in_traffic_value_minutes : strategy = everyMinute, restoreOnStartup
}
Thanks for your help
Steffen