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

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.

Sure:

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?
:confused:

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?

According to such assumption even the item would be optional!
In short, no, square brackets do not say optional.

Following can be found Here under Concepts:

Almost all parameters are optional, some are however needed to result in a meaningful user interface.

You wanted to show a chart, stating the item name seemed required for you, however what period did you intend to show? Unlimited? If not, a setting would be required, don’t you agree?

And if you think that something is missing in the documentation, YOU can file a change via a pull request. This is an open source project!

True, I see now they all have .

I agree, needing a period makes sense in this case. But, what indication is there that that particular one IS required? Is it not possible that it has some sort of default, thus falls into the “Almost all” category. Obviously the item can’t have a default, begin/end/legend apparently do. :thinking:

Indeed, I can and could. But, I’m far from comfortable with OH in general or it’s documentation style to assume I’m qualified. :roll_eyes:

1 Like

For something like this if you were confused and now understand. You are very well qualified to know if there is a sentence or two that could be added or changed that would have avoided the confusion. You don’t have to be an expert to contribute, and all contributions are reviewed so you can’t break something.