Persistence API Queries Fail

Hi

Openhabian

openHAB 5.1.1

RPi5 8Gb Ram

Hi I upgraded to openHAB 5.1.1 from 5.1.0 this morning

I happened to be trying to do some API work and I noticed that the persistence queries for the items do not seem to work.

I try to run the query via the API as follows none of the seem to work (its the same results if i run direct from the openHAB web interface) I ran the 2nd to last one that shows that these persistence services are installed and then I can get the configs of the Persistences services (done for mapdb last the others resturn the correct results for the query of the service config)

My Question is how do I debug this since there are no errors in the openHAB log when it fails

/rest/persistence/items?serviceId=inmemory

[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]

/rest/persistence/items?serviceId=mapdb

“{“error”:{“http-code”:500,“exception”:{“class”:“java.lang.IndexOutOfBoundsException”}}}”

/rest/persistence/items?serviceId=rrd4j

/rest/persistence/health

/rest/persistence

[{“id”:“inmemory”,“label”:“In Memory”,“type”:“Modifiable”},{“id”:“rrd4j”,“label”:“RRD4j”,“type”:“Queryable”},{“id”:“mapdb”,“label”:“MapDB”,“type”:“Queryable”}]

/rest/persistence/mapdb

{“serviceId”:“mapdb”,“configs”:[{“items”:[“*”],“strategies”:[“restoreOnStartup”,“everyChange”],“filters”:}],“aliases”:{},“cronStrategies”:,“thresholdFilters”:,“timeFilters”:,“equalsFilters”:,“includeFilters”:,“editable”:true}

Do you have .persist files or is persistence configured through the UI?

In MainUI do you see a warning complaining about “default strategy”?

Hi @rlkoshak All of the persistence is managed through the UI

There are NO (none) warnings in openhab.log that I could see about persistence strategy

OK, so it’s not the removal of the default strategy.

The only presistence or persistence add-on related change listed is a minor bug fix in the UI (a link needed a “/”). That maybe could be relevant. But I don’t think so because it changed a different page, not the API. Persistence health page: Fix invalid problem link by florian-h05 · Pull Request #3663 · openhab/openhab-webui · GitHub

Can you confirm in other ways whether or not persistence is saving data? A rule perhaps?

Can you post the full REST API call’s URL?

Hi @rlkoshak

