Script: Using input_select in MQTT topic

I’ve setup input_select with several computer names and I’m trying to use an it in a “Call service” “MQTT.publish” topic like this:


topic: computers/{{ states('input_select.computer_names') }}/command
payload: >-
  { "prog": "execute", "arg1": "/usr/bin/say", "arg2": "Hello World", "arg3": "" }

Is this possible or am I going about it completely the wrong way?

It was a formatting issue, I used single quotes around the variable, they needed to be double quotes.

All working fine now.