Dynamic Topics in MQTT Sensors and Switches

I have an ESP32 that controls a strip light. It has many effects and each of those has a different topic for each of the possible configurations. I can make different dials and switches that can control the strip light in HA for one device. However, I have many strip lights that have an ID that they use for them to be controlled individually, they differentiate using their ID in the topics they subscribe to. For example, the topic set/strips/1/powerState would set the power state in strip 1. I have a dropdown menu that I use to choose the device that I configure. So I would like to have something like a template on the command_topic and the state_topic of each of the switches and stuff. Something like set/strips/{{ input_select.device_ids }}/powerState.

However, I looked everywhere for a method to do that, but nothing can solve this problem for me. I could theoretically make a standard switch that uses the template platform and have it so that it can use the mqtt.publish service. However, then I cannot easily have it change the current state based on the actual state of the device, which would make it much less useful.

Any ideas?

Edit: rephrase the issue

You can use a Template Select to perform a sequence of actions when you change the selected option.

Template Select documentation

Semi-Practical Examples (See “Example 2: Template Selects in place of an automation”)

The drawback of this method is that the order of operations is inflexible. I needed something similar for a pre-set select for out Echo devices and landed on using two Input Selects, a few button cards, and some scripts:

image

Card Configuration
type: custom:stack-in-card
cards:
  - type: custom:mushroom-title-card
    title: Alexa Media Player Control
  - type: entities
    entities:
      - entity: input_select.alexa_mini_player_selector
        name: Select Alexa device
        icon: phu:echo-dot-gen-3
      - entity: input_select.music_select
        name: Select Genre/Source
        icon: mdi:music-box-multiple-outline
  - type: grid
    columns: 3
    square: false
    cards:
      - type: button
        icon: mdi:volume-minus
        icon_height: 28px
        tap_action:
          action: call-service
          service: script.alexa_mini_media_player_decrease_volume
      - type: button
        color_type: theme
        icon_height: 28px
        icon: mdi:play
        tap_action:
          action: call-service
          service: script.alexa_music_chooser
      - type: button
        color_type: theme
        icon: mdi:volume-plus
        icon_height: 28px
        tap_action:
          action: call-service
          service: script.alexa_mini_media_player_increase_volume

Whoops, I didn’t phrase my issue correctly. I’ll edit it now.