Hi @rlkoshak,
I was trying to set up presence simulation. I practically copied your entire code (renamed some groups and variables).
But I get an error when the rule is saved.
My rule:
// ***************************
// Global variables
// ***************************
var int presence_days = 1
var int presence_delay = 50
var String persistence = "influxdb"
// ***************************
// Presence Simulation
// ***************************
rule "Presence Simulation"
when
Time cron "0 0/5 * * * ?"
then
if (Virtual_PresenceSimulation.state == ON) {
gPresenceSimulation.members.forEach(light,i |
val oldState = light.historicState(now.minusDays(presence_days), persistence).state
if(oldState != light.state) {
createTimer(now.plusMillis(i*presence_delay)) [|
logInfo("Pres_Sim",light.name + " got " + oldState)
light.sendCommand(oldState.toString)
}
]
)
}
end
The error:
2017-07-19 19:36:37.585 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'presence_simulation.rules' has errors, therefore ignoring it: [19,25]: no viable alternative at input 'val'
[24,25]: extraneous input '}' expecting ']'
I cant’ find out what is wrong with the code.
I assumed the “}” and “]” got switched. So I adapted the last bit in the rule to:
light.sendCommand(oldState.toString)
]
}
)
}
end
But it didn’t solve anything…