Condition inside an Action

Hello!
I am having issues with my automation…
I want the service script.turn_on to run only if alarm_control_panel.alarm_1 has the state disarmed.
When reading documentation I believe the following to be correct but I get an error pasted in the bottom.
Thankful for any advice!

 - alias: Evening lighting on
   trigger:
     platform: sun
     event: sunset
   action:
     - service: homeassistant.turn_on
       entity_id:
         - group.frontyard_lights
         - group.backyard_lights
     - service: notify.html5
       data_template:
         message: "God evening! Turning on the outdoor lighting."
       data:
         data:
           tag: 'notification-about-sunset'
     - condition:
         condition: state
         entity_id: alarm_control_panel.alarm_1
         state: disarmed
     - service: script.turn_on
       entity_id: script.say
       data:
         variables:
           where: 'media_player.kok'
           what: 'God evening! Turning on the outdoor lighting.'

17-02-02 08:52:40 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: [condition] is an invalid option for [automation]. Check: automation->action->2->condition. (See /home/homeassistant/.homeassistant/configuration.yaml, line 16). Please check the docs at https://home-assistant.io/components/automation/

Try:

  - condition: and
    conditions:
     - condition: state
       entity_id: alarm_control_panel.alarm_1
       state: disarmed
2 Likes

Yes this fixed it, thank you.
Seems like a bug because i shouldn’t need and/or when I only have one condition :joy:

I think it should be

   action:
     - service: homeassistant.turn_on
       entity_id:
         - group.frontyard_lights
         - group.backyard_lights
     - service: notify.html5
       data_template:
         message: "God evening! Turning on the outdoor lighting."
       data:
         data:
           tag: 'notification-about-sunset'
     - condition: state
       entity_id: alarm_control_panel.alarm_1
       state: disarmed
     - service: script.turn_on
       entity_id: script.say
       data:
         variables:
           where: 'media_player.kok'
           what: 'God evening! Turning on the outdoor lighting.'
3 Likes

Seems to work! Nice catch. Now I won’t need and/or when only having one condition.