How to get LAN IP:port address of HASOS in links sent to speaker/media_player instead of external URL?

Hi,
Original title was: “Can’t get ESPhome speaker/media player to play on-server content. DNS fails.” but I sorted that out, partially.
I made an ESP32 Voice Assistant that half works: I can use voice to turn things On/OFF and I can use the Media Player control from Devices/MyESPDevice/Control to play media from external DLNA sources, but I can’t play music I copied in the HASOS Media Server even though I can browse to it and select it; not can I “say” anything using the TTS tester by the media sources; even though the audio file gets created and I can play it if I copy the URL from the log in a browser.
I’m a noob at this, but I searched a lot, and I suspect my problem may have something to do with TTS calls do not include the port number in the URL.
So, I think my hardware is OK but I must be missing some configuration, and I also get the spoken replies, albeit not without Google (or other external) DNS.
I use the latest HASOS, DuckDNS and an apache proxy.
A link from the log for TTS looks like this:
https://myDNSname.duckdns.org/api/tts_proxy/0ae04e66200484218de7bd20937fe8be5f17dad2_en-us_894b186240_tts.piper.mp3
… and from the post I mentioned above it looks like having the port number added somehow to the IP may work, but what do I know?
I just noticed in the log that something else may be most relevant: after the URL, there’s a line stating:
[WiFiGeneric.cpp:1438] hostByName(): DNS Failed for myDNSname.duckdns.org
So maybe it’s not about the port number? Somehow, how could I replace the host name with the IP address?
As you can see below in my own reply, I was able to fix the main problem by adding a DNS server to the ESPhome wifi section.
But I can’t help feeling things would be better if the LAN address of the HASOS server was pointed to the player device, both for speed and so that it works if the internet is down. After all, one reason I wanted Home Assistant is so that my system doesn’t depend on the internet. Eh?
Thanks for helping.

I sort of mostly fixed it: I added a line “dns1: 8.8.8.8” to the Wifi configuration of the device, using the Google DNS.
It now works, but it’s slow.
Is there any way to make Hope Assistant pass it’s IP address rather than the host name to the TTS service?

1 Like

How did you ge\t the URL to have your myDNSname.duckdns.org in it? Here I just get an (internal random interface, but correct) IP address in the URL, which ESPHome obviously can’t connect to. I do have DNS setup properly, so how does this work?

I think I got it, in network settings, I had some things set to ‘automatic’ including the ‘local address’. If this is automatic, then it will take the IP address it seems, which is also set to automatic. Setting the hostname seems to fix/avoid this issue.