Switch multiple devices to on or off with the same voice command in Alexa on/off

Hi everyone,

just recently migrated from openhab because of all the nonstop issues with it.
Just have put everything in my home in HA and now look to automate my home cinema again correctly with a simple Home Cinema ON or OFF command spoken to Alexa.

However, the automation does not yet work - sometimes it gets the OFF instead of ON commands in the automation.
As you can see here, I want to be able to change multiple switches to on or off in one order. What is the best way because it seems this is not correct and was only openhab logic. Can somebody point me for the best solution here for switching multiple devices on and off with one voice command? Thanks and looking forward to see what home assistant can do :slight_smile:

YAML Code as follows:

- id: '1730013215761'
  alias: 'Heimkino '
  description: ''
  triggers:
  - trigger: state
    entity_id:
    - input_boolean.heimkino
  conditions: []
  actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.projector
    enabled: true
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.projector
    enabled: true
  - action: media_player.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: media_player.living_room
  - action: media_player.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: media_player.living_room
  - action: media_player.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: media_player.wohnzimmer
  - action: media_player.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: media_player.wohnzimmer
  - type: turn_off
    device_id: ca4b9649da765578c13bdcef10332f89
    entity_id: f6913a2cf5d6a40bb4e11d35f3a1dbed
    domain: remote
  - type: turn_on
    device_id: ca4b9649da765578c13bdcef10332f89
    entity_id: f6913a2cf5d6a40bb4e11d35f3a1dbed
    domain: remote
  mode: single

The problem is that you have no way of controlling which action to take to either turn on or off the devices.

Right now the automation pretty much instantaneously turns on then turns off every device. Sometimes the on sticks, sometimes the off sticks.

you can either use an ‘if-then’ structure or a ‘choose’ structure to decide if the automation turns on or off the devices.

Here is the ‘if’ version:

- id: '1730013215761'
  alias: 'Heimkino '
  description: ''
  triggers:
  - trigger: state
    entity_id:
    - input_boolean.heimkino
  conditions: []
  actions:
  - if:
    - condition: state
      entity_id: input_boolean.heimkino
      state: 'on'
    then:
    - action: switch.turn_on
      metadata: {}
      data: {}
      target:
        entity_id: switch.projector
      enabled: true
    - action: media_player.turn_on
      metadata: {}
      data: {}
      target:
        entity_id: media_player.living_room
    - action: media_player.turn_on
      metadata: {}
      data: {}
      target:
        entity_id: media_player.wohnzimmer
    - type: turn_on
      device_id: ca4b9649da765578c13bdcef10332f89
      entity_id: f6913a2cf5d6a40bb4e11d35f3a1dbed
      domain: remote
    else:
    - action: switch.turn_off
      metadata: {}
      data: {}
      target:
        entity_id: switch.projector  
      enabled: true
    - action: media_player.turn_off
      metadata: {}
      data: {}
      target:
        entity_id: media_player.living_room
    - action: media_player.turn_off
      metadata: {}
      data: {}
      target:
        entity_id: media_player.wohnzimmer
    - type: turn_off
      device_id: ca4b9649da765578c13bdcef10332f89
      entity_id: f6913a2cf5d6a40bb4e11d35f3a1dbed
      domain: remote
  mode: single