Failed to cast media error. Google Speakers

Hello all. I have this annoying issue.

I’ve been trying to use TTS but of course its not working. I’m getting these errors

Failed to cast media https://homeassistant.xxxxx.com/api/tts_proxy/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d_en_-_google_translate.mp3 from tts.base_url (https://homeassistant.xxxxx.com). Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address

My setup is pretty interesting. I’m running homeassistant in a VM inside of Promxmox. I am also running docker swarm. So when a request comes into my network, it hits docker swarm which passes the traffic to the VM. I am using traefik as a reverse proxy and using SSL through letsencrypt.

Inside of my network, all my IOT (which includes the google speakers) devices are on a separate VLAN which generally are not allowed to access anything on my main network except the VMs hosting docker and homeassistant but they do have access to the internet.

When I join my IOT network, I can access the mp3 file and can hear what is being played but I get the error within home assistant. I can also access my homeassistant url outside of my network as well so I know it does work.

Here is my config for TTS

# Text to speech
tts:
  - platform: google_translate
    base_url: https://homeassistant.xxxxx.com

I turned on logging within homeassistant. I’m getting this when I try to do TTS

2021-12-12 14:10:23 DEBUG (MainThread) [bellows.ezsp.protocol] Application frame 5 (nop) received: b''
2021-12-12 14:10:23 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140347041858944] Received {'type': 'call_service', 'domain': 'tts', 'service': 'google_translate_say', 'service_data': {'entity_id': 'media_player.office_speaker', 'message': 'test'}, 'id': 26}
2021-12-12 14:10:23 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=tts, service=google_translate_say, service_data=entity_id=media_player.office_speaker, message=test>
2021-12-12 14:10:23 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=play_media, service_data=media_content_id=https://homeassistant.xxxxx.com/api/tts_proxy/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3_en_-_google_translate.mp3, media_content_type=music, entity_id=['media_player.office_speaker']>
2021-12-12 14:10:23 INFO (SyncWorker_3) [pychromecast.controllers] Not launching app CC1AD845 - already running
2021-12-12 14:10:23 DEBUG (SyncWorker_3) [pychromecast.socket_client] [Office speaker(192.168.12.32):8009] Sending: Message urn:x-cast:com.google.cast.media from sender-0 to 18c12b25-ca79-4a64-8c49-1fb5d4ffe474: {'media': {'contentId': 'https://homeassistant.xxxxx.com/api/tts_proxy/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3_en_-_google_translate.mp3', 'streamType': 'BUFFERED', 'contentType': 'music', 'metadata': {}}, 'type': 'LOAD', 'autoplay': True, 'customData': {}, 'requestId': 17, 'sessionId': '18c12b25-ca79-4a64-8c49-1fb5d4ffe474'}
2021-12-12 14:10:23 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140347041858944] Sending {"id": 26, "type": "result", "success": true, "result": {"context": {"id": "d0b1edf33dfed781980ac6dfca130ffc", "parent_id": null, "user_id": "38c06adc6b2d458ab7ca2bb52f601b81"}}}
2021-12-12 14:10:23 DEBUG (Thread-17) [pychromecast.socket_client] [Office speaker(192.168.12.32):8009] Received: Message urn:x-cast:com.google.cast.media from 18c12b25-ca79-4a64-8c49-1fb5d4ffe474 to *: {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 2, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 12303, 'volume': {'level': 1, 'muted': False}, 'media': {'contentId': 'https://homeassistant.xxxxx.com/api/tts_proxy/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3_en_-_google_translate.mp3', 'streamType': 'BUFFERED', 'contentType': 'music', 'metadata': {}}, 'currentItemId': 1, 'extendedStatus': {'playerState': 'LOADING', 'media': {'contentId': 'https://homeassistant.xxxxx.com/api/tts_proxy/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3_en_-_google_translate.mp3', 'streamType': 'BUFFERED', 'contentType': 'music', 'metadata': {}}, 'mediaSessionId': 2}, 'repeatMode': 'REPEAT_OFF'}], 'requestId': 0}
2021-12-12 14:10:23 DEBUG (Thread-17) [pychromecast.controllers] Media:Received status {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 2, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 12303, 'volume': {'level': 1, 'muted': False}, 'media': {'contentId': 'https://homeassistant.xxxxx.com/api/tts_proxy/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3_en_-_google_translate.mp3', 'streamType': 'BUFFERED', 'contentType': 'music', 'metadata': {}}, 'currentItemId': 1, 'extendedStatus': {'playerState': 'LOADING', 'media': {'contentId': 'https://homeassistant.xxxxx.com/api/tts_proxy/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3_en_-_google_translate.mp3', 'streamType': 'BUFFERED', 'contentType': 'music', 'metadata': {}}, 'mediaSessionId': 2}, 'repeatMode': 'REPEAT_OFF'}], 'requestId': 0}
2021-12-12 14:10:23 ERROR (Thread-17) [homeassistant.components.cast.media_player] Failed to cast media https://homeassistant.xxxxx.com/api/tts_proxy/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3_en_-_google_translate.mp3 from tts.base_url (https://homeassistant.xxxxx.com). Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address
2021-12-12 14:10:23 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=media_player.office_speaker, old_state=<state media_player.office_speaker=idle; volume_level=0.3100000321865082, is_volume_muted=False, media_content_id=https://homeassistant.xxxxx.com/api/tts_proxy/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3_en_-_google_translate.mp3, media_position=0, media_position_updated_at=2021-12-12T14:10:20.263598-05:00, app_id=CC1AD845, app_name=Default Media Receiver, entity_picture_local=None, friendly_name=Office speaker, supported_features=152463 @ 2021-12-12T14:10:20.109244-05:00>, new_state=<state media_player.office_speaker=idle; volume_level=0.3100000321865082, is_volume_muted=False, media_content_id=https://homeassistant.xxxxx.com/api/tts_proxy/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3_en_-_google_translate.mp3, media_position=0, media_position_updated_at=2021-12-12T14:10:23.960376-05:00, app_id=CC1AD845, app_name=Default Media Receiver, entity_picture_local=None, friendly_name=Office speaker, supported_features=152463 @ 2021-12-12T14:10:20.109244-05:00>>

Heres the TTS page that I was following.

Any ideas? This has been bugging me for over a month.

1 Like

You may what to sanitize your logs. Your HA url is visible.

2 Likes

I’m having a similar problem. I’m running my HA on Trunas Scale which is using kubernetes. Home assistant sees it’s IP address as 172.16.66.152, but that IP is internal to the kubernetes cluster. I need home assistant to broadcast it’s public url “ha.mydomain.com” or at the very least 10.10.0.2:8123 which is on the network where my cast devices are. Is there a way to override which address home assistant uses when telling devices to play home assistant media?

I’m seeing this in my logs when I try to use text to speech:

* Failed to cast media http://172.16.66.152:8123/api/tts_proxy/51292a973ff969a6a8c11feeb47bc7d0e22175db_en_-_google_translate.mp3 from internal_url (http://172.16.66.152:8123). Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address

I just got mine working. I set the external and internal urls in my configuration.yaml file. Now when I use TTS it sends the correct IP address of 10.10.0.2 instead of that kubernetes cluster IP.

Here are the docs on setting the internal_ip: