I have a requirement to store 4x persistent variables, for 4x user selectable (using a habpanel widget/item combo) values. These values need to persist including through power cycles of the host (raspberry Pi).
The persistence addon seems an overkill for this reqt., so Is there anyway in HA/habpanel to store / retrieve these values say in a JSON within a file in area? or any area?
Why, that’s exactly one of the main use cases for why persistence exists.
If all you need is the one value, no charting or anything, use the MapDB which only stores one value per Item and configure those Items with the restoreOnStartup strategy. It’s an embedded database so all you need to do is install the add-on and configure the .persist file and you are done.
It doesn’t get too much more light weight than that
No, because this is the job provided by Persistence.
The first part of the article is the synopsis. There’s nothing more to tell about MapDB persistence.
Both configurational parameters are optional and that’s it. There’s nothing more to document. You just install it and for everything else regarding persistence you need the following
Have a look at my mapdb.persist: Besides installing that’s all I need. Every item i want to use i put into the group gRestoreOnStartup
Of course if you still don’t want to use it, create a rule that writes values to a file and after that use the systemstarted trigger to read those values. You then create a much less capable persistence that behaves like MapDB but you will have to struggle with creating and parsing files. And for every item you want to add, you need to change your code.
Sorry but i can’t see the what keeps you from using MapDB
I’ve used it since OH 1.6. Never had a problem with it.
@tillykeats, And I’m not aware of any problems you are finding on posts on the forum. Are you finding anything more recent than about three years ago? Can you site any “nothing but probs” more recent than a few years ago in specific? There were problems with MapDB back in the pre OH 2.0 time frame where MapDB was used instead of JSONDB.
If your data is numerical, you can use rrd4j instead. It too is embedded, limits itself in size.
Just to head off a common mistake a lot of new users make. * is not a wild card. SomeItemName* does not mean “All Items that start with 'SomeItemName`”. It means “all members of the Group ‘SomeItemName’”.
It’s in the docs but a lot of users apparently miss it.