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!
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?
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
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…
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
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.
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
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: