Time Variables Available in 2.1.8
Rule Machine has been enhanced to support variables representing time. Like other Global or Local Variables, Time Variables can be created and deleted, their values set, and Connectors created for use in Dashboards. Hubitat Dashboard now has a Variable Time template to display and change Time Variable Connectors. Time Variables show time of day in either 12 hour or 24 hour display depending on the hub's setting for time displays, and show hours and minutes. If Action logging is enabled, changes to Time Variable Connectors are logged.
Note that Time Variables are for time of day use, not time duration. In many contexts of Rule Machine duration can be specified with a Number or Decimal Variable in the seconds field, specifying seconds of duration (e.g. in Delays).
A local Time Variable must have a Connector to be used for a triggering event, while global Time Variables do not have this requirement.
Time Variable as Certain Time Trigger
When defining a Certain Time trigger event, there is a new choice to use a Time Variable. The trigger will initially be scheduled at the current time of the Time Variable. Should that Time Variable time be changed by changing its Connector, the scheduled time will be updated.
Time Variables in Triggers
When defining a Variable trigger event with a Time Variable, comparison operators are available as with other variable triggers. These include =, !=, <, >, <=, >=, changed, increased and decreased. It is possible to compare a Time Variable to a selected time or to another Time Variable.
Setting Time Variables in Actions
Time Variables may be set in Rule Actions. Available options are set to a selected time, current time (Now), Sunrise, Sunset, an Offset to the current value (+ / -) in minutes, or to another Time Variable with an optional Offset in minutes. These Offsets can be a numeric value, or Number or Decimal variables using %variableName%.
It is possible to set a Number or Decimal Variable to the difference between two Time Variables. The resulting value is the first time subtracted from the second time, expressed in minutes.
Time Variables in Conditions
Time Variables may be used in the Time of Day Condition. This includes the condition of a specific minute of time, or Between Two Times.
Conditions involving Time Variable comparisons can be created, similar to those used for trigger events.
Time Variables in Wait for Events
A Time Variable may be used in the Certain Time event of Wait for Events Action. As with Time Variable trigger events. if the time value of a Time Variable used this way is changed by a Connector, the Wait for Event Certain Time is updated accordingly. When a local Time Variable is used in Wait for Event, it must have a connector, while this is not required for a global Time Variable.