Can I use variables in a state trigger?

I have a necessary action in my automation with a state trigger that looks like this:

sensor.termostat_8_temperature

That then sends over MQTT with this code:

{
  "payload_template": "{{states.sensor.termostat_8_temperature.attributes.node_id}},{{states.sensor.termostat_8_temperature.state}}",
  "topic": "eg/Gulvtemperatur"
}

So it sends the node_id (in Z-wave) and the temperature that the node just has sendt to the Z-Wave network. But is it possible to use a wildcard instead of the 8 in the state trigger, make that into a variable and then use the variable instad of the 8 in the MQTT send?