Sticky Triggers and Other New Rule 5.1 Features

The 2.3.1 release includes some notable new features for Rule 5.1:

Sticky Triggers

For most triggers, specifically those that actually result in some state change, it is now possible to add a length of time the triggering device must remain in the trigger state before the trigger actually fires. Consider this example:

This example will trigger upon the passing of 2 minutes after the Front Door opens and stays open. If the door closes before 2 minutes, it won't trigger.

There are always users looking to figure out how to do something like this in the community. It turns out that Basic Rule can do this sort of thing, but that Rule Machine was lagging behind. So this feature catches up with Basic Rule, and goes a bit further.

These triggers don't support "And stays..." -- these are mostly stateless events.

Button LED
Certain Time
Cloud End Point
Days of Week Schedule
Keypad Codes
Local End Point
Location Event
Lock Codes
Periodic Schedule
Rule Paused
Security Keypad

Sticky Wait for Events

Just as with triggers, it is now possible to specify a time that an event used in Wait for Events must stay in the state that would satisfy the Wait. As with a sticky trigger, if the state changes before the time is up, the Wait won't conclude -- it will continue to wait. Like this:

All Devices for Triggers

It is now possible to select between Any and All for multiple devices used in a trigger. Previously, only Any was available. When All is selected, this means that the trigger will fire when the last of the devices obtains the selected state.

Enhanced Time Since Event Condition

The Time Since Event Condition has been expanded to allow the specific event value to be looked at, not just the event attribute. It is possible to look at **Any Attribute**, or for a selected attribute, **Any Value**, or a selected event value. Like this:

Allows Decimal Variables in Number Contexts

In contexts such as dimmer levels, hue/saturation/colorTemperature values, etc, where an integer value is required by the device, Rule 5.1 now allows Decimal variables to be used, not just Number variables. It truncates a decimal value to convert it to integer for the device command (e.g. 22.999 becomes 22).

Enable/Disable Individual Actions

It is now possible to disable one or more individual actions. When disabled, they will be shown in italics. Disabled actions will be skipped when the rule runs. It is possible to re-enable disabled actions using the same pull-down, where a disabled action is labeled as such.

Select Default Date Format

The default date format for use with %date% can be set.

Format DateTime to String

There is a new option for Set Variable for a String Variable, where it can be set to a formatted value of a DateTime variable. A long list of possible formats for both time and date are available. For example, this is useful if you want to announce a set variable time with TTS; you'd first format the DateTime variable into a String variable using the desired format, and then speak the String variable.

Metering for Multi-Device Custom Actions

It is now possible to select metering for multiple device commands in Custom Actions. This introduces a short pause after each device command, allowing less impact on mesh networks. This can be used with every command the devices support.

Random Delay for Actions

It is now possible to select a random delay for individual actions. As with other delays on individual actions, the action is scheduled to run after the delay, and execution of following actions continues.

Cancel Pending Actions when Required Expression Becomes False

An option has been added that causes pending actions to be cancelled should the Required Expression become false. Previously, the Required Expression only conditioned whether the rule could be triggered or not. With this option selected, the Required Expression becoming false would cancel any pending waits, repetitions, or delays as well.

Create a Rule 5.1 from a Basic Rule or Simple Automation Rule

It is now possible to import a Basic Rule or Simple Automation Rule into Rule Machine, creating an equivalent Rule 5.1. See this post.