More efficient way to copy a switch state without a loop?

Can anyone recommend a more efficient way to copy a switch state from one to another, emulating a 3-way switch, without creating a loop?

For example, this works by explicitly checking each switch state so that it’s not turned on if already on and not turned off if already off… but is quite long:

##################################################################
- alias: Turn on patio light 1 with patio light 2
##################################################################
  trigger:
    platform: state
    entity_id: switch.patio_light_2
    from: 'off'
    to: 'on'
  condition:
    condition: state
    entity_id: switch.patio_light_1
    state: 'off'
  action:
    service: homeassistant.turn_on
    entity_id: switch.patio_light_1

##################################################################
- alias: Turn off patio light 1 with patio light 2
##################################################################
  trigger:
    platform: state
    entity_id: switch.patio_light_2
    from: 'on'
    to: 'off'
  condition:
    condition: state
    entity_id: switch.patio_light_1
    state: 'on'
  action:
    service: homeassistant.turn_off
    entity_id: switch.patio_light_1

##################################################################
- alias: Turn on patio light 2 with patio light 1
##################################################################
  trigger:
    platform: state
    entity_id: switch.patio_light_1
    from: 'off'
    to: 'on'
  condition:
    condition: state
    entity_id: switch.patio_light_2
    state: 'off'
  action:
    service: homeassistant.turn_on
    entity_id: switch.patio_light_2

##################################################################
- alias: Turn off patio light 2 with patio light 1
##################################################################
  trigger:
    platform: state
    entity_id: switch.patio_light_1
    from: 'on'
    to: 'off'
  condition:
    condition: state
    entity_id: switch.patio_light_2
    state: 'on'
  action:
    service: homeassistant.turn_off
    entity_id: switch.patio_light_2

Hi
do you mean this?

Did you ever figure out a better way to do this? I tried this years ago, but had issues with the lights just constantly switching back and forth… I think it must’ve been because I didn’t include the conditions after the triggers, so I might have to try that, but did you find a simpler way of setting this up?

This is the latest method I’ve been using:

####################################################
- alias: patio light 3-way led sync fix
####################################################
    platform: state
    entity_id: switch.patio_light
    to:
      - 'on'
      - 'off'
  action:
    service_template: homeassistant.turn_{{ trigger.to_state.state }}
    entity_id:
      - switch.patio_light_led_1
      - switch.patio_light_led_2