Hello
Is there anyone who can help me with a lua code?
I want to report a temperature to a website from a temperature sensor that I have.
I report currently with a Domoticz Rpi Razberry but want to move everything to my Veraplus.
The code that I run on Domoticz setup now
Command Array = {}
command array [ ‘OpenURL’] = ‘http: //www.XXXXX.nu/rapportera.php ? hash = XXxxxxXXXxxXXXxxxXXxxxXXxx’ … string.format ( “%. 2f”, otherdevices_temperature [ ‘Back’])
return command array
Thanks in advance
Hi,
I would not use the array word. But something like.
local command = {}
command['openURL'] =...
return command
Also note that LUA is case sensitive so Command is not command. It are two different variables.
Cheers Reme
Heli4ce
January 7, 2017, 10:41pm
#4
Hi!
This is how I do it, seems to work,
–Report to Thingspeak
–Fetch data
local Rpt_Temp = luup.variable_get(“urn:micasaverde-com:serviceId:GenericSensor1”, “Temperature”, 44)
– Send data
local http = require(“socket.http”)
http.TIMEOUT = 5
result, status = http.request(“http://api.thingspeak.com/update?key=xxxx&field1=“..Rpt_Temp..” ”, “run=run”)
Good luck!
/Heli
Johan71
January 14, 2017, 2:38pm
#5
[quote=“Heli4ce, post:4, topic:194995”]Hi!
This is how I do it, seems to work,
–Report to Thingspeak
–Fetch data
local Rpt_Temp = luup.variable_get(“urn:micasaverde-com:serviceId:GenericSensor1”, “Temperature”, 44)
– Send data
local http = require(“socket.http”)
http.TIMEOUT = 5
result, status = http.request(“http://api.thingspeak.com/update?key=xxxx&field1=“..Rpt_Temp..” ”, “run=run”)
Good luck!
/Heli[/quote]
hi tried to thingspeak but it dosent work
is the name Rpt_Temp your temp sensor name?
the field urn:micasaverde-com:serviceId:GenericSensor1 is in my micasaverde urn:schemas-micasaverde-com:device:TemperatureSensor:1 is that correct ?
//Regards Johan