Alarm automation with flic button & status based on event

I currently use this automation on a flic button to set an alarm at night:

  • id: ‘1545341495331’
    alias: all lights off flic hold
    trigger:
    platform: event
    event_type: flic_click
    event_data:
    button_name: flic_80e4da736822
    click_type: hold
    action:
    service: alarm_control_panel.alarm_arm_home
    entity_id: alarm_control_panel.yale_smart_alarm


What I would like to add is an event where the automation would also check to see if the door is locked:

  entity_id: lock.assa_abloy_yale_conexis_l1_sdl1000ch_locked
  state: 'locked'

and if its “unlocked” then turn a light red so a visual indication there is a problem & cancel the alarm set

Is this possible/how would it be coded?

First, you need to properly for mat your code when you post it into the forum. see the blue box above.

But what I would do is to create two scripts - one for the normal condition that just arms the alarm, the other for when the door isn’t locked that turns on the red light.

then in the action of the automation above:

action:
  service: script.turn_on
  data_template: 
    entity_id: >
      {% if is state('your_door_lock_entity', 'locked')
        script.arm_alarm
      {% else %}
        script.turn_on_red_light
      {% endif %}

makes perfect sense, thanks for this

- id: '1545341495328'
  alias: alarm set home flic hold
  trigger:
    platform: event
    event_type: flic_click
    event_data:
      button_name: flic_80e4da734197
      click_type: hold
  action:
    - service: media_player.media_stop
      entity_id: media_player.family_room
    - service: script.turn_on
      data_template: 
        entity_id: >
          {% if is state('lock.assa_abloy_yale_conexis_l1_sdl1000ch_locked', 'locked')
            script.arm_alarm
          {% else %}
            script.turn_on_red_light
          {% endif %}

I get an error using the above, presume formatting? (invalid template (TemplateSyntaxError: expected token ‘end of statement block’, got ‘state’) for dictionary value) any ideas?

you (I) forgot the _ between is and state:

{% if is_state('lock.assa_abloy_yale_conexis_l1_sdl1000ch_locked', 'locked')

still getting an error,is there a missing % & } on that line?

yes, sorry, i shouldn’t do this in the middle of the night when I’m so sleepy :sleeping: :wink::

{% if is_state('lock.assa_abloy_yale_conexis_l1_sdl1000ch_locked', 'locked') %}

spot on works great, thanks for the assistance :slight_smile: