[Solved] Migration to OH3, all items are automaticaly included in the Mysql persistance

OS: Debian 10.0 with java 11.0
openHAB version:Last, downloaded Satarday.

Hello all, following my migration from OH2 to OH3 I’m testing the persistance again using Mysql, it works with the below code without errors but it creates persistance not only to the configured item but also for all the other items! Am I doing something wrong??? Thanks.

jdbc.cfg
"
url=jdbc:mysql://192.168.1.51:3306/openhab?serverTimezone=Europe/Berlin
user=openhab
password=openhab
tableNamePrefix=Item
tableUseRealItemNames=false
tableIdDigitCount=0
"

items
"
String Sala_CPE_rec {channel=“mqtt:topic:MyMQTTBroker:TH_CPE_Pe:TH_CPE_Pe_rec” }
Switch Sala_CPE “Test Light []” {channel=“mqtt:topic:MyMQTTBroker:TH_CPE_Pe:TH_CPE_Pe_SW” }
Number Sala_CPE_TMP “Temperatura [%.1f°C]”
"

persistance
"
Strategies {
everyHour : “0 0 * * * ?”
everyDay : “0 0 0 * * ?”
every5min : “0 0/5 * * * ?”
default = everyUpdate
}

Items {
Sala_CPE_TMP : strategy = every5min,restoreOnStartup
}
"

rules
"
rule “testrec”
when
Item Sala_CPE_rec received update
then
if (Sala_CPE_rec.state.toString.contains(“Slave,”)) {
var String[] buffer= Sala_CPE_rec.state.toString.split(",")
if (buffer.get(1).contains(“ON”)) postUpdate(Sala_CPE,ON)
else if (buffer.get(1).contains(“OFF”)) postUpdate(Sala_CPE,OFF)
Sala_CPE_TMP.postUpdate(Double.parseDouble(buffer.get(2)))
//getActions(“telegram”,“telegram:telegramBot:FS6”).sendTelegram(“Test”)
}
end
"

Filename? This matters.

The file name is:

mysql.persist

But you’re using jdbc persistence, yes?

(In OH3, an absent xxx.persist file causes a default “persist everything” strategy.)

so what you say is if my project is called for example “test” and all my files are:
test.items
test.rules
test.things

I must have a file called test.persist for my persistances, right?

No, you must have a persistence file that matches the name of the service you’re using, as stated in the documentation.

Persistence Strategies are configured in a file named <persistenceservice>.persist , stored in $OPENHAB_CONF/persistence . Replace “persistenceservice” with the name of your persistence add-on (e.g. rrd4j.persist ).

So if you’re using JDBC, then it’s jdbc.persist. Otherwise, the service doesn’t know where to look for the strategy and will persist everything.

I assume you’re migrating from MySQL to JDBC, in which case the JDBC docs mention that you have to rename the file.

Remember to install and uninstall the services you want, and rename persistence/mysql.persist to persistence/jdbc.persist .

However, it would be easy to miss this as it’s tucked under an image.

Thanks, its working now :sweat_smile: :sweat_smile: