Help with select

Hi
I have 3 select template as below

select:
  - platform: template
    name: Source_1 Priority"
    id: Source_1_Priority
    icon: mdi:format-list-bulleted
    optimistic: true
    restore_value: true
    options:
      - "First"
      - "Second"
      - "Third"

  - platform: template
    name: Source_2 Priority"
    id: Source_2_Priority
    icon: mdi:format-list-bulleted
    optimistic: true
    restore_value: true
    options:
      - "First"
      - "Second"
      - "Third"

  - platform: template
    name: Source_3 Priority"
    id: Source_3_Priority
    icon: mdi:format-list-bulleted
    optimistic: true
    restore_value: true
    options:
      - "First"
      - "Second"
      - "Third"

I need to set automation between them as if I select First option from any of 3 replace this option from the other and vice versa for others

in other words, I need always have options First, Second, and Third in one of select template not to be duplicated in other

First question - I assume that if you select a value, the prior select value replaces that in the select template that previously had the new value chosen?

That is - if a select has a value of First and I replace it with Second, the select that had a value of Second now becomes First?

@zoogara Correct

Ok - this is a bit hacky but it works (so far):

globals:
  - id: source1_index
    type: int
    restore_value: true
    initial_value: '0'
  - id: source2_index
    type: int
    restore_value: true
    initial_value: '1'
  - id: source3_index
    type: int
    restore_value: true
    initial_value: '2'

select:
  - platform: template
    name: Source_1 Priority
    id: Source_1_Priority
    icon: mdi:format-list-bulleted
    optimistic: true
    restore_value: true
    initial_option: "First"
    options:
      - "First"
      - "Second"
      - "Third"
    on_value:
      lambda: |-
        auto index2 = id(Source_2_Priority).active_index();
        auto index3 = id(Source_3_Priority).active_index();
        if (index2.value() == i) {
          auto call = id(Source_2_Priority).make_call();
          call.set_index(id(source1_index));
          call.perform();      
          id(source1_index) = i;
        } else {
        if (index3.value() == i) {
          auto call = id(Source_3_Priority).make_call();
          call.set_index(id(source1_index));
          call.perform();                  
          id(source1_index) = i; 
        } }

  - platform: template
    name: Source_2 Priority
    id: Source_2_Priority
    icon: mdi:format-list-bulleted
    optimistic: true
    restore_value: true
    initial_option: "Second"
    options:
      - "First"
      - "Second"
      - "Third"
    on_value:
      lambda: |-
        auto index1 = id(Source_1_Priority).active_index();
        auto index3 = id(Source_3_Priority).active_index();
        if (index1.value() == i) {
          auto call = id(Source_1_Priority).make_call();
          call.set_index(id(source2_index));
          call.perform();      
          id(source2_index) = i;
        } else {
        if (index3.value() == i) {
          auto call = id(Source_3_Priority).make_call();
          call.set_index(id(source2_index));
          call.perform();                  
          id(source2_index) = i;
        } }

  - platform: template
    name: Source_3 Priority
    id: Source_3_Priority
    icon: mdi:format-list-bulleted
    optimistic: true
    restore_value: true
    initial_option: "Third"
    options:
      - "First"
      - "Second"
      - "Third"
    on_value:
      lambda: |-
        auto index2 = id(Source_2_Priority).active_index();
        auto index1 = id(Source_1_Priority).active_index();
        if (index2.value() == i) {
          auto call = id(Source_2_Priority).make_call();
          call.set_index(id(source3_index));
          call.perform();      
          id(source3_index) = i;   
        } else {
        if (index1.value() == i) {
          auto call = id(Source_1_Priority).make_call();
          call.set_index(id(source3_index));
          call.perform();                  
          id(source3_index) = i; 
        } }

@zoogara thanks for your code

ESP8266 crashe and reboot when selecting between options

Ah. Well was tested on an ESP32. Maybe you have memory issues.

Are you using idf or Arduino platform?

Arduino …

Yeah sorry ignore that, you don’t really have a choice with ESP8266.

Umm no idea really. If you are using one of those multi relay boards with embedded ESP8266 then you are stuck with limited memory. Otherwise try with an ESP32.

Maybe someone else can think of an approach that uses less lambda.

@zoogara thanks i try my best