Best way to set switch on switch off priorities

Hi team !

I’m looking for the best ways to set solar routing priorities:
I can gradually route percentage of my production to my water heater then switch on/off 4 different 1000W heaters with inertia. I am looking for the best way to set priorities in my heaters.
I was thinking of 4 different dropdown list : priority1, priority2, priority3, priority4. I tried the below yaml only with priority1 dropdown list ( the other remaining “hardcoded”).

I’m using “{{‘switch.’~states(‘input_select.priority1’)|slugify}}” to create my entity_ID from the dropdown name and it turns out good in the developper tools/template, HA finds no issue in the yaml, I reload my automation. But it gets diabled in the integration / automation section.

Is there a better way than 4 different dropdowns ? what I want is really set on order.

What am I doing wrong recreating my entity ID from the dropdown option ?

thanks.

here is my automation code for context

Oliv


- id: '1759777633943'
  alias: auto_chauf_on
  description: ''
  triggers:
  - trigger: numeric_state
    entity_id:
    - number.esp32_living_router_level
    above: 70
  - trigger: numeric_state
    entity_id:
    - number.wh_router_level
    above: 70
  - trigger: numeric_state
    entity_id:
    - number.esp32_living_router_level
    for:
      hours: 0
      minutes: 0
      seconds: 5
    above: 70
  - trigger: numeric_state
    entity_id:
    - number.wh_router_level
    for:
      hours: 0
      minutes: 0
      seconds: 5
    above: 70
  - trigger: numeric_state
    entity_id:
    - sensor.zb_meter_power_b
    for:
      hours: 0
      minutes: 0
      seconds: 16
    below: -200
  conditions: []
  actions:
  - choose:
    - conditions:
      - condition: state
        entity_id: "{{'switch.'~states('input_select.priority1')|slugify}}"
        state: 'off'
      sequence:
      - action: switch.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: "{{'switch.'~states('input_select.priority1')|slugify}}"
    - conditions:
      - condition: state
        entity_id: "{{'switch.'~states('input_select.priority1')|slugify}}"
        state: 'on'
      - condition: state
        entity_id: switch.chauffage_oce
        state: 'off'
      sequence:
      - action: switch.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: switch.chauffage_oce
    - conditions:
      - condition: state
        entity_id: switch.chauffage_oce
        state: 'on'
      - condition: state
        entity_id: switch.chauffage_mezz
        state: 'off'
      sequence:
      - action: switch.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: switch.chauffage_mezz
      - action: number.set_value
        metadata: {}
        data:
          value: '0'
        target:
          entity_id:
          - number.esp32_living_router_level
          - number.wh_router_level
  mode: single