OpenHAB2 REST API combined with Workflow

Hello,

To be able to control OpenHAB using widgets on my iOS devices i tried to make Workflow work. Since there is not a lot of documentation to work from i’m posting this.

Workflow
To start off add a “Text” action, this is used to post the body of the API request. I mostly use TOGGLE here, but if you want a dedicated ON or OFF button that is possible as well, just put the respective value in the “Text” action.

After that add the “URL” action, here you can define the url according to the following parameters:

http://hostname:port/rest/items/<item>

The last action you’ll have to add is the “Get Contents of URL” action and click on advanced, the following parameters are required:
Method: POST
Headers:
Key: Content-Type Text:text/plain
Key: Accept Text: application/json
Request Body: File
Click to add file and than choose “Magic Variable” which makes you able to select the “Text” from the first step. Now the Workflow should work

.

The drawback is that with these settings it is only possible to use the workflow widget when using my home wifi. I have been trying to make it work using a remote connection, but that has not worked out yet…

If you have any questions or remarks feel free to reply!

Cheers

3 Likes

thank you this is very useful !
but only on Wifi … or you have a magic why ?

Sadly, i have not been able to make it work outside of my Wifi. If you manage to figure it out i would like to hear te solution aswell!

Maybe it would work from outside if you provide a “VPN on Demand” Profile to your iOS Device.

Hint: Within an VPN Profile File it is possible to define adress ranges that will open a VPN Tunnel automatically.

VPN on Demand in German