Rule creation assistance

I have a rule that I'm trying to figure out and get to work correctly. I have a gate on the property, and a vehicle sensor buried at the entrance. There is a traffic light at the gate, controlled by a Zen17.

The first rule happens, when the gate is the closed position, and then opened for a vehicle to come in, the traffic light cycles from Red, to Yellow and finally Green, as the gate is fully open.

I'm trying to create a rule, that when the gate is already open, and a car drives in, the Green light would turn on.

I created what I thought would work, but the issue, is that it works while the traffic light is cycling, because the gate was just opened, and a vehicle was detected.

I wrote the rule, based on vehicle detection, and then turn on the Zen17 for Green. So I get two rules overlapping.

I think maybe I need one rule, with both triggers in it, like a "and or' type of rule, but don't know where to start.

Showing both rules (as you have them now) is the only way other folks are going to be able to provide any meaningful help.

without seeing the rule I'd say you need a variable and 2 or 3 conditions attached to the light changing to green, but let's see the rule

I realized I forgot the rules, once I tried to paste something elsewhere...

Here is the first rule, that sequences the light, with the trigger of the Gate opening.

Here is the other rule, I think I need to combine them somehow, so that the Gate opening is a trigger, and or the vehicle detector. But when the gate opens, AND the vehicle is detected, obviously they run at the same time. In other systems, I would set a flag for the gate being open status.

I'm confident someone smarter than me can offer a way to combine all of this into one rule, but rules are free - it's no problem using multiple rules to get something done (and that approach is often preferable due KISS)...

In that spirit, I'd move the second rule to Rule Machine and just add a Required Expression that the gate is already open.

2 Likes

I think Iā€™m understanding the request to combine everything into one rule. My suggestion is based on the assumption that the gate only opens if a car is present. If that is true, then Iā€™m thinking the following might work (or at least get it closer to what you want)

Trigger
Car is present

Actions

If gate is closed,
do the color sequence
Else
Green light
End-If

In this rule, a car triggers the sensor. If the gate is closed, it does the color sequence. If the gate is open, it goes directly to Green.

I think this is the solution. I didn't think of the operation that way, but you are right. The gate stays open most of the day, So Green would work, but if the gate was closed, and the car trigger happens, then it would run the sequence. All in One rule. I'll give it a try. Thanks!