I've been using the Maker api with javascript fetch() to access my switches. But I'm confused about how I can use the api to access variables. Is there a separate api from the one in Maker? I have a variable that I set in an app action, and I've read about the getGlobalVar(String name)
in the api instructions. But I don't know how I use it in the api call. Is it just embedded in the url? Where?
Create connector devices for your variables. And then access those using Maker API.
Ok. Being a newb, I could really use a bit more explanation.
Look at the section on creating connectors in the hub variables documentation …
https://docs2.hubitat.com/user-interface/settings/hub-variables
I had read that section. To me it said that connectors were something that was used in older versions and not needed these days! When I set one up in settings, I then saw it in Maker and now I understand that I access it as a pseudo-device in my javascript code. Thanks.
Maker API hasn’t changed in ~3-4 years; some changes would also break many existing external integrations. So it remains one of those older apps that cannot directly use hub variables.
As an alternative to creating a connector, you could use Rule Machine for this instead of Maker API. The idea is similar, just a different app to handle this, since Maker API has not been changed to allow direct access, while Rule Machine does offer this feature.
To do so, create a rule, then add a local or cloud endpoint trigger (depending on your needs). Then, use the Rule Machine hub variable HTTP API to set the hub variable — specifically, a GET
to something like:
http://<your-hub-ip>/apps/api/<rule-app-id>/trigger/setHubVariable=<variable-name>:<variable-value>?access_token=<access-token>
for local, or similar for cloud with the cloud URL substituted for the beginning part.
That being said, Maker works too, aside from the fact that I hate to encourage connectors when there's another way given that some people aren't as cautious with them as you are.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.