MQTT sensor template not working

- name: “Get_volumes”
state_topic: >-
‘media_title’),’ ‘, state_attr(‘media_player.sound_system_2’, ‘source’),’ ‘,
state_attr(‘media_player.lg_webos_tv_oled65g1pta’, ‘source’),’ ',
state_attr(‘media_player.sound_system_2’, ‘sound_mode’)) | join }}”

- name: "test"
  state_topic: "voldb/9HD Melbourne TV Audio Live TV PURE DIRECT"

The Test sensor works, but for some reason the Get_volumes which produces the same state_topic string according to developer tool , not working. I am new to using MQTT and would welcome some help.

You managed to format the test sensor, but the one that is not working, you did not format.

“voldb/9HD Melbourne TV Audio Live TV PURE DIRECT” is what I get from developer tools template.

Now I understand. You can’t template the state_topic

Is there any other way to get the data?. My template works with dump service, but I cannot seem to able to read MQTT_DUMP file. Looks like description for file sensor is out of date…