Persistence triggers

Hi

I just started using persistence in my setup, and wanted to try my motion sensor.
When it detects motion, it changes state from OFF to ON, and after 30 s it changes back, from ON to OFF.

When looking in the persistence docs I only see the Cron triggers, everyChange and everyUpdate.
Using everyChange will in this case generate a row in the db both when going from OFF to ON, and when going from ON to OFF.
Is there a way to only get the OFF to ON transition recorded in the db?

Thanks!

/GC

i don’t think there is a way to do this in OH right out of the box.
But of course this is doable, depending on what kind of persistence you are using.
Basically you need some sort of cli for the database

What’s wrong with recording ON->OFF as well?

You can explicitly persist data from within a rule, something (untested, sorry) like

when item changed from OFF to ON
then
    item.persist
end

(and you can remove item from your “auto” persistence service)

1 Like

Well, it’s not a big problem, but for my purpose it’s simply a waste of space.
I was mainly asking if there are any obvious things I’ve missed, since the documentation is kind of sparse in some areas.

/GC

Space should not be an issue, and if it really was you can use a persistence service to compress/auto-aggregate older data such as rrd4j. I`m sure once you omit recording half of the events, right the other day you’ll encounter an application where it would be helpful to still have access to that data.