Home » Blog » Enhancing Voice Assistant: Integrate an External Speaker using ESPHome

Enhancing Voice Assistant: Integrate an External Speaker using ESPHome

Hey, welcome back to my channel! Today, I’m going to show you how to connect the Voice Assistant in Home Assistant to an external speaker so that the responses to your spoken instructions are more clearly audible than on your Atom Echo or S3 Box! Let’s get started!


โญโญโญ NOTE: โญโญโญ

This article accompanies a YouTube video. I wrote it for people who would rather read than watch a video. To keep doing this, I want to ask you to check out the video, leave a comment under the video, give the video a thumbs up, and subscribe to my YouTube channel. This means that the video is offered more often to new visitors so that they also stay informed of the latest Home Assistant tutorials.

Thank you for your support!

Ed

Click here to watch the video

Introduction

Over the past year, Home Assistant has taken significant steps in adding the capability to control your devices using your voice. I’ve created a few videos on this topic, including these where you can learn how to implement it yourself. Various devices are available to activate Home Assistant via voice, with the Atom Echo and ESP32 S3 Box being the most commonly used at the moment. However, a drawback of these devices is that their built-in speakers are not very loud. Recently, I received a question on my Discord server about how to play back the response from these devices on an external speaker for better clarity. I delved into this and found a solution without the need for soldering. You can redirect the response to a Smart Speaker like a Google Home Speaker, making it much more audible! And the process is quite simple.

In this video, I won’t explain how to activate the voice assistant in Home Assistant. If you want to know how to activate the voice assistant in Home Assistant, please check out these videos where I explain it step by step. I’ll show you how to connect an external speaker to the Atom Echo. This principle works the same for the ESP32 S3 Box, so if you have that, you can also follow this tutorial.

Updating the code for the Atom Echo

If you have installed the Atom Echo in Home Assistant, you will find it listed among your devices in ESPHome. You might need to adopt your Atom Echo first. You probably won’t need to do this, but if you do, please proceed with the adoption process.

  • Go to ESPHome.
  • Click on “Adopt” for the discovered M5Stack Atom Echo device.
  • Copy the encryption key. You might need it later, but my experience is that Home Assistant handles this automatically.
  • Click Install

The latest firmware is now being installed on your Atom Echo. We will modify this firmware so that the response audio is also played on your smart speaker, making it more audible. Note: If you manually modify the firmware, updates for the Atom Echo will no longer be downloaded automatically. So, if new functionality is added for the Atom Echo, you will need to repeat these steps each time there are code updates for the Atom Echo itself. However, updates for the latest version of ESPHome will still be applied to your Atom Echo when a new version of ESPHome is released.

Selecting your Smart Speaker

Before we modify the code for the Atom Echo, we need to know the entity name of the smart speaker we want to use.

  • Go to one of your dashboards in Home Assistant and click somewhere within that dashboard.
  • Press the “e” on your keyboard.
  • Type media_player.
  • You will see a list of media players now.
  • Write down the entity name of the media player of your choice.
  • In my case, it’s media_player.googlehome1277

Adding the Smart Speaker to the ESPHome code for the Voice Assistant

Now we are going to invoke this media player in the ESPHome code.

  • In ESPHome, click Edit in the M5Stack Atom Echo card.
  • Copy the API and Wifi lines to a text file. You will need these later.
  • Go to the following Github page. You can find the link to this page in the description of this video.
  • If you use this tutorial for the ESP32 S3 box, then go to the firmware page for the S3 Box. That link can also be found in the description of this video.
  • Copy the code from the GitHub site by clicking on the copy icon.
  • Go back to ESPHome and replace the code for the Atom Echo with the copied code from GitHub.
  • Now scroll up to the api: line and paste the API code you copied earlier below the api: line.
  • Go to the wifi line and paste the Wi-Fi code you copied earlier below this line.
  • These two pieces of code make sure that your Atom Echo will still work in Home Assistant.
  • Now we are going to add the code that will send the response to your smart speaker.
  • Scroll down to the on_tts_start lines.
  • Enter the following code below the on_tts_start section. Make sure you have the indentation right.
What did we do?

What happens here is that once the Text To Speech is ready, this text is sent to the media player we selected, and it is spoken there. There is a slight echo between the text spoken on the Atom Echo itself and the Smart Speaker. Unfortunately, I couldn’t fix this. I couldn’t find anywhere how to mute the speaker of the Atom Echo while still playing the text on the Smart Speaker. If you know how to do this, please let me know in the comments under this video!

You can type out this code for free from the screen, or download it for the price of a cup of coffee via the link in the description of this video, making it easier for you to simply copy and paste the code.

Installing the new firmware for the Voice Assistant

  • Click Save.
  • Click Install.
  • Now choose how you want to update your Atom Echo.
  • I will choose ‘Plug into this computer’ because I connected my Atom Echo to my PC.
  • If you are running ESPHome locally without using HTTPS, you may encounter a message prompting you to create the firmware file and upload it through the ESPHome web interface. Otherwise, the firmware will be updated automatically. Currently, the firmware is being compiled in my case, and I need to wait until it’s ready for download. The compilation process might take a significant amount of time, so consider grabbing a coffee for yourself. Or even better, buy me a coffee! ๐Ÿ˜‰
  • After compilation is complete, click on ‘Download Project’.
  • The firmware file is now downloaded to your PC.
  • Click ‘Open ESPHome Web’.
  • Click ‘Connect’ and select the USB port to which your Atom Echo is connected.
  • Click ‘Connect’ again.
  • Click ‘Install’ and select the firmware file that you just downloaded.
  • Click ‘Install’ again.

The firmware is now being installed on the Atom Echo. If you encounter an error message, disconnect the Atom Echo from your PC, reconnect it, and restart the above procedure.

Making sure that the ESPHome device may invoke services in Home Assistant

After the installation is complete, we need to do one more important thing! We have to set up Home Assistant to allow our Atom Echo to invoke services in Home Assistant.

  • Go to Home Assistant.
  • Go to Settings.
  • You will see a repair message that the ESPHome device is not permitted to call a Home Assistant service.
  • Click Devices and Services.
  • Go to the ESPHome integration card.
  • Click Configure next to the Atom Echo device.
  • In the options popup, enable “Allow the device to make Home Assistant service calls” and click “Submit”.

Testing the Voice Assistant response using a smart speaker

Your Atom Echo will now send the responses to your Smart Speaker as well. Let’s test this!

As you can hear, a nice notification is audible through my smart speaker. You can customize these notifications exactly as you prefer. In this example, I have created an automation that responds to a few predefined phrases. This way, you can ensure that your smart speaker reacts just the way you want it to.

I hope this tutorial has helped you enhance your voice integration in Home Assistant. If my videos save you time and frustration, consider sponsoring me, just like these amazing people do. Without your financial support, I cannot continue creating these tutorials. Unfortunately, YouTube ad revenue is insufficient to make a living, and I also need your help. The links to Patreon, Ko-Fi, and how to become a channel member are in the video description. Thank you for watching, and don’t forget to give this video a thumbs up and subscribe to my channel.

I’ll see you soon in my next video!

Bye Bye!

#homeassistant #smarthome #smarthomesolutions #homeautomation #voiceassistant #ESPHome #externalspeaker #technology #homeimprovement #smartdevices #homeintegration #smartliving #smarthometechnology #intelligenthome #hometech #automatedhome #smarttechnology #connectedhome #homeinnovation #smartgadgets #voicecontrol #homeentertainment #m5stackatomecho #esp32s3box



Back to all articles