Manual Alarm triggers immediately rather than waiting for trigger_time

Hello everyone.

I have defined a Manual Alarm like the following:

alarm_control_panel:
  - platform: manual
    name: "Home Alarm"
    pending_time: 30
    trigger_time: 30

Then I have an automation to trigger it while armed away like the following:

  - alias: "Alarm trigger while armed away"
    trigger:
      - platform: state
        entity_id: binary_sensor.door_window_sensor_xxxxxxxxxxxxxx
        to: 'on'
      - platform: state
        entity_id: group.all_motion
        to: 'on'
    condition:
      condition: state
      entity_id: alarm_control_panel.home_alarm
      state: 'armed_away'
    action:
      - service: input_boolean.turn_off
        data:
          entity_id: input_boolean.mute_gateway_sounds
      - service: alarm_control_panel.alarm_trigger
        entity_id: alarm_control_panel.home_alarm
      - service: script.play_sound
        data:
          ringtone_id: 10004
          ringtone_vol: 50
          delay: 2
      - service: notify.iOS
        data:
          message: 'Alarm fired away'
          title: 'Home Assistant alert'
          data:
            push:
              badge: 5
              category: "ALARM"

If I understood well the documentation, with my configuration alarm should not be triggered until 30 seconds had passed since the triggering conditions and should trigger only for 30 seconds.

In a regular alarm system (not software based), you’re supposed to have time after arming the alarm (to avoid it to be triggered before you actually leave - this one is working fine) and also time before triggering it (to avoid it triggering immediately, to give you time to disarm it - this one is NOT working fine).

Am I missing something here, or is my alarm misbehaving?

Thanks in advance for your help.

You seem to have misunderstood the way this component works. You need 2 automations for an alarm to work.
The component works as follows.

Alarm is unarmed -> nothing happens.
Alarm gets armed (either home or away) -> pending for the pending_time -> Alarm is armed.
Alarm gets triggered -> pending for the trigger_time -> Alarm is triggered.

As you can see you need to separate your automation into two parts. One that does the triggering of the alarm and the seconds one which is the actual alarm (e.g. a siren).

Hope this helps.

~Cheers

Hello @PhyberApex.

First of all, thanks for taking the time to answer me.

Clear on the way the component is supposed to work, but my automations are separate, I just forgot to post also the arming one.

 automation:
  - alias: "Alarm arm pending"
    trigger:
      platform: state
      entity_id: alarm_control_panel.home_alarm
      to: 'pending'
    condition:
      condition: state
      entity_id: alarm_control_panel.home_alarm
      state: 'pending'
    action:
      - service: input_boolean.turn_off
        data:
          entity_id: input_boolean.mute_gateway_sounds
      - service: script.play_sound
        data:
          ringtone_id: 10006
          ringtone_vol: 4
          delay: 2

  - alias: "Alarm trigger while armed away"
    trigger:
      - platform: state
        entity_id: binary_sensor.door_window_sensor_xxxxxxxxxxxxxx
        to: 'on'
      - platform: state
        entity_id: group.all_motion
        to: 'on'
    condition:
      condition: state
      entity_id: alarm_control_panel.home_alarm
      state: 'armed_away'
    action:
      - service: input_boolean.turn_off
        data:
          entity_id: input_boolean.mute_gateway_sounds
      - service: alarm_control_panel.alarm_trigger
        entity_id: alarm_control_panel.home_alarm
      - service: script.play_sound
        data:
          ringtone_id: 10004
          ringtone_vol: 50
          delay: 2
      - service: notify.iOS
        data:
          message: 'Alarm fired away'
          title: 'Home Assistant alert'
          data:
            push:
              badge: 5
              category: "ALARM"

How does the automation know it should wait for the pending/trigger time?

Thanks again for your help.

In this case you need 3 automations. The time is between the state armed_(away/home),pending, triggered.

You are missing the automation for the triggered state.

  - alias: "Alarm trigger while armed away"
    trigger:
      - platform: state
        entity_id: binary_sensor.door_window_sensor_xxxxxxxxxxxxxx
        to: 'on'
      - platform: state
        entity_id: group.all_motion
        to: 'on'
    condition:
      condition: state
      entity_id: alarm_control_panel.home_alarm
      state: 'armed_away'
    action:
      - service: input_boolean.turn_off
        data:
          entity_id: input_boolean.mute_gateway_sounds
      - service: alarm_control_panel.alarm_trigger
        entity_id: alarm_control_panel.home_alarm

  - alias: "Alarm triggered"
    trigger:
      - platform: state
        entity_id:  alarm_control_panel.home_alarm
        to: 'triggered'
      - service: script.play_sound
        data:
          ringtone_id: 10004
          ringtone_vol: 50
          delay: 2
      - service: notify.iOS
        data:
          message: 'Alarm fired away'
          title: 'Home Assistant alert'
          data:
            push:
              badge: 5
              category: "ALARM"

This should do the trick.

~Cheers

1 Like

Thanks again for your help.

After understanding the statuses of the alarm, using platform state and from/to statuses, I managed to control the alarm as I wanted to.

Thanks a lot, for your insights and ideas, @PhyberApex.

This community rocks!!!

1 Like