[SOLVED] When does the persistence create a new entry?


(Sascha Billian) #1

Hi everybody.
OpenHab 2.3 on Raspberry 3 with openhabian-config 1.4
I am using mysql as a persistence service.

assuming the value of an item hasn’t changed, should the following create a new entry in the table for the item?

item:

Number IrrigationRaisedBedMoistureMin   "min. Bodenfeuchte Hochbeet [%d %%]"       <water> (gGardenIrrigation, gPersistence)

Persistence:

gPersistence* : strategy = everyChange, restoreOnStartup

Part of a rule that gets regularly executed

IrrigationRaisedBedMoistureMin.sendCommand(IrrigationRaisedBedMoistureMin.state as DecimalType)

For me everytime the rule gets triggered, there isn’t an update in the persistence service. So I think that the persistence only stores new data when an item is updated and in addition the state of the item also has changed. But what I want to acheive is getting a new data set in the table if the item even if the state value has not changed
I see in the log that the item gets updated with the new state;

2018-07-12 22:34:42.719 [ome.event.ItemCommandEvent] - Item 'IrrigationRaisedBedMoistureMin' received command 40

Am i doing something wrong here?


(Sebastian) #2

This is the answer. everyChange means the value must change. If you want to persist also updates for the same value you have to use everyUpdate as persistence strategy.

As alternative or additional you can also use time based strategies like every minute or even combine all of them


(Sascha Billian) #3

oh boy…I hate it when the answer is in the docs :wink:

Thanks a lot for the hint, @hannibal29