Code to control harmony via a smartapp?


(Ryan Detzel) #1

I can’t find any examples of this. I want to create a virtual switch that when used turns the tv off and sonos on. The sonos part I have working but I don’t know what capabilities to include to trigger commands on the harmony. What device is this? Is it just a switch?


(Dan) #2

The latest version of the Harmony Connect smartapp will prompt you to create virtual switch devices for any activity that it finds for the Harmony. If you do that, then the capability will be switch. So I guess you can switch that virtual switch off with the virtual switch that you’re creating.

The only issue that I see, is that, as far as I understand it, the Harmony virtual switches will turn a specific activity on or off. I.e. if you have a virtual switch, say “Watch TV”, then turning that on, will start the “Watch TV” activity on the Harmony, and turning it off will be equivalent to hitting the off button on the remote / app. It will turn off the components associated with the “Watch TV” activity. So turning off the switch is not a generic “end any activity”.


(Joshua Lyon (SharpTools.io Dashboard)) #3

capability.mediaController

Attributes:

  • activities
  • currentActivity

Commands:

  • startActivity(string)
    • Use the ID of an activity from the activities attribute as a string to start the activity
  • getAllActivities()
    • Refreshes the activities attribute
  • getCurrentActivity()
    • Refreshes the currentActivity

The Harmony also has:

  • activityOff()
    • stop the current activity
  • allOff()
    • Turn off everything

(Ryan) #4

I used this write up. Working flawless. I renamed the devices in ST so there’s natural language (i.e. The Television for Watch TV so I can say 'Alexa, turn on the Television"). Then I wrote a simple Rule Machine rule to shut off my sonos when The Television switch turns on. Works like a charm and the write up is very well done and easy to follow.


(Justin) #5

I am having a terrible time with ST connecting and finding my Logitech Hubs.

I saw that users on the forum, in particular @juano2310, changed the code so I decided to go into the repository and grab this code instead.

When I try to install the app and before I get can to the ‘Logi’ login screen I receive the following error message:

{"error" : "invalid_request", "error_description" : "Missing or invalid argument."}

Perhaps it is the method in which I am installing the app?

Anyway, anyone who has had issues with ST finding logitech hubs, please chime back as I am stumped.


(Juan Risso) #6

Hi Justin,
The code connects to the cloud so it requires a clintId and ClientSecret that is only available to partners of Logitech so coping the code won’t help :frowning:
I recommend to make sure that the hub is on the last firmware available since for some reason if there is an update pendent it won’t be available on the cloud and we can not find it from SmartThings.


(Justin) #7

I assume you mean the Logitech hub?


(Juan Risso) #8

Yes, correct, the Logitech Harmony Hub :slight_smile: