How to do a http GET request and use the data in a virtual sensor?

I have searched the forums and I feel stupid.
I want to do the following simple thing:

Make a http request to a website where I have a temperature reading. Something like this:
http://whatever.com/temp.txt
The response will just be the temperature i celsius.
Right now the response is: 18.7

I want to pull this data every minute and add it to a virtual temp sensor that I can use for automation in Hubitat. Is there an inbuilt driver I can use for this or how shall I solve this?

Regards,
David

Do this using Rule Machine. With a periodic trigger.

1 Like

@aaiyar ninjaed me while I was making a sample Rule with the most relevant part...

1 Like

Not that I'm an expert, but I actually did this.
The string probably has to be converted to a number if you want to do anything with it.

Thanks! I'm getting closer...
Where do I find the "Set Response from GET response"? I'm looking and clicking everywhere ut I can't find this setting :sweat_smile:

You get it if it's a string, vs number, like you have it now.
I'd say, do the string, then convert the string to a number. There's a function for that.

Slight word of caution in that polling anything every min isn't really a great idea. It may not be to impactful if this is only done on one device. But that frequent of polling can be problematic as your environment grows.

If you have the ability to control it you may be better served by having the device push the state only when it changes. Then use maker API with a update command that will put the update on the device when it is recieved.

1 Like

Thank you! Found it after created a string local variable

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.