Help with Conditions

I have done some fairly basic rules in Rule Machine, but have never gotten into the world of "Conditions".

The Problem: I have written a rule where if I tell my car's Alexa I am approaching the house, it will turn on the outside lights, set the kitchen lights to a set dimmed level, and then shut off both sets of lights after a set time. I also want to add opening the garage door, then closing it.

What I want to do: I want to have it so that the garage door part works at all times, but the lights will only come on if it is after sunset and before sunrise.

What do I do?

Any help is, as usual, most appreciated. Thanks in advance!

  • The Retired Viking -

Since you already have a rule, it might be best if you shared that, then someone can suggest modifications to make it work how you like (instead of starting over).

That being said, it sounds like you just need to wrap specific actions in a conditional, then the actions inside will only be executed if the expression is true when that line is reached. I'd normally suggest adding an "IF THEN...", which requires an "END-IF," this block enclosing the actions you want to restrict based on the evaluation of the expression.

For example, if your actions currently look something like this:

Open: Garage Door
On: Kitchen Lights, Outside Lights

Then you'd want it to look like:

Open: Garage Door
IF (Time between sunset and sunrise) THEN
  On: Kitchen Lights, Outside Lights
END-IF

Of course, you will need to modify the exact actions and what exactly is inside the conditional based on what you actually want to do when.

2 Likes

Here is what I have so far. I have not yet added the garage door function because I have not yet installed the device I bought to make it work. I have a Chamberlain opener so all the ways I have available are locked out (thanks, Chamberlain!). I forget the brand, but it is a device that mashes on the button of a regular sun-visor garage door opener button.

So if you put all of the actions you have between the If and end if as @bertabcd1234 has above it will only do those actions between sunset and sunrise. You would than put the garage actions eithe before the if or after the end-if so those actions will run anytime the rule is triggered.

I only know how to use Rule Machine. Does it generate code I can add the if / end if into place? Or is there some way to do this with the Rule Machine? (I've not written code since the days of Turbo Pascal!)

This is all Rule Machine, not code. Just add the "IF THEN" (and "END-IF," although there are also UI shortcuts that appear when you're likely to need them) from the menus the same way you add any other actions in your Rule.

I just this minute dived in and put this together. Again, the garage door button-masher isn't in-place yet.

Am I on the right track?

1 Like

Close! But your expression is broken. You have two conditions, sunset-30 (which will be true at exactly that time only) and "Time between sunrise+30 and," which is incomplete as you are missing the end time. I assume you want a single condition like "Time between sunset-30 and sunrise+30", but once you figure out the logic for that, the rest sounds like what you want!

That's exactly what I want. I'm scratching my head and stroking my beard in thought but not sure what to do. Thanks very much for the help.

You already did it once in your example above, but there you just didn't finish the other side of the between.

Go into Actions


Click on Manage Conditions


Finish the Ending at Section with Sunrise

Click done with conditions
And it will be completed

I think I have it sussed out. Had an interruption here but will give it a try later.

Thanks again!

1 Like

Pay VERY close attention to the order in which you click the “finished” or “done” buttons when writing rules. I you “finish” the ‘outer’ part of something before the ‘inner’ part. You will get broken rules like you had earlier.

1 Like

You might also be interested in this thread: Alarm Beeper For Garage Door

I also have a remote button masher for my garage door. It works great. The issue is in making closing the door safe and up to code when nobody is there to see that it's safe.