Author Topic: Guide: Harmony Scene control on Vera via Arduino  (Read 670 times)

Offline Vanlon

  • Newbie
  • *
  • Posts: 14
  • Karma: +1/-0
Guide: Harmony Scene control on Vera via Arduino
« on: December 28, 2016, 09:41:14 am »
This is the solution I used to work around Harmony only working single lights and not controlling scenes on my Vera.  None of us would be here if we didn't like screwing around with stuff so we're going to throw a little Arduino in the mix.  What this does is captures a IR command sent by your Harmony to a fake device and sends it through the ethernet as an http request to your Vera to trigger the Scene. This guide is going to use an HK AVR114 for the commands, as it was the most readily available boat anchor in my storage closet.

Here's a list of what your going to need:
-Arduino Uno
-Arduino Ethernet Sheild
-Power Supply
-IR Receiver
-Some wires (I bought a starter kit when I did this)
-Arduino IDE installed on your computer, you can get it here

I'm not going to go in depth on installing and getting you up to speed on Arduino.  It's relatively simple, they designed it that way so kids could do it.  You're looking for a challenge anyway.  If you can't do it just search for the answers in the bottom of a bottle like you always do, or use Google for a change.

The first thing you'll need to do is attach your Uno to your ethernet shield, you just press them together.  Next I've attached a diagram of how to wire up your IR receiver, on your Arduino board.  I just use the wire that came with the kit, easy plug and play.  Three wires later you are done with the hardware portion.   I could have went with a Wi-Fi Sheild but I have a general distaste for it and everything in my house is hard wired.  Attached is a picture of the finished product.

Next for the code to upload to your Arduino board via the IDE, the mac address can stay as it is.  The board IP needs to match your network.
Code: [Select]
/*-----( Import needed libraries )-----*/

#include <IRremote.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:

// MAC address
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0x1E, 0x6D };
byte ip[] = { 192,168,1,177 };  //Static address of this board
byte server[] = { 192,168,1,150 };  // IP address of Vera
EthernetClient client;

int receiver = 2; // pin 1 or S of IR receiver to Arduino digital pin 2

IRrecv irrecv(receiver);           // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'

void setup()
{
  Ethernet.begin(mac, ip);
  delay(1000);
  irrecv.enableIRIn(); // Start the receiver

}

void loop()
{
  if (irrecv.decode(&results)) // have we received an IR signal?

  {
    translateIR();
    irrecv.resume(); // receive the next value
  } 
}

void translateIR() // takes action based on IR code received
{
  switch(results.value)
  {

  case 0x414e9966: //HK AVR144 Direction Up 
    client.connect(server, 3480);
    client.println("GET /data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=14 HTTP/1.1"); //Change the SceneNum to your Scene
    client.println();
    client.stop();
    break;

  case 0x414e59a6: //HK AVR144 Direction Down
    client.connect(server, 3480);
    client.println("GET /data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=4 HTTP/1.1"); //Change the SceneNum to your Scene
    client.println();
    client.stop();
    break;

  }

  delay(500);

}

Don't forget to change your Vera Address and the Scene numbers in the code to your corresponding scenes.

Once you have all that jammed into your Arduino board, go plug it in next to your Harmony and get out the ever intuitive companion app.

Add the device Harmon Kardon AVR-144 to your Activity (it's a receiver)
Link the Direction Down HK button to a button on your Harmony, I used the colored ones.
Link the Direction Up HK button to a button on your Harmony

Sync it and you're done!

That was easy, in case you want to some more messing around, add more scenes, create a arduino passcode lock, whatever here are some more IR button codes for the AVR-144

Code: [Select]
/*
 * HK AVR144 Buttons
 * 1 = 10ee11e
 * 2 = 10e11ee
 * 3 = 10e916e
 * 4 = 10e51ae
 * 5 = 10ed12e
 * 6 = 10e31ce
 * 7 = 10eb14e
 * 8 = 10e718e
 * 9 = 10eb946
 * 0 = 10e7986
 * Up = 414e9966
 * Down = 414e59a6
 * Left = 414e837c
 * Right = 414e43bc
 */

Works well, haven't had it glitch to date.  The only downside of this is that you need an activity running for it to work, but you're most likely watching TV with your remote anyway.


« Last Edit: December 31, 2016, 11:05:55 am by Vanlon »

Offline Vanlon

  • Newbie
  • *
  • Posts: 14
  • Karma: +1/-0
Re: Guide: Harmony Scene control on Vera via Arduino
« Reply #1 on: December 31, 2016, 03:19:42 pm »
Method 2

The next way to control your scenes via Harmony Hub is with a Raspberry Pi HA Bridge.  This method only works with remotes that have home control buttons on them. I don't think they sell the ones without anymore but in the case you have an older one, see method 1.

The guides already exist on the web so I will just list them.  The software is available from BWS Systems  It can control your Vera with both Amazon Echo and Harmony Hub.  The setup is here at github.

After you have this set up the HA Bridge will emulate a Phillips Hue Bridge.  A guide for that part of the setup is here.  You don't need to set up an account for it to find your scenes, they will automatically show up as lights.
« Last Edit: January 02, 2017, 04:29:26 pm by Vanlon »