Connection rule: disconnected for more than 15 seconds

No idea why, but I have a connection item for my alarm that does seem to disconnect for a short period before it reconnects. I should figure out why.

But anyway, is there an easy way in a rule that I can only trigger a notification if the state is CLOSED of my contact item for more than say 15 seconds rather than on immediate state change.

Is this a use of the expire binding, or should I just start a timer on disconnect, and cancel if it reconnects within 15 seconds.

It isn’t a case if either or. Design Pattern: Expire Binding Based Timers

But your thinking is on the right track. You need to create a timer of some sort when the state changes to CLOSED. If the Item changes to OPEN cancel the timer. When the timer expires send your notification.

Whether you use Expire to implement the Timer or use one internal to the Rule is in this case a matter of personal preference.

Reply for future reference:

rule "Alarm Connection notifications"
        Item alarm_connection_heartbeat changed
        if (alarm_connection_heartbeat.state != NULL)
                if (alarm_connection_heartbeat.state == CLOSED)
                        disconnection_timer = createTimer(now.plusSeconds(15), [|
                                Notify_Paradox.postUpdate("Connection to the Alarm panel has been lost")
                                disconnection_timer = null

                else if (disconnection_timer !== null)
                        disconnection_timer = null

Basically posts a notification if I lose connection to the alarm for more than 15 seconds. I do have a switch that denotes the connection is live, this can be updated so that a further automation can be started (ie restart my alarm monitor container)

1 Like