open door reminder in jruby:
rule "open door reminder" do
changed Door_Sensor, to: OPEN # If you just have one sensor
changed Door_Sensors.members, to: OPEN # If you want to deal with a group of door sensors
run do |event|
after(15.minutes, id: [:door_reminder, event.item]) do |timer|
next unless event.state.open?
Voice.say "#{event.item} is open"
timer.reschedule
end
end
end
You can use a UI based rule, just set up a trigger when the sensor changed to OPEN and only use the after
… end
block from above as your script. So this is the body of your rule:
after(15.minutes, id: [:door_reminder, event.item]) do |timer|
next unless event.state.open?
Voice.say "#{event.item} is open"
timer.reschedule
end
For this situation, you debounce it.
Jruby offers three types of debouncing mechanisms for you to choose