-
Notifications
You must be signed in to change notification settings - Fork 0
ESP HA Alexa Ducker
This is a cutom-made ESP8266 project that can detect when the Amazon Echo (2nd gen) activation light is on or off and trigger automations in Home Assistant.
This can be useful in scenarios where the Amazon Echo is placed in a room with a lot of background noise such as TVs. We can then trigger an automation when the light sensor goes above a certain level and lower the speaker or TV volume in Home Assistant.
I'm aware some devices like Chromecast, Fire Cube or Sonos offer a similar integrated "ducking function" but this is a standalone DIY solution which can be integrated with any system. In my case, I own an LG CX TV, Denon AVR Receiver and Shield TV Pro and am perfectly happy with this setup.
The tutorial will guide you how to build your own hardware and connect it to Home Assistant using the ESPHome integration.
I'm also sharing my Node Red flow with the automation to lower the TV volume and bring the volume back to its original volume once the request is complete.
Note that this solution may soon become redundant as the amazing team at Home Assistant have recently released the wake word function with their local voice assistant. This proposed solution can easily be achieved with their "Assist In Progress" sensor, without any extra hardware required. However I found in my tests that the local voice assistant still needed some work in general before replacing all my Echos so I hope you will still find this DIY project useful.
- NodeMCU V3 ESP8266
- TSL2561 Lux Sensor
- Amazon Echo 2nd Generation
- Light sensor 3D printed mount
You will of course need a Home Assistant server running on a Raspberry Pi or any other system. This tutorial won't be covering this part but there are tons of tutorials available online. One of my favourite YouTubers is Lewis from Everything Smart Home - probably a good place to get started and understand the fundamentals of Home Assistant.
The light sensor mount STL file can be downloaded here. I must credit Gary from GBLdesigns on Esty who has helped me perfect the original 3D mount design I sent him. He's a really top guy so if like me you don't own a 3D printer, I highly recommend Gary for your 3D prints.
(Apologies for the very bad soldering here - this was my first attempt since Secondary School)
Install the ESPHome add-on from the Add-on Store
Click the "+ New Device" button and choose a name for your sensor
Choose "ESP8266" for the device type
The node has been added to ESPHome and you will need to connect the ESP8566 to your computer for the first time to flash the ESPHome firmware on it
Note: This method only works if your Home Assistant runs secure (HTTPS) in the browser. If you use NabuCasa you can use the secure public URL that you can find in; Configuration -> Home Assistant Cloud under Remote Control.
Assuming you’re accessing Home Assistant under HTTPS click “Plugged-in directly from this computer“. A browser pop-up will show, you need to allow the browser to connect to the COM3 of the USB. Select the COM and click connect. ESPHome will now flash the chip from the browser.
Click on the "Edit" button to add the sensor configuration, copy this yaml code and paste it in your ESPHome yaml configuration. You will need to add your WiFi credentials.
You can now unplug the ESP8266 from your computer and plug it to a wall socket. It will now attempt to connect to the WiFi, and if everything goes well we should start seeing the lux data from the logs.
We can also see that our "Alexa Light Sensor" has been created as a Home Assistant entity and can now proceed with the automation.
In this example, the event state node will activate if the sensor.alexa_light_sensor is greater than 0.20 lux.
If the LG TV in the living room is on, it will send a volume command to the Denon AVR Receiver to be reduced to 10 for 3 seconds (you can adjust that delay to be longer if you want).
After the 3 seconds, when the request is over, it will bring the original volume back to how it was before (volume 30 in the above screenshot).
You can find the full Node Red flow here. You can import it in Node Red (Settings > Import) and adjust it to your needs.