wolfgang ziegler


„make stuff and blog about it“

Push this Button to Play a Song

March 14, 2022

Recently, my kid learned about this dreadful, trashy, folk-pop song (*) from a kindergarten friend and wants to listen to it on our Alexa device all the time. The only problem (besides that this song is pure trash) is that Alexa has a hard time finding it when he asks for it.

Being the nice dad that I am, I promised to "build something" so he could listen to this song (did I already mention that it is trash).

Home Assistant

It turns out this "something" was quite easy to implement with Home Assistant.

  • There is Home Assistant Community Store.
  • Which offers the Alexa Media Player integration.
  • Having those setup and configured, an automation can be created, that runs a specific song on a selected Alexa device. Play a song on an Alexa device with a Home Assistant automation.
  • As a trigger for this automation I defined a WebHook, which gives me a URL that I can invoke via curl. Trigger the automation via a WebHook

Shelly IoT Button

So far, so good. Unfortunately, I can't have my kid run curl commands to listen to his song yet. A physical device would be nice for that. Luckily, I had this Shelly IoT Button that I bought a while ago and never really had a use for. Well, now I had.

Shelly IoT Button

I thought I was ready at that point, but it turned out that this button only supports sending GET requests.

Note: The Shelly Button only supports GET requests!

Trying to find a quick solution to this problem turned up nothing, but apparently Home Assistant will add support for GET requests in WebHooks soon (here is the PR) but in the meantime, I had to find a workaround.

IFTTT

Luckily, there is IFTTT and its Webhooks integration for that kind of problem.

Listening for an incoming GET request (from the Shelly button) and sending the POST request to Home Assistant Cloud is set up in a minute.

Make sure to enable the WebHook in Home Assistant Cloud for that!

Make the WebHook available in Home Assitant Cloud

Connect the URLs via IFTTT

Then, the only thing missing is configuring the IFTTT (GET) URL in the Shelly button ...

Configuring the Action URL of the Shelly IoT Button

... and voila: dreadful, trashy music on heavy rotation - what have I done 😱?

(*) I added the Rick roll link because I don't want to give the "artists" committing this atrocity of a song any credit.