Rule Machine - Get peer assistance here with setting up rules

I’m creating this thread as a place to find assistance in programming the logic of the Rule Machine App. @bravenel - I see you doing a lot of updates every day and posting them in the [Release] thread, I figure this will help to keep it clean and not get hijacked… as much…

I’ll start!

I’ve set up some rules for my front porch lights. I haven’t figured out how to do with any less than “4” separate rules. I’d like to simplify this as much as possible.

What I want:

  1. Lights come on 20 minutes prior to sunset, go off at 11 pm, and be set to 30%

  2. When either my wife or I come home between sunset and 11pm, even if the other is already there, the lights go from 30% to 99% for 10 minutes. After 10 minutes they go back to 30%.

  3. If it is after 11 pm and before sunrise, I want the lights to come on at 99% when we come home, and go off after 10 minutes.

Explanation of my Logic process in Rules I’ve created ~

Part 1 - Lights come on 20 min before sunset at 30% (Truth). They Go off at 11 pm (False).

Part 2 - App detects new presence and adjust the lights if they are at 30%. Lights go from 30% to 99% when one of us arrives between sunset - 20 and 11 pm. (Only used False on this one. That way it triggers when our presence comes home)

Part 3 - App detects lights at 99% and adjust the lights to 30% after 10 minutes. (False left blank)

Part 4 - Between 11:05 pm and Sunrise the app detects if the lights have come on (presence arrival after 11 pm turns on the lights, done in Part 2) and turns them off after 10 minutes.

My thoughts…
Part 1 turns the lights on from time A to time B
Part 2 detects presence and turns the lights to bright,
Part 3 detects lights on bright and dims them after 10 minutes. This one works for Part 1 time and after Part 1 time until sunrise
Part 4 detects presence after Part 1 time and turns the lights off.

Wow… I’m confused, but I think I actually need one more rule… Rule Part 1.1 - turns lights on from time C to time D only with presence detection

Ok, I’d like to simplify this… what are y’all’s thoughts???

7 Likes

Ok, I’ve tested this the way it is set up above… and everything works.

  1. the lights come on at sunset -20 and go off at 11 pm ( Part 1 did this before sunset)
  2. the lights go from 30 to 99 during above time when presence arrives (Part 2 did this upon arrival). The lights went back to 30 after 10 minutes (Part 3 did this after 10 minutes)
  3. the lights came on at 99 upon arrival after 11 pm (Part 2 did this)
  4. the lights went to 30 after 10 minutes (Part 3 did this)
  5. the lights turned off after 10 more minutes (Part 4 did this)

Amazingly to me, it works!

1 Like

Sometimes the best solution is the complex one!

1 Like

@bravenel

Logic question about rule machine.
Is there any functional difference in including a “mode” as a condition or using the “restrict on mode” feature?
I assume that both would logical AND the mode with the other conditions.

Big difference. Restrict on Mode prevents Rule Machine from evaluating the entire rule unless there is a Mode match. With Mode as a condition, it continues to test for true/false of your other conditions, but won’t fire until the specified mode is also true/false.

1 Like

Do these logs seem weird to anyone? My stats are not really staying on the true condition, and I think the second line (the top line) is setting them off… even though the mid line is setting a delay.

7:42:15 PM: info Second Floor Occupied is False
7:42:15 PM: info Second Floor Occupied is False, but delayed by 30 minute1
7:42:15 PM: info Second Floor Occupied: mZone-Upstairs motion inactive

Edit: A more full log, and my true’s are showing a delay even though it’s my false only that is delayed. @bravenel is this possibly a Rule Machine issue, or user error? My rule is: Motion Active AND Mode(Home), and my True Action is set thermostat set points (heat and cool) and my false is set thermostat set points but after a delay…

No rush, this partially works right now (home/away), it’s only the occupied and delay that is stumping me.

As far as I know, if you enable the delay, it applies to the whole rule- it’s not really a true or false action, even though it is selectable there. - I presume you combined the true and false actions into one rule… separate out the false conditions to it’s own rule and put the delay in that rule instead…

Man, I wish there was a way to make a rule only run based on the current state of a device, and not be affected by it’s state change. Off to browse the competition! :wink:

@bravenel - if the Smart Weather tile is used as a condition (specifically the illuminance value is used, in a less than condition (like <1000 lumens) will the rule evaluate every time the value updates and is a value under 1000, or only when it goes from more than 1000 to less than?

The rule evaluates whenever it gets an update from the “device”. If the rule was false before because lux was 1200, then it reports 990, that would make the rule become true, and take it’s true actions.

right, but if it goes from 990 to 800, would it trigger the rule to run true again? – (i have a light set to on for 5 minutes if person a or b present and illuminance < 1000, but that won’t work if it keeps re-running as true each time the illuminance value updates with a value less than 1000

No, because the rule became true the first time it went below 1000. It won’t do anything until it goes false, or goes true again after going false. If it stays below 1000, nothing happens. The rule is evaluated on each new report: same outcome, no action.

You can always set the true and false for the same state. That might work

I asked this in the other thread at one time, but this one still is not clear.

If my mode changes from any mode TO home mode AND it is between sunset and sunrise turn on this series of lights.

The problem that I have is if set my two conditions as:
MODE: Home
Time: Between Sunset and Sunrise

Won’t it also trigger if I in home mode and sunset hits? I don’t want that. I only want it to take action if it is dark when I am arriving home and the mode changes to home.

1 Like

Just thinking, if you have aV2 hub, isn’t this better suited for smart lighting? Local control, fast response, etc.

I love rule machine but I only use it for things that SL can’t do.

I was simplifying. I also want it unlock some locks, take delayed clean up actions shuting down those lights and locking those locks.

You could add a second home mode, called home night and link to that as a condition instead.

Toasty -

Not sure I follow. Are you suggesting a mode Home Night, that automatically switches on at Sunset and off at Sunrise?

I don’t see how that solves the issue. Plus the complications of another mode, etc.

I have a rule that turns on a light to red at 20% when mode is Home (Armed) and Presence is TRUE . When this evaluates to FALSE I want to set the color to warm white and turn the light off. (I also want to do some other stuff that Smart Lighting can’t do. I just haven’t added that logic yet). The reason I want to set the color back to white when FALSE is so that the light will operate normally when alarm mode is not active.

I have tried setting the bulb level to 0, thinking this would equate to off, but that actually sets the bulb level to 99.

I have also tried turning the light off while setting the color to white and the bulb level to blank or 0 (I tried both settings).

I ended up creating another rule that just sets the color to white and bulb level to 0 when mode is Home (Disarmed) TRUE. Nothing for FALSE. This will only work on every other repetition between armed and disarmed (first rep it will work, second rep it sets the light to white 99, third rep it works, fourth rep it sets it to 99, etc),

Could this be a sequence or logic issue?

I suspect that the setting the bulb level to 0 is being caught by the Device Type, changing it to 99. I could catch that in the color handler in Rule Machine, and turn the bulb off after the color has been set. But I don’t have enough experience with color bulbs and their software to know if this is the right thing to do or not. You would think that light level 0 means off, but there may be some reason they treat it the way they do.