API RESTful Documentation?

I'm getting started with the Maker API.

Where can I find more detailed documentation?
For example, one of the RESTful API calls sends a device command:

Send Device Command (replace [Device ID] with actual subscribed device id and [Command] with a supported command. Supports optional [Secondary value])

http://IP_Addesss/apps/api/6/devices/[Device ID]/[Command]/[Secondary value]?access_token=[your_access_token]

This makes sense, but where can I find a list of all the commands and secondary values?

For example, to turn a switch, the command is "on", but what about dimmers, door locks, etc.

My understanding is that I can also query the hub to get the hub name, etc., where can I fid that API?

I've checked Developer Documentation | Hubitat Documentation, but not finding it there.

Thanks.

Maker API is an app (really something anyone could have written), not part of Hubitat's development environment per se, so those docs won't help you. The app itself gives you several examples in app (as you seem to have found above), otherwise the documentation for this app should also:

You can find the commands any particular device supports under "Commands" on the device detail page. Optional and required parameters, if any, will also be displayed. There is some standardization here in that device capabilities require specific commands (and attributes). So pretty much any switch is going to implement the "Switch" capability, then you know it supports the on() and off() commands. Maker API can help you see some of this too. For locks, the plain "Lock" capability requires lock() and unlock(). Maker API can show you both capabilities and commands for a particular device depending on what you're after.

I don't believe these are exposed via Maker API. You can get them in app (and I think driver...) code via the location object: Location Object | Hubitat Documentation (though it's not common to need this information).

It may be helpful to take a step back and share what you are actually trying to do. Do you need Maker API, or are you trying to write a custom app or driver on the hub itself?

3 Likes

Thank you, very helpful.

I may misunderstand the Maker API then, I thought I needed it to get an access_token as well as authorize what devices my app can control? (Allow Endpoint to Control These Devices)

Driver Capability List | Hubitat Documentation is particularly useful. Just what I was looking for.

I'm building a custom app (actually migrating my app from a different hub to Hubitat's). It's a C# app with a responsive web UI that I've used for years.

Here's a screenshot of the device dashboard for example.

2 Likes

You do; I don't think I said anything above that contracts this, so let me know if there's a specific point of confusion. Maker API (like any Hubitat app) can only control the devices you've authorized for it.

Maker API generates the access token for you, though you do need to retrieve it for your use somehow.

Seems like a good use of Maker API, then! I should clarify that by "app" above, I meant in the context of Hubitat, where apps are sort of little applets that (typically...Maker API is a bit different) perform automations -- in case that caused any confusion.

Thanks. Re: Maker API, is there a better approach then? Do I still need an access token and need to authorize end points? Or, is there a better approach when creating a custom app like mine?

Maker API seems like a good choice; the alternative is writing your own app on the hub as well to handle this communication (but Maker API was created so you don't have to).

You need to authorize devices in Maker API on the hub. This control what gets exposed and is controllable via the app.

You don't need to generate an access token (in case you read about that in the developer docs; Maker API takes care of that for you). However, you do need to use the access token in the HTTP requests, per the Maker API examples and docs. How you get this to your C# app is up to you. Copy and paste is a typical way. :smiley:

Take a look at @thebearmay 's hub information driver HERE.
He uses many of the api calls available from hubitat to obtain various hub details.
VERY useful.

2 Likes

Thanks.

One more API follow-up...

When I query all devices via a call such as:

Get all devices with full details:
http://192.168.1.69/apps/api/6/devices/all?access_token=xxx

One of the device fields returned is type. For example, a plug in outlet returns:
"type": "Aeotec Smart Switch 7 US",

Is this field the only way to determine a device's type? There might be dozens of different switches, lights etc., each with a unique name (vs. a general category such as "switch").

Let's say I want to query the hub and group all the lights together. Going through every light "type" seems incredibly inefficient if these devices don't have a "parent" / "class" type.

Thanks.

Seems like you are really looking for the capabilities instead? "Type" in this context means the specific driver that the device is using. This is necessary to know in some cases (e.g., if you have an app targeted towards a specific brand and model of device with a dedicated driver) but is generally not what you are looking for.

1 Like

Thanks. It sounds like that's what I'll have to use.

Capabilities though are different than a type. For example, a plug-in switch, an outlet, and outdoor module all have a "switch" capability, but are all different types. If I wanted to group them by type, it does not appear there is any easy way to do that , especially as there are so many "types".

There is capability "Outlet" that is functionally identical to capability "Switch" (which is far more common) that some drivers may implement, or some may do both -- but, yes, this is tricky. Normally that difference doesn't mater to an app, just the fact that it reports a switch attribute and has on() and off() commands. If you want to get more nuanced, you'll either need to make your own inferences based on other data (device name, driver, etc.) or something else, like offering the user to select different categories of devices on their own based on what they know.

Thank you.

One last question as you're so helpful... is there a method to determine if the hub has lost contact with a device? (Perhaps the battery died, or there was a network issue, etc.) Other hubs I've used have an attribute (unreachable for example).

Does Hubitat have such a thing?

1 Like

At any standardized level, no -- in no small part due to the fact that for many kinds of devices, this is impossible to know (e.g., battery powered Z-Wave devices are normally sleeping and not listening for commands from the hub). Some LAN devices offer a networkStatus attribute (as many such devices have a better way to know; not all), and there is an informal effort among some community drivers to offer a healthStatus attribute for their drivers if it makes sense (and perhaps sometimes even when it doesn't :smiley: ).

This is one of the reasons I wrote this app, since there isn't a good way to know for many devices except whether they've had "activity" recently: [RELEASE] Device Activity Check - Get notifications for "inactive" devices. But that won't help you with this particular question.

3 Likes

Thanks. That's unfortunate. I wonder how the other hub manufacturers implement it then... it's nice to know what a device has stopped responding.

How about getting the lat/long from the hub? Can that be done? (I see the getLocation object in the docs, but is there a RESTful API call?)

The only one I'm familiar with is SmartThings, which people made fun of for being inaccurate and causing problems. I know the platform has changed since then, but I'm not sure about this particular part. :wink: I've also seen it in Zigbee2MQTT, again, often not quite accurate since not all devices are awake all the time. For many devices, there just isn't a good way to know.

I don't believe this is available in Maker API. Maker API is not a complete implementation of the development environment over HTTP; it's just an app (on the hub) that someone wrote using this development environment to allow things like device control over HTTP using a simple API -- without you needing to write anything on the hub to do so yourself. If you need more/different information or finer control, you might want to consider writing your own app on the hub to handle this communication instead of using Maker API. That being said, it's built-in, easy and should work if it does what you need.

1 Like

Thanks. I was hoping I could do what I needed via a REST API (not have to write an on-hub Groovy app). Sounds like that won't be possible.

Are there any plans to release a complete RESTful API?

Not available from MakerAPI by itself, but if you add the Hub Information Device you could use MakerAPI to request from there.

1 Like

Thanks. Can you elaborate? (I'm new to Hubitat). When you say "add the Hub Information Device", what do you mean?