Hi,
I’m trying to create 2 rules. First when I enter the bathroom witch on Sonos and keep this on until in this case 60 sec no movement. Second rule I don’t know how to create this one. It should start when the timer from the first rule is expired.
var Timer BadkamerBezetTimer = null
var Number StartVochtigheid
var Number BadkamerBezet // do we have a boolean ??
var Number BadkamerRadio
rule “BadkamerIsBezet”
when
Item Beweging_gEVBadkamer changed from OFF to ON
then {
if (BadkamerBezetTimer === null) {
BadkamerBezet = 1
BadkamerBezetTimer = createTimer(now.plusSeconds(60))
sendCommand(SonosBadkamerVolume, 12)
sendCommand(SonosBadkamerControl, PLAY)
BadkamerRadio = 1
} else {
BadkamerBezetTimer.reschedule(now.plusSeconds(60))
}
}
end
// in the above rule I get error message Rule ‘BadkamerIsBezet’: An error occurred during the script execution: index=1, size=1
rule “BadkamerIsVrij”
when
Item BadkamerBezetTimer === nill // need to do something when trigger is zero
end
Rules are triggered based on events on Items and in some cases time or Things. BadkamerBezetTimer === null is a state, not an event, and BadkamerBezetTimer isn’t an Item it’s a varaible. You can’t trigger a Rule in this way. If you need to do something when the Timer variable becomesnull, add the code right after you set the Timer to null. Note that when the Timer runs it does not set the variable to null, you have to do that yourself, usually as the last line of the lambda that you pass to the Timer.