there is a set of functionality in the persistence service that allows limited use of historic data, most statistical.
They are great so far but I’ll miss some functionality like;
get a list of historical items for an item within defined range in time
get a list of historical items for an item within defined range in time filtered by a state or state range
I’ would be untested of developing it or extend the current implementation if possible.
can anyone give me hint or a starting pont to begin with?
Firstly, this would be something that needs to be supported/supportable by all the persistence add-ons. I think you are OK on that point but I raise that to point out that this is going to be bigger than just updating the one JDBC add-on.
First you’ll need to implement the new persistence actions in openhab-core. The class you want to add to is PersistenceExtensions (openHAB Core 3.3.0-SNAPSHOT API) which will expose these new methods to rules. Beyond that, follow the way the other methods in that class work to see what other core classes need to be updated.
Then you’ll need to update all the Persistence add-ons to implement these new actions. You’ll have to think about how to handle MapDB (which only stores one value per Item) and rrd4j (which requires an every minute or so strategy).
Thanks Rich,
so it seams to be more work as I’ thought. Therefore I’ll have the following Questions:
Do you think the effort is worth it?
Would we need some kind of requirement document?
I’m good with JAVA and JDBC but would need support on other DB’s specially rrd4j and mapDB
From the effort it seams to me it would only be worth wile if it meet more then my personal need. Do you see a potential interest in the subject that would make it worth wile?
It’s been asked for before. I personally don’t have a need for this so it’s not worth it to me. But you clearly do have a use for this so that’s really a question only you can answer.
No, but I’d open an issue on Github and discuss with the maintainers before spending too much time implementing something to make sure there isn’t some gotcha.
I suspect that once you look at the actual code you will find that it’s already got example code in there that gets the values between two timestamps. You don’t have to really do much to figure out the interface between OH and these DB’s yourself. Just copy/use what’s already there.
Thank you so far.
I’ got the source of the openhab-cor and openhab-api. I’ got the code from the main branch. is this correct or what branch should I base on?
how and where would i open an issue for my proyect? Isn’t Develop /Add-ons the correct place ?
You’ll need to work in both openhab-core and openhab-addons. The API between OH and the persistence add-ons is defined in openhab-core. You are looking to add to the API so you need to make changes there.
Then the add-ons that implement specific persistence services need to be updated to conform to that new API. Those live in openhab-addons.
Open the issue in core first or open one in both places and add a link between the two.
As for the correct branch, I’d assume main but don’t develop on OH so couldn’t say for sure. My understanding is that main is the latest and greatest. Though you’ll want to create your own branch based on main to make your changes.