Trying to RRD4J my temperature sensors

Hi, my goal is to log my three temperature sensors to RRD4J and display them in a chart.
Seems not to work, since I am getting an empty chart and there is no evidence in the file system to the temperatures being logged. What am I doing wrong? Is anything needed to be done in the openhab.cfg? I am running 1.8.0-SNAPSHOT, the temperatures are being displayed correctly in a “String” item:

String Temp_Outside "Temp. Out [%s °C]" <temperature> (gMyGroup) {myBinding}
String Temp_Room1 "Temp. Room 1[%s °C]" <temperature> (gMyGroup) {myBinding}
String Temp_Room2 "Temp. Room 2[%s °C]" <temperature> (gMyGroup) {myBinding}

My rrd4j.persist:

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

    // if no strategy is specified for an item entry below, the default list will be used
    default = everyChange
}

Items {
    Temp_* : strategy = everyMinute, restoreOnStartup
}

The openhab.log notes, that this is being read upon startup:

2015-08-31 22:40:26.402 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.8.0).
2015-08-31 22:40:54.846 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2015-08-31 22:40:56.279 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2015-08-31 22:41:05.696 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'

My addons-folder contains the following persistency-addons:

-rw-r--r-- 1 root root   6194 Aug 30 00:13 org.openhab.persistence.exec-1.8.0-SNAPSHOT.jar
-rw-r--r-- 1 root root   7415 Aug 30 00:13 org.openhab.persistence.logging-1.8.0-SNAPSHOT.jar
-rw-r--r-- 1 root root 624568 Aug 30 00:13 org.openhab.persistence.rrd4j-1.8.0-SNAPSHOT.jar

I doubt that RRD works with strings - why aren’t you using a number for the items?

Chris

Because my binding seems to work with strings only. If I change the item to

Number Temp_Outside "Temp. Out [%.1f °C]" <temperature> (gMyGroup) {myBinding}

it doesn’t show a value anymore :frowning:

If it’s a binding you’ve written, then just convert the state to a number… Something along the following lines should do it…

String text = "12.34";
return DecimalType.valueOf(text);

One way or another, you’ll need to convert this to a number, or it won’t be very useful.

Take a look at your rrd4j.persist: I’m quite sure that the asterisk in items is used to denote group items. I think a * cannot be used as a wildcard for item names.

I don’t think so! I use the Asterisk in my persist files - admittedly by itself as I log everything and it doesn’t log only group items!

The wiki shows the following -:

// persist all items once a day and on every change and restore them from the db at startup
* : strategy = everyChange, everyDay, restoreOnStartup

// additionally, persist all temperature and weather values every hour
Temperature*, Weather* : strategy = everyHour

This indicates that Temperature* will log all temperatures.

I’m reasonably sure that the problem is that strings can not be persisted in RRD (there may be other problems as well, but it won’t work until numbers are used).

The wiki page says that a single single asterisk selects all items in the system, but a name followed by an asterisk stands for a group item:

* - this line should apply to all items in the system.
<itemName> - a single item identified by its name. This item can be a group item, but note that only its own (group) value will be persisted, not the states of its members.
<groupName>* - all members of this group will be persisted, but not the group itself. If no strategies are provided, the default strategies that are declared in the first section are used. An alias can be optionally provided, if the persistence service requires special names (e.g. a table to use in a database, a feed id for an IoT-service etc.)

The author of the question tries to persist items based on a wildcard match on Temp_*, which is not a group in his item definitions. I think gMyGroup* : strategy = everyMinute, restoreOnStartup should work here.

Fair point, but I don’t think this will completely stop it working as the default strategy would also result in data being persisted (although the everyChange strategy will not be reliable for RRD as it needs everyMinute, but it would still persist data).

I still think the initial problem is that RRD will not log strings…

I too had this confusion with the asterisk being used as the group identifier (and personally think it is very counter intuitive). The setup in the Wiki is using the notion that the items are added to the groups called Temperature and Weather when they are created… not that it is referencing all items starting with Temperature or Weather.

Regardless of what RRD can store… I don’t see how one can imagine graphing a string value.

I had the same problem and solved it:

Indeed, the documentation is correct in saying that all members of a group are persistent if entered by groupname* : strategy = xx

So this means that if you have temp sensors like:

Number TempX (grouptemps) ..... Number TempY (grouptemps) ..... Number TempZ (grouptemps) .....

Your rrd4j line needs to be like this:

grouptemps* : strategy = everyMinute, restoreOnStartup

But the most important thing is that you need to declare your group explicitly in an items file, something like:

Group grouptemps

If you omit this, it doesn’t work

Tested this on OH 1.7.1

1 Like

I recently encountered a similar issue and found this topic on Google.

For some reason the °C is causing troubles. Since other units are working properly (for e.g. ``%`), I guess the little circle is the problem.

So this doesn’t work:

Number Temp_Outside "Temp. Out [%.1f °C]" <temperature> (gMyGroup) {myBinding}

What works however is:

Number Temp_Outside "Temp. Out [%.1f]" <temperature> (gMyGroup) {myBinding}

When editing your item definition, be sure to delete the according persistence file as well, since it is already contaminated with the little °C bug at this time.
In this example: Shut OpenHAB down, delete <OPENHAB_HOME>/etc/rrd4j/Temp_Outside.rrd and bring the system back up again.

I wonder if this works:

Number Temp_Outside “Temp. Out [%.1f] °C” (gMyGroup) {myBinding}

Since now the Number is a number with no string [%.1f] this is a string [%.1f °C]

Just a possible observation

tom

I’ll try but according to the examples you put the unit inside of the brackets

I was able to try it with the mysql binding and in both cases a number was stored into the db.

I was comparing the item definitions to the way other pattern matching works, in for example regex

I was wrong.

I wonder what meaning of the brackets is…

I had a similar issue, where my charts were plotted very intermittent. A few values were logged, others not, seemingly completely random.

The problem was with this config:

Strategies {
        everyMinute : "0 * * * * ?"
        everyHour       : "0 0 * * * ?"
        everyDay        : "0 0 0 * * ?"
        default = everyChange
}
Items {
        * : strategy = everyChange, restoreOnStartup
        TEMP* : strategy = everyMinute
        HUM* : strategy = everyMinute
}

As soon as I switched order it started working:

Strategies {
        everyMinute : "0 * * * * ?"
        everyHour       : "0 0 * * * ?"
        everyDay        : "0 0 0 * * ?"
        default = everyChange
}
Items {
        TEMP* : strategy = everyMinute
        HUM* : strategy = everyMinute
        * : strategy = everyChange, restoreOnStartup
}

I guess that on the first matching line, that is whats logged, and no further lines are read. Resulting in me only seeing the dots in the charts where a change actually happened.

Charts need at least one point every minute, so only logging on change is not enough.
Although my issue was with the openhab2 persistent binding, it might be the same in openhab1.

Hope this can help someone.
/Tobias

1 Like

Help it did indeed! Getting a single dot on my charge was an improvement over nothing at all!

Thanks.