Rule Engine Turns on Wrong Switch in Rule

I have a strange problem. I have a rule that turns on a switche when motion is detected on a sensor. I know the rule is correct. However, when the rule is invoked, one of the switches (even though it has the correct switch selected) turns on another switch.

I have tried deleting and re-adding the rule, but the same thing happens. Here's the simplified scenario:

There are are two switches -- SWITCH 1 and SWITCH 2.

"If motion is detected turn on SWITCH 1"

SWITCH 2 is actually turned on.

When I go to the devices tab and turn on SWITCH 1. The correct light (SWITCH 1) is active.
When I go to the devices tab and turn on SWITCH 2. The correct light (SWITCH 2) is active.

Therefore, it only occurs in the Rule Machine.

Like I said before, I have deleted and re-added the rule. Is there anything I can do without trying to exclude and include SWITCH 1 again?

Thanks-in-advance.

Maybe post the rule, what does the logs show. You should enable all logging for the rule and run it. Perhaps you have another rule that is being triggered that is changing the switches,

The log should show you what is happening. If you are able to control the switches via the device page with no issues then removing and re-adding the switch is probably not going to help.

Also check the 'In use by' section at the bottom of the device page for both devices just to see if there is an old automation that you may have forgotten about that could be causing this.
Maybe an old IFTTT or Google/Alexa automation.

Here is the rule:

Trigger: Back Porch Motion changed

IF (Time between Sunset and Sunrise(F) [FALSE]) THEN
IF (Back Porch Motion active(F) [FALSE]) THEN
Cancel Delayed Actions
On: Outdoor Corner Floodlights, Back Porch Lights, Outdoor Backyard Floodlights
ELSE-IF (Back Porch Motion inactive(T) [TRUE]) THEN
Delay 0:06:00 (cancelable)
Off: Outdoor Corner Floodlights, Back Porch Lights, Outdoor Backyard Floodlights
END-IF
END-IF

I will turn on logging, but I'll have to wait until tonight to see the results based on the code above. I don't feel like changing the Time between Sunset and Sunrise since I'm not at the house right now.

It is used by one other rule that just ensures it is turned off at 8:00AM in the morning.

Also, it is used by: Dashboard and Maker API.

Thank you for the tip. It's much simpler as well.

1 Like

Curious as to why the second IF is needed when the trigger has been set/changed to "active" . Does the Wait for Condition actually cause these actions to run again?

furom - What is the trigger event for the code you posted -- changed or active?

So if my assumptions are correct, is what I have below another way to "skin the cat"?

1 Like

Well I turned on all all logging for both the rule and the switch, but nothing showed up except that the light was turned on/off digitally when I activated the motion sensor. The motion sensor just said that it was activated/inactivated

RM:Back Porch Motion Detected 2021-04-22 03:20:49.469 PM EDT
RM Back Porch Motion motion inactive 2021-04-22 03:20:49.463 PM EDT
location RM:Back Porch Motion Detected 2021-04-22 03:18:05.415 PM EDT
RM Back Porch Motion motion active

Is there anything else that could be causing the Rule Engine to turn on/off the wrong switch?

Bump. Has anyone experienced this before?

The original question mentions switch 1 and switch 2, but the copy of the rule you posted seems to show 3 devices, so it isn't exactly clear what the experience is.
The logs from RM would help see what is going on, but if I understand correctly, you said you turned logging for the rule on but there wasn't any RM logs at all?

What hub and platform version are you running?

I was trying to simplify things. The rule has 3 switches. Two of them work correctly. The one "Back Porch Lights" is the one that is SUPPOSED to be turned on. However, it turns on another switch that isn't in the rule, but exists on the hub.

I am running the Elevation -- latest version of the platform.

What does RM stand for? I turned on the logging for both the devices and the rule, but couldn't find anything of any significance. How should I turn on the logs correctly and where would I find them once the rule runs?

EDIT -- Never mind. RM stands for Rule Machine.

Thanks.

Under logging drop down select all options.

Then as you run the Rule have the log page open(current), or after you run it go to logs and look at past logs.

Will do. I'll let you know how it goes.