How can I persist serveral items in another way then the "default"-behavoir?

Tags: #<Tag:0x00007f616e262b00> #<Tag:0x00007f616e262a38> #<Tag:0x00007f616e262970>

Hello,
i have the problem, that i want to save the state of my weather items on everyUpdate and all other items on everyChange with mysql. My weather items begin with “localCurrent”.

This is my mysql.persist:

Strategies {
   default = everyChange, restoreOnStartup
}
 
Items {
   //*: strategy = everyChange, restoreOnStartup
   localCurrent* : strategy = everyUpdate
}

But when I’m doing this nothing is persisted anymore. Can you help my with that issue?
Maybe I have to put all “normal” items into one group and the weather items in another.
But I’m wondering, why I can’t use it in the style above.

Thank you
Nico

these are not elements starting with localCurrent
these are all elements included in the group.
Create a group “gLocalCurrent”, add the necessary elements to it and change the line to gLocalCurrent* : strategy = everyUpdate

1 Like

Okay thank you. I try this and report later.

Hi,
I now found out that it seems to work, when I use this configuration:

Strategies {
   default = everyChange, restoreOnStartup
}
 
Items {
   *: strategy = everyChange, restoreOnStartup
   gWeather*: strategy = everyUpdate, restoreOnStartup
}

Thank you for your help.
It’s solved now.

1 Like

Please be careful when specifying every Item to persist.

This stuff comes with an overhead. On a resource limited Pi it can impact performance. On an SD card based system, it can increase wear on the card by frequent writes.
Depending on the technology your Items may be associated with, and how often it updates them, this can get really noticeable.

Have a think about which Items you really need to persist. Important settings, things to be charted, etc. Don’t persist/restore just to make rules easier - write your rules to deal with the case that an Item may not be ready at system startup.

I’ve got just a half dozen important settings that I persist/restore, and maybe ten others persisted only for charting.

EDIT - late postscript
Another risk with “persist everything” strategy - at the moment, Location type Items cannot be persisted. They will break your service.

1 Like