Help using TTS and sending a message to a media player

Hi all,
I am running hassio and this is my configuration.yaml entry for Amazon’s Polly service:

# Configure Amazon Polly
tts:
  - platform: amazon_polly
    aws_access_key_id: my key
    aws_secret_access_key: 'my key'
    region_name: 'us-east-1'
    voice: Joanna

I don’t get any errors loading that component.

I get the following error when trying to send a message.

Error executing service <ServiceCall media_player.play_media: media_content_id=http://192.168.1.7:8123/api/tts_proxy/a506d9c4f9af3a8b8cf232d737dd9bc8449ce4d3_en-us_2695048230_amazon_polly.mp3, media_content_type=music>

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 403, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 694, in play_media
    raise NotImplementedError()
NotImplementedError

So it seems it cannot execute the service call play media to one of my home media players.

This is the script I am using to test. I have 2 media players recognized by HA, a Roku and a Samsung wireless sound bar.

I tried adding “entity_id: media_player.samsung_wireless_audio_hwk650” into the script and I get the same error. If I don’t include an “entity id:” the docs said it would broadcast over all my media players.

Here is my test script in my automations.yaml file:

# Test Amazon Polly
- id: test_amazon_polly
  alias: Test Amazon Polly
  initial_state: True
  trigger:
    platform: template
    value_template: "{% if is_state('sensor.where_is_brandon', 'Home') %}true{% endif %}"
  action:
    - service: tts.amazon_polly_say
      data_template:
        entity_id: media_player.samsung_wireless_audio_hwk650
        message: >
          <speak>
              Hello from Amazon Polly
          </speak>

I’m home of course when I run the test the script and that is when my log shows the Error executing service <ServiceCall media_player.play_media: error... appears.

Any help would be greatly appreciated and thanks!

I don’t have the (speak) part in the message and your entity_id doesn’t need to be indented

- service: tts.amazon_polly_say
  entity_id: media_player.speaker
  data_template:
    message: > 
        In 15 minutes {{ states.sensor.eventmessage.state }} begins today
    cache: true

I replaced my automation code with yours and changed the media.player ID… I still get the same Error of:

Error executing service <ServiceCall media_player.play_media: media_content_id=http://192.168.1.7:8123/api/tts_proxy/5cf6531a130a9c0c214280bf8079da17eb7f456c_en-us_2695048230_amazon_polly.mp3, media_content_type=music, entity_id=['media_player.samsung_wireless_audio_hwk650']>

It appears the problem is related to executing it to my media player, almost like I am missing the entire media player component…

I have auto discovery on and I do have a Roku, Samsung TV, and the Samsung sound bar detected and functional…

I did search for that error but no luck… should I be declaring my media-player and hard coding it into my configuration.yaml file?

I don’t use discovery because it slows down startup and turns my TV on so mine is hard coded. check your state page to see if HA sees it.

image

Thanks for trying to help me out.

I do have three listed there, that’s all good and they all say “On”… hmmm wondering what else it could be.

media_player.roku_yp007e997171
media_player.samsung_8_series_65_un65ks8000
media_player.samsung_wireless_audio_hwk650

You might try your roku to see if its the media player. Also, you can check the TTS directory in your configuration directory for the actual mp3 to see if it plays ok.

Good idea, I investigated a bit and here’s what I found:

When I click all of my media players in the home assistant view, only the Roku has the line “Text to Speak” at the bottom (but I’m guessing this shouldn’t matter since all I’m looking for here is a “media_player” to output a sound).

My TTS directory does work and I see all my recent .MP3’s in there.

Perhaps I have to declare a “media-player” in my configuration.yaml file and not rely on the discovery… I’ll try that out now…

Argh, that didn’t work either… I specified a media_player in my configuration.yaml file as follows:

media_player:
  - platform: samsungtv
    host: 192.168.1.8

Still get this error:

Error executing service <ServiceCall media_player.play_media: 
media_content_id=http://192.168.1.7:8123/api/tts_proxy/a506d9c4f9af3a8b8cf232d737dd9bc8449ce4d3_en-us_3494009040_amazon_polly.mp3, media_content_type=music, entity_id=['media_player.samsung_tv_remote']>
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 403, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 694, in play_media
    raise NotImplementedError()
NotImplementedError

your device might not support TTS. try searching this forum for “NotImplementedError TTS”

Awesome @RobDYI, I’ll give that a shot, I was hoping at least the Roku would support it since it offers the “Text to speak” option, but I get that same error with my Roku when I tried.

Found a Smart Things solution for my Samsung Sound Bar, so it looks like it doesnt natively support TTS…

But don’t think I can apply it to my HA setup: