Setting Global Variable with HTTP GET Value

I'm new to Hubitat.. switching from SmartThings. Anyway, I have a really quick question about using the RM to set Global Variables.

For example I have a remote panel at my house that has an Webserver running on 192.168.1.55:8866.
Turn on/off switch1 --> http://192.168.1.55:8866/Switch1/toggle (GET Returns 200 OK Code) - This works...
Status of switch1 --> http://192.168.1.55:8866/Switch1/status (GET returns html/text --> On, Off,Unknown,etc..)

I want to set the global variable Switch1_Status = "On, Off, Unknown.. etc" whatever is reported by http://192.168.1.55:8866/Switch1/status

Anyway, when I set up RM to do this the logs say the GV is set to null...

Logs:
Set Switch1_Status from GET response: http://192.168.1.55:8866/Switch1/status
Switch1_Status variable is

If I do a curl on any device on my network to http://192.168.1.55:8866/Switch1/status I get the response I expect...

My thought is the web server response format is not what the RM is expecting...

Any assistance would be great... this is the last piece before I make my full migration away from ST...

Thanks in advance..

Hello and welcome to Hubitat!!!

First off, there really isn't a need to do this with a GET request. Why not simply set the RM Global variable based on the switch's status directly within Rule Machine? Like this:

Actions:
If Switch 1 is on THEN
     Set GV to True
Else
     Set GV to False
END-IF

However, there really isn't a need to use a global variable for a switch's status because you can just use the switch's status as a condition within the rule. Rather than use a GV that will have to be updated, just use the Switch's status as a condition within your conditional action and save yourself the trouble. Introducing a GV into the equation adds a layer of complexity without any real benefit.

What you are asking is to set a GV based on what is returned from an HTTP GET request performed by Rule Machine, you simply have to pick that selection when you pick your Global Variable to set:
image

The trick is, it has to be a String type variable. I don't believe the option is available for any of the other variable types because the response is always first parsed as a string. You can then convert it to a number, by setting a number variable equal to the string variable. The issue here is, it is going to set the string to the entire response from your HTTP GET call. Then you would have to parse it further, which RM doesn't really allow you to do easily. But, like I said, you should never need to query the Maker API from within Hubitat itself. That's like begging for an invite when you're already at the party.

Thank you for your response. So the switch in question is a pool control panel that has an raspberry pi reading values off the RS485 buss. I mention this because the only way I can get the true state of the switch (on, off, unknown, faulty... etc) is to quarry the web interface via http (aka http://192.168.1.55:8866/switch1/status). I completely get your point about the "party" but i just want a way to store the status of the switch beyond on and off. Given that, I was just wondering if RM could set the global variable (string) to the string value that's returned from my remote stays query of the raspberry pi server using the "set from http GET request"... I think I'm missing something fundament here... so apologies in advance.

My apologies, I thought you were making the requests from Hubitat TO Hubitat.

What software do you have reading those values off the RS485 bus on your pi? If the device responds to HTTP GET messages, it wouldn't be hard to write a driver that handles calls to the device for you. That way it would shot up in Hubitat just like any other device. Is this a device you control from other points than just within Hubitat? If so, querying is always going to give you a lag in reporting the correct status. But that is much easier to handle though a driver as well.

However, even if you choose to handle this through Rule Machine, you may find it easier to handle through a Virtual Device rather than a GV. Virtual Devices can be used in any app. A RM global variable is restricted to being used only in RM.

nodejs-pentair - npm I wrote a web server that frond ends the node web server so I can manipulate the web request outputs. You're right... a driver is a better solution. I saw the set variable by "set from http GET request" and thought that would save me some time (plus I'd learn a few things about Hubitat)... I'm lazy... anyway, appreciate the insight... I'll focus on getting the driver working.

One more quick question... how do you find the access token for the RM? Thanks again.

Okay...this is a separate issue/question right? Because if your other system is sending the information to Hubitat without Hubitat sending a GET message to your other system, then that is a totally different ball of wax. You would only need an access token if you were setting up your Tasmota devices to send HTTP messages from Tasmota without any querying by Hubitat.

But to answer your question, you get your local or cloud link from RM when you add one of those two triggers to the rule. You'll see words "cloud link" or "local link" in blue (hyperlinks) after you add them to your rule. That will have the access token that you need to use.