Automation with conditional on minutes since setting SimpliSafe alarm

I am trying to set up automation so opening a garage door shuts off my alarm and makes an API call (to change heat/AC on Nest - custom API since Google is awful and doesn’t work natively with Home Assistant :face_with_symbols_over_mouth:)

The flow I think I have right now (below) is … if my garage door or my wife’s door opens and the alarm is set to home or away it takes the appropriate action.

The missing piece is I only want this to happen if the alarm has been set for longer than 10 mins
or else I’ll set the alarm on my way out and opening my door to leave will disarm it.

I’ve been poking around but can’t find how to do it. Is there a way to get the time since the state change on the alarm and use that as a conditional?

- id: '1580851534466'
  alias: Shut off alarm if garage door opens
  description: ''
  trigger:
  - entity_id: cover.brians_garage_door
    from: closed
    platform: state
    to: open
  - entity_id: cover.courtneys_garage_door
    from: closed
    platform: state
    to: open
  condition:
  - condition: or
    conditions:
    - condition: state
      entity_id: alarm_control_panel.123_fake_road_alarm_control_panel
      state: away
    - condition: state
      entity_id: alarm_control_panel.123_fake_road_alarm_control_panel
      state: home
  action:
  - condition: state
    entity_id: alarm_control_panel.123_fake_road_alarm_control_panel
    state: 'off'
  - data:
      parameters: cool=70&heat=72
    service: rest_command.l48l_state

Add the following condition

- condition: state
  entity_id: alarm_control_panel.123_fake_road_alarm_control_panel
  state: 'away'
  for:
    minutes: 10

Not sure if you can do a for in a condition state. [Edit petro beat me too it]

- condition: state
  entity_id: alarm.entity
  state: 'armed'
  for:
    minutes: 10

or in a template get the status of the alarm and last updated in action

{% if states.alarm.state == 'armed' and states.alarm.last_updated > 600 %}
  do something
{% endif %}

I didn’t see the option to do for in the GUI automation editor for condition. I just saw them in triggers.

I’ll give it a try in the YAML and see if it works and if not will give the template a try.

Thanks!

@popboxgun - i noticed your state is armed in your example. I’ve been struggling on where to find documentation on supported states for different devices. So for SimpliSafe alarm control panels am I wrong in assuming the state can be home, off, and away ? Is the state only armed and something else? This would be for setting the alarm and also querying it’s state in a conditional.

(Tagging @bachya too since he would know probably more than anyone :grinning: )

I just filled in generic info, i’d look at the developer tools -> states and see what it sets itself to.

Ah! Thank you! I’m only a few days in and I hadn’t looked at this page at all. Sometimes the answers are so close by … instead of Googling all this, if I had just stumbled over there I’d be in way better shape.

Wow, it’s going to be some stuff a lot easier.

For anyone who stumbles upon this thread in the future looking for the info. The three states for SimpliSafe are disarmed, armed_home, and armed_away.

@brian1917 Sounds like you got your answers. :+1: Let me know if I can be of service.