Hi
could someone help me with the following code that is not working, the testvariable is not passed to the http request
local testvariable = “hi Lloyd how are you”
local http = require(“socket.http”)
– 5 Second timeout
http.TIMEOUT = 5
result, status = http.request(“http://192.168.10.112:5005/sayall/%testvariable%”)
result, status = http.request(“http://192.168.10.112:5005/sayall/” … tostring(testvariable))
Of course if this has has other than alphanumeric characters (like spaces, punctuation, …) you will also need to URL encode the contents of testvariable first.
Im trying to something similar with a prowl notification, using a variable from a sensor. First creating a variable of the current temperature then passing that to the http.get command to raise a nification… Im not sure how to ammend the script below :
local livingroomtemp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”,143
First when posting code use
```
code
```
As the forum will strip the " and add ”. Adding syntax errors due to pretty quotes. Check for this if you copy and paste code.
Here what it should look like.
local livingroomtemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",143)
local tempurl = ("https://api.prowlapp.com/publicapi/add?apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&application=Notification&event=Vera%20Alert&description=" .. tostring(livingroomtemp) .."&priority=1")
local status, result = luup.inet.wget(tempurl,5)