Send a device attribute in http post request


#1

I’m sure it’s possible but I’m struggling with the how.

I’m trying to figure out how to make a http post request but include a devices attribute. In my case, posting to influx db.

In linux we’d do something like this with curl

$ curl -i -XPOST "http://localhost:8086/write?db=mydb" --data-binary 'mymeas,mytag=1 myfield=90 1463683075000000000'

#2

I save the attributes into a variable and send that with the POST call.

image


#3

Okay, I think I got it. But I need to tell it in the post what database to put it in, which is the first argument in the post I believe. I made a variable called database and made the value of it the name in influx. But when you check your variables, it puts them in whatever order it wants.

Maybe it shouldn’t be json for influxdb or I’m just being dumb here lol


#4

I just realized that my example above is not accurate. The url I’m calling is a node that receives the data and that’s what pushes it into my database in the proper format.


#5

Ahh. That’s why I’m trying to avoid.

I have like 2 or 3 values I want to log, but I’m trying to avoid setting up node red just for that. I started poking around in webcore thinking there’s gotta be a way to do it.

I wonder if I can just use the post value field to type sort of free form and include my variables… Gonna poke around with that.


#6

I’m going to try and play with it also with a mocking server as I do not have an influxdb installation. I’ll try to copy the curl url you posted above.


#7

Setting the post to custom, then the string to value you can definitely call your variables by putting them in curly brackets. I just need to figure out the syntax to put it all in now.

I just did a test first by sending myself a push notification containing the variables…

I’m getting frustrated. I wish I could see what webcore is sending and getting back in response but none of that is in the log. In the log it looks like it’s sending what I want, but I’m not seeing any errors come back from influx.

I think I’m close, but the problem lies in I don’t know how I need to format it.


#8

Got it figured out! I ended up having to get a packet capture to see what error influx was sending back to figure it out. My issue was a space after the comma in the post data. In my grabbing at straws I tried putting the field in quotes also which it did not like.

I’ll share the complete piston when I’m done with it for future searchers :slight_smile:


#9

So here’s the finished product… Basically I run Hubitat, and use the Hub Information driver but wanted to log all the stats in my influx/grafana setup without installing node red just for this one task.

And what I was trying to accomplish: