(05.07.2016, 05:58)admin Wrote: There's a similar script which uses HTTP for communication:
http://forum.logicmachine.net/showthread.php?tid=320
Example for your AC system:
Code:function parse(txt)
local chunks, key, value, result
chunks = txt:split(',')
result = {}
for _, chunk in ipairs(chunks) do
key, value = unpack(chunk:split('='))
result[ key ] = value
end
return result
end
ip = '192.168.1.1'
http = require('socket.http')
url = 'http://' .. ip .. '/aircon/get_sensor_info?'
result, err = http.request(url)
if result then
data = parse(result)
-- log(data)
grp.update('1/1/1', data.otemp)
else
alert('HTTP request failed: ' .. tostring(err))
end
i hope someone can help me,
i try to use this script, but i got a fail
it said
Quote:Resident script:11: attempt to call global 'parse' (a nil value)For me it looks like he cant connect to my airco?
stack traceback:
I changed the IP adres on line 1 to the IP adres of my airco
add the group adresses to my Wiser/LM
and if i open my browser and browse to 'http://192.168.11.99/aircon/get_sensor_info?'
i see the next line: 'ret=OK,htemp=18.0,hhum=-,otemp=15.0,err=0,cmpfreq=0,mompow=1'
like the names on line 12, 13 and 14.
what is what im doing wrong.
i need to say this is the first time, i try to get http request.