Set hub variable from bash script with curl call?

Hi all,

I'm hoping to find a nice way to set some hub variables from a bash script running on my Raspberry Pi which is on the same network as the hub.

I saw some related posts on here but they didn't seem to quite hit my use case. I believe I need to hit the hub API with a curl call and provide an apikey, but Maker might be involved?

Has anyone been through this one that can provide some assistance?

Thx

I'm looking at this: Rule Machine | Hubitat Documentation

I don't quite get why I need to have a rule to make this work but I'll try to work through this concept. I guess the API calls somehow leverage a rule which seems odd.

This documentation seems to assume we know what we are doing. Referencing access_token with no explanation of where to find it, how to set it up etc?

I believe an access_token is provided when you set up Maker API. I recall doing this to set up Locative presence sensing, but this is very confusing.

You do know what you're doing. :slight_smile: This is accurate (and the docs mention it, which is I assume where you got it from):

And that is because when you add a local (or cloud, depending on your needs) endpoint trigger to a rule, you will get a URL. You can use that URL as a start, modifying the paths or parameters as needed. It includes the access token (and the app ID, which you will also need--the 10249 in the example above).

When I create a Maker app, it seems all about getting info and controlling devices which is not what I want to do. I simply want to make an API call to set a hub variable.

It's also unclear whether I can repurpose the access_token already created for my Maker which is set up for Locative presence or not.

It's also unclear how the connection is made between an app with a Local end point trigger and an access_token from a Maker app. i.e. Having more than 1 Maker app means having than 1 access_token

That is correct. Why are you trying Maker API? You linked to the Rule Machine docs above, and that is the correct app to use for this purpose.

No. Access tokens are particular to the app they were created for.

Correct. The access token is sort of a password. It does not "connect" the HTTP call to a particular app; the app ID in the URL does that.

You need to create a rule with a local (or cloud, whatever you need) endpoint trigger. If you only want to use the HTTP API to set a variable, you don't even need any actions, just the trigger.

Where do I get an access_token if not from a Maker? This is the root of my confusion. The API call to set a hub variable requires one.

You need to create a rule with a local (or cloud, whatever you need) endpoint trigger. If you only want to use the HTTP API to set a variable, you don't even need any actions, just the trigger.

When you add a local (or cloud, depending on your needs) endpoint trigger to a rule, you will get a URL. You can use that URL as a start, modifying the paths or parameters as needed. It includes the access token (and the app ID, which you will also need--the 10249 in the example above).

If that second part sounds confusing, just try it and you'll see. :slight_smile:

Again, even if you got this token, it would not work for another app.

Ok now I see what happened, I ran into a RM bug where I cloned a rule, deleted the trigger, and when I added Local end point trigger I didn't see that URL link.

I see it now creating a fresh rule.

Thanks @bertabcd1234 very straightforward once I worked around that bug. Once again a massive waste of time due to bugs.

1 Like

What is the actual bug behavior and the steps to reproduce?

I don't have time right now to figure it out, it also could have been me simply led astray by the unintuitive nature of things... I don't know.