HTTP with Global Variable

I wish to use HTTP to set/change the value of a string global variable in my hubitat. For testing purposes I was trying to do it from the browser on my computer. I am reading and using MakerAPI instructions. I created a Global Variable in RM. I tested with http://192.168.3.120/apps/api/909/devices/922/events?access_token=3b194cb2-d309-45c8-8dc9-166308b64ecb and that responded with the recent events OK. So I am confused should I be using a Send Device Command or a Send POST URL to set the value of my Global Variable? My assumption was the Send Device Command but I am having trouble figuring what to send as command and values. For testing I wanted to change the value of my Global Variabe to abc123. I tested sending http://192.168.3.120/apps/api/909/devices/922/CurrentValue/abc123?access_token=3b194cb2-d307-45c8-8dc9-166308b64ecb but I get An unexpected error occurred.

You really shouldn't post your access token on a public forum...

The POST url is the address the hub sends events to - it is not used to send commands to the hub.

In general you can only use Maker API to trigger COMMANDS. You can't just write to a random currentValue.

That said, I don't use variables in Hubitat, so maybe there is something special there that is different than normal devices.

1 Like

Yup. I think @Angus_M makes use of a global variable connector device to keep the value of a NR global context in sync with a Hubitat global variable. At least at one point of time he was interested in doing so.

Good point. If you make a GV connector, you should be able to add that to maker api and write to it remotely. Something like this:

http://(hubip)/apps/api/(app number)/devices/(device number)/setVariable/(value)?access_token=xxxxx

EDIT: Just tried it, works fine. :+1:

1 Like

Thanks much. Got it working OK. FYI the setVariable command does not work if the S is capitalized and that is what I was doing. Do you know is there a command list somewhere that shows exactly how each available command should be 'spelled.

Of course not. Commands are case sensitive. :slight_smile:

Each command should show how it is spelled in the command box on the device detail page. So you should never have to guess. See below.

Screenshot 2021-05-10 10.13.46 AM

Or from Maker API you can get the details of a device, and it will list all commands (and obviously you can get the spelling form there too).

2 Likes