Its been awhile since I have posted, I have been busy with numerous items! One of them was an item I wanted to share to continue improving my system design, development, and cloud experience. As an architect, I have felt a little lacking in development (I don’t think I have done any enterprise level development in about 5 years!), and wanted to make sure that I understand the technologies in order to help design larger complex systems.

If you are interested in just seeing the final product skip down below to see the youtube video, otherwise going to explain how I came across developing the project.

I was watching a youtube video where someone was working on a project to catalog their old vinyl records, and they were using NFC tags to catalog them in their database for their collection. I thought to myself “I wonder if I could take it one step further, and grab my old CD collection and utilize a cloud service to play the album?” So I sat down and started thinking about the system in question. Here is what I had for my home automation setup:

  • Home Assistant
    • This of course is my central hub for all things home automation. It has my Zigbee hub, my Google account, and etc integrated into it. I even got my wife’s aquarium system hooked up with home assistant to monitor her ph levels (which is going to be a future data project I am going to do for some data scientist studying).
  • Google Home Minis
    • This is what I am using for voice commands and casting music.
  • Sharptools.io
    • I use this for some dash boarding and controls. It’s main integration is home assistant.

So i was ready and had a few ideas in my head, but I had to lay out a few conditions first:

  • I wanted to contain traffic to my private network as much as possible.
  • No reaching into my network. I don’t want to broadcast anything that would identify myself to the internet. If i had to reach out, that’s fine, but no reaching into my network.
  • Try and utilize Home assistant integration as much as possible and reuse existing toys I have. This was a bit of a challenge cause there were some out of the box tools already that could make this much easier.

So the idea was to take all my cd collection and mount them on the wall. I wanted to give the ability to a guest visiting to easily pick an album from my catalog and play it to listen to. Thus came the first issue: How do I make a good user experience selecting the albums? If I wanted, I could easily mount a tablet on the wall, logged in with my Spotify account and just say “Pick whatever you like!” Seemed too easy. So I wanted to limit selection to at least things popular in my teenage and early adult years (jeez feels so far back). So figured we could mount our CD collection and that’s when I thought of either utilizing QR codes or NFC tags.

Why not both?

So luckily NFC tag writing was an easy feature for hooking up the automation. Home Assistant provides the ability to easily hook up your music provider of choice and the outputs for it (I went with the YAML editor):

So now with home assistant on my phone, if I scan the NFC tag that I register it should trigger to play the given automation I created based on the tag’s id. So after some more prototyping I finally got the following design layout:

  1. The phone would scan over the given NFC tag and the call would be made to Home Assistant via the app on the phone.
  2. The Home Assistant app would then call the Home Assistant server and then execute the given automation
  3. Home Assistant server would then make a call to my Google Home minis downstairs and then play the given album
  4. The Google home minis would start casting from Spotify based on the media ID that was played from it.

It worked great! There were a couple of things that were irking me about this solution though:

  1. You had to have home assistant installed on your phone and logged in to my admin console. This was a non-starter, there was no way I was giving my credentials or doing user maintenance for my friends to come over. So I had to improve this user experience.
  2. Spotify was easily integrated into Home Assistant and my Google Home minis, but this was an extra cost now for a premium subscription. There anyway I could reuse an existing service I have?
  3. How could I allow the controls of the Google Home minis for volume, next song or etc? The experience was a bit lacking for controlling the music once selected.

So I quickly started working on adding in an extra orchestration layer. I had all these NFC tags now, and needed to use them (I didn’t want to admit defeat to my wife and tell her I wasted 30 bucks really). So the thought occurred: What if I create a web service to make the call to home assistant instead of straight from the phone? Everyone has a browser on their phone, so making a GET request with a parameter should be easily accomplished. The web service can hold an authorization token and centralize the configuration. I can even work on a rotation service for the key! It checked all the boxes for my next set of skills to work on:

  • I would develop the service in .Net Core 7 (seemed to be a popular framework for work these days)
  • I would utilize a docker container since my mini pc has limited memory and CPU.
  • Gives me a chance to learn more about the Open API standard all the folks at the water cooler have been talking about.

I started my .Net Core 7 project, and made a quick service that would basically be listening for any get request to the “JukeBox” endpoint and make a subsequent call to my home assistant to fire the automation event I created earlier:

Tried it out with a couple of Postman calls and it works! Now just need to host it. So setup Docker Desktop on a minipc I have and pushed the published image to a private docker repo:

So now the design looks more like this now:

  1. The phone would scan over the given NFC tag and read the captured URL and open the browser with the URL
  2. Browser then calls the URL and executes the given web service
  3. The web service then calls and executes the Home Assistant automation routine with the given URL parameter from the web service
  4. The Google home minis would start casting from Youtube Music (already was paying for premium on another subscription) for the given album.

So for the final product:

Little hard to see, but I simply held up my developer phone (no home assistant installed, nearly stock android), the NFC tag was scanned, and it opened the browser to the web service URL and called the automation pretty quickly (the sound is coming from all my Google Home mini speakers, not the tablet itself). All traffic except for the actual streaming of the music is over my home automation network, so nearly all local traffic. Really happy with the results and looking forward to working on it more.

So I am really looking forward to continuing the project by mounting my cd collection and then inserting the NFC tags. I do plan on going back and adding the QR codes but that will be once I have the entire collection mounted on the wall(s). Oh and here is a better view of the Sharptools dashboard. This is used to control the volume, skip or repeat songs and etc. I still wanted to make sure that a guest has the ability to control the music.

Let me know if you enjoyed this article on a new home automation project. I am going to continue these to work on system design, development, and experiment with new (maybe to me) technologies. Happy Holidays!

Leave a Reply

Your email address will not be published.