Automation help needed; wait for disarming

All my away/home and alarm arm/disarm is done by a combination of phone tracking and motion detection. This works really wel.

However I had no way to arm/disarm in the case of a guest so I have added a RFID reader to my setup but this will only be used by for instance the cleaning lady.

Now I want to add a delay to my arm and disarm in the case the panel is used. So more concreet:
Normally when nobody home and alarm is in away mode; Any sensor triggers a notitification (and sirene which is still disabled for now).

However now I want to give the cleaning lady the time to disarm the alarm with the RFID tag (let’s say 60 sec). In case of success I disarm the alarm, if no success the alarm sounds/notification start.

I’m struggling with how to build in the 60 sec ‘pauze’ that gives the time to disarm or, if nothing being dis-armed, actually sounds the alarm.

#the automation that defines if the alarm is in away mode or not
- alias: “Someone home”
trigger:
- platform: state
entity_id: group.all_devices
from: “not_home”
to: “home”
action:
- service: input_select.select_option
data:
entity_id: input_select.Occupancy
option: “Home”
- service: input_select.select_option
data:
entity_id: input_select.alarm
option: “None”

The automation that kicks in when there is motion & alarm is in away mode

  - alias: Any_motion_while_away
    trigger:
      platform: state
      entity_id: 
        - binary_sensor.motion_a
        - binary_sensor.motion_b
        - binary_sensor.motion_c
        - binary_sensor.fibaro_system_fgms001_motion_sensor_sensor_10_0
        - binary_sensor.motion_e
        - binary_sensor.motion_f
      from: "off"
      to: "on"
    condition:
      condition: or
      conditions:
      - condition: state
        entity_id: input_select.alarm
        state: "Vacation"
      - condition: state
        entity_id: input_select.alarm
        state: "Away"
    action:
      service: notify.mypushover
      data_template:
        message: "{{ trigger.to_state.attributes.friendly_name }}"
        title: "Alarm"
        target: ""

Hi,

Have you tried to implement this in your automation:

It has a feature of “pending” that you are looking for.

Had looked at it but the documentation is very thin and don’t really get how it all works/should be used.

Yeah, documentation is lacking.
However, it looks like a “swither” between three different states with option to delay between states, quite simple.

It’s really not that much different than what you are doing with your automations, Ty - check into it. Here’s the automations I am using associated with it - the only real difference between yours and mine is that I am setting the arming state manually.

# Alarm based automations
- alias: 'Armed away'
  trigger:
    - platform: state
      entity_id: binary_sensor.kitchen_entry
      state: 'on'
    - platform: state
      entity_id: binary_sensor.side_door
      state: 'on'
    - platform: state
      entity_id: binary_sensor.office_motion
      state: 'on'
    - platform: state
      entity_id: binary_sensor.tearoom_motion
      state: 'on'
    - platform: state
      entity_id: binary_sensor.second_floor_motion
      state: 'on'
    - platform: state
      entity_id: binary_sensor.tea_room_slider
      state: 'on'
    - platform: state
      entity_id: binary_sensor.dining_room_1
      state: 'on'
    - platform: state
      entity_id: binary_sensor.dining_room_2
      state: 'on'
    - platform: state
      entity_id: binary_sensor.tea_room_slider
      state: 'on'
  condition:
    condition: state
    entity_id: alarm_control_panel.ha_alarm
    state: armed_away
  action:
    - service: alarm_control_panel.alarm_trigger
      entity_id: alarm_control_panel.ha_alarm
    - service: notify.pushbullet
      data:
        message: 'Robert, the alarm has been triggered while you were away.'

- alias: 'Armed home'
  trigger:
    - platform: state
      entity_id: binary_sensor.kitchen_entry
      state: 'on'
    - platform: state
      entity_id: binary_sensor.side_door
      state: 'on'
    - platform: state
      entity_id: binary_sensor.second_floor_motion
      state: 'on'
    - platform: state
      entity_id: binary_sensor.tearoom_motion
      state: 'on'
    - platform: state
      entity_id: binary_sensor.office_motion
      state: 'on'
    - platform: state
      entity_id: binary_sensor.tea_room_slider
    - platform: state
      entity_id: binary_sensor.dining_room_1
      state: 'on'
    - platform: state
      entity_id: binary_sensor.dining_room_2
      state: 'on'
    - platform: state
      entity_id: binary_sensor.tea_room_slider
      state: 'on'
  condition:
    condition: state
    entity_id: alarm_control_panel.ha_alarm
    state: armed_home
  action:
    - service: alarm_control_panel.alarm_trigger
      entity_id: alarm_control_panel.ha_alarm
    - service: notify.pushbullet
      data:
        message: 'Robert, the alarm has been triggered.'

I haven’t updated it since I bought my siren/strobe and added some sensors but will be doing that soon.

Do you want something like the for: command for a trigger described here.

Bit busy with work so only had time to follow up now. Finally added the alarm component but still not sure how to use it in the context of giving you the time to disarm.

@rpitera in your automation above:

I get the trigger (any sensor to ‘on’) and the condition ('only if alarm panel is armed_away). But then; How to you avoid the notification is send immediate when trigger and condition is true (instead of 'pauzing and giving someone time to disarm the alarm) ? Or does the first action create some kind of pauze, evaluates if the alarm is disarmed > if yes quites the automatoon, if no continues.

That’s all set in the options on the manual alarm control panel. Here’s my code for that:

#
#
#  Alarm Control Panel
#
#
alarm_control_panel:
  platform: manual
  name: "HA Alarm"
  code: REDACTED
  pending_time: 60
  trigger_time: 60
  • name (Optional): The name of the alarm. Default is “HA Alarm”.

  • code (Optional): If defined, specifies a code to enable or disable the alarm in the frontend.

  • pending_time (Optional): The time in seconds of the pending time before arming the alarm. Default is 60 seconds.

  • trigger_time (Optional): The time in seconds of the trigger time in which the alarm is firing. Default is 120 seconds.

  • disarm_after_trigger (Optional): If true, the alarm will automatically disarm after it has been triggered instead of returning to the previous state.

Now that I think about your question, I really should have posted this info with the automation; I’m sorry if I confused the heck out of you! :innocent:

Thanks, your a patient guy! I actually read the documentation but still not sure how this works. Are you sure your automation is implemented correctly? I think actions in an automation always get executed immediately and in sequence (or you need to use -delay- but still they would continue after the delay is over.

In other words with your automation I would expect; independent of the trigger time (in your case 60 sec) you will get the notification immidiately (and not after 60 sec) when a sensor is tripped (and alarm panel is armed)

Should your automation not end after below and have another automation that uses the alarm trigger as a the trigger or condition, which would then allow for the 60 sec to disarm time , and if not disarmed, would excute any alarm actions?

  action:
    - service: alarm_control_panel.alarm_trigger
      entity_id: alarm_control_panel.ha_alarm

I’ve tested it and it seems to work reliably. I haven’t really used it for a long time since I created it because I haven’t been going out much lately but I do remember having to play with the two timing parameter to get it to notify me in a reasonable time when tripped while still allowing me to set the alarm and leave without tripping it or feeling rushed out the door.

I’ll try playing with it again after adding my new sensors and updating some entity names and let you know.

the trigger time seems not to work. the lowest it goes seems to be 15sec. i want it to be instant.