Problems set switch mqtt on mp3 in nodemcu with tasmota

You can keep most of the defaults in mqttbox. After you put in your broker credentials, then add subscriber and put # in the topic.

gpbenton suggested that you don’t need the leading / in your topic. I verified this on my test setup that he is correct. “cmnd/musica/POWER” and “/cmnd/musica/POWER” are completely different topics.

I’m sorry I did not know before, I’ve already installed and used the mqttbox and after many tests, the only thing that works for me is:

- platform: mqtt
  name: "MP3 Player On"  
  command_topic: "cmnd/musica/MP3Play"
  state_topic: "stat/musica/MP3Play"
  qos: 2
  momentary: 300

- platform: mqtt
  name: "MP3 Player Off"  
  command_topic: "cmnd/musica/MP3Stop"
  state_topic: "stat/musica/MP3Stop"
  qos: 2
  momentary: 300

I think you need a template switch, to send different MQTT messages for on and off. Something like this (this is untested)

switch:
  - platform: template
    switches:
      mp3 player:
                 turn_on:
                     service: mqtt.publish
                      data:
                          topic: "cmnd/musica/MP3Play"
                          payload: ""
                 turn_off:
                     service: mqtt.publish
                      data:
                          topic: "cmnd/musica/MP3Stop"
                          payload: ""

but you will also need to set the value_template field, and I’m not sure how you get the state of your player.

I wouldn’t bother with a template switch for a simple on/off MQTT message. (Unless there’s a benefit to the template switch that I missed?)
It appears that disenator is getting results from his testing.

For now I’ll leave it like that because what you have to do, do it right, which is to issue an alarm of an alarm clock.
Thank you very much for all your help.