[Blueprint] Turn off switches when the alarm is armed

Tags: #<Tag:0x00007fc3fb682740>

Modified Frenck’s Blueprint

blueprint:
  name: Turn off switches when the alarm is armed
  description: A blueprint that turns off the selected switches when the alarm is armed.
  domain: automation
  input:
    alarm:
      name: Alarm Control Panel
      description: Select a Alarm Control Panel
      selector:
        entity:
          domain: alarm_control_panel
    armed_away:
      name: When the alarm is armed "Away"
      default: true
      selector:
        boolean: {}
    armed_home:
      name: When the alarm is armed "Home"
      default: true
      selector:
        boolean: {}
    armed_night:
      name: When the alarm is armed "Night"
      default: true
      selector:
        boolean: {}
    armed_custom_bypass:
      name: When the alarm is armed "Custom Bypass"
      default: false
      selector:
        boolean: {}
    switches:
      name: Switches
      description: Select one or more switch to turn off
      selector:
        target:
          entity:
            domain: switch

    switch_off_wait:
      name: Wait time
      description: Time to wait until the switch should be turned off.
      default: 5
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds

trigger:
- platform: state
  entity_id: !input 'alarm'
  to:
  - armed_away
  - armed_custom_bypass
  - armed_home
  - armed_night
variables:
  on_armed_away: !input 'armed_away'
  on_armed_custom_bypass: !input 'armed_custom_bypass'
  on_armed_home: !input 'armed_home'
  on_armed_night: !input 'armed_night'
condition:
- condition: or
  conditions:
  - condition: and
    conditions:
    - '{{ on_armed_away }}'
    - condition: state
      entity_id: !input 'alarm'
      state: armed_away
  - condition: and
    conditions:
    - '{{ on_armed_custom_bypass }}'
    - condition: state
      entity_id: !input 'alarm'
      state: armed_custom_bypass
  - condition: and
    conditions:
    - '{{ on_armed_home }}'
    - condition: state
      entity_id: !input 'alarm'
      state: armed_home
  - condition: and
    conditions:
    - '{{ on_armed_night }}'
    - condition: state
      entity_id: !input 'alarm'
      state: armed_night
action:
- delay: !input switch_off_wait
- service: switch.turn_off
  target: !input 'switches'

Thanks a lot @tteck for this blueprint.

Is it possible to update it in order to allow “Turn On” switches when the alarm is Home for example ?

Better evolution is to be able to assign turn on or turn off to a switch in any alarm state .

Thank you