Just for my understanding, since I just started using a MySQL database together with OpenHAB 2, and the state(s) some light switches are placed into the database. I use the strategy “everyChange”.

Now if I use these rules shown here, the periodic check is done every 10 minutes.

In case, e.g. I go into the bath room, turn on the light, stay there for about 2 minutes, and then leave it and turn the light off again, this won’t be replayed, as the check is done only every 10 minutes, right?

Would it make sence, to do the periodic check every 1 minute, if not present? Would this lead to a more accurate presence simulation? Or would this be too much for my little raspi 3? In Addition, I would’t log the check, as this leads to a real full log then.

I think reducing the interval to 1 minute would really replay the “real life”.

What’s your opinion about that?

And now for beginners like me: where would I implement this rule? Up to now, I only used the PaperUI on OpenHAB with Raspi 3. Where could I store the values for Presence and Lights_away_auto?

I have my trigger at 5 minutes on an rPi3. Works fine, although Im not using the code above. I do mine differently. I also never toggle the simulation, it’s automatic. I have several rules to determine human presence based on door/window contacts, my indoor camera motion etc. If no human presence is detected for a configurable amount of time, then human simulation begins:

Random lights

max 2 hours each light

max 2 lights on at a time

max 20 minutes of ‘no’ light turned on

lights only turn on based on astro sunset time

During day time

I randomly play 2 radios, 1 upstairs, 1 downstairs.

Both chromecast audios

Random play uri/stations

Max 2 hours each per continuous play

Max 20 minutes of silence (both off)

when simulation has started, it does not rely on cron to determine the next ‘tick’ but I rely on a timer. Once timer has ended, a new timer starts with the new random duration.

Thanks, it works now!
Hint for newbies (note to self…): It won’t work if you put a group that only contains other groups as “gLights_auto”
It will iterate over the groups and will be unable to access their historic state etc. You want to iterate over a group of Lamps (or Things for that matter).

Great idea and I’m just about to implement it.
One general question about the behaviour of persistence:
I’m using influx with a „onChange“ strategy. When I turn a light on persistence will insert the state with timestamp into the influxdb. So far so good. Let‘s say I turn on a light 7 days ago at exactly 7pm. The presence simulation queries the state of that light at 7:05pm. There won’t be an entry in the influx db with timestamp 7:05. I guess the persistence service will return the „last known“ state which is the State with timestamp 7pm, right?