How to send the entity_id or name as part of MQTT payload

I am having a small problem that I am sure there is a simple solution for.
I have set up a MQTT light and I want to be able to include the entity_id as part of the payload.
Something like this:


  • platform: mqtt
    schema: template
    name: “myFirstMQTTLight”
    command_topic: “firstMQTTqueueToTurnOnLight”
    command_on_template: “ON, {{ entity_id}}”
    command_off_template: “OFF, {{ entity_id}}”
    The idea is that I have one topic to turn lights on/off and I pass the entity_id in the payload and this will be used by the MQTT receiver on the other side.

For some reason it is not working. The MQTT receiver receives only "ON, " with basically nothing in place of the entity_id. I am sure I am getting the use of variables in templates wrong.
Thanks for your help in advance,


The light turn on / off services do not support variables in the data. e.g. the light.turn_on service only supports these attributes: