Consuming Rest API

Hello guys.
I am new in the Hubitat, but already like it a lot. I wonder about some possibilities which I'd like to achieve and I am not sure if HE allows it. I am interested in creating some communication with some Rest APIs. Ideally, I would like to use them the same as some physical devices, so I would like to have them available in dashboards, rule engines etc.

I assume that I would need to create custom driver. Am I right? I would appreciate if someone point me the right direction to start.

Thank you and it is nice to meet you :slight_smile:

When I hear "RESTful API" I equate that with "Callable URL", with the intent of controlling hub devices from other endpoints (Tasker, EventGhost, the browser window, Blue Iris, cloud apps, IFTTT, etc.).

If this is what you're after, good news: MAKER API (a built-in app you can install on your Hubitat C-7) gives you a "Local URL" and a "Cloud URL" for each Device you assign to it. Plus a few more to play with, and all are simple HTTP GET Requests. The URLs offer a convenient way to list Devices, their Capabilities, and/or send Commands to them from outside the hub.

Conversely, if your goal is to use your HE to make outbound GET requests, reaching out to other external API's, that's entirely doable as well, using Rule Machine. It has a built-in Action called "HTTP Request" (I believe), which captures the response into a local variable called %text%, that you can act upon, simply read, or use for things like Notifications.

Hope I'm reading your question correctly, and have provided a couple of jumping off points for you to explore.

WELCOME ABOARD!

  • Libra
2 Likes

Which devices are you trying to control?

Regardless, this driver example may be a useful starting point: HubitatPublic/httpGetSwitch.groovy at master · hubitat/HubitatPublic · GitHub

5 Likes

thanks for the response. This action in Rule Machine sounds promising. I definitely would need to give it a try. From my understanding, I am able to handle only GET using this method, but is there any out of the box possibility to handle POST methods as well?

Regarding Maker API, as I can see it can be used only for exposing API from HE, but in my scenario, I am looking for a way to consume 3rd party APIs.

Thanks a lot!

This is an old link but still useful?

Also this thread as well maybe..

1 Like

I don't have any of it yet, but I am during building my house and as I can see, for sure there will be some incompatible devices which will not be supported. For example, I would like to have switchers for window shutters grouped in one place on a single panel, so it is hard to handle it using just zigbee/z-wave devices, so I am thinking maybe about knx for that, expose API and handle it in HE, but we'll see.

BTW your link is great, it seems understandable and I think it is a good place to start.

Thanks a lot

1 Like

Thanks for the examples, for sure it will be helpful!

1 Like

I looked in Hubitat Package Manager (another fine app you should consider installing), using a keyword search on terms like "API" or "POST" or "REQUEST", and found nothing helpful. Although clearly others are aware of 3rd party ("User") apps that are purpose-built for dealing with HTTP calls.

You asked specifically whether Rule Machine can initiate HTTP POST requests, and the answer is yes. It can also send PINGs to a given URL.

All things considered, I think you will be able to integrate your entire system without too much fuss. Good luck!

  • Libra
2 Likes

Awesome, thank you guys. Didn't even imagine that I would receive so much help from your side in just 1 hour. It is more clear now!

I'm not an employee of Hubitat, Inc (and assume @LibraSun isn't either).. that's one of the really cool things about this community, a lot of folks are very active and helpful.

3 Likes

Download the Hubitat app