How do you control "strings" of the Harmonyhub binding via the REST API?

Hello, i hope anyone can help me.

I would like to control my PS4 or my TV with S.E.P.I.A. and do this in openhab via the Harmonyhub.
The developer and I are trying to find out how S.E.P.I.A. that can change strings.

Now my question, how do you control the strings that the Harmony Binding creates using the REST API?

Here are my current actions that I have created:
{“link”:"[",“state”:“NULL”,“stateDescription”:{“pattern”:"%s",“readOnly”:false,"options":{“value”:“PowerOff”,“label”:“PowerOff”},{“value”:"Fernsehen gucken",“label”:“Fernsehen gucken”},{“value”:“Film über Fernseher gucken”,“label”:“Film über Fernseher gucken”},{“value”:“PS3 spielen”,“label”:“PS3 spielen”},{“value”:“PS4 spielen”,“label”:“PS4 spielen”},{“value”:“SHIELD TV spielen”,“label”:“SHIELD TV spielen”},{“value”:“Film auf PS3 gucken”,“label”:“Film auf PS3 gucken”},{“value”:“Film auf SHIELD TV gucken”,“label”:“Film auf SHIELD TV gucken”},{“value”:“Film auf PS4 gucken”,“label”:“Film auf PS4 gucken”}]},“commandDescription”:{“commandOptions”:[{“command”:“PowerOff”,“label”:“PowerOff”},{“command”:“Fernsehen gucken”,“label”:“Fernsehen gucken”},{“command”:“Film über Fernseher gucken”,“label”:“Film über Fernseher gucken”},{“command”:“PS3 spielen”,“label”:“PS3 spielen”},{“command”:“PS4 spielen”,“label”:“PS4 spielen”},{“command”:“SHIELD TV spielen”,“label”:“SHIELD TV spielen”},{“command”:“Film auf PS3 gucken”,“label”:“Film auf PS3 gucken”},{“command”:“Film auf SHIELD TV gucken”,“label”:“Film auf SHIELD TV gucken”},{“command”:“Film auf PS4 gucken”,“label”:“Film auf PS4 gucken”}]},“editable”:true,“type”:“String”,“name”:“HarmonyHub_”,“label”:“Fernbedienung”,“tags”:[“sepia-room\u003dlivingroom”,“sepia-state-type\u003d”,“sepia-type\u003dtv”,“sepia-name\u003dHarmonyFB”],“groupNames”:[]}

How can I now change the status via the REST API so that the actions are carried out?
For example, playing on PS4, the PS4 and the soundbar would also be switched on.

I hope my englisch is not to bad.

Thanks you for your help

1 Like

Have you installed the restdocs UI addon? That lets you try to figure out how to use the API. Only you know the details of your system setup.


If I understand you correct, you want to control HarmonyHub actions via a REST API?

Then you should do a POST request like this:

Depending on your API you could use e.g. curl (or import it):

curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "PS4 spielen" "http://yourIPofOpenhab:8080/rest/items/HarmonyHub_"

You could try out by using “Openhab REST API” or e.g. Postman or Insomnia or “Advanced REST Client” or any other REST Client you like…

First you could try Openhab REST API: go to POST /items/{itemname}:

Then click “Try it out!”.
P.S: I’ve detected your Sepia Topic on Github.

This will only run with openHAB if you also create a .sitemap file with the following content:

sitemap test label="My home automation" {
    Frame label="Test" {
       Text label="HarmonyHub Actions" icon="receiver" {
	     Frame label="Harmony Hub" icon="receiver" {
		   Text item=HarmonyHub_ icon="receiver"
		   Switch item=HarmonyHub_ mappings=[PowerOff="AUS", "Fernsehen gucken"="Fernsehen gucken", "Film über Fernseher gucken"="Film über Fernseher gucken"]
		   Switch item=HarmonyHub_ mappings=["PS3 spielen"="PS3 spielen", "PS4 spielen"="PS4 spielen", "SHIELD TV spielen"="SHIELD TV spielen"]
		   Switch item=HarmonyHub_ mappings=["Film auf PS3 gucken"="Film auf PS3 gucken"]
		   Switch item=HarmonyHub_ mappings=["Film auf SHIELD TV gucken"="Film auf SHIELD TV gucken"]
		   Switch item=HarmonyHub_ mappings=["Film auf PS4 gucken"="Film auf PS4 gucken"]

This will map the corresponding strings.

Then you do not need to use the REST API.

Please first read how to create sitemaps.


Thanks for the quick responses. I will test and report it.

SEPIA is using exactly this HTTP POST request to push the state to the Harmony but so far we had no luck with it. Could you explain a bit why “This will only run with openHAB if you also create a .sitemap”?

What I understand from the docs section about sitemaps it is used to create UI elements that will trigger the actions right?

SEPIA is using the REST API to send the command via voice, thats why we need to figure it out :slight_smile:

If you want to use the action strings for HarmonyHub with openHAB you have many options.

One is the REST API, see command above.

If you want to control it (with openHAB only) via PaperUI (–>Control), BasicUI or ClassicUI (or iOS APP or Android APP) , you have to create a .sitemap file where you can map the “action strings” (like e.g. “PS4 spielen”) to items.

Or you could use DSL-Rules.

REST command and .sitemap you will find both above.

All Harmony actions are controlled with thing channel “currentActivity”. And in your example you have linked item HarmonyHub_ to this channel. That is correct.

As far as I understood @Smarthome-Creator the Paper-UI buttons are working fine, all the Harmony devices can be controlled. The question is only about the precise REST API command.

If SEPIA was set up correctly it should send exactly that HTTP POST request:

 curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "PS4 spielen" "http://yourIPofOpenhab:8080/rest/items/HarmonyHub_"

But in our first tests it had no effect (as mentioned above). Maybe we need to double-check the voice command.

Just to make sure. Basically the REST API command is the same as e.g. controlling a lamp?

curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "70" "http://yourIPofOpenhab:8080/rest/items/HueWhiteLamp1_Brightness"

Yes, it is.

You can try out with openHAB Rest API, exactly like in my screenshot above. If the action then is triggered, then it is a not a problem of openHAB.

Look in openHAB’s events.log and you should see commands from your POST
If there was a problem, that should show up in openhab.log

I found the “problem” myself.
It was a logical mistake on the part of the user.