Google TTS working with certificates

There are a few threads on here about Google TTS not working when using HA setup as secure. After looking for a solution that would work with my home network setup, I finally created a simple HassIO add-on that exposes the TTS media files over an HTTP port.

I found the TTS files are exposed in the /config/tts directory, so the add-on simply starts up an Python3 http.server and exposes that directory to the URI /api/tts_proxy which is what HA appends to the base URL.

Hence, simply by setting your base_url to http://(ip of ha) things start working without making modifications to your home network or having to expose the entire HA server as HTTP.

If you are interested, the add-on can be added using the HassIO repo I created (all documentaton and such is there): https://github.com/mljenkinsdotcom/hassio-addons

There are several other solutions available, none of which worked for me (or I was comfortable with) after I upgraded my home router to one that unfortunately had less features (realized after I purchased it). These include:

  • Blocking Google’s DNS servers (8.8.8.8 and 8.8.4.4) for all Google home devices and putting in a local DNS entry for my HA hostname to point to the local IP
  • Looping back my external IP (that resolves to the HA hostname) so the Google home requests to the external IP just came back into HA
  • Switching HA to an HTTP only configuration and using a proxy (i.e. NGINX) to expose HA as HTTPS externally

Note, I am still having some issues with the Google TTS acting like it is going to broadcast, and then not broadcasting. This seems to happen randomly, and could be something with my local network, since it works 90% of the time. Eventually I’d like to write a quick Python script utilizing the http.server rather than running it from the command line as I currently do in the add-on. This would allow me to have a debug feature to log the requests so you could see what is going on in the HA console.

If anyone has any better solution for getting TTS to work without making network modifications, i.e. an add-on, please share. I did run across one custom add-on that allowed TTS, but it appeared to use the Google assistant call and needed an API key to reach out to Google. I didn’t want to set all that up, and also didn’t want to change my current actions away from using the tts.google_say service.

If you have any comments on the add-on I created, you can share them here on on GitHub.