Nested conditions

Hi,

I’m trying to write an automation script with nested conditions. Here is what I wrote so far:

- alias: Start music in bedroom
  trigger:
    platform: state
    entity_id: switch.bedroom_2_3
    to: 'on'
  condition:
    condition: and
    conditions:
      - condition: or
        conditions:
          - condition: state
            entity_id: media_player.kodi_bedroom
            state: 'idle'
          - condition: state
            entity_id: media_player.kodi_bedroom
            state: 'off'
      - condition: or
        conditions:
          - condition: state
            entity_id: media_player.mpd
            state: 'paused'
          - condition: state
            entity_id: media_player.mpd
            state: 'off'
  action:   
    - service: switch.turn_on
      entity_id: switch.mpd_bedroom
    - service: switch.turn_off
      entity_id: switch.mpd_livingroom
    - service: media_player.turn_on
      entity_id: media_player.mpd

However, it doesn’t work: voluptuous.MultipleInvalid: not a valid value for dictionary value @ data['conditions'][0]['condition']

Is it possible to write this kind of nested conditions?

This should work… not sure what’s wrong here.

I opened an issue on the site, as another user and me were having same problem with conditions.
https://github.com/home-assistant/home-assistant/issues/2029

There was a bug that would mark it as invalid. I have a PR here: https://github.com/home-assistant/home-assistant/pull/2037

Will release this as 0.19.4 tonight. Sorry.

Great, I’ll test it later today. Thanks!

I thought you could only have one action in an automation - did this change in 0.19?

Yes, it did: 0.19: Empowering scripts and Alexa - Home Assistant

Automation: allow script syntax for action (@balloob)

A welcome improvement! (But aren’t they all? :slight_smile:)

And just to confirm now that I upgraded to 0.19.4 and tested again: it works fine! Thanks @balloob :thumbsup: