[Fine tuning] TTS speech commands to my mediaplayer with Node-RED/MQTT

I use Node Red to send TTS speech commands to Home Assistant, using MQTT. I managed it get to work, but I need some fine tuning.

What I have so far:
Node Red

Home Assistant:

  - platform: mqtt
    state_topic: "/HomeAssistant/Say"
    name: "Spraak"
    icon: mdi:message-alert-outline


- id: '1547996179779'
  alias: Spraakmelding
  - entity_id: sensor.spraak
    platform: state
  condition: []
  - entity_id: media_player.squeezebox_radio
    service: media_player.turn_on
  - data_template:
      cache: false
      message: '{{states(''sensor.spraak'')}}'
    entity_id: media_player.squeezebox_radio
    service: tts.google_say

This working beautifully. I can send any text to the MQTT topic and my Logitech Squeeze Radio is pronouncing it.

So far, so good…

I want to automate it something more. I want to have something that when music is played, the speech command is executed, and when done, start the music again when the speech command is finished.

Can anyone help me with that? I’m absolutely no Home Assistant Guru (just starting to explore for 2 months or so).

Thank you in advance!

Hey, 4 years later i’m very interested how you configured the nodes. (I’m new to Node Red, i think it’s necessary?)