Hub: C8
Platform Version: 2.4.1.167
I have a question about 'cancel delayed actions' vs 'cancel rule timers' (as referred to in the docs).
In the rule machine docs it says:
"Choosing the Cancelable option allows the delay to be cancelled with the Cancel Delayed Actions action elsewhere in the same rule, but this must be done explicitly."
Then it says:
" The Cancel Rule Timers actions will also cancel delayed actions (and can be called on the rule from any rule, not just the same rule), but it affects all rule timers, not just delays. It will also cancel delays with or without the Cancelable? option selected."
There's two things I don't understand about the above:
-
If an action is delayed then how can a "cancel delayed actions" action execute elsewhere within the same rule while the delay is underway in the same rule? If the rule is executing the delay action, then it's paused until the delay completes, so how can another action in the same rule ever cancel that delay when it can only execute after the delay completes? Is there some way to have multiple threads of actions executing within the same rule that I'm not yet familiar with? If not, it seems like 'cancel delayed actions' can never do anything? (obviously I must not be understanding the docs)
-
The 'cancel rule timers' action cancels the delay for me, but it goes one further and seems to cancel the entire rule execution, not just the delay action in progress. In the script below, the
ELSE
that should occur afterIF (Variable armPending = false)
never executes when the other script sets armPending to false during the delay. Why?
It's a bit difficult to understand the documentation because the vernacular used in the docs isn't exactly the same as the options available. For example, the phrase 'Cancel Timed Actions' is nowhere to be found...so I'm not sure if doing The Right Thing.
Help me comprehend this, please!
My scripts:
Enable alarm:
Required expression:
Variable alarmArmed(false) is = false(T) AND
Variable alarmTriggered(false) is = false(T) [TRUE]
Security(off) turns on
Actions:
IF (Back Door, Front Door all motion is inactive(T) [TRUE]) THEN
Set alarmState to 'arming'
Set armPending to true
Notify iPad, iPhone11ProMax: 'Alarm will arm in 30 seconds'
Delay 0:00:30 (cancelable)
IF (Variable armPending(false) is = true(F) [FALSE]) THEN
IF (External Only(on) is on(T) [TRUE]) THEN
IF (Back Door, Front Door all motion is inactive(T) [TRUE]) THEN
Set alarmArmed to true
Set alarmState to 'armed'
Set armPending to false
On: ASTAT-Blue-Ext Only
Notify iPad, iPhone11ProMax: 'Alarm Enabled Ext Only'
ELSE
Set alarmState to 'disarmed'
Set armPending to false
Off: Security
Notify iPad, iPhone11ProMax: 'Check Ext Doors, Arming Cancelled'
END-IF
ELSE
IF (Front Door, Back Door, Apt Motion, Apt Door all motion is inactive(T) [TRUE]) THEN
Set alarmArmed to true
Set alarmState to 'armed'
Set armPending to false
On: ASTAT-Red-Alarm Armed
Notify iPad, iPhone11ProMax: 'Alarm Enabled'
ELSE
Set alarmState to 'disarmed'
Set armPending to false
Off: Security
Notify iPad, iPhone11ProMax: 'Motion Detected, Arming Cancelled'
END-IF
END-IF
ELSE
Set alarmState to 'disarmed'
Notify iPad, iPhone11ProMax: 'Arming Cancelled'
END-IF
ELSE
Off: Security
Notify iPad, iPhone11ProMax: 'Check Ext Doors'
END-IF
Alarm Status - Cancel Arm Pending
Required expression:
Variable armPending(false) is = true(F) [FALSE]
Trigger:
Security(off) turns off
Actions:
Set armPending to false
Cancel Timed Actions: Alarm Status - Enable (New)
Set alarmState to 'disarmed'
Notify iPad, iPhone11ProMax: 'Alarm Cancelled'