Help with a rule - action followed by timed action

I recently installed a Konnected interface and its working really well.

Due to a limitation of my alarm panel I can only know when the alarm has been set or unset. In actual use we either set the alarm fully when we leave or ā€œpart setā€ when we go to bed - but Hubitat would only know that the alarm is set in both cases.

What Iā€™d like to do is do different actions depending on whether it was part set or fully set.

If we fully set the alarm then we will leave the house (or the alarm would trigger!] and the front door must be opened within 30 seconds. If we ā€œpart setā€ it the front door wonā€™t be opened within the next 30 seconds...

If Alarm CHANGES TO ON And front door opened within 30 seconds
Do action
Else if Alarm CHANGES TO ON and front door not opened within 30 seconds
Do a different action

How would I go about creating this in rule machine ?

Thanks in advance!

D

How are you wiring it up to know that the alarm is either set or not? You are trying to also use HSM in addition to your wired alarm system? Why is that? isn't the wired alarm system enough? Most of the time people use the interface board to use the wired sensors in your home automations but keep security functions in the wired system instead of extending that to Hubitat as well.

Iā€™m using it purely to make use of my PIR sensors and wired contact sensors and my panel has several Comms pins that I can tie in to, to know if my alarm has been armed or triggered.

Iā€™m not using HSM at all, but it does mean I can do a few neat things like when I walk out of the house and hit the arm button on my alarm keypad it will also turn off every appliance in the house, for example.

It is also a way for me to know if my alarm has been triggered, if it has I get a push notification and then also turn on all the outdoor and indoor lights..

The alarm system itself remains standalone and Iā€™m using the Konnected Interface wired up to my alarm panel...

In my rule machine query above, actions might be along the line of ...

If Alarm CHANGES TO ON And front door opened within 30 seconds
Turn off the entire house
Else if Alarm CHANGES TO ON and front door not opened within 30 seconds
Turn off only downstairs

.. turning the alarm on and off is done via my traditional alarm keypad panel...

You didn't mention how the traditional alarm actually interfaces with Hubitat, but I'll assume it's a virtual switch that gets turned on when the traditional alarm is armed (full or partial) and turned off when disarmed. If it's something else, you'll have to adjust your trigger and the outermost conditional below as appropriate.

Here is my attempt at creating a rule that looks like it should do about what you want:

You can eliminate my "log" actions, which are basically just there as comments to show you my logic. The "magic" part, I think, is the "wait" action: after the alarm is armed, it will either wait for your door (contact sensor) to open. If it does, it will proceed with the actions, and that inner IF should evaluate to true and run the "fully armed" actions. If instead it proceeds because the 30-second timeout elapsed, the contact sensor should be closed and you can run the "partially armed" actions.

Note that there is a potential weakness here: the door cannot already be opened when the alarm is turned on, since this waits for a change to open after the trigger of the alarm turning on fires. If it was open before and left open, it will assume a full arm even though it was not opened afterwards. If it was open before and then closed (e.g., because you left but the door was open first and you were aiming for a full arm), it will only do a partial arm. You could add some additional complexity to this rule to handle these situations, or if you don't think you'll ever do that, you could leave it as-is. (There is also the theoretical possibility that you could close the door in the literal millisecond or so between opening it to signal the end of the "Wait" and the end of the evaluation for the next "IF," making it false, but I think that's highly unlikely, if not humanly impossible.)

Hope this is helpful! I have not tested it, so let me know if you (or anyone) sees any potential holes in the logic.

1 Like

Thank you so much for the detailed reply and taking the time to write the rule, thatā€™s really helpful and very much appreciated ! Iā€™ll give this a go tonight.

To handle the door already open I guess I could change the rule such that itā€™s an open or close event within 30 seconds ...

I realised that thereā€™s a bit of an issue with this...

I donā€™t actually know whether the alarm is armed until after the alarm panels 30 second exit timer finishes.

So the logic would need to be along the lines of

if AlarmPanel changes to ā€˜ONā€™ AND frontdoor changes to ā€˜openā€™ OR ā€˜closedā€™ in the past 60 seconds
do action

Is that possible ?

You would have to trigger off the front door opening and then the alarm being armed within the next 30 seconds.

As suggested above, the door would need to be a trigger somewhere since RM doesn't have a direct way to check whether x happened in the last y seconds. It would certainly work as a trigger for your "full arm" rule. However, I can't think of a way to make that alone work for the "partial arm" situation where the door doesn't change at all.

One way that would work for either situation (full of partial arming, i.e., with or without door changing) is to create a global variable to track if the door was opened/closed recently, using a separate separate rule to set it appropriately. Then, you can use that variable as a condition in a rule that is similar the one originally proposed where the alarm system arming/disarming is a trigger.

The "main" rule would end up looking something like this:

The rule for setting recentDoor woudl be pretty simple. You can customize it according to exactly what you think would reasonably happen, but the below should handle most situations, though again you can customize the actual "window" and trigger (e.g., you could only use "opened" or "closed" if you think that would be more appropriate, and it could be: you're likely to always close the door, so unless your contact sensor generates spurious repeated "closed" events when nothing changes, it would also work):

image

And of course you'd need to create the variable:

image