How to create a variable entity_id based on a variable?

Hello, I am trying to create a script using an entity_id based on a variable passed to the script. In this example I can use 1 script for switching on 4 different sonoff switches

automation:
  - alias: switch_sonoff_1
    trigger: []
    action:
    - service: script.switch_sonoff_on
      data:
        switch: "1"
#script
  switch_sonoff_on:
    alias: "Switch sonoff 1-4 on"
    sequence:
      - service: switch.turn_on
        entity_id: switch.sonoff_1000cadaec_<use variable switch>

So houw to create a template to add the switch number to the entity_id.

entity_id: “switch.sonoff_1000cadaec_{{ switch }}”

Thanks Olen, and how to do when it is part of a message:

{{ states('sensor.date_time_stamp') }} status Sonoff {{ switch }}: {{ status.switch.sonoff_1000cadaec_<use variable switch>.state }}

I’d do a multiline and something like

 {% set entity = 'switch.sonof...' ~ switch %}
 {{ states(entity) }}

(Sorry for the short answers. Mobile only here)

No problem. It is working. Thanks…