[SOLVED] Mqtt-persistence - how?


I am trying to use mqtt persistence (for owntracks) and have some questions about the cfg:

I use items like:

Switch  home_NCO  "NCO@Home [%s]"   {mqttitude="mosquitto:owntracks/mosquitto/NCOs_iPhone/event:Home"}

Switch  home_DNA "DNA@Home [%s]"  {mqttitude="mosquitto:owntracks/mosquitto/DNAs_iPhone/event:Home"}

So in mqtt-persistence I have put:
message=%1$s, %3$s

How can I check if it’s working?
I don’t see an mqtt persist file in /var/lib/openhab2/persistence
(on OH1 it’s the same issue)
(the rrd4j folder is there with all the items in place)

Thanks in advance.

MQTT Persistence just sends the states of your Items to MQTT Topics. It doesn’t actually save anything outside of what your Broker is configured to save. Consequently you will not see any mqtt folders in the persistence folder.

What exactly are you trying to achieve with MQTT persistence?

Hi Rich,

my problem is, that the geofencing data (owntracks) seems to be gone after a while.
I get the information from owntracks into OH (Mosquitto) and can display it in a google maps webview including the time stamp of the mqtt message from owntracks.

However, after a while this information is gone (e.g. time stamp: -) and my hope is to store for long term availability.
Is this idea nonsense?

If you have your information in openHAB, then you can use any of the available and suitable persistence solutions, like MySQL, RRD4J, etc. No need to use MQTT persistence in this case.

Thanks @KjetilA,

you are absolutely right.
So I am wondering why I need mqtt persistence anyway? does it have more features /better match to mqtt messages than e.g. mapdb?
However, it seems that mapdb does the job.
RRD4J is not a option because the mqtt messages are no numbers but strings, right?
Anyway - problem solved - Thanks again.

You don’t need MQTT persistence at all in this case. You are correct that rrd4j will not work if your Item’s are strings… MapDB only works if all you care about is the most recent value. If you want to save historic data you need to use db4o or an external db like MySQL or InfluxDB.

Alright - thanks @rlkoshak.
I will give it a try with db4o then.

Hi @rlkoshak,

I just wanted to start investigating into db4o.
Unfortunately it’s not included in OH2. Do you know, if it’s going to be available in OH2 later on?

It would appear they have dropped db4o. It is probably for the best as there are not any tools we can use to make management of it possible.

Look to the SQLite which functionally will work the same (i.e. won’t require you to set up a separate server).

Hi @rlkoshak,

thanks for the confirmation.
I will give SQLite a try then.