I don’t have cable, but instead I have a PC hooked up to my television and receiver. I’ve recently embarked on remote controlling my setup better. It was an adventure, to say the least.
For your pleasure and/or our adventures with technology, let me explain what I did.
So, there’s a number of devices in our living room:
- A PC, for watching Netflix, Youtube, and for gaming.
- A television (with no cable TV), attached to the PC.
- A Playstation 3, for some console gaming and playing Blu-rays.
- A receiver hooked up to the PC with 5.1 surround attached.
- A Chromecast audio, to listen to music from a laptop or smartphone.
Hooking up a computer to a TV works pretty well, but it means having a lot of remotes:
- A TV remote
- A remote for the receiver (which broke)
- A wireless keyboard
- A wireless mouse
- A phone or laptop to control chromecast
- A Playstation controller to control the PS3
The problem was, when I wanted to turn on Netflix, I had to walk to the receiver to turn it on, then turn on the PC, then walk to the couch. Then: turn on the TV with its remote, turn on the wireless keyboard and mouse, log in to Windows, then double-click the Netflix shortcut. After that I often found myself getting back up, walking to the receiver, and adjusting the volume. Groan.
A similar problem occurred with the Chromecast. Put the laptop aside, walk to the receiver, turn it on, switch to the right channel, walk balk, turn on Google Music on the Chromecast. And again, chances are I needed to walk back to adjust the volume. Sigh
Time to fix all these problems.
Step 1 Logitech Harmony Hub
I had a Logitech Harmony remote before, but only the basic model. This is a universal remote but lacks the ability for programming sequences of commands and controlling multiple devices at once. The Harmony Hub and Harmoney 950 remotes don’t have these limitations.
The Logitech Harmony is supported by a large database of devices, and if that isn’t enough, you can add custom command by teaching the Harmony commands from the original remotes.
However, PCs don’t have a remote. There are two ways to get around this:
- Connect to the PC using Bluetooth. Basically, your Harmony pretends to be a bluetooth keyboard.
- Buy an IR remote for your PC. This also acts like a PC keyboard, but controlled through a remote.
I chose option two.
Step 2: Flirc
Flirc offers several products for remote controlling PCs. The basic IR-USB device is a tiny plug similar to a Wifi or Bluetooth dongle. You shove it into a USB port, and you’re set. It acts like a customizable keyboard.
By installing the Flirc UI software, you can fully customize which IR signals trigger which keys. Like a Harmony hub, you can teach it IR commands from other remotes.
Aside from this, Flirc is in the Logitech device database, which already has a lot of basic commands for the Harmony Hub.
Step 3: AutoHotkey
Now I had a universal remote and an IR keyboard, but now what?
Easy: link keyboard key combinations to actions.
AutHotkey is a freeware application that helps map keys to commands on Windows. So that key combination you set up in Flirc can be used to start a browser or an application.
With that, I was almost there. The Harmony remote could control the various devices, including the Flirc IR remote. Through Flirc, the Harmony remote could send keyboard commands to the PC, which AutoHotkey translated to actions (like starting Netflix and Chrome).
That was the theory anyway…
Hurdle 1: two students but no teacher
You can teach the Harmony remote any command you want, and you can teach Flirc any command as well. Awesome! But wait, you can teach them any command from an IR signal. Drat, where was I going to get a custom IR signal. The existing remotes were a bad idea, because they already controlled my existing devices.
Luckily, I hoard old cables, plugs, and other tech stuff like the apocalypse is coming. A short search turned up: an old PS2 remote!
It worked like a charm. I taught Flirc the old PS2 commands (1,2,3,4,…0) and mapped them to ‘ctrl+alt+win+1’, ‘ctrl+alt+win+2’, etc. Then I taught the harmony remote the same PS2 1,2,3,.. commands. Finally, I mapped the ‘ctrl+alt+win+1′,’ctrl+alt+win+2’, etc. commands in AutoHotkey. Note that I used ctrl+alt+win to avoid problems with regular keyboard actions on the PC, or problems with gaming.
Hurdle 2: Starting is not switching
Using AutoHotkey, I could start applications. I added several commands to my remote, calling them ‘Netflix’, ‘Youtube’, and ‘Steam’. Starting those with a command is easy enough.
However, clicking Netflix, then Youtube, then Steam, would start all three. Hurdle number two: how to stop apps. Enter Powershell.
Now, I’m not a Powershell programmer, and I’d much rather use Linux Bash scripting or something similar. However, because of gaming, I’m using Windows, and I suspected using Bash on Windows would be more hassle to get things done than using Powershell.
I stand by my decision, in hindsight. In Powershell, you can quickly search existing processes and terminate them by name. I’ll not bore you with the details, but simply killing an application like Chrome will cause error messages on restart, so that required a bit more magic.
Now my setup was working pretty well. I had Netflix, Youtube, Steam, and I could switch between them. I put a link to the code at the bottom of this post, should you want to know more about it.
Hurdle 3: Fullscreen
One extra requirement was to set up the Dutch public broadcast channels for my mother-in-law. She babysits regularly, and likes to watch the news, and she likes to listen to the classical radio channel. Luckily, all of those are available as livestreams (for example, NPO1).
Unfortunately, getting those streams playing in fullscreen is not so easy. First you have to actually start the stream, then you have to click the fullscreen button. Both of which are trivial actions with a mouse, but how do you do that in Powershell, or from a remote? You can’t.
Luckily, I had an alternative, in the form of Selenium. Selenium is a piece of software I use a lot for automated testing at my day job. It allows you to remotely control a browser for testing purposes from code.
With some fiddling, I managed to create a simple server that can click buttons to start playing something and set things to fullscreen. I made it a bit more advanced, so it can be send commands to quickly switch from one web page to another without having to restart. I then changed my Powershell scripts to use this application.
Icing on the cake
The way I’m using the remote, it turns out I don’t need the regular up, down, left, and right commands.
Instead I decided to use AutoHotkey to control the mouse cursor instead. There’s an example script for that on the site. That required some more tweaking to work from the remote, because the original script was too complicated, but I managed to make it work. Yeah.
The working result
I’m very happy. I can now turn on my TV, receiver, and PC with the click of a button, then adjust the sound with the remote, as well as switch to different websites. I can even do it from an app. It’s pretty awesome for a day of tinkering.
Should you want to use the code for your own projects, feel free.