Yes, I know, but does it get updated?
Most (but not all) devices will update the Item to ON even if it’s already ON. By default updates are not shown in events.log but there are lots of ways to descover how the Item is updated:
- sometimes it’s covered in the binding docs
- use the developer sidebar and fillter the event stream to just see those updated events
- create a rule that triggers on “received update to ON” and log something
Updates are a different event from changed. Update will trigger the rule even if the Item is already ON.
We want that because it means the rule will trigger every time motion is detected, not just every 90 seconds.
But, since the 90 seconds < 5 minutes the following approach should work. We are not at your machine. We cannot guarantee that any rule will work exactly as typed. You will have to have to adjust as necessary.
var Timer tBadLicht = null
rule "Licht Bad ausschalten, wenn keine Bewegung erkannt"
when
Item Bewegungsmelder_Bad_IKEA_of_Sweden_Motion updated to ON
then
if(tBadLicht == null || tBadLicht.hasTerminated) {
createTimer(now.plusMinutes(5), [
Moes10504_Switch1.sendCommand(OFF)
])
}
else {
tBadLicht.reschedule(now.plusMinutes(5))
}
end
That rule will sendCommand OFF to Moes10504_Switch1 five minutes after the last time
Bewegungsmelder_Bad_IKEA_of_Sweden_Motion is updated to ON.
Another alternative that can work in this case is to use Expire. Navigate to Moes10504_Switch1 and click “Add metadata”. Choose Expire and configure it as follows:
value: 0h5m0s,command=OFF
config: {}
Then create a rule:
var Timer tBadLicht = null
rule "Licht Bad ausschalten, wenn keine Bewegung erkannt"
when
Item Bewegungsmelder_Bad_IKEA_of_Sweden_Motion updated to ON
then
Moes10504_Switch1.sendCommand(ON)
end
This approach will command the switch to ON every time the motion sensor detects motion. Five minutes after the last motion is detected Expire will command the Item to OFF.
In both cases though that it’s the motion sensor that drives things, not the light switch.