Analyze/Charts not working for switches

I have a somewhat weird issue that I just noticed for switches.

I migrated an OH2 openhabian installation that was using influxdb as a persistence service before. The openhabian update/migration went smooth (so far) and persistence was working right off the box nicely with the new charts that you get when you press the analyze button.

However it never worked for switches, the graph is there, but there are no values) and I just figured that the charts don’t work for categories, only for numbers. But then I saw my friends fresh OH3 Installation with rrd4j as the default persistence service. And there I noticed, he DOES have graphs for switches.

So back at my installation, I check everything. influx is the only persistance service installed.

This is my Influx.persist file:


Strategies {

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

    default = everyUpdate

}

Items {
        iPhone_Online : strategy = everyChange
        RestoreOnStartup : strategy = restoreOnStartup

}

The iPhone item usually isn’t there, I just added this as a test item.

But neither the iPhone nor the other items show.

Do I need to change something in the binding or service config for this to work with switches?

  1. Even though it’s the only one installed, do you have it configured as the default persistence engine in settings?

  2. Look in InfluxDB and see if the values are being saved. I’ve seen some reports that InfluxDB isn’t doing so well with Switches but I’ve moved off of InfluxDB to rrd4j so can’t say much more than that.

  1. yes, that’s the label above the select radio button when I go to settings
  2. yes, influxdb does store the item updates
> select value from  iPhone_Online
name: iPhone_Online
time                value
----                -----
1612954910668000000 0
1612954931794000000 1
1612954996835000000 0
1612955122916000000 1
1612955971594000000 0
1612956031705000000 1
1612956096732000000 0
1612956221874000000 1
1612956286901000000 0
1612956607030000000 1
1612956672098000000 0
1612956732145000000 1
1612956917395000000 0
1612957225425000000 1

Do you have any more info on influx’s problems with switches? I’d assume if the data is saved, there shouldn’t be a general problem? Or do I need to define a mapping 1/0 to some format that the chart understands somewhere?

Maybe it’s time to switch to rrd4j however I kinda like keeping my data “forever” plus, while the new OH3 charts are nice, I kinda want to keep some grafana charts for now. I mean I guess I could run them in parallel, rrd4j as default for the charts and influx in the background for grafana … but that would be kinda overkill.

And at the moment it seems the problem here seems to be OH3 and not influx?

For reference, this is what the chart (or any other switch chart) looks like:

I’ve not used InfluxDB with OH 3 so can’t help and more than I have. All I can say is it works fine with rrd4j so it is possible to work. You could use the REST API Docs (under developer tools) and query persistence for one of your Items and see what gets returned. At a minimum that will show you the raw data that OH 3 retrieves to generate the charts.

1 Like

Thank you, great advice!

Coming closer …

Two things of note:
1st: within influxDB the timestamps are zero padded (probably not a problem)
2nd: all values except the first return twice
3rd: all values are “OFF”

see my last post, timestamp 1612954931794000000 is 1 ( = ON ) in influxdb
yet the rest api returns

    {
      "time": 1612954931794,
      "state": "OFF"
    },

and that, twice! (Longer JSON excerpt below).

Now … I’d guess I can rule out that it’s a problem with the chart, but with the persistance service.

But now I have no clue what else to do. Is this worth trying to contact a maintainer over? I believe the twice logged values still might be a configuration thing (although it’s not visible in the query?), however that all values return as 0=OFF I can’t explain at all. Except there somehere is a mapping to be defined for ON/OFF values in regards to persistence?

{
  "name": "iPhone_Online",
  "datapoints": "77",
  "data": [
    {
      "time": 1612954910668,
      "state": "OFF"
    },
    {
      "time": 1612954931794,
      "state": "OFF"
    },
    {
      "time": 1612954931794,
      "state": "OFF"
    },
    {
      "time": 1612954996835,
      "state": "OFF"
    },
    {
      "time": 1612954996835,
      "state": "OFF"
    },
    {
      "time": 1612955122916,
      "state": "OFF"
    },
    {
      "time": 1612955122916,
      "state": "OFF"
    },
    {
      "time": 1612955971594,
      "state": "OFF"
    },
    {
      "time": 1612955971594,
      "state": "OFF"
    },
    {
      "time": 1612956031705,
      "state": "OFF"
    },
    {
      "time": 1612956031705,
      "state": "OFF"
    },
    {
      "time": 1612956096732,
      "state": "OFF"
    },
    {
      "time": 1612956096732,
      "state": "OFF"
    },

Edit:
I checked out some other switch items: same situation, except the first value all timestamps are there twice, all states are OFF. I also checked some switch items that are not part of my “RestoreOnStartup” Group, also the same picture …

Then I checked some NUMBER items and there is no duplication of values for those.

That’s a pretty good sign that there is something wrong on in the binding. I suggest filing an issue.

Thank you, just filed it here: