Use a raspberry pi and a Harmony remote to send network commands to every device - AVS Forum | Home Theater Discussions And Reviews
Forum Jump: 
 3Likes
  • 1 Post By cjacobs
  • 1 Post By cjacobs
  • 1 Post By residentsystems
 
Thread Tools
post #1 of 6 Old 02-06-2020, 07:45 PM - Thread Starter
Member
 
cjacobs's Avatar
 
Join Date: Oct 2019
Location: Indianapolis, Indiana
Posts: 107
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
Quoted: 43 Post(s)
Liked: 115
Use a raspberry pi and a Harmony remote to send network commands to every device

Hi Everyone.
I’ve always loved the Harmony remotes for feel and functionality, but they can be frustrating with the things they CAN'T do and should
I’ve been reading avsforums for a while and spent a lot of time googling if anyone had developed a good DIY remote solution to get really good integrated control that worked without IR commands.

Unfortunately, I have never found exactly what I wanted – to have control of devices over the network (not IR) from a remote like the Harmony that I can program myself.
There are a couple of companies that have interesting looking stuff, but they only sell to certified installer people and much more expensive than Harmony
so I thought on it a while and came up with a “Hack” that is working better than I had ever hoped, so I thought I’d share in my first post as an avsforums member.

I’m posting on here for any others out there like me who want to do this and share my learnings – not for the faint of heart right now.
I’m also looking for anyone who is a better programmer (or one with more time) than me to help me “simplify” the software base for other people to use and add to the capability.

So what did I do? I had a Harmony Elite w/Hub. Since Harmony barely supports anything over the network (why Logitech, IR Sucks!), I started looking at devices it could control and wondering if I could spoof it and come up with a way to know what activities and buttons were being pressed. Once I figured out how to do that, it was a should be a simple matter of running whatever network command to any device that I wanted. I found the Roku ECP (External Control Protocol) and determined that Harmony uses it for the network commands. However, Harmony needs to “find” the Roku on your network before it will work. It uses something called SSDP (Simple Service Discovery Protocol) in order to discover the Roku – It then goes and gets a bunch of config data from the Roku over normal HTTP web calls. I figured if I could make another computer answer the same way as the Roku, I could trick the Harmony into sending it Roku commands.

Step 1 (Nov ‘18) - I went out and bought a Raspberry Pi (~$60), you can probably do this with a Pi Zero W ($20) as well, but I haven’t tested it. I also considered putting it on my HT / Gaming PC, but didn’t want it running all the time. I then loaded a free visual development environment (NODE-RED) that is specially designed for easily tying together IOT (Internet of Things) and started playing with coding up SSDP and the associated configuration pages that a Roku reports via the discovery process. I copied these pages from my actual Roku and then modified things like IP address, Name, etc. Bought a network sniffer so I could watch the messages being sent with WireShark and make sure mine matched. I got it all working, and now the myHarmony desktop software and app will discover the Raspberry PI, but thinks it’s a Roku TV. Even the Roku App on my phone thinks the Raspberry PI is a Roku TV!
Step 2. (Dec ‘18) I then set up a HTTP messaging on the rPI to be able to receive the REST commands sent from the Harmony Hub and do something with them.
Step 3. (Dec ’18) I made a custom activity on the Harmony remote, selecting the “Roku TV” as the only device so it prepopulated most of the buttons with Roku TV network commands.. Push Button –> Command received a message in rPI.
Step 4. (Dec ’18) Now test that I can pass on the command to another device. So I open a telnet port to my Pioneer receiver within NODE-RED and connect it to send the receiver’s volume up command whenever I receive a message from the harmony hub “Volume Up” command to the “Roku”.
Step 5. (Dec ’18) Now I think I have something I can work with!. The next thought was that with long and short presses on the harmony with the version of remote with light and plug control, I would need about 68 different commands to hard coded keys, plus any touchscreen commands I might want to add, but the Harmony interface to the Roku TV only has 20 something unique commands that can be assigned to buttons. So then I came up with a scheme that for most of the typical buttons (‘Play, Reverse, Forward, etc.) I would program the buttons as Harmony defaults them, but for “additional” and custom keys you need to program a two step macro and then decode on the rPI side.
Step 6. (Jan ’19) Next I discovered that someone had already written a NODE-RED Harmony WebSocket driver, which I used to identify when I changed activity on the remote – Got this easily working. So now I can make a list of the startup and shutdown things that I want to do with each activity in the rPI and not the Harmony software.
Step 7. (Jan/Feb ’19) Since I can read the activities and buttons, and can send commands on telnet as well as HTTP, and can also send IR commands and activities back to the Harmony so other apps can easily control, The only thing left in my house that I’m controlling over IR is the xBox when I watch BluRays. I’ve convinced myself that I can write a central controller that FINALLY ties all my stuff together.
So I coded it up for all my devices, and have been running it in my house for about 9 months, trouble free. I no longer get weird harmony things – especially with devices that use toggle or cycle commands with IR – I just send them direct network commands. I rarely get any weird delays over the wifi in my house.
Step 8. (Feb ’19 – Aug ’19) – Enjoy fruits of previous labor for 6 months. Raspberry PI just sits in a cabinet, unseen, doing its thing. Occasional debug of glitches reported by family, add new features, etc.
Step 9. (Sept ’19) A house move combined with new components caused me to begin re-architecture – Original code is very specific to my old system, and doesn’t seem as easy to share or maintain as I’d like. So I thought about it and set up an architecture where devices, activities and maps are all read in from config files and interfaces are generic. I came up with simple JSON text files that describe the commands to each of my devices, as well as their interfaces and feedbacks (1 file per device type), another to describe each activity (1 for each activity) and a file to map your physical buttons to the Roku commands.
Step 10. (October ’19) Write my various activity and device files, test new system. Document my system a little and post!