Sorry should have mentioned that the persistence seems to be running (i had checked from “ANALYZE” under one of the items but here is an API Call for the Same element and from rrd4

(I purposely did not post the whole output)

So its just the other API calls that do not appear to be working.

Result is

/rest/persistence/items/solarLithium01_lithium01_SOC?serviceId=rrd4j

{"name":"solarLithium01_lithium01_SOC","datapoints":"1440","data":[{"time":1767906840000,"state":"83.0"},{"time":1767906900000,"state":"83.0"},{"time":1767906960000,"state":"83.0"},{"time":1767907020000,"state":"83.0"},{"time":1767907080000,"state":"83.0"},{"time":1767907140000,"state":"83.0"},{"time":1767907200000,"state":"83.0"},{"time":1767907260000,"state":"83.0"},{"time":1767907320000,"state":"83.0"},{"time":1767907380000,"state":"83.0"},{"time":1767907440000,"state":"83.0"},{"time":1767907500000,"state":"83.0"},{"time":1767907560000,"state":"83.0"},{"time":1767907620000,"state":"83.0"},{"time":1767907680000,"state":"82.0"},{"time":1767907740000,"state":"82.0"},{"time":1767907800000,"state":"82.0"},{"time":1767907860000,"state":"82.0"},{"time":1767907920000,"state":"82.0"},{"time":1767907980000,"state":"82.0"},{"time":1767908040000,"state":"82.0"},{"time":1767908100000,"state":"82.0"},{"time":1767908160000,"state":"82.0"},{"time":1767908220000,"state":"82.0"},{"time":1767908280000,"state":"82.0"},{"time":1767908340000,"state":"82.0"},{"time":1767908400000,"state":"82.0"},{"time":1767908460000,"state":"82.0"},{"time":1767908520000,"state":"81.0"},{"time":1767908580000,"state":"81.0"},{"time":1767908640000,"state":"81.0"},{"time":1767908700000,"state":"81.0"},{"time":1767908760000,"state":"81.0"},{"time":1767908820000,"state":"81.0"},{"time":1767908880000,"state":"81.0"},{"time":1767908940000,"state":"80.0"},{"time":1767909000000,"state":"80.0"},{"time":1767909060000,"state":"80.0"},{"time":1767909120000,"state":"80.0"},{"time":1767909180000,"state":"80.0"},{"time":1767909240000,"state":"80.0"},{"time":1767909300000,"state":"80.0"},{"time":1767909360000,"state":"80.0"},{"time":1767909420000,"state":"80.0"},{"time":1767909480000,"state":"79.0"},{"time":1767909540000,"state":"79.0"},{"time":1767909600000,"state":"79.0"},{"time":1767909660000,"state":"79.0"},{"time":1767909720000,"state":"79.0"},{"time":1767909780000,"state":"79.0"},{"time":1767909840000,"state":"79.0"},{"time":1767909900000,"state":"79.0"},{"time":1767909960000,"state":"79.0"},{"time":1767910020000,"state":"79.0"},{"time":1767910080000,"state":"79.0"},{"time":1767910140000,"state":"79.0"},{"time":1767910200000,"state":"79.0"},{"time":1767910260000,"state":"79.0"},{"time":1767910320000,"state":"79.0"},{"time":1767910380000,"state":"78.0"},{"time":1767910440000,"state":"78.0"},{"time":1767910500000,"state":"78.0"},{"time":1767910560000,"state":"78.0"},{"time":1767910620000,"state":"78.0"},{"time":1767910680000,"state":"78.0"},{"time":1767910740000,"state":"78.0"},{"time":1767910800000,"state":"78.0"},{"time":1767910860000,"state":"78.0"},{"time":1767910920000,"state":"78.0"},{"time":1767910980000,"state":"78.0"},{"time":1767911040000,"state":"78.0"},{"time":1767911100000,"state":"78.0"},{"time"

If that worked this is very strange indeed because that uses the same rest API calls you are trying to use from the explorer.

I’m not sure where else to go except filling an issue on core.

I don’t know why there is no response inyour case. I do get one for mapdb. rrd4j will always return an empty list as this call has not been implemented for rrd4j (the internal api says this is optional, and not al services are even capable of providing this easily).

Thanks @Mherwege for rrd4j do you think it could be worth i implementing this because i was think to use this particular API call as part of a persistence documentation and config audit?

I am not sure. I would need to look at the rrd4j code and library to check if it is possible. I can see it being useful. Currently I don’t think this API is used much. To be useful, it should work for all. I can also see me building this into to health check: are there items in a persistence store that don’t exist anymore in OH?

Hi @Mherwege so i had a quick look at the rrd4j api and it appears that it does not prove a method to access all sources and that then would mean parsing all the stored files to determine the source information. The Java programming side of things is out of my capabilities but with the file parsing it would appear quite a bit of work (even if possible ) and then also probably to slow for an api call

Yes, indeed. It looks like it is constrained.

I want to look at what can be done in general to improve this. I have created a PR to show in the UI Item Details if the Item has a persistence configuration and if anything is effectively persisted.

See: [MainUI] Item persistence status in item detail by mherwege · Pull Request #3765 · openhab/openhab-webui · GitHub

For the last bit, I am currently using the REST API call you point to. But:

  1. It is wasteful as it will query all items and I only need it for one.
  2. It does not give an answer for all persistence services.
  3. I can’t distinguish between not supported by the service and nothing persisted for the item (when it is not supported, it also returns an empty array).

So I am thinking about extending this API to allow it to:

  1. Only query for one item.
  2. Return a null value when this is not supported by the UI (in the REST API that would then become a not supported HTML code or something like that).

That would make it possible to show more data, and make a distinction in the UI between not supported and nothing persisted.