Influxdb doesn't store item values

Hi,
I’ve setup influxdb persistence service following the tutorial. The connection with Influxdb is working. When I login on the influx database, show databases shows openhab_db and show measurements shows me the names of the items created by openhab. However, there are no time stamps and values; select * from itemname is empty for all items. So, I must be missing something in my setup.
I’m running Openhab 2.5.6-debian and influxdb (1.8.7) both as a docker image. Also I’ve a python script running in another docker that is posting weather observations to influxdb and that is all OK. I can visualize that data in grafana without problems. The python script uses the same credentials to set up the connection to influxdb as openhab.
Any ideas where I go wrong?

influxdb.persist

// persistence strategies have a name and definition and are referred to in the “Items” section
Strategies {
every5Minutes : “0 /5 * * * ?”
everyHour : “0 0 * * * ?”
everyDay : “0 0 0 * * ?”

// if no strategy is specified for an Item entry below, the default list will be used
default     = everyChange

}

Items {
// state of following group of items will be restored on startup
// check for race conditions on startup
restoreOnStartupgroup* : strategy = everyChange, restoreOnStartup

// Smartmeter time series group
// Every 5 minutes state is stored in database, downsampling of data
// required at database level to limit datavolume! 
sm_timeseriesgroup* : strategy = every5Minutes

// Infrastructure monitoring data
// Every update is stored in the database, downsampling of data
// required at database level to limit datavolume!
id_timeseriesgroup* : strategy = everyUpdate

// Climate data
// Every 5 minutes state is stored in database, downsampling of data
// required at database level to limit datavolume!
cd_timeseriesgroup* : strategy = every5Minutes

}

influxdb.cfg

url=http://influxdb:8086
user=openhab
password=VerySecret
db=openhab_db
retentionPolicy=autogen

Example item:>

Number:Energy SM_Energy_Delivered_Tariff1 “Energy Delivered Tariff1 [%.3f kWh]”
(sm_timeseriesgroup) {channel=“mqtt:topic:smartmeter_data:energy_delivered_tariff1”}

Try add a default strategy… I think this issue has been up before, and as far as I recall a default strategy is needed… Like this:

Strategies {
 everyMinute : "0 * * * * ?"
 everyHour : "0 0 * * * ?"
 everyDay : "0 0 0 * * ?"
 every15min : "0 0/15 * * * ?"
 default = everyMinute
}

Also note that if you change the persist file or Item group membership, you need to restart the service for changes to take effect.

@Kim_Andersen there is a default policy default = everyChange… Do you remember where you saw that this might be an issue??

@rossko57 I admit that could have been an issue originally but I did full restart of the server already and that didn’t resolve the issue.

Have you actually created Group Items? People have made the mistake before of only linking member Items.

What does openhab.log have to say? There should at least be a message about loading your persist file.

I had to check but yes there is an items file that defines the groups that are specified in the infuxdb.persist file. The group for the example items is

Group sm_timeseriesgroup “Smartmeter Timeseries Group” <“line.svg”>

The logs show loading of the persist file, and all things and items, without errors.

2020-08-20 19:34:47.892 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘lightcondition.items’
2020-08-20 19:34:48.021 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘homegroups.items’
2020-08-20 19:34:48.172 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘infrastructure.items’
2020-08-20 19:34:48.231 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘outdoorlightgroups.items’
2020-08-20 19:34:48.264 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘persistentgroups.items’
2020-08-20 19:34:48.351 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘weather.items’
2020-08-20 19:34:48.483 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘milight.items’
2020-08-20 19:34:48.507 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘livingroomlightgroups.items’
2020-08-20 19:34:48.515 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘alarmgroups.items’
2020-08-20 19:34:48.539 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘iotgroups.items’
2020-08-20 19:34:48.579 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘chimesgroup.items’
2020-08-20 19:34:48.612 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘smartmeter.items’
2020-08-20 19:34:48.835 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘influxdb.persist’
2020-08-20 19:34:49.150 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘home.sitemap’
2020-08-20 19:34:49.328 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘astro.things’
2020-08-20 19:34:49.372 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘smartmeter.things’
2020-08-20 19:34:49.443 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘weather.things’
2020-08-20 19:34:49.505 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘infrastructure.things’
2020-08-20 19:34:52.670 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘smartmeter.rules’
2020-08-20 19:34:53.131 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘frontdoor.rules’
2020-08-20 19:34:53.318 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘milight.rules’
2020-08-20 19:34:53.424 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘outdoorlight.rules’
2020-08-20 19:34:53.598 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘lightcondition.rules’
2020-08-20 19:34:53.785 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘bedroomlight.rules’
2020-08-20 19:34:53.837 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘network.rules’
2020-08-20 19:34:53.915 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘exhaustfan.rules’
2020-08-20 19:34:53.960 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘qosgroup.rules’
2020-08-20 19:34:54.023 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘kitchenlight.rules’
2020-08-20 19:34:54.258 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘garagedoor.rules’
2020-08-20 19:34:54.321 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘livingroomlight.rules’