I have a pretty complex system with multiple Harmony’s, multiple TVs, a Projector, Multiple receivers, Multiple Roku’s and multiple TIVOs, as well as a HTPC, Video Matrix, Screen Combiner, Motorized Mask System, Network Controlled LED strips, Network Relays, Network Power Supply, etc. I can control every single one of them from the Harmony. I can also send/receive data to an iPad/iPhone via programs like iRule. I also wrote an interface to a Wink Hub* and was able to control it and I have high confidence that I can control anything that I can get a hold of the API for.

How well does it work?
PROs
  • Activities launch much faster because you don’t have to put in the long delays for most of the devices.
  • No noticeable speed difference pressing remote buttons.
  • Ability to direct control things that Harmony doesn’t let you do.
  • No annoying times when something doesn’t configure correctly because an IR command got missed – Network Commands are super reliable in comparison
  • Ability to do things like set my Volume to a specific number every time I turn on system, rather than be whatever it was before. Ability to control specific Surround Sound commands, projector calibration, etc.
CONS
  • Some touchscreen functions likefavorites aren’t currently working. I didn’t use those anyway, so haven't worked on it too much
  • Harmony or Roku could change something and break the interface unexpectedly.

There are still a ton of things that one can add to this.
  1. Automate the Harmony side of defining the buttons – it’s annoying that they don’t let you copy an activity – but it’s a one time setup.
  2. Update the Harmony WebSocket – there are a few things I had to hard code to match my system. I know it could be auto detected, but too much work for my purposes.
  3. Fix package.json dependencies on GitHub with all the dependencies correctly defined for easy download for other users
  4. Break the main code into more libraries that are separate and can be updated individually.
  5. Bug fixes and interface extensions (I know that some devices use a “unique” protocol (like Pioneer ISCP for example) on top of telnet. I’ve only defined what I need for my devices.
  6. Other interfaces, like Bluetooth, RS-232 and Zigby/Zwave
  7. Figure out how to get favorites working.
  8. Figure out the feedbacks for better interface to iRule type of systems
  9. Auto configure multiple websockets.
  10. All IP addresses need to be written down in config files and then controlled in your router to not change – could make more dynamic – too much work, little benefit to me.
  11. Advanced Internal functions? - One example is that I wrote a function that emulates lens memory for my projector
  12. Add Alexa, Google support
I've attached a logical diagram of the system that I made, along with a few screen shots of NODE-RED in action, and a few screen shots of my Harmony config


The source code is in 2 repositories at


https://github.com/craigsjacobs/RokuSSDP
https://github.com/craigsjacobs/RokuEmulator
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	102
Size:	121.6 KB
ID:	2681538   Click image for larger version

Name:	Capture2.PNG
Views:	104
Size:	39.1 KB
ID:	2681540   Click image for larger version

Name:	Capture3.PNG
Views:	97
Size:	150.3 KB
ID:	2681542   Click image for larger version

Name:	Capture4.PNG
Views:	89
Size:	113.2 KB
ID:	2681544   Click image for larger version

Name:	Capture5.PNG
Views:	76
Size:	172.1 KB
ID:	2681546  

Click image for larger version

Name:	Capture6.PNG
Views:	88
Size:	219.7 KB
ID:	2681548   Click image for larger version

Name:	Capture7.PNG
Views:	91
Size:	312.6 KB
ID:	2681550   Click image for larger version

Name:	Capture8.PNG
Views:	89
Size:	68.1 KB
ID:	2681552  
LVS likes this.

Last edited by cjacobs; 02-06-2020 at 07:52 PM.
cjacobs is offline  
Sponsored Links
Advertisement
 
post #2 of 6 Old 02-06-2020, 09:29 PM - Thread Starter
Member
 
cjacobs's Avatar
 
Join Date: Oct 2019
Location: Indianapolis, Indiana
Posts: 107
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
Quoted: 43 Post(s)
Liked: 115
Screen shot of Roku app. The PI is the harmony interface. It shows up 2x because I have it wired and wireless at the moment. If I turn one or the other off, it only shows up once. Notice I changed the last digit of the Serial number from one of my other Roku’s






Sent from my iPhone using Tapatalk
LVS likes this.

My Build - The "CRAVE" Theatre
Custom Home Automation - RaspberryPI Harmony Hacker
cjacobs is offline  
post #3 of 6 Old 02-13-2020, 12:42 AM
Member
 
Join Date: Dec 2019
Posts: 122
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 91 Post(s)
Liked: 48
Very cool.
cjacobs likes this.
residentsystems is online now  
Sponsored Links
Advertisement
 
post #4 of 6 Old 02-18-2020, 08:54 AM
Member
 
risk1994's Avatar
 
Join Date: Sep 2006
Posts: 101
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 21 Post(s)
Liked: 15
I guess there's more than one way to skin a cat. I too wanted to use my RPi to capture remote control entries and dish out network commands. (see my thread here)

I didnt have a Harmony, just a plain old Universal IR. I already had a PI living right in the firing line of my IR blaster where all my equipment was....I wanted to give it another job and have the ability for my remote to send out network commands (I too hate IR, I much prefer network commands)

I used a FLIRC device on the PI and Mapped remote control buttons to execute network commands for the Roku as well as some HA stuff like lights. It works, but its not responsive enough. Sounds like your solution might be snappier, if more difficult to execute.

After all this hassle I think I'd really like to skip all the middle man stuff and just have a remote that can send network commands directly, like those URC's, but they are SO expensive and need software you cant get.

In a perfect world ALL my devices would have the ability to respond to network commands like the ROKU (TV, BluRay, everything) if that were the case I might be more inclined to put in the effort or expense.

I salute you in your effort...Its a really nifty solution you came up with there. Sounds really cool.
risk1994 is offline  
post #5 of 6 Old 02-18-2020, 09:21 AM - Thread Starter
Member
 
cjacobs's Avatar
 
Join Date: Oct 2019
Location: Indianapolis, Indiana
Posts: 107
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
Quoted: 43 Post(s)
Liked: 115
Thanks,


I would love the URC type solution, but I refuse to use the companies that only sell to “certified” professionals. I don’t want to be calling someone every time I want to make a modification. And as you say, pretty expensive. For me, most of the “hard” work was figuring out how to get the SSDP working and then figuring out how to best arrange my system to get to something flexible and easy to maintain. Also, I had to teach myself javascript and Node Red as I went.


Sent from my iPhone using Tapatalk

My Build - The "CRAVE" Theatre
Custom Home Automation - RaspberryPI Harmony Hacker
cjacobs is offline  
post #6 of 6 Old 06-21-2020, 07:23 PM - Thread Starter
Member
 
cjacobs's Avatar
 
Join Date: Oct 2019
Location: Indianapolis, Indiana
Posts: 107
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
Quoted: 43 Post(s)
Liked: 115
I also just updated the raspberry pi system so that it now interfaces to HEOS on my Marantz amplifier. So now I can use iRule, or my Harmony remote to connect to my Marantz receiver, as well as my whole house amplifier (HTD) and tell the Marantz Zone 2&3 to stream Pandora and Sirius online to any room. I have iRule setup to read my HEOS favorite lists and allow me to select a channel and get all of its graphics. Also have a page on it that looks like pandora app and shows album art, time, etc.

We can now all use our iphones to play music in the room we are in.

My Build - The "CRAVE" Theatre
Custom Home Automation - RaspberryPI Harmony Hacker
cjacobs is offline  
Sponsored Links
Advertisement
 
Reply Remote Control Area

Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off