By Jason Snell
May 28, 2020 4:43 PM PT
Last updated July 27, 2020
Automating my iPod Hi-Fi’s volume control… because I can
“Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should,” warned Ian Malcolm in “Jurassic Park.” I can relate. Sometimes I work to solve a problem using technology not because it’s necessary, but because it’s fun.
Fact one: I work at my desk, listening to music. I generally don’t like to use headphones because they can make my ears sore after a while, and they cut me off from the sounds of my house and neighborhood. So when I was setting up my home office, I wanted a nice set of speakers, and I realized that I still had my old iPod Hi-Fi sitting around.
The iPod Hi-Fi, a compact iPod speaker system Apple built to try and outclass the popular Bose SoundDock has ended up as the butt of many jokes. It was a flop. But you know what? For all its faults, it was a pretty good speaker. I took it with me to family camp up in the mountains for many years. And while I don’t listen to music on an iPod anymore, the iPod Hi-Fi has something that the HomePod lacks: an auxiliary audio-in jack. So my music plays, every day, through an iPod Hi-Fi attached to my iMac Pro via a headphone cable.
Fact two: The problem I discovered upon hooking my iPod Hi-Fi up to my iMac via the auxiliary input was that when I shut the iMac down at the end of the day, the iPod Hi-Fi emitted an annoying buzzing sound. I also didn’t like the idea of leaving the thing powered in overnight when I wasn’t using it, so I plugged the iPod Hi-Fi into my switching power strip that senses the power draw on a single, master outlet and uses that to switch off a few other outlets. Now when my iMac shut down, my iPod Hi-Fi powered down too. Buzz gone, power draw solved.
Fact three: For some reason, Apple designed the iPod Hi-Fi’s volume to reset after a power cycle. I can have the iPod Hi-Fi set to the perfect volume for my use during the day, but the next morning it will always be several volume steps too low. This requires me to keep an Apple Remote on my desk and, when I start listening to music, I have to click it four or five times to get it to be an acceptable volume.
Fact four: Having to click a stupid Apple Remote every day when I want to listen to music is not much of an imposition in the grand scheme of things. And yet… surely, surely there was some way for me to eliminate this need. I was so preoccupied with whether or not I could, I didn’t stop to think if I should.
Automating the infrared
Here was the plan: Find a device that could be controlled by my Mac and press the volume-up button on my iPod Hi-Fi every morning when I started up the computer. A search for USB-based infrared blasters turned up empty, so I looked for networked ones instead. I settled on the Global Caché WF2IR, a little device that connects to your local Wi-Fi network and can emit infrared signals on command.
This week I took delivery of the WF2IR and discovered that it’s limited to some very specific Wi-Fi variants and frequencies, and is completely incompatible with my Eero Wi-Fi routers. Fortunately, I still have an AirPort Express in a bin, so I pressed it into service and managed to get the WF2IR to connect to the Express.
While the WF2IR can be controlled via a TCP connection, Global Caché’s setup utilities only run in Windows. Fortunately, a fellow named Martijn Rijnbeek has written Mac equivalents for cheap on the Mac App Store. I downloaded several of them, intercepted the Apple Remote’s infrared code, and figured out the proper command to send to the WF2IR to get the volume to increase.
Fantastic. The next step was to scour the Global Caché website to find the right PDF that detailed how you control the thing remotely. Once I had that, I needed to figure out how to make a TCP connection to a specific port on the WF2IR so I could issue test commands.
That command is netcat, and after some trial and error I discovered the command I needed to issue was
nc -c 192.168.1.75 4998 — at which point I was “in” the WF2IR and could send it the command to press volume up on my iPod Hi-Fi.
Now the next trick. I needed to figure out how to script this entire connection, so that I could create a simple AppleScript app and add it to my login items. But how do you combine using the
nc command to connect and entering a command into the remote device into a single line?
After some Googling, I discovered that the answer was to pipe the unix
printf command through netcat, like so:
printf "the-commandrn" | nc -c 192.168.1.75 4998
The WF2IR is very finicky about carriage returns, so I have to send my command with
rn and use the
-c flag in
nc to inform it I’ll be using carriage returns. It worked! I ran an infrared emitter under the grille of the iPod Hi-Fi and down under my desk into the WFIR box.
My next step was just to embed this script in AppleScript, and throw in a
repeat statement and a one-second delay, so that my script presses Volume Up seven times:
try — Check to see if the WF2IR is responding yet, — because it powers on with the iPod Hi-Fi! do shell script "printf "get_NET,0:1\r\n" | nc -c 192.168.1.75 4998" on error — If there was no response to the previous check, wait a minute delay 60 end try repeat with i from 1 to 7 —repeat 7 times delay 1 do shell script ("printf "the-command\r\n" | nc -c 192.168.1.75 4998") end repeat
I saved the script as an application, added it to my Login Items, and for the last two days I haven’t had to touch that Apple Remote once.
At least dinosaurs didn’t run amok
I spent $115 on an WFIR and it’s now consuming power, as is my old AirPort Express! And if the AirPort Express dies I will need to buy a new access point just to keep the WFIR running. This seems dumb and wasteful.
I should probably return the WFIR and get the IP2IR, which is literally the same product but with an Ethernet port. Right? That would be better. I think that would definitely be better.
So in the end, I have spent a lot of time and a little bit of money to create a button pusher. (Believe it or not, I did look into a “button pusher” that could just tap the capacitive volume button on the top of the iPod Hi-Fi a few times. It seemed less elegant even than this.)
Was this project necessary? Absolutely not. And yet it was fun to put together. And I can’t emphasize this enough, I don’t have to click the Volume Up button on that little Apple Remote several times every morning. It’s the little things, sometimes, that bring pleasure to life.
If you appreciate articles like this one, support us by becoming a Six Colors subscriber. Subscribers get access to an exclusive podcast, members-only stories, and a special community.