Query data from influxdb

Hi all,

I use influxdb as my default persistence service. Items updates are recorded at influxdb. Everything works fine. Now I want to query data from influxdb within rules and sum up values. But I don’t get any values back.

openhab 2.5.2-1
influxdb 1.7.10-1

snipset from my rule

rule “Update Gas”
Item GasqmTotal001 changed
var Number tempValue

// Read Today Value
tempValue = GasqmTotal001.deltaSince(now.withTimeAtStartOfDay,“influxdb”)

if (tempValue == null) {

but the rule does not return any data

I turned on tracelevel for influxdb

020-02-24 22:48:18.070 [DEBUG] [.internal.InfluxDBPersistenceService] - got a query
2020-02-24 22:48:18.071 [TRACE] [.internal.InfluxDBPersistenceService] - Filter: itemname: GasqmTotal001, ordering: DESCENDING, state: null,  operator: EQ, getBeginDate: null, getEndDate: Sun Feb 23 00:00:00 CET 2020, getPageSize: 1, getPageNumber: 0
2020-02-24 22:48:18.072 [DEBUG] [.internal.InfluxDBPersistenceService] - descending ordering
2020-02-24 22:48:18.072 [TRACE] [.internal.InfluxDBPersistenceService] - appending limit 1
2020-02-24 22:48:18.073 [TRACE] [.internal.InfluxDBPersistenceService] - startEntryNum 0
2020-02-24 22:48:18.074 [DEBUG] [.internal.InfluxDBPersistenceService] - query string: select value from "autogen"."GasqmTotal001" where  time < 1582412400s  ORDER BY time DESC limit 1
2020-02-24 22:48:18.078 [DEBUG] [.internal.InfluxDBPersistenceService] - query returned no series

if I type in the query, it will be empty
select value from "autogen"."GasqmTotal001" where time < 1579820400s ORDER BY time DESC limit 10¨

if I type in with ns timestamp I receive the expected data

select value from "autogen"."GasqmTotal001" where time < 1582563909809000000 ORDER BY time DESC limit 10


name: GasqmTotal001
time value

1582563609 5266.59
1582563310 5266.57
1582563010 5266.55
1582562709 5266.51
1582562410 5266.41
1582562110 5266.3
1582561809 5266.23
1582561509 5266.17
1582561210 5266.12
1582560910 5266.1

scripts are proven to work with older versions
openhab 2.4
influxdb 1.7.6

has anyone else similar experiences?



There’s a weird looking double quote at the end of that - I assume that is a typo?

And there really is data less than time specified? The data you list doesn’t have any with older timestamps, but it’s probably just not shown here.

Seems like this has to be an issue with InfluxDB. The query looks valid. The InfluxDB documentation says that second precision is valid here. openHAB can’t do anything more than the query, so it seems more likely to be an issue with InfluxDB.

What happens if you increase the time with the ‘s’ suffix - does it seem like it is ignoring the ‘s’ completely? I.e., try this:

select value from "autogen"."GasqmTotal001" where time < 1582563909809000000s ORDER BY time DESC limit 10

Then chop off a zero or two and see if it still returns any data. Sorry, this isn’t much help.

1 Like

thanks for your help… i figured out the problem

  1. in influxdb.conf I set the auth-enabled parameter to true in [http] section
  2. I imported my old data again into influxdb… looks like the first import was not fully successful… and I didn’t checked carefully enough :grimacing:

I am moving my openhab installation to an new instance and migrate to the latest versions of the involved applications…

thanks for you hints, helped a lot.