Ahh sorry… Missed that…
I think there are some threads in here. try search for Influxdb doesnt read values or something simular.

Influxdb can persists both indivdual items or groups. But ofcouse the group need to exsists if he has added it ans an group to the persisting file.

Did you create the Group Items? i.e.

Group sm_timeseriesgroup
Group id_timeseriesgroup
Group cd_timeseriesgroup

Number SM_Energy_Delivered_Tariff1 "Energy Delivered Tariff1 [%.3f kWh]" (sm_timeseriesgroup) {channel="mqtt:topic:smartmeter_data:energy_delivered_tariff1"}

I’m pretty sure that mqtt is not capable to use UoM Items.

Maybe try increasing the log level on the persistence to get more information on what it is doing?

log:set trace org.openhab.persistence.influxdb

See https://www.openhab.org/docs/administration/logging.html

@Udo_Hartmann
The thread Kim_Andersen was pointing to was about missing Group definitions and also rossko57 mentioned that in his reaction. I checked and the Groups were all defined see above.
The persistence is on selected sensors that write every 5 minutes their to Influxdb to generate a timeseries for graphs with grafana. These have UoM, which I just took of in the definitions in the items file and restarted Openhab. That did not make a difference. You’re correct in that it was merely decoration as Openhab did not really much with the UoM. Also I did not expect that taking UoM would help as I’ve persistence also on all actors everyChange so that I can restart and get same state back. Their behavior when it comes to persistence is identical, only the itemnames appear in Influxdb no values. In fact you see slowly appearing all itemnames from actors in Influxdb after they change state.
@jswim788 Need to think about how to do that. I’m running in a docker and have some difficulties with interacting with the openhab engine. Can’t connect to Karaf e.g.

Is it just your cron persist strategy that is broken? i.e. check if your everyChange Items are actually persisting.

They are not persisting. They only thing I see when monitoring Influxdb (a clean openhab_db database) that on change the itemname is created in the openhab_db. There is no timestamp or itemstate stored.
So my conclusion was that openhab has sufficient privileges to write in the database and the everyChange does fire.

Give it a try with a single group item only in your persist file, like my file:

Strategies {
 everyMinute : "0 * * * * ?"
 everyHour : "0 0 * * * ?"
 everyDay : "0 0 0 * * ?"
 every15min : "0 0/15 * * * ?"
 default = everyMinute
}

Items {
Temperatur*, gLumiance*, gSugeTemp : strategy = restoreOnStartup, everyChange, everyMinute 
Fugtighed*, gChart*  : strategy = restoreOnStartup, everyChange, everyMinute
BatteriLevel : strategy = restoreOnStartup, everyChange, everyMinute
nilan_Output_ExhaustSpeed, nilan_Output_InletSpeed : strategy = restoreOnStartup, everyChange, everyMinute
PV* : strategy = restoreOnStartup, everyChange, everyMinute
gTotalEnergy : strategy = restoreOnStartup, everyChange, everyMinute
gPower, gPower* : strategy = restoreOnStartup, everyChange
 }

I use both single group items as well as wildcards.

Kim I followed your advice and change my persist file. I moved all comments on top of the Strategies and Items section. I also combined the two identical strategy definitions. I can’t explain why but it works!, so I’m not complaining. I’ll mark yours as the “solution”.

// persistence strategies have a name and definition and are referred to in the “Items” section
// if no strategy is specified for an Item entry below, the default list will be used
Strategies {
every5Minutes : “0 0/5 * * * ?”
everyHour : “0 0 * * * ?”
everyDay : “0 0 0 * * ?”
default = everyChange
}

// restoreOnStartupgroup state of these items will be restored on startup
// check for race conditions on startup
// sm_timeseriesgroup* Smartmeter time series data
// id_timeseriesgroup* Infrastructure monitoring timeseries data
// cd_timeseriesgroup* Climate timeseries data
// For all timeseries data downsampling of data required at database
// level to limit datavolume!
Items {
restoreOnStartupgroup* : strategy = everyChange, restoreOnStartup
id_timeseriesgroup* : strategy = everyUpdate
sm_timeseriesgroup*, cd_timeseriesgroup* : strategy = every5Minutes
}

1 Like

Glad you got it fixed :slight_smile:

Sorry must have skipped while reading :blush: