Can't play a TTS message if I use HTTPS to access HA

Hello everyone!

Initially I was accessing HA via http and everything worked fine, being able to output TTS messages and play mp3 files stored in /config/www/ on musiccast speakers.

But after enabling HA access via https using DuckDNS and Let’sEncrypt I can’t get it to work anymore. The TTS service correctly generates the audio files but the speakers do not play anything.

My configuration is the following:

http:
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem
  
homeassistant:
  external_url: "https://xxxx.duckdns.org:my_port"
  internal_url: "http://my_local_IP:8123"
  country: ES
  media_dirs:
    local: /media
  allowlist_external_dirs:
    - /config/www
    - /config/www/images/snapshots
    - /config/www/videos
    - /config/www/tts

tts:
  - platform: google_translate
    service_name: google_translate_say
    language: "es"
    cache: true
    cache_dir: /config/www/tts/
    time_memory: 300

I have also tried playing a file test.mp3 stored in /config/www/ using the play_media service from the developer tools tab using the following settings and it doesn’t work either:

service: media_player.play_media
data:
  media_content_id: http://my_local_IP:8123/local/test.mp3
  media_content_type: music
target:
  entity_id: media_player.musiccast_kitchen

I’ve been searching the internet for several days and reading tutorials and posts but I can’t solve the problem.
Please can someone help me?

I have not heard of that problem before and my only wild guess would be that some piece of code does not like that you mix HTTP and HTTPS. I know many browsers have it that way.

Thanks for answering.
Not to mix http and https, how could I send the URL of the local mp3 file without using http? Is there a way to do it with https? And in the case of TTS, is there another way to do it?

I have tested that the mp3 file is accessible using https. Thus, if in Google Chrome I put its address in the form https://xxx.duckdns.org/local/test.mp3, the browser plays it without problem.
Using this URL in the play_media service doesn’t work either.

service: media_player.play_media
data:
  media_content_id: https://xxx.duckdns.org/local/test.mp3
  media_content_type: music
target:
  entity_id: media_player.musiccast_kitchen

I am having this same issue. Were you ever able to find a solution?

The issue is that chromecast devices use Google dns, regardless what you tell them to use.

Thus, when you provide your duckdns url, it resolved to your external ip, rather than the internal IP.

To make TTS work on my network with https, I did the following:

Configure dnsmasq and create an A record for your HA server. Then change your dhcp server to hand out the ip address of your ha server for your dns server.

Then, block the chromecast devices from accessing 8.8.8.8 and 8.8.4.4

Thdy will now use the internal dns server, which will resolve to the internal IP of your home assistant server, and it should work.