Rule Machine Question: Cancel delayed action on truth change

Hopefully this isn’t a case of RTFM…

I’ve been creating a lot of rules lately that involve cancelling delayed actions on truth change. I find that this will only work when I specify a trigger that is always true anytime that particular capability changes its state…

For example…I have a space heater in my room. I made a rule that says to turn it off after two hours:
TRIGGER heater is switched on
CONDITION heater is on
ACTION turn it off, delay by 2 hours, cancel on truth change

I set the condition to be when the heater is on, so that way if I turn it off, it cancels the scheduled action. However, when viewing that rules page in the IDE, it still shows the scheduled task. I found that in order for cancel on truth change to work, I had to change the rule to be defined as:

TRIGGER heater is switched on OR heater is switched off
CONDITION heater is on
ACTION turn off heater, delay by 2 hours, cancel on truth change

I’m guessing this is because the rules will only be evaluated when a trigger event occurs, which means the cancel action would never run, because it doesn’t know the condition changed to false?

I have another similar rule set up that I’ve been using.

This one is for my kitchen light, which I have turn on when it detects motion.

I have two rules, one that says to turn the light on when motion is detected. The other rule says:

TRIGGER: kitchen motion is inactive OR kitchen motion is active
CONDITION: kitchen motion is inactive
ACTION: turn off kitchen lights, delay by 5 min, cancel on truth change

I had to add the bolded part in order for the cancellation to work, otherwise it would always turn off after 5 min, no matter what.

Yea, you have it mixed up. If you want to use cancel, it has to be in a Rule.

There are three types of automations you can setup with Rule Machine:

  • a trigger [has Triggers, but no Conditions]
  • a rule [has Conditions and Rule, but no Triggers]
  • a triggered rule / conditioned trigger [has Triggers, Conditions and Rule]

This can be confusing, especially the last one.

A “trigger” is simple, event causes action.

A “rule” evaluates conditions under a logical rule to decide actions, and only takes actions when the rule truth changes.

A “triggered rule”, better thought of as a “conditioned trigger”, only does something when the trigger event occurs. When it occurs, the truth of the conditions under a logical rule decides the actions. At no other time will that rule be evaluated.

For doing things that entail cancel, you pretty much must use a rule, not a triggered rule.

1 Like

So, it sounds like I’ve been doing it right, provided I completely remove my trigger.

For example, with my heater. Since the trigger will fire every time the switch state changes (to on or off), then there is no need for the trigger, as the rule/condition (in this case the same) covers it.

This totally changes how I’ve been using Rule Machine. Because I ALWAYS provide a trigger no matter what…I know it says “optional”, but I never knew why.

This makes a lot more sense now, because I have a lot of rules where my trigger capabilities are also my conditions. Now I know that’s no longer necessary.

I always thought that the rules section was just a way of customizing a trigger. And that the trigger section was only optional because you could “evaluate” rules as an action in another rule.

Originally, 2200 posts ago, Rule Machine only had rules. They are hard enough to understand, but make sense once you do grasp the idea of conditions and a logical rule. But, triggers were a needed element as well. I knew fully well when I introduced triggers that it would lead to confusion. What to do? I decided to give the functionality and try to deal with the confusion.

The best idea is to read the original documentation, which is kept up to date.

So in the end, this is a RTFM situation. hahaha, I’ll go do that now.

Up till now I interpreted it as.
IF this happens (triggers)
THEN do this (actions)
BUT only if this is true (or false) (rule/conditions)

I saw conditions as a way of supplying a list of variables to act on, and the rule section as a way of customizing the logic of how those variables are used.

Now I understand it correctly though. It makes more sense. The trigger feature seems mostly helpful when your trigger capabilities are not the same capabilities that you are using in your conditions.

Sorry in advance… I’ve been searching the forums but can’t find what I am looking for. I too want to cancel an action on truth change, but I can’t seem to find that. I am new to rule machine and I thought that I’ve seen that option before but I don’t now.

Here is what I am trying to do.

Rule - When switch 1 is turned on
Action - Do some action after a delay.

What I don’t know how to do is cancel if the switch is then turned back off during the delay.

Try Delay These Actions. If you are on Android it’s difficult to see the option to Cancel on truth change, due to a bug in the Android mobile app. Set a delay number of minutes, then go back into the Delay These Actions a second time, and you should see the Cancel option.

1 Like

I do see it after going back in now. Thanks!

I see the Delay These Actions as the first choice under Actions for True. I also see inside Delay These Actions I have an option for Cancel on truth change. Then the second choice is the Control Switches which I want to use. Inside there I have chosen my switches, Turn off these switches, but under that I see Turn on or off these switches after delay, pending cancellation (default is OFF). Can you explain this? I’m trying to understand the differences between the two ways I can delay turning off these lights.
I hesitate to take a stab at it, but I’m guessing the first option is a catch all with a delay and the second one inside of “Control Switches” is specific to switch type devices?

I am loving RM and IMO Samsung owes you a rather large pay check.

On a side note, what are your feelings on the updates ST has done over the past week? Do you see any specific change or improvement. I am in the dark as to what you dev’s are pirvy too.

@bravenel I hate to pile on questions and sort of hijack this thread, but since its short and somewhat old, here goes. Whats the difference between using a time of day (or between two times) as a condition and “Only between two times” under restrictions?
Example: I want to turn off 3 switches and run “close garage door” and set mode to night. Conditions are no motion from two sensors and between 12am-5am. Delayed for 20 minutes in case I’m still burning the midnight oil.

Quick side question, does it hurt to run a close garage door if the door is closed? My idea is to catch a left open garage door. Obviously I don’t want a crazy mixup opening the door. You know ST cloud and all. I am sure I can make a sophisticated rule to check for open first, but I thought the simpler the better.

The first one delays all of the actions of that part of the rule (Actions for True). The second one delays the specific switches selected.

The difference is that Time of Day as a conditions causes schedules to be created for the start and end times, and the rule will be evaluated at those times. The Only between two times restriction does not create any scheduled events, and causes the rule to only do anything during that period.

Use case for the former might be something like wanting to be notified of a door open at night; if the door happened to be open at the start time you’d be notified. With a restriction, you would only be notified if it opened during the period.

It’s a subtle but important distinction.

Closing a garage door that is already closed should do nothing.

Thank you very much. I understand and yes, subtle but important distinction on that time of day. Kudos on making such a powerful piece of software.

S@bravenel or anyone else willing to help. I am loving rules machine but am not a coder by trade, so some of the options don’t make sense to me. I know there are 10,000 posts about Rule Machine, but I am looking for a thread at walks through defining some of the options.

  • Cancel, Delay, Truth changes (I think I get it from above), some of the differences in lighting, pending cancellation, capture state,

I think I figure out when look at examples of screen shots posted, but understanding the actions (in most cases), I can create my own rules better or new ones.

Of course I find the user guide 3 minutes later. Please ignore

Ok, I’m confused… and if you’ve read any of my posts… I’m the master of confusing posts…

What are you asking?

I was trying to get a better understanding of some of the Action options as some were not clear on when and how to use. As soon as I posted this, I kept searching and found the RM User Guide which had some explanations of these. Some are more clear but some are still a little confusing to me on how I should use them, if at all.

1 Like

Ahhhh ok. Thanks.