Small update/improvement to the Presence Simulation rule for anyone who want to re-use it:
Added the 3 variables on top to be easier to adjust the settings.
-
days = 7
(in days of course) is how long back in time the rule will go to pull state information from the items to be “replayed” to simulate presence -
delay = 50
(in milliseconds) is the time gap between each sendCommand (to avoid overloading the bus) -
persistence = "influxdb"
(text) is the selected persistence service from which to pull the historical data. This is useful if you use a default persistence like rrd4j or mapdb and have influxdb as a 2nd tier persistence service.
var int days = 7
var int delay = 50
var String persistence = "influxdb"
rule "Simulate Lights on Vacation"
when
Time cron "0 0/5 * * * ?"
then
if (Vacation_Mode.state == ON) {
gGF_Lights.members.forEach(light,i |
createTimer(now.plusMillis(i*delay)) [|
logInfo("Vacation",light.name + " got " + light.historicState(now.minusDays(days), persistence).state)
light.sendCommand(light.historicState(now.minusDays(days), persistence).state.toString)
]
)
}
end