#media card with text input not working

1 messages · Page 1 of 1 (latest)

austere wedge
#

I'm trying to to create a card that has a text input and uses tts.google_translate_say to play through speakers. I've been troubleshooting and can get it to work if all hardcoded, or if it test in dev tools actions. I think I'm not formatting something correctly in the card's tap action. I've been using chatgpt for help and now running in circles trying to debug. Current code plays out of the speaker "states input_text.media_message" instead of the actual text from that input

type: vertical-stack
cards:
  - type: entities
    title: Media Device and Message
    entities:
      - entity: input_select.media_player
        name: Select Media Player
      - entity: input_text.media_message
        name: Enter Message
  - show_name: true
    show_icon: true
    type: button
    name: Send Message
    icon: mdi:send
    tap_action:
      action: call-service
      service: tts.google_translate_say
      service_data:
        entity_id: media_player.computer_speaker
        message: "{{ states('input_text.media_message') }}"
void current
#

Stop using ChatGPT...

austere wedge
#

I tried google too lol... I found other similar examples from a year or so ago but they also don't work

void current
#

With that said... You can't use a template in a tap_action like that.

#

You could do it with a script that has input fields though.

austere wedge
#

ah okay, so change it so that the tap action fires the script?

void current
#

Yup.

austere wedge
#

thanks, going give it a try! end goal is using drop down input select for speaker and text input for what to say

void current
#

Gotcha... yeah, not 100% sure you can get there, but you could get it to where the script run dialog pops up and you can choose from there.

austere wedge
#

that works exactly how I wanted now, thanks! sharing code in case someone needs it

#

script

alias: announce message
sequence:
  - action: tts.google_translate_say
    metadata: {}
    data:
      cache: false
      message: "{{ states('input_text.media_message') or 'Default message' }}"
      entity_id: "{{ states('input_select.media_player') }}"
description: send tts to speaker
#

cards

type: vertical-stack
cards:
  - type: entities
    title: Media Device and Message
    entities:
      - entity: input_select.media_player
        name: Select Media Player
      - entity: input_text.media_message
        name: Enter Message
  - show_name: true
    show_icon: true
    type: button
    name: Send Message
    icon: mdi:send
    tap_action:
      action: call-service
      service: script.announce_message
#

2 helpers, input text and input select