Please excuse what is quite probably a very simple question to answer, but I’ve been searching in circles. I’ve probably seen most of what I need, but wouldn’t recognize it if I did. I’m looking for a simple way to pass a device state through an http post method For example, I’d like to pass a thermostat temperature every X minutes. I figure I can handle the timer through a scene, and have the scene handle the post through code.
I’m assuming that I use a variation of this:
local http = require("socket.http")
http.TIMEOUT = 5
result, status = http.request("http://192.168.0.113/runprocess.htm", "run=run")
The server that accepts the post:
http://api.thingspeak.com/update?key=MYAPIKEY&field1=0
Adding 1 plus 2, I get 3:
local http = require("socket.http")
http.TIMEOUT = 5
result, status = http.request("http://api.thingspeak.com/update?key=MYAPIKEY&field1=TEMP", "run=run")
How do I get the temperature into ‘TEMP’? I know that I need to query it. This is the code I would use for Variable Container:
local lul_utemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 29)
luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable2",lul_utemp, 45)
So now I add 3 and 4 and I get this:
local lul_utemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 29)
luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable2",lul_utemp, 45)
local http = require("socket.http")
http.TIMEOUT = 5
result, status = http.request("http://api.thingspeak.com/update?key=MYAPIKEY&field1=TEMP", "run=run")
This is where I get stuck. I suspect that I’ve got extra stuff in here and I’ve no idea if I have everything I need. Plus I can’t figure out how to get CurrentTemperature into the URL string.
Any help would be most appreciated.