Saturday, January 8, 2022

Replacing a Chromecast Audio with a Raspberry Pi - Part 2 - Two Years Later

Well, life happened and the promised overview of how to set up a replacement for ChromeCast Audio never happened (obviously).  If, however, you're here, you're clearly interested in how to hook a Raspberry Pi to an intercom system or something similar.  It looks like I'm going to deliver on my original promise, just a couple of years late.

Thanks to a burst water heater, we're in the midst of a major remodel and the intercom system mentioned in Part 1 needs to be relocated; as part of the relocation we're also planning to upgrade it.  NuTone offered an upgrade path to a "more modern" intercom system called an NM100 that leverages the existing intercom wiring.  As part of this effort, I plan to build a new Raspberry Pi 4 to address a couple of issues:

  • The old Raspberry Pi 3 was only a 1GB model and I'm going to need some more horsepower (more on that in a moment)
  • My husband didn't like the fact that the old Pi had to be externally powered
  • The new intercom system doesn't have the doorbell integration that the old one did (at least not without some hacking)
The need for more horsepower stems from the fact that we have Z-Wave controlled by yet another Raspberry Pi.  That one was in a central closet that is going to become a pantry as part of this remodel so it really needs to go away.  As the "intercom Pi" will be hidden inside a wall and central to the house, it's a great opportunity to combine both functions into a single Pi.  I won't be covering how to implement this; just the audio functionality.

With regard to the doorbell, I had mentioned in Part 1 that our NuTone doorbell has inductive pickups just like an electric guitar.  The old intercom system had a connection that this fed into and would play the doorbell's sound throughout the house.  Unfortunately, the new NM100 doesn't support this feature.  This is something I wish to maintain so I need a solution.

Hi Fidelity Audio with an AUX Input on a Raspberry Pi

In the previous iteration of my intercom interface, I made use of the prior generation of this board (HiFiBerry DAC+ Pro) which didn't have an AUX input.  Now, they offer the HiFiBerry DAC+ ADC Pro board which has an audio input.  I've ordered one and hope that I'll be able to leverage it to mix any audio that's playing on the intercom system with the sound of the doorbell.  My expectation is that I can simply plug the line-level output from the inductive pickups into the audio input of this board.

More on that later once I receive the board.

The Hardware

This is going to be pretty straightforward.  The hardware consists of just a handful of items:
  • A Raspberry Pi 4B 4GB model
  • A PoE power splitter to eliminate the need for a "wall wart" to power the Raspberry Pi
  • The aforementioned HiFiBerry DAC+ ADC Pro hat
  • HiFiBerry's steel enclosure designed to accommodate the DAC+ ADC Pro board and a Raspberry Pi 4
  • RCA audio cables to patch the Pi into the intercom
I'll be dropping an Ethernet cable down the wall where the intercom system is to be located.  This will be plugged into a PoE switch and will provide power for the Pi.  I would have preferred to use a PoE hat; however, the DAC+ board is currently occupying that slot.

Of course, a 4GB Pi 4 is massive overkill for this application; it would run just fine on a 1GB Pi 3B (which is what my old system is currently running on) but as I mentioned above, I'm planning to move my Z-Wave controller to this Pi as well.

That's probably enough for this update.  I'll start on Part 3 once I get the DAC+ board in and document the setup.

Tuesday, December 17, 2019

Replacing a Chromecast Audio with a Raspberry Pi - Part 1 - Background


A bit over a year ago, my husband and I purchased a 1976 Tudor-style McMansion.  The fixer-upper featured landscape lighting, a drive gate, a pool and more square footage than any sane couple would consider, so it was perfect for us.  You see, we had a wonderful house before but we finished it.  We didn't have any more projects--it was beautiful, we had invested too much money into it and it fit our lifestyle to a tee.  Therefore, it was time to move on.

I promise this isn't one of those posts like you get when you look for a recipe.  You know the ones, where the author spends 22 pages telling you their life story, how they traveled to this quaint little inn in a tiny European country and had this amazing dish that they spend 10 more pages telling you how...  Anyway, a bit of background information, then I'll get to the meat of this.

Okay, so I lied.  If you don't want the backstory, feel free to jump to Part 2.



The intercom system

One of the features of this house was, due to its size, an intercom system.  In this case, it was a Nutone IMA-303 system that, while complete, happened to be broken.  I was, however, familiar with it from a previous house I had owned and was determined to get it going.  With a bit of help from eBay, I picked up a renewed Master Station and brought it back to life.

For the sake of context, if you're not familiar with a whole-house intercom system, they offer some cool features:

  • The obvious part: holding down the talk button on one of the stations and speaking into it will broadcast your voice throughout the house
  • A pretty cool feature where, if you have a doorbell with electronic pickups (think electric guitar), the sound of the doorbell will be broadcast to all stations
  • A speaker at the front door that you can listen to from any station by holding down the "outdoor listen" button, or speak to with the "outdoor talk" button
  • An AM/FM radio that will play throughout the house
  • Most importantly and relevant to this posting, a Phono jack that would allow you (at the time) to plug in a record player and torment everyone with your favorite Barry Manilow album
That last bullet is what really had me inspired.  I figured I could hook up an iPod or something and stream music from our iPhones when we're spending half of the day every Saturday cleaning.

Searching for the perfect streaming box

Before I get into the replacement of the Chromecast Audio, I really need to provide a little insight into what led me to use one in the first place.  That's going to require me to fast-forward from our initial purchase to about nine months ago when I finally got fed up with trying to do announcements with our Amazon Echos and the wonderful integration done on alexa_media_player.

The problem I kept running into was that trying to get all of our Echos to reliably do text-to-speech or even skills like weather announcements at the same time was proving impossible.  It was then that I remembered the intercom system and its Phono input--the perfect way to get announcements everywhere in the house, not just where the Echos are, and simultaneously.

Now, getting a media player and plugging it into the intercom system was conceptually a pretty trivial matter--there are any number of them on the market.  The problem is, the HAF is a major consideration here because the Master Station for the intercom system is in the breakfast room.  Basically, that means that it had to be invisible--i.e. actually be inside the Master Station.

After a bit of research, I stumbled across the Chromecast Audio.  Not only was it tiny, had no display nor speakers, but it also was directly supported by Home Assistant!  Bingo!

Except... This was March of this year and Google had discontinued the Chromecast Audio just three months prior.  Once again, eBay to the rescue.

I did run into a few problems getting the Chromecast Audio provisioned, and the stupid "pop" noise it makes when you change the volume was a constant annoyance; however, the integration into Home Assistant and Node-RED was really rock-solid.  A couple of months ago, they even released firmware that gave you the option of eliminating the pop, so I was mostly golden.

Some of the stuff I've implemented over the last eight months:
  • Use of the Amazon Polly text-to-speech service with the Brian voice (a proper British gentleman's voice)
  • A virtual grandfather clock that plays Winchester chimes every quarter-hour and the hourly chimes at the top of every hour
  • Morning announcements of travel time to my husband's office every 10 minutes (I work from home)
  • Evening announcements of his ETA once he leaves work
  • Reminders of when to feed the dogs and start cooking dinner
  • Warnings about the alarm being set and the garage door or drive gate being open
  • Warning about being in bed and the alarm not being set
  • Notifications when the house status changes (occupied/empty/work-from-home/evening/night)
  • Notifications related to the HVAC (it's too cold; turning on the heat and vice-versa)
  • Notifications about the washer or dryer starting and finishing
Basically, the sky's the limit for announcements and most of these have been really useful quality-of-life items.

All is not perfect in paradise

I will say that getting all of the above to really work well did present a challenge.  Node-RED doesn't provide any synchronization functions like locks or semaphores and calls to media_player.play_media are asynchronous.  This regularly resulted in announcements being interrupted by other announcements or the quarter-hour chimes of the grandfather clock.  Polling the status of the player was reasonably reliable; however, about once a week I'd run into a situation where the player would just hang due to a failed API call and I'd have to manually restart Node-RED.

While this wasn't really a deal-breaker, the other bigger issue was the lack of integration between the Chromecast Audio and our Apple ecosystem.  There really isn't a good way to do Airplay to a Google device from an iPhone.  I did come across AirConnect; however, even the author states that it's not a perfect solution because it's impossible to synchronize between the two protocols.  It was this issue that was really the straw that broke the camel's back.  One Saturday when we were working on the house, I had AirConnect running and every time I'd fast-forward past a song, all of the chimes and TTS that were queued-up from Home Assistant would all play (they couldn't play while I was streaming).  This would then cause AirConnect to fail and I'd have to fight to get it working again.  After a half-dozen instances of this, I had finally had enough.  It was time to replace the Chromecast Audio with something that was compatible with our ecosystem and not a black box.

I'll cover my false starts and experiences in Part 2.

Replacing a Chromecast Audio with a Raspberry Pi - Part 2 - Two Years Later

Well, life happened and the promised overview of how to set up a replacement for ChromeCast Audio never happened (obviously).  If, however, ...