How to output the TTS response to the device that received the trigger-sentence?

I have this automation to read the morning briefing stored in sensor.llm_cache using TTS:

alias: automation__morgentliches_update_vorlesen
description: ""
triggers:
  - trigger: conversation
    command:
      - guten morgen
conditions: []
actions:
  - set_conversation_response: ""
  - action: tts.speak
    metadata: {}
    data:
      cache: true
      media_player_entity_id: media_player.home_assistant_voice_095917_media_player
      message: >
        "{{ state_attr('sensor.llm_cache',
        'morning_greeting').get(now().strftime('%Y-%m-%d'), {}).get('me', 'THIS
        ALTERNATIVE TEXT DOES NOT WORK YET.') }}"
    target:
      entity_id: tts.piper_docker
mode: single

This works as expected on my Voice PE device media_player.home_assistant_voice_095917_media_player.

But I have two Voice PEs and the HA app on my mobile phone.

I would now like to modify this automation so that it automatically outputs the response to the Voice PE or mobile phone that received the trigger-sentence. How do I do this?

Have you tried setting this up as a custom sentence/intent script? It’s my understanding that the response should automatically go to the device that received the command.

If you want to specify a media player, I think you’ll have to find some other means of identifying it - last detected movement before the command was given, for example, or room-level presence detection.

Normally I think you would only do this if you wanted to direct the response to a different device from the one that received the command - a better quality speaker, for example.

Is piper.docker not the normal TTS agent for the device? If it is, there’s no need to squelch the response, just use your template there:

alias: automation__morgentliches_update_vorlesen
description: ""
triggers:
  - trigger: conversation
    command:
      - guten morgen
conditions: []
actions:
  - set_conversation_response: |
      {% set greetings = state_attr('sensor.llm_cache','morning_greeting') %}
      {% set date = now().strftime('%Y-%m-%d') %}
      {{ greetings.get(date, {}).get('me', 'THIS ALTERNATIVE TEXT DOES NOT WORK YET.') }}
mode: single

Otherwise you could use the device_id, but you would need to branch the logic if you want to make sure the Conversation text input works…

alias: automation__morgentliches_update_vorlesen
description: ""
triggers:
  - trigger: conversation
    command:
      - guten morgen
conditions: []
actions:
  - variables:
      message: |
        {% set greetings = state_attr('sensor.llm_cache','morning_greeting') %}
        {% set date = now().strftime('%Y-%m-%d') %}
        {{ greetings.get(date, {}).get('me', 'THIS ALTERNATIVE TEXT DOES NOT WORK YET.') }}
  - if:
      - "{{ trigger.device_id is not none }}"
    then:
      - action: tts.speak
        metadata: {}
        data:
          media_player_entity_id: |
            {{ device_entities(trigger.device) | select('match', 'media_player.') | first }}
          message: "{{ message }}"
        target:
          entity_id: tts.piper_docker
    else:
      - set_conversation_response: "{{ message }}"
mode: single