[SOLVED] OH2, Persistance, Charts, Influxdb, mapdb and initial questions

openhabian (i.e. RaspberryPi)
openHAB 2.5.0~S1507-1 (Build #1507)

I have mapdb set up to persist item values between restarts.

But, I’d like to get some charts going.

If I install influx, does that replace mapdb? Can I continue using mapdb to persist values?

When I go to PaperUI to Extensions and select Persistance, it lists InfluxDB (V1.0) 1.14.0.SNAPSHOT. Is this the latest version? (A lot of the other Extensions (like bindings) seem to have 2.5 snapshot)

Also, when I look at:

It shows:

Chart [item=<itemname>]...

Does itemname refer to an item I’ve got defined in an .items file?

When I add the following to my .sitemap:

Frame label="Room Temp" {
        Chart item=ms6_temp_short icon="temperature" refresh=30000

Visual Studio Code shows this in the PROBLEMS tab:

rule ruleChart failed predicate: {getUnorderedGroupHelper().canLeave(grammarAccess.getChartAccess().getUnorderedGroup_1())}?

Not sure what that means…(ms6_temp_short is a valid item, but I’ve not set up the influxdb at this point)

Also, is it still required to got to openhabian-config and install Influx/Grafana or is that done via PaperUI/ Extensions?


1 Like

MapDB is just for the restart, it saves only the last state of an item and can therefore be used for all your items ( which you should do with other databases).
IMHO all persistence services are OpenHab1 services. So, yes that one should be good.
Yes the “item=…” is expecting an itemname, either defined by your items file or one automatically created by PaperUI.
That warning sounds to me as if it is coming from the rule-file " ruleChart".

Lastly on your question regarding influxdb :


  • Understood, mapdb only stores last value of item.
  • and is used for all items.

but, I don’t understand: ( which you should do with other databases)
Use other db’s for all data, instead of mapdb?
Or use others to persist data for history?
Confused. :blush:

So, this is something VSC is missing and may not be an error to OH?

Well, I was reading this tutorial:

And, I thought it looked a bit old and may have changed for OH2. But your link seems to mirror what the tutorial does.


MapDB COULD be used for all items, and the following bracket is missing the NOT, one should not persist all items in a database that stores over a large timeframe, because that is wasting storage-space.
You should only store those items which you have a real interest in.

Regarding VSC, do you have such a rule file? Then post it’s contents. But VSC is giving a warning, not an error!

Technically, VSC lists it in the PROBLEM tab, so yes, not an error.

No, I’ve never added anything to VSC.

I’m guessing ruleChart is something that defines syntax checking in the VSC syntax rules for OH.
But, that’s a WAG on my part. :wink:

I’ve now got a working InfluxDB and it is persisting some values. Tested with Grafana. :slightly_smiling_face:

How does one reference the persisted values in a .sitemap?

As shown previously in my .sitemap:

Frame label="Room Temp" {
        Chart item=ms6_temp_short icon="temperature" refresh=30000

Throws a warning in the OH events log when I save the file, so VSC must know something.

How does a site map chart know which db to select the data from? (Now that I have both mapdb and influxdb, and the default (in PaperUI) is set to mapdb)

When you have two databases for persistence, you need to make a choice as to which is the default service. In your case you have set it to mapdb, which means that your chart (without any further info) will still try to use mapDB, which of course does not work, as mapDB stores only exactly one value per item. You have two choices that depend on your comfort level:

  1. switch to influxDB as default service
  2. tell your chart explicitly where to pull data from (also described in the docs)
Frame label="Room Temp" {
        Chart item=ms6_temp_short icon="temperature" refresh=30000 service="influxdb"

The root problem is when I add that line (even with the addition of a service) I get the following when I save it:

[WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'default.sitemap' has errors, therefore ignoring it: [36,5]: rule ruleChart failed predicate: {getUnorderedGroupHelper().canLeave(grammarAccess.getChartAccess().getUnorderedGroup_1())}?

A similar message as shown in VSC.

Sorry never seen this type of error and the only thing that comes to mind is paring it back to basics:

  • make sure that nothing else in your sitemap is wrong…maybe make a new sitemap, just with this chart
  • delete all other entries (refresh, icon, etc) just to make sure that you do not get something weird from somewhere else
  • you are running a snapshot, maybe it is not as stable as desired; go back to 2.5M1; I have a few charts like yours in my sitemap and it runs there without issues.

No and yes. You can have as many persistence add-ons installed as you want. I use InfluxDB for charting and MapDB for restoreOnStartup.

Yes. All of the Persistence add-ons are 1.x version add-ons. If it’s listed in PaperUI, it is the latest version of that add-on for that version of OH.

Or defined through PaperUI.

It has other uses too. For example, if you have an Item that you only ever need the lastUpdate time, MapDB is a good choice.

It doesn’t always make sense to restore all Items on startup. Sometimes it is better to allow an Item to remain NULL rather than to populate it with stale and possibly incorrect data. Other times it is better to recalculate the value during the System started Rule rather than restore some old and possibly incorrect value.

It all depends on personal preference and your use case. RRD4J is a great database to choose for numeric data where it is OH that the precision of the values stored can degrade a bit as the data gets older. But in exchange for the data becoming less precise as it ages you get a database that never grows larger no matter how much data you store in it.

InfluxDB, MariaDB, MongoDB, etc are great choices for exposing historic data to external tools or for charting. Which one to choose is largely a matter of preference and compatibility with other tools you want to use with the data (e.g. Grafana).

No, it’s still valid except for one thing. Grafana doesn’t really support generation of static images any longer. Everything else is valid.

See InfluxDB+Grafana persistence and graphing

Hmmm. I wonder if it is expecting a Group instead of a single Item. Most of the time we have more than one Item we want on the same chart and to do that we use a Group containing all the Items you want to chart. Maybe support for charting a single Item is broken?

VSC uses OH itself to check the code so you should see the same error in both places. It’s the same parsing code that is creating the error.

I added a group roomtemps and added ms6_temp_short item to it.

I then changed the .sitemap to:

Frame label="Room Temp" {
        Chart item=roomtemps icon="temperature" refresh=30000 service="influxdb"

Same warning.

As for using Grafana. I created a panel and tried this in the .sitemap:

Frame label="Room Temp" {
        Image refresh=30000 url="http://openhabianpi:3000/d/q3K-5YiRz/my-first-dashboard?orgId=1&tab=axes&from=now-8h&to=now"

I get a frame with no image. But, if I take that url and drop it in a browser it is fine. (The tutorial mentions there could be a permissions issue, but, shouldn’t I see that if I drop it into the browser by hand?)

From the docs:

Chart [item=<itemname>] [icon="<iconname>"] [label="<labelname>"] [refresh=xxxx]
[period=xxxx] [service="<service>"] [begin=yyyyMMddHHmm] [end=yyyyMMddHHmm] [legend=true/false]

The order of the parameters is VERY important
It looks like the label parameter is optional but it may not be, try:

Frame label="Room Temp" {
        Chart item=roomtemps label="Temp Chart" icon="temperature" refresh=30000 service="influxdb"

You error seems to refer to a rule called ruleChart. Could you post that rule, please?

1 Like

I would be happy to, if there was such a rule. :sunglasses:

I checked all .rule files.

I also did a recursive grep on the openhab2-conf directory. Nothing.
Then a cd /, same grep. Nothing

Adding label=“Temp Chart” to the Chart made no difference.

In order for us to have a look at that reported “problem” please post the whole file, that way we might reproduce the warning.


sitemap default label="My home automation" {
    Frame label="Status" {
        //Text item=Day_Start label="Date [%1$td.%1$tm %1$tH:%1$tM]"
        Text item=Date label="[%1$tm/%1$td/%1$ty]" icon="calendar"
        Text item=Motion_Count label="Motion Count: [%d]" icon="motion"
        Text item=vTimeOfDay label="Time Of Day [%s]" icon="time"
        Text item=DriveState label="Drive TOD [%s]" icon="time"
        Text item=NTPTime label="System Time [%1$tl:%1$tM %1$tp]" icon="time"
        Text item=ms6_temperature label="Basement Temp: " icon="temperature"
    Frame label="Places" {
        Group item=Bedroom
        Group item=Livingroom
        Group item=Garage
    Frame label="Lights/Switches" {
        Switch item=All_Lights
        //Switch item=myScenes mappings=[0="OFF",1="ON",2="left",3="right"]
        Switch item=Plug_3_Swt label="Node 3"
        Slider item=Plug_3_Dim label="Node 3"
        Switch item=White_Puck_10 label="White Puck"
        Switch item=Black_Puck_12 label="Black Puck"
        Switch item=Plug_15 label="Plug 15"
        Switch item=Plug_16 label="Plug 16"
    Frame label="Scenes" {
        Switch item=TheaterScene
    Frame label="Room Temp" {
        //Image refresh=30000 url="http://openhabianpi:3000/d/q3K-5YiRz/my-first-dashboard?orgId=1&tab=axes&from=now-8h&to=now"
        Chart item=roomtemps icon="temperature" label="Temp Chart" refresh=30000 service="influxdb"

That was an easy one, we are all blind!
You are missing the required period setting!!!

So, don’t the square brackets indicate optional argument?

And, yes, if I add a period= it does work. :grinning:

Interestingly, the Chart now works in the sitemap, but the Image from grafana (when un-commented out) still shows a broken image. But, the same url works fine in a frame in HABPanel.

So, assuming I missed the docs stating “period” is required, where does it say that?

And, if it doesn’t, should there be an issue added to amend said docs?