Persistence reading

Does anybody knows when there will be a way to directly query the database from rules.

Thanks

There’s getAllStatesSince/Between and soon an Until version.

Thanks Jim

Thanks, but would you know if it is possible to retrieve a specific state for specific item? i.e. what was the state value of item ‘A’ when item ‘B’ state was 75 as an example?

Gaston

the best you could do is to loop through historical states for item B that matches your desired state, find the timestamp, and look at itemA at that timestamp.

That what I thought, I do not like that but…

Thanks many times for your help and have a nice day

Gaston

The state / data is not indexed in influxdb, so you can’t search using that.

You could use mysql or postgresql persistence and manually add the extra key and perform a separate query, not using the persistence api, I suppose, I have never tried it but theoretically it should be possible.

Hi,
I was thinking of MariaDB for that but not sure that’s gonna fly.
I still do not understand why Openhab does not support standard data base operations just like read and write…maybe to simple??.
I have seen (in community) that Openhab is for home automation(not for data analysis)…nice, sure it is not needed to support DB systems just for opening and closing lights… but some automation rules may need to do more complicated things than just that…

And by the way, just for opening and closing lights, I would not be using Openhab…HA is quite easier to use.

Thanks again

Best regards

You can use whatever DB you want in however manner you like from within jruby with https://sequel.jeremyevans.net/ or any other means that is compatible with jruby.

Openhab itself supports mysql (and mariadb, I guess?) for storing persistence and as I said above, you could query it however you like.

If it were easy to do and there was a demand for it, someone would have volunteered to implement it. A search of the forum shows there is at least a little bit of demand so that leaves that maybe it’s not so easy to provide a uniform API that works with SQL, NoSQL, Time Series, and round robin databases to perform complex cross indexed queries like this. What’s a “standard” database operation in SQL might be nearly impossible for a Time Series database or a NoSQL database.

But if anyone thinks this is easy and volunteers to implement something workable, I’m certain it would be well received by the maintainers and the community.

There is a MySQL persistence option and I used it ages ago with mariadb.
It’s in the add-on store.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.