I am a new HE user (4 days) and I am having heck of a time trying to figure out how to get a rule working properly. I am a decent IT guy but sucks at programming.
I would like to:
When the this light is already on, and when a motion is detected, turn the this light to 100%.
after 5 minutes with no motion, turn it down to 5%.
if motion starts before that 5 minutes timeout, keep light at 100% and start counting 5 minutes again after the motion stops, cycle repeats.
If the light is off, don't do anything.
What I know is my motion sensor (Bosch Zigbee PIR) triggers for 3-4 seconds, then won't trigger again for about 4 minutes.
I have been looking online for examples that I can use. This is what I have so far...
Is there a reason you're using the running variable? There may be some oddity with your sensor that I don't understand (going "active" and then not generating another "active" event for several minutes isn't uncommon--and should be fine as long as it doesn't get stuck at "inactive" in the interim), so it may be simpler to leave that out. The only problem I see is that your lights are going to dim to 5% after motion stays inactive for 5 minutes since the ELSE will run anytime the IF condition isn't true, which would include any time the lights are off.
I'd start with something simple like this and see if it works for you:
IF (NOT Light is on) Exit Rule
Dim: Light to 100%
Wait for events: motion inactive
Wait for events: elapsed time --> 0:05:00
Dim: Light to 5%
(I'm using a slightly different paradigm than you did above since I think using the "active" trigger with "Waits" makes things easier than using IF THEN/ELSE with delays and cancellations, but it's otherwise pretty similar aside from how it handles the light already being on as something that will prevent anything from happening; that's a simple conditional, but you could make it a "full" one if you wanted or wrap this entire set of actions in such a conditional instead of using Exit Rule.)
You could write two sensors into a rule with a bit more work, but I'd probably take the easier route: use the built-in Zone Motion Controller app to "combine" those two sensors into a single sensor, then write a rule in the same manner as the above with that device instead.
It should also be noted that if you just want a normal "turn lights on with motion, then turn off" setup, then the built-in Motion Lighting or Simple Automation Rules apps can handle that without the "zone" sensor; you can just choose more than one sensor in those apps, and they do all the work for you. But because your "only change if on" and "dim instead of turning off" thing, you'll need something else (actually, I think you could trick Simple Automation Rules into doing this if you use the right restrictions and whatnot, but the rule is pretty easy to write and gives you more flexibility if you need it).