Harmony Hub Control

From Domoticz
Jump to navigation Jump to search

This guide describes how to control your Harmony Hub with Domoticz.

Since version 1.1956 Domoticz has native support for the Harmony_Hub.

Goal

The goal is to control your Harmony Hub with Domoticz using Dummy switches.

Components used

  • Domoticz
  • C++ Application (HarmonyHubControl)
  • Harmony Hub

Prerequisites

  • Raspberry Pi running Debian Wheezy
  • Running Domoticz installation
  • Dummy switches activated in Domoticz
  • Harmony Hub

Needed information from Harmony Hub

  • IP address
  • Username (email address)
  • Password

Install additional software on your Pi

HarmonyHubControl

HarmonyHubControl is software written in C++ and is communicating with the Logitech servers to control your Harmony Hub.

Login to your Raspberry and issue:

git clone git://git.code.sf.net/p/harmonyhubcontrol/code harmonyhubcontrol-code

Rename the folder for easy using:

mv harmonyhubcontrol-code HarmonyHubControl

Go to the HarmonyHubControl folder:

cd HarmonyHubControl

Compile the application:

make HarmonyHubControl

Using the application

Testing the application

First you should issue this command:

./HarmonyHubControl

The output should be this:

Syntax:
HarmonyHubControl.exe [email] [password] [harmony_ip] [command (optional)]
   where command can be any of the following:
       list_activities
       get_current_activity_id
       start_activity [ID]
       issue_device_command [deviceId] [command]
       list_devices
       get_config

To get all your activities issue:

./HarmonyHubControl [email] [password] [harmony_ip] list_activities

You will get something like this:

LOGITECH WEB SERVICE LOGIN     : SUCCESS
HARMONY COMMUNICATION LOGIN    : SUCCESS
HARMONY COMMAND SUBMISSION     : SUCCESS
PARSE ACTIVITIES AND DEVICES   : SUCCESS

Activities Available via Harmony : 

Apple TV - 5766811
......

Launch one of the activities by:

./HarmonyHubControl [email] [password] [harmony_ip] start_activity [ID]

Using the application within Domoticz.

To use this application within Domoticz you have to add a Dummy switch to launch the application.
In this example we will only add two switches to control and one to switch off.

Dummy Switches

These names are only examples Add 3 dummy switches (on/off)
One called AV control (To switch off everything)
One called TV (to control the activity Watch TV)
One called DVD (to control the activity Watch DVD)
Get the ID's of the switched.

domoticz_main

Rename _domoticz_main (in /domoticz/scripts/) to domoticz_main if you haven't done it already.

mv _domoticz_main domoticz_main

Edit the file domoticz_main

sudo nano domoticz_main

Add this to that file:

//TV

if [ "$device_id" = "1" ] ; then
 if [ "$status" = "On" ] ; then
     exec `home/pi/HarmonyHubControl/HarmonyHubControl [email] [password] [harmony_ip] start_activity [ID]` &
 fi
fi

//DVD

if [ "$device_id" = "2" ] ; then
 if [ "$status" = "On" ] ; then
     exec `home/pi/HarmonyHubControl/HarmonyHubControl [email] [password] [harmony_ip] start_activity [ID]` &
 fi
fi

//AV control

if [ "$device_id" = "3" ] ; then
 if [ "$status" = "Off" ] ; then
     exec `home/pi/HarmonyHubControl/HarmonyHubControl [email] [password] [harmony_ip] start_activity -1` &
 fi
fi

Make domoticz_main executable:

sudo chmod +x domoticz_main

Sub/Slave Devices

To control the switches we should make use of sub/slave.
When pressing the TV switch the AV control will switch on also.
When pressing the AV control switch to off the TV and DVD switches will also go off and everything will be switch off with the Harmony Hub.

Press edit on the AV control switch.
Add TV and DVD as Sub/Slave Devices on the Edit page.

Now press TV and see whats happening, the activity watch TV should start and the switch AV control should did come on.
When pressing the AV control Off all the activities should be stopt and the switch TV should go Off.

Discuss

To discuss this, please use this forum topic