Tasker and MyOpenHAB REST API

Has anyone successfully used the REST API with the new MyOpenHAB could service? I’m trying to use Tasker to trigger an item via the cloud service and I’m not having any luck. So far I’ve tried:

https://[username]:[password]@myopenhab.org
path = /rest/items/FrontPorchLight

and

https://myopenhab.org, same path

I can’t seem to figure this one out. Any help is appreciated.

Thanks!

I got this working with the following:

https://my.email%40email.com:my-password@home.myopenhab.org/rest/items

The trick was percent encoding the ‘@’ in my email address / username.

1 Like

Did you also try a POST to toggle a light for example?
I use Postman to send a HTTP POST request but I only get this back without an update of my item:

{
"link": "https://myopenhab.org/rest/items/Z1_OO1_Heater_State",
"state": "OFF",
"stateDescription": {
"pattern": "%s",
"readOnly": false,
"options": []
},
"type": "Switch",
"name": "Z1_OO1_Heater_State",
"label": "Bed light",
"category": "switch",
"tags": [
"Switchable"
],
"groupNames": []
}


When I send the same plain\text command “ON” to the local url “http://IP_ADDRESS:8080/rest/items/Z1_OO1_Heater_State” this works perfectly. Can someone tell me why and how to fix it?
@rlkoshak , I have a feeling that you could help me on this matter. If you have time, it would really be helpful!

You have to include basic auth in your URL. When going through myopenhab.org you must provide your username and password or else it doesn’t even have a way to know what account you are trying to connect to let alone whether you are authorized.

Look at michaeldavie’s example URL above.

The general format is https://username:password@myopenhab.org/

I did use this basic auth as you mentioned. But the response with is just:

{
"link": "https://myopenhab.org/rest/items/Z1_OO1_Heater_State",
"state": "OFF",
"stateDescription": {
"pattern": "%s",
"readOnly": false,
"options": []
},
"type": "Switch",
"name": "Z1_OO1_Heater_State",
"label": "Bed light",
"category": "switch",
"tags": [
"Switchable"
],
"groupNames": []
}


My content-type is text/plain and the body is ON. I tried to point out that it works like this with the local url but that I cannot get it working with the myopenhab url. Do you have any idea why?

Are you certain this is a POST? When I do a POST to command an item the response body is empty. That looks like a GET response body.

Can you bring up the REST API Docs through myopenhab.org and make the call through the Docs?

You just made me solve my own question, thank you Rich!

I had to use home.myopenhab.org and HTTPS instead of HTTP.
Another question, is myopenhab a reliable solution? If no, what are the alternatives and how to implement them?

1 Like

myopenhab is just an running instance of https://github.com/openhab/openhab-cloud.
You can set up your own cloud instance instead of using the one hosted by the OH foundation.

A tutorial for this can be found here:

1 Like

I use it to open my garage doors. In the past year or so I’ve never had a failure. There are occasional downtimes but thoes have become more and more rare over time.

If you don’t want to depend on the services, like Jerome mentions, you can set up your own instance.

2 Likes

I had some more downtimes in the last time,
but didn’t want to blame anyone or anything before investing eneough time in failure research.

Is it possible to register user through URL as you did above for user login ?

thanks

Hi!

I do not think this is possible.

Verstuurd vanaf mijn iPhone

Thank you,