Newbie question

Hi all. new here from wink. could someone show me a walk through on how to perform this type of rule?
virtual button pressed

loop while virtual button not released
set color of bulb to red
wait 1 minute
set color of bulb to blue
wait 1 minute
loop

I'm not new to programming but the rules machine interface is confusing me. I think mostly because i don't understand the nomenclature yet.
let me know if this is the wrong place to request this type of assistance
TIA

You can send held and released events from a virtual button, but you cannot hold down a single button and get a released event when you stop pressing it.

You could toggle a virtual switch with a button push. So push once, it’s on, push again it’s off.

Conditional actions are what you need to use to build this.

You can use wait for event: elapsed time 1min

And there’s a repeat, but be sure to set the virtual switch off state to give you a stop repeating actions

1 Like

i didnt' see the elapsed time event. thanks for the heads up. i'll do some more fiddling around

UPDATE: See the post below for a better way to do this: Newbie question

This is a rather complicated automation to write. Here is one I just did, with different times. It works.

One note: I set the repeat loop time to just over the combined two wait timeouts, so as to be sure a Wait wasn't pending when the loop started over. The Wait sets %device% to 'timeout' when it times out, or to the device name when the wait event actually happens. So testing to see which happened to decide whether to exit the rule or keep going.

2 Likes

thanks for this. i'll have to click around to find all the commands you're using.
in my attempts to do what you have above i didn't see the ability to set just a repeat just based on time. i only saw number of times and time to wait.

Agreed, and impressive. I was just thinking that it would nice if "held" and "released" were available as conditions.

Each repeat, each time around the loop, has to have a time specified. There is not a repeat action that is 'keep repeating until 30 seconds have elapsed'. The reason for the time on each loop is that you don't want the hub to just spin on that loop, consuming all of its compute resources.

You can do these types of repeat:

  1. While loop. Continue repeating as long as a condition is true (Simple Conditional action with Repeat as the action).
  2. Counted loop. Repeat n times.
  3. Repeat until loop. Put a test in the loop on some condition(s) and Stop Repeating when met (similar to the above).
  4. Infinite loop. Don't put Stopable on the Repeat. Hmmm, not sure how you'll ever stop this one -- it would have to be stopped by some other rule or a different branch of this rule when re-triggered.
  5. Stopable loop. As shown above.

They are events, so not a condition. You can capture the event into a variable, and then you have something that can be a condition (last event was...).

2 Likes

There is a better way to do this than what I showed above, using two rules instead of one. Both rules are fired by the same event, namely the button being pushed. One rule just does the alternating lights, and the other just waits for the button release. This is both simpler and more reliable. Here are those two rules, and you can see how much simpler it is this way:

Again, the times are not the same, but you could make those whatever you want.

2 Likes

Hi all, new to HE here... Been working on some RM rules for the past 9 hours (it's literally past 2am here in Australia) and still can't get them to work the way I need them to.

All I am trying to achieve is to have my bathroom and other 2 rooms in the house light turn on upon contact sensor 'closed' event. I created a few rules using the Simple Automation app but my flatmates have been leaving the door shut (out of habit) so the lights stay on forever. Then I wanted to set rules to have the lights turn off after a certain time but it just ain't working for me. I've tried every single logic I could think of.

Here are a few screen shots of some of them:

Here are some of the logs:

I've got it working by removing some of the logic from RM and using Simple Automation rules to do the rest of the job but I feel like I shouldn't have to as RM can do it all.

Here's the one from RM which is working:

And here is the one from SA which complements the RM one:

Please help!