Representing the status of a switch using light with one automation

My goal is to represent the state of my ikea tradfri outlet using my led panel, but use only one automation. With 2 automation I can easily do this, but I want less clutter in the automations UI.
My current setup looks like this:

alias: StatusBadAP
description: ''
trigger:
  - platform: device
    type: changed_states
    device_id: dd078cc22f66841edbbf3a272fb07afc
    entity_id: switch.ikea_of_sweden_tradfri_control_outlet_0586bbfe_on_off
    domain: switch
condition:
  - condition: state
    entity_id: binary_sensor.pc
    state: 'on'
action:
  - wait_for_trigger:
      - platform: device
        type: turned_on
        device_id: dd078cc22f66841edbbf3a272fb07afc
        entity_id: switch.ikea_of_sweden_tradfri_control_outlet_0586bbfe_on_off
        domain: switch
  - type: turn_on
    device_id: 37ea63788980e0982773985e02cd909b
    entity_id: light.wled
    domain: light
  - wait_for_trigger:
      - platform: device
        type: turned_off
        device_id: dd078cc22f66841edbbf3a272fb07afc
        entity_id: switch.ikea_of_sweden_tradfri_control_outlet_0586bbfe_on_off
        domain: switch
  - type: turn_off
    device_id: 37ea63788980e0982773985e02cd909b
    entity_id: light.wled
    domain: light
mode: single

This works kinda, but only every second time I turn the outlet on, the light turns on as well. Can you point my to my mistake?

Seems a bit double… you have a trigger then you wait for the trigger…try to reduce

The problem is, i dont know how to write automations with a decision path. If I use this:

alias: StatusBadAP
description: ''
trigger:
  - platform: device
    type: changed_states
    device_id: dd078cc22f66841edbbf3a272fb07afc
    entity_id: switch.ikea_of_sweden_tradfri_control_outlet_0586bbfe_on_off
    domain: switch
condition:
  - condition: state
    entity_id: binary_sensor.pc
    state: 'on'
action:
  - condition: state
    entity_id: switch.ikea_of_sweden_tradfri_control_outlet_0586bbfe_on_off
    state: 'on'
  - type: turn_on
    device_id: 37ea63788980e0982773985e02cd909b
    entity_id: light.wled
    domain: light
  - condition: state
    entity_id: switch.ikea_of_sweden_tradfri_control_outlet_0586bbfe_on_off
    state: 'off'
  - type: turn_off
    device_id: 37ea63788980e0982773985e02cd909b
    entity_id: light.wled
    domain: light
mode: single

The only path that works is the turn_on one.

Can you please write your logic then…what I seem to read is :
If [switch toggle] and [pc=on] then [if switch on] then [light] and [switch off] then [light off]
I guess??? you want
If [switch toggle] and [pc=on] then [light toggle]
…with the GUI ‘automations’ this is easy to do

alias: Test
description: ''
trigger:
  - platform: device
    type: changed_states
    device_id: 11912cbe164d06eeea349429c9fa0bcd
    entity_id: switch.switch_2
    domain: switch
condition:
  - condition: state
    entity_id: device_tracker.laptop
    state: 'on'
action:
  - type: toggle
    device_id: 0cc1715bd198ab32dd15506030958598
    entity_id: light.light_2
    domain: light
mode: single

The logic should be: “If switch on and pc on turn light on and set its color to red, if the switch is off and my pc is on turn the light on and set its color to green, if the pc is off turn it off”.
Since I use the light also for other notifications, I want to be sure it represents the correct state of the switch.

The answer is probably in the ‘choose’ then…use Automation-GUI and skip the first conditions, go straight to Actions, here you have the possiblity to choose multiple options ( an if/then/else alike setup )…if you want even more than that…templates remain but these could become daunting to maintain and then I would suggest two automation…for now I believe Choose would work for you

Yeah, that one works. Thank you!
I seriously haven’t seen the choose section lol