Automation to automatically disarm alarm at dawn

I use a Boolean switch to arm my security system. I’m trying to create an automation that uses another Boolean switch to turn off the alarm at dawn. In a YAML parser, I’m getting an error: “(): mapping values are not allowed in this context at line 167 column 20.” Any clue what I’m doing wrong? How can I use two conditions?

  - alias: 'Turn Off Alarm at Dawn'
    trigger:
      platform: sun
      event: sunset
      offset: "-00:15:00"
    condition: and
    conditions:
      - condition: state
          entity_id: input_boolean.alarm_autooff # this is line the YAML parser is flagging.
          state: 'on'
      - condition: state
          entity_id: input_boolean.alarm_armed
          state: 'on'
    action:
      entity_id: input_boolean.alarm_armed
      service: switch.turn_off

Here’s where I defined the Booleans. Do I need hyphens?

input_boolean:
  alarm_armed:
    name: Alarm Armed
    initial: off
    icon: mdi:shield
  alarm_autooff:
    name: Turn Alarm Off at 7am
    initial: off
    icon: mdi:clock

You need another condition statement above the other two and then indent the other two appropriately. Another user just corrected me on this in another thread a few minutes ago! :grin:

1 Like

I just saw your thread. Will check it for clues, thanks!

1 Like

Well my configuration now passes a YAML parser. However, My multiple boolean declarations is causing errors! Does anyone have sample configuration code for multiple Booleans? :tired_face:

Working (I think) automation:

  - alias: 'Turn Off Alarm at Dawn'
    trigger:
      platform: sun
      event: sunset
      offset: "-00:15:00"
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: input_boolean.alarm_autooff
          state: 'on'
        - condition: state
          entity_id: input_boolean.alarm_armed
          state: 'on'
    action:
      entity_id: input_boolean.alarm_armed
      service: switch.turn_off

Alright, I think I have it working. We’ll see if the automation works in the morning.
I found the correct format to define multiple Booleans from @MarkoMarjamaa - ty!

I quote:

input_boolean:
  yard_heater_push_button:
    name: Start yard heater
    initial: off
  yard_heater:
    name: Yard heater
    initial: off
  yard_heater_motion_sensor:
    name: Yard heater Motion Sensor
    initial: off

So my working Boolean code is:

input_boolean:
  alarm_armed:
    name: Alarm Armed
    initial: off
    icon: mdi:shield
  alarm_autooff:
    name: Turn Alarm Off at 7am
    initial: off
    icon: mdi:clock

Your action is incorrect though, as the service has to go ABOVE the entity_id… the entity_id is the data of the service, not the other way around:

action:
  service: switch.turn_off
  entity_id: input_boolean.alarm_armed

It is like shorthand for this:

action:
  service: switch.turn_off
  data:
    entity_id: input_boolean.alarm_armed
2 Likes

Yeah it didn’t work this morning, hehe. Thanks @jbardi I’ll try that!
Btw: Any idea if there’s a difference between the input_boolean.turn_off service and switch.turn_off?

Alright, I can now say this issue is SOLVED! Thanks @jbardi and @rpitera
Btw, my need for this automation became apparent when I went to take the trash to curb on garbage day and neglected to turn the alarm off. It made for an unfortunate breakfast…:grin:
Here’s my final working code snippet for using one boolean to control an automation for a second boolean:

input_boolean:
  alarm_armed:
    name: Alarm Armed
    initial: off
    icon: mdi:shield

  alarm_autooff:
    name: Turn Alarm Off at 6:45am
    initial: off
    icon: mdi:clock

automation:
  - alias: 'Turn Off Alarm at 6:45'
    trigger:
      platform: time
      after: '06:45:00'
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: input_boolean.alarm_autooff
          state: 'on'
        - condition: state
          entity_id: input_boolean.alarm_armed
          state: 'on'
    action:
      service: input_boolean.turn_off
      entity_id: input_boolean.alarm_armed
1 Like

Hey @quantumpelvis You mentioned that you are currently auto arming your alarm system. Are you able to please share that code snippet in this thread? I have a DSC alarm with envisalink, and would like to create a “Go to Bed” Scene that automatically arms the alarm once triggered.

Thanks!

Hey @shep - I’m actually auto-disarming my alarm in the morning. But to automatically arm your alarm, it should be a little easier. Assuming your alarm shows up as a switch, it would be something like this:

automation:
  - alias: 'Go to bed'
    trigger:
      platform: time
      after: '21:00'
    action:
      service: switch.turn_off
      entity_id: entityIDofYourAlarm

Hi , can’t manage this to work what are the exact steps you took to make it work ?

Thanks !!! :slight_smile:

Sure, I’ll try to provide more detail.

For my alarm, I have an Aeotec Siren, a z-wave device. Home Assistant automatically detects it as a switch. I have automations triggered by door sensors that turn my Siren to “on” as long as the boolean I defined above as “Alarm Armed” is set to “on”.

So a prerequisite to this is to have a working alarm automation. Also, since I’ve created this solution, I’ve upgraded my Home Assistant. Now there are automation entities which could be turned off and on at certain times, simplifying the process.

Anyway, here’s a missing piece of the code where I put “Alarm Armed” to work:

  - alias: 'Security Breach Front'
    trigger:
      platform: state
      entity_id: binary_sensor.aeotec_dsb29_doorwindow_sensor_2nd_edition_sensor_3
      state: 'on'
    condition:
      condition: state
      entity_id: input_boolean.alarm_armed
      state: 'on'        
    action:
      entity_id: switch.aeotec_zw080_siren_gen5_switch_4
      service: switch.turn_on

What kind of hardware are you working with?

Hi

Thanks for the reply

I have a DSC 1818 Panel connected to an Envisalink 4

I am trying to automate the alarm to arm at 10:00 PM for example and disarm automaticall at 7:00 AM

Thanks for your help.