Configure alarm door sensor with delay before triggering alarm?

I have a bunch of alarm sensors, including a 433MHz door sensor on my front door. I have an automation which triggers the house alarm if any of the sensors are triggered when there is nobody home. At the moment this all works well apart from the front door sensor - it triggers as soon as the front door is opened, and usually before the system has registered the first person arriving at home.
Any ideas for how I can set this up as a delayed trigger, so that it waits for say 30 seconds before evaluating the “is anyone home” condition and setting off the alarm?
The sensor talks to a Sonoff RF Bridge running Tasmota, with separate payloads for the door opening and closing.

If the front door has an MQTT binary sensor then use the on_delay option.

Failing that it might help if you post your yaml.

Thanks. This is the automation that I currently have:

alias: Trigger alarm while armed (home or away)
trigger:
  - platform: mqtt
    topic: tele/rf-bridge2/RESULT
    payload: 0A720A
    value_template: '{{ value_json.RfReceived.Data}}'
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: alarm_control_panel.home_alarm
        state: armed_away
      - condition: state
        entity_id: alarm_control_panel.home_alarm
        state: armed_home
action:
  - service: alarm_control_panel.alarm_trigger
    entity_id: alarm_control_panel.home_alarm
mode: single

(0A720A is the MQTT payload when the door is opened).

The info at that link mentions an off_delay, but not an on_delay - ???

Ah my mistake, I see that there is no delay_on option.

Maybe you could define an MQTT Binary Sensor as per the link to the Docs above then use this in your trigger with the “for” option to provide the delay that you are looking for:

  trigger:
  - platform: state
    entity_id: binary_sensor.front_door
    to: 'on'
    for: 00:30:00

The binary_sensor would probably also need the delay_off option setting to something greater than 30 otherwise it could go on then off for less than 30 secs and fail to trigger the automation.

Thanks. If the door was opened then closed within the 30 seconds would it not then bypass the trigger altogether? If I understand it correctly, this logic would only trigger the alarm if the door is actually left open for 30 seconds. What I’m hoping to achieve is that opening the door will trigger the alarm regardless of how long it is open, but only if the alarm is still armed 30 seconds after the door has been opened (i.e. I want to give HA 30 seconds to detect the arrival of the first person home before it allows the door sensor to trigger the alarm).

Oh, in that case it sounds like you are after almost exactly what I have configured for my alarm:

- id: '1998183160480'
  alias: Alarm - Trigger while Armed
  description: Trgger alarm when front door opens if it is armed
  trigger:
  - entity_id: binary_sensor.front_door
    platform: state
    to: 'on'
  condition:
  - condition: template
    value_template: '{{ not is_state(''alarm_control_panel.ha_alarm'', ''disarmed'')
      }}'
  action:
  - choose:
    - conditions:
      - condition: state
        entity_id: alarm_control_panel.ha_alarm
        state: armed_away
      sequence:
      - service: alarm_control_panel.alarm_trigger
        target:
          entity_id: alarm_control_panel.ha_alarm
      - service: script.sonos_broadcast_mp3
        data:
          delay: 00:00:03
          mp3_file: http://192.168.1.20:8123/local/3-beeps.mp3
          volume: 0.2
      - wait_for_trigger:
        - platform: template
          value_template: '{{ is_state(''alarm_control_panel.ha_alarm'', ''disarmed'')
            or is_state(''alarm_control_panel.ha_alarm'', ''triggered'') }}'
        timeout: 00:02:00
      - choose:
        - conditions:
          - condition: state
            entity_id: alarm_control_panel.ha_alarm
            state: triggered
          sequence:
          - service: script.sonos_broadcast_mp3
            data:
              delay: 00:00:30
              mp3_file: http://192.168.1.20:8123/local/school-fire-alarm.mp3
              volume: 0.2
          - service: logbook.log
            data:
              message: Home alarm activated while armed_day
        default: []
    - conditions:
      - condition: state
        entity_id: alarm_control_panel.ha_alarm
        state: armed_night
      sequence:
      - service: script.sonos_broadcast_mp3
        data:
          delay: 00:00:06
          mp3_file: http://192.168.1.20:8123/local/smoke-alarm.mp3
          volume: 0.2
      - service: logbook.log
        data:
          message: Home alarm activated while armed_night
    default: []
  initial_state: 'on'
  mode: single

This works as follows, just strip out the Sonos sound stuff or adapt to your situation:

  • Automation triggers when the front door opens and there is a condition that the alarm must not be disarmed.
  • If the alarm is armed_away then 3 beeps are sounded, it then waits for the alatm to change to either disarmed or triggered with a timeout of 2 mins (30 secs for your application). If the state is triggered then the alarm is sounded and a message written to the log. otherwise the automation halts.
  • If the alarm is armed_night then a sound is immediately sounded to alert us.
1 Like