Turn an ESP8266 WemosD1Mini into an audio notifier for Home Assistant: Play MP3, TTS & RTTL

I have made many updates on the initial project these last days. Please find the list below.
There still a this issue about Google TTS (if a good ESP developper can take a look it would be welcome! :sweat_smile:)
++!

/*******************************************************************************************
"MrDiy Audio Notifier"  
Credits to original source : https://gitlab.com/MrDIYca/mrdiy-audio-notifier
Modified by Schmurtz for Platformio and ESP32 : 

Release Notes (yyyy/mm/dd): 
V0.1 - 2021/12/22 : 
  - Added these comments, pinouts and additionnal DAC settings  
  - Now compatible with platformio  
  - Now compatible wih ESP32
  - Added support for Google Translate TTS  
V0.2 - 2021/12/29 : 
  - fix playing RTTTL & SAM 
  - added aac playback, useful for many radios  
  - added flac playback (working?)  
  - added comments to change the SAMvoice (robot, elf , ET...)  
  - fix errors msg "connect on fd 63, errno: 118, "Host is unreachable""
due to mqtt actions before wifi connects
V0.3 - 2022/01/03 : 
  - Migrate to IotWebConf 3.2.0   (Thanks to markvader) 
V0.4 - 2022/01/08 : 
  - NEW: You can set these options directly in web interface
		(These settings are saved & restored after a reboot)
		 * audio output (no DAC, internal or external DAC), reboot required 
		 * audio volume 
		 * default TTS sam voice style can be set in web interface  
		 * default TTS google voice language can be set in web interface
  - NEW: Firmware update with web interface 
  - NEW: MQTT command feedback msg when a problems are detected (topic "answer")
  - FIX : longer MQTT server name are supported 
  - Breaking change : MQTT TTS commands renamed: samvoice /googlevoice  
  - Less different firmwares + Schmurtz_ESP_Flasher : Windows script for easy flashing  

/*******************************************************************************************```
2 Likes

@MrDIY
Is there a chance, that your feature is getting a component within esphome?
Have you already build something with the amplifier PAM8403 (like you said at 2min20s at your video)?

I build a multisensor just like this one but with an esp32

By the way I use other esp32 with relays (silent solid state relays) and switches to control light and many others (garage door, lawn irrigation, heating control…) and for controlling LED-lights with WLED.

I want to have a multisensor in every room for every possible home automation purpose. One goal is to notify via audio that the door bell was pressed and someone is at the door. I can imagine many other purpose to notify with sound (call the kids to eat). Right now I do that with simple passive buzzer and the Rtttl component of ESPHome (Rtttl Buzzer — ESPHome).

Your approach is great but I need an extra ESP just for this feature. If I could use an ESPHome component I would only need an amplifier and 2 speaker, both very cheap, and my multisensor would have a great and flexible feature.

Why ESP32 and not ESP8266?
Because of Bluetooth. I didn’t test it yet, but from all I have read…

…it should be possible to connect ESP32(-multisensor) not only to HomeAssistant via WiFi but additionally with each other via BLE. So all these ESP32 should work even if my router/WiFi and/or HomeAssistant is damaged.

@MrDIY (is there a better topic than this one?)
Is it possible to combine your Noise Detector with this audio player in one ESP8266 (https://www.youtube.com/watch?v=_D4Go4CFwes). The noise detection just doesn’t work with ESP32, I had numerous sensors (KY-038 / KY-037, MAX9814, MAX4466, INMP441) and I think, the ADC from ESP32 doesn’t work as the one from ESP8266. If your player doesn’t get into ESPHome in time (what I think), so I could use two features in one D1-mini.

Update to version 0.5 :

  • NEW: increase and decrease volume with MQTT commands (+ and -)
  • NEW: increase and decrease volume physical buttons on GPIO 13 and 14
2 Likes

Great work!

1 Like

Thanks to the readme of this repo and this reddit post it is now possible to use MrDIY Notifier with Home Assistant TTS.
It use an atomation which replicate the current audio source from another player to the MrDIY Notifier.
It could be nice to have a real entity media player dedicated to MrDiy Notifier but in the meantime it helps.

alias: Send audio to MrDIY Notifier
description: ''
trigger:
  - platform: state
    entity_id: media_player.GoogleHome
    to: playing
condition: []
action:
  - service: mqtt.publish
    data:
      topic: diy/play
      payload_template: >-
        {{
        states.media_player.GoogleHome.attributes['media_content_id']}}
mode: single
2 Likes

I’m looking for a way to transform MrDiy Notifier into a real Media Player entity in Home Assistant.

After some research, Media_player.template (Community post & Github repo) seems very nice too !

Edit : hass-multiroom-mqtt-mediaplayer github & community post could be an alternative too.

1 Like

Hiya Mr. Schmurtz!

I just wanted to stop by and say thank you for your efforts on this project. I was pointed to your code two days ago by Mr DIY and I just got my I2C circuit up and running. This works really well and I can’t wait to transfer it from breadboard to soldered circuit. I’ll be doing that step next.

I am running version 0.4 and just randomly stumbled upon this post saying you upgrading to 0.5 yesterday! I’ll flash it ASAP.

Thank you and thank you Mr DIY for this project. This was just challenging enough for a beginner like me to Home Automation, Home Assistant, ESP8266 and MQTT to get working. You guys are awesome, keep up the great work

2 Likes

Thanks @HurstOlds , happy to see that someone else than me use it :sweat_smile:
This is typically the best feedback that we could expect when we work on this kind of project :wink:

Good news : you can now declare MrDiy Notififier as media player in Home Assistant so sending TTS to the notifier is even easier.
image

This new feature is in progress, not sure which MQTT media player I will use at the end but for now it’s starting to work with “media-player-template”, see my post about it here (still in progress…).

May be the Notifier status would be easier to retrieve with hass-multiroom-mqtt-mediaplayer or hass-mqtt-mediaplayer… We will see that later …

1 Like

Edit: I didn’t see your link in the post on how to implement this as a media player. I look thru that and give it a try.

Also, I flashed version 0.5 and reported a bug I’ve been having when trying to use /googlevoice/ commands. I reported the bug over on your github page.

I so far have two of these speakers up and running. One is 0.5 and the other is 0.4. I’ll reflash to 0.5 when I get a chance. I have at least one more I’m looking to assemble this week. The DAC circuit that you provided is awesome. Works really well and there are none of the hiss and pops that my previous circuit had that I built off the original MrDIY schematic.

I’m really enjoying this project. I still have to work on setting up a local HFS style file share for streaming/playing MP3 files on these speakers. I’ll be working on that this week as well. Thank you!!

Yes this is an identified bug. I’ve made a complete answer on your issue on Github. But when you use it like a media player this is a good workaround to use Google TTS without problems :wink:

About the new 0.5 : there is no big difference : it just allow to manage volume in a handier way. I don’t know if you see that : at the bottom of the web UI there’s a link to upload new firmware easily !

1 Like

Version 0.6 released : no more long hang after Google TTS playback. Not totally perfect but a lot better than before :wink:

As a reminder, since version 0.4 you can set the default google TTS language in the web UI or override it directly in your MQTT command :
Bonjour,fr
or
Guten Tag,de-DE

Awesome, I’m going to flash it now.

I have a question about updating firmware, that I haven’t been able to find in any of the readme docs. How do you use the GUI firmware update option? When I click on it, there’s an option to update the firmware, or update the filesystem.

Do I just pick the bin I need and do firmware? You have other files in the firmware folder, are those for updating the filesystem? (boot_app0, partitions.bin, bootloader_qio)

I just went from 0.5 to 0.6 by only flashing the firmware via the GUI and it’s not working correctly. I figured there must be more to it, in terms of updating via the GUI.

Also, as a feature request, do you think you can make the main GUI display which version of the software it’s running? I’m going to have upwards of 5 of these bad boys throughout the house, it’ll help track which firmware is on each one.

For now, to get to 0.6, I’ll just pull it out of my enclosure and flash it manually to see if 0.6 works that way.

Okay, so I had a chance to do some further testing. Looks like just choosing to flash the firmware bin to the unit works for upgrade. sending the /samvoice/ command is what was broken. I posted /samvoice/ as an issue on the github for version 0.6

After some further testing, here is what I’m seeing. I am running two of these speaker notifiers.
Speaker 1 was running firmware 0.4
Speaker 2 was running firmware 0.5

I upgraded speaker 2 to version 0.6 and it works, just samvoice is broken.

I just now upgraded speaker 1 to version 0.6 and there’s a problem running both at version 0.6 This was an issue I saw when running Mr DIY original firmware one more than one speaker. It’s basically created a MQTT storm, where both units keep firing off messages saying they’re idle and connected. When this happens, I can’t send commands to either speaker.

To further test, I downgraded speaker 1 to version 0.5. speaker 2 running version 0.6 and it has the same problem. Both are firing messages non stop via MQTT, causing neither of them to work.

So I stepped speaker 1 back down to version 0.4 . Speaker 2 is running latest 0.6 version, and now both work as expected. I presume version 0.5 introduced an issue that causes multiple notifiers to break.

One further test to confirm:

If both speaker/notifiers are running firmware version 0.4, they both work correctly. No issues with contention and no MQTT storm of broadcasts from the notifiers.

Thanks for all your test and feedback, it helps a lot to improve quickly the project !

To update firmware from the UI, just click on “browse” in the firmware section and pick one firmware file (I give compiled firmware directly in the github repo) like “FW_v0.61_ESP8266_d1_mini.bin”.
You don’t need to update filesystem.

I’ve just release version 0.61 which fix the MQTT storm when you have 2 Notifiers simultaneously and the crash problem with SAM voice TTS on ESP8266. :wink:

I tested it out and the issues I had reported on the github are all resolved in version 0.61. Thank you! I’ll be spinning up a couple more of these speakers over the next few days :slight_smile:

Hello
I’m starting your project, I have an esp32 devkitc on hand.
On the ESP32 I also use GND and RX same ESP8266 ?, is there anything else to know about the ESP32?
Thank you for your work.

Hi April,

Did you find the full circuit schematic for this project? It shows all of the pins you need to connect. It’s more than just the RX

Hi there, I haven’t seen a full schematic, unless you mean the text one here:

However the pinouts for esp32 and esp8266 are here:

Thank you for your help, I will test it.
sorry but I’m new to ESP32
With computer amplified speakers I have to use internal DAC or no DAC ?