Help with Persistence DB config


(Aaron) #1

Hi everyone

i’m looking for links and pointers to learn how to get a decent persistence dB up and running. (I’m already reading the persistence section of the manual) and I’m currently using mapdb for restore on startup functions that @unixe helped me with thanks again for that.

What’s my options for storing values for on/off & numbers like temp?

I dont realy care about file sizes but it can’t be stupid big like above 10GB so i would most probably not store all values like socket signal strengths ect but I would begin with just storing every value too make it simple

I just don’t know where to start here


(HomeAutomation) #2

There is a good post from rich here. I cannot find it but look for it.

In short for me the best is:

  • use mapdb for restore on startup because all item types can be handled. Use everyChange, restoreonstartup
  • use rrdj4 for graphs (datas will aggregated!) Use everyminute
  • use jdbc for datas you want to inspect in details wihtout any aggregation. Use everychange, everyupdate

(Aaron) #3

Thanks

how would you start setting up rrdj4 is it just the same as setting up mapdb install the addon from the ui and create the text config files ?


(Jürgen Baginski) #4

The problem with rrd4j is in your case that it handles only numeral data.


(Aaron) #5

so its not usefull for storing the ON/OFF state of sockets and lights what would you recomend ?


(HomeAutomation) #6

@Sharpy
yes, the same as mapdb. But you need to persist everyminute. Oethrwiese it will show no graphs. And as opus mentioned, only numeral datas!

Strategies {
    everyMinute : "0 * * * * ?"

(Aaron) #7

ok thanks

is there a more appropriate db to handle my needs ? or does this mean runnning multiple databases?


(HomeAutomation) #8

As I wrote.

mapdb for restoreonstartup

Other persistance service as you like. mapdb from my point of view is mandetory for restoreonstartup because other databases starts to late on OH start to do this job.


(Aaron) #9

Sorry i read your first post wrong i thought datas said dates got confused

so rdbc can store on/off or text items ?

what size are your db files?


(HomeAutomation) #10

jdbc can store every kind of datas because there is a sql database in backgroud.
Only problem, as said, to trustable for restoreonstartup. driver starts to late.

You can say why use rrd4j too? If you need it only for graphs, the database does not grow up. It stays on a very little kByte.


(Aaron) #11

that was my next question :wink: yes graphs would be nice. I just thought it would be useful to get up and running and i was looking at videos on youtube and saw that another HA system had a nice feature that could be useful

this timeline veiw (having problems with a motion sensor and checking the log is impossible)

i think i will give what you said a try and just run the 3 databases
what sort of size can the other DB grow too?


(HomeAutomation) #12

the jdbc database can grow to every value. Depends on the hard drive and the datas you put in the database :wink:


(Aaron) #13

Storage should not be too much of a problem I’m running my OH on Windows so it’s got access too big drives and my nas

speed is important I don’t want to wait forever for the dB I will keep this thread posted

One more thing how do you tell oh too send the info too the right dB (is that done in the configuration files) and would you leave mapdb as default?


(HomeAutomation) #14

This is controlled by the persistance setting in OHdir\conf\persistence.

Install the persistnace service with paperui.

Create a related file for every persistance you need
mapdb.persist ==> mapdb
jdbc.persist ==> jdbc

This will do the job.


(Jürgen Baginski) #15

If you are looking to do all (except RestoreOnStartUp ) in one NONGROWING Database, you could use proxy items to store 9 for On and 1 for Off. That way you could use rrd4j.


(Aaron) #16

I was going to ask if something like this was possible but decided not too ask thinking it wouldent be or would be hard

MY understanding is create separate virtual switch items and use a rule if on send 9 to virtual switch and then store this item in the dB


(Rich Koshak) #17

Other useful links:

https://docs.openhab.org/configuration/sitemaps.html#element-type-chart

There is no limit to how big the DBs can grow and how quickly they grow depends on how often one saves values to it.

I’ve been running OH with InfluxDB on about a dozen Items which get updated at rates of every couple minutes to a couple times an hour. A little more than 6 months worth of data takes up 52MB.


(Aaron) #18

ok so i have got the rrdj4 DB up and running thanks for the help on that i just need a little more work

here is a snip from the log

19:29:04.068 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'LRGoogleHome_Online' with state '1' in rrd4j database
19:29:04.158 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HueBridge_Online' with state 'ON' in rrd4j database (again)
19:29:04.158 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HueBridge_Online' with state '1' in rrd4j database
19:29:04.228 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Motion' with state 'OFF' in rrd4j database (again)
19:29:04.228 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Motion' with state '0' in rrd4j database
19:29:04.267 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Temp' with state '17.28' in rrd4j database
19:29:04.307 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Light' with state '0.9997697679981565' in rrd4j database
19:29:04.328 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Battery' with state '100.0' in rrd4j database
19:29:04.353 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Motion2' with state 'OFF' in rrd4j database (again)
19:29:04.353 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Motion2' with state '0' in rrd4j database
19:29:04.393 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Temp2' with state '12.41' in rrd4j database
19:29:04.424 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Light2' with state '0.9997697679981565' in rrd4j database
19:29:04.451 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'HUE_Battery2' with state '100.0' in rrd4j database
19:29:04.475 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'Plug1_Online' with state 'OFF' in rrd4j database (again)
19:29:04.475 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'Plug1_Online' with state '0' in rrd4j database

it looks like stuff is being written to the db successfully i have created a graph and that seems too be working aswell.

it also looks like rrd4j db can actuall store an on and off value and converts it itself as seen in the log

i used this to start the DB

Strategies {
    everyMinute : "0 * * * * ?"
}

Items {
	* : strategy = everyMinute
}


How do i manually add items too this file i couldent work out how too do that and the docs aint helping on that one ?

is it possible to and add exclusions to the list?

with rrd4j storing on/off values should i still setup the other DB?


(Rich Koshak) #19

https://docs.openhab.org/configuration/persistence.html#items

Look at the example in that section.

Also, see Design Pattern: Group Based Persistence for how to do it using Groups.

No.