Influx db2 - Openhab 3.1M5 deltaSince (Start_of_day) not working when lines without item name in database (from Openhab 2.5)

I hadn’t time to test it, but can you test if with that modification it works correctly?

Another option is to try to migrate your data, in Influx2 there isn’t an update, but with flux and to operator you can create a transformed copy.

something like this should do the work (not tested):

   from(bucket: "origin")
  |> range(start: -100y, stop: now()) 
  |> to( 
  bucket:"copy",
  tagColumns:["item"],
  fieldFn: (r) => ({"item": if exists r.item then r.item else r._measurement})
)

Thanks @lujop I try but no change to the query

	|> range(start:-100y, stop:2021-06-26T22:00:00.000000000Z)
	|> filter(fn: (r) => r["_measurement"] == "Lesekopf2Channel1")
	|> sort(desc:true, columns:["_time"])
	|> limit(n:1, offset:0)

should be the correct Version
bundle org.openhab.persistence.influxdb:3.1.0.202106271336 (273)[org.openhab.persistence.influxdb.InfluxDBPersistenceService(314)] : invoking activate:

I also tried the copy with “to” but it’s also not working - here the result in a new bucket.

I will investitigate why it put “item” in the value field. I gues the fieldFn is not working for Tags

Excuseme @Asmodeon, I have made a silly mistake on my part. Can you try again with that updated version?

it’s running but not working

2021-06-27 18:36:25.533 [TRACE] [.influxdb.InfluxDBPersistenceService] - Query from(bucket:"openhab_db/autogen")
	|> range(start:-100y, stop:2021-06-26T22:00:00.000000000Z)
	|> keep(columns:["_time", "_value"])
	|> filter(fn: (r) => r["_measurement"] == "GoEChargerTotalChargedEnergy_C")
	|> sort(desc:true, columns:["_time"])
	|> limit(n:1, offset:0)

the influx creates a lot of errors in the log and no result anymore

I tried directly in Influx

 runtime error @3:5-3:38: keep: schema collision detected: column "_value" is both of type string and float

If i include _measurement it’s working in influx

|> keep(columns:["_time", "_measurement" ,"_value"])

Annother problem - with keep the query needs 10 second - without keep - 0 second

If i put the keep behind the filter is fast again.

from(bucket:"openhab_db/autogen")
	|> range(start:-100y, stop:2021-06-26T22:00:00.000000000Z)
	|> filter(fn: (r) => r["_measurement"] == "GoEChargerTotalChargedEnergy_C")
	|> keep(columns:["_time", "_measurement" ,"_value"])        
	|> sort(desc:true, columns:["_time"])
	|> limit(n:1, offset:0)

I implemented your suggested changes.
Hope that is the good one:

Thanks @lujop Great work - it seems to work
no error in the log and all item have the calculated value of today.
Nethertheless I will do additional test when the values of today are in the database. Want to be sure that no side effect will appear. Keep you updated.

Best Asmodeon

1 Like

Thank you very much for your testing @Asmodeon
I will wait some days and submit a PR if you confirm that all it’s OK.
I’ve updated some test also to verify that generated queries looks good with new keep logic.

@lujop From my point of view everything is working now. I also did test with puting on additional columns and remove them - no issue.

Thanks for your testing @Asmodeon
I will try to make a PR that weekend then.

Cheers