This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Http Api command to Zennio Getface IP
#6
State has to be polled so you need a resident script. Adjust sleep time as needed, but do not use 0 as it will consume all CPU.
Uncomment and modify grp calls depending on how many inputs are used.
Code:
require('json')
require('socket.http')

res, err = socket.http.request('http://192.168.1.101/api/io/status')
if res then
  data = json.pdecode(res)

  if type(data) == 'table' then
    ports = data.result.ports
    log(ports)
    -- grp.checkwrite('1/1/1', ports[ 1 ].state)
    -- grp.checkwrite('1/1/1', ports[ 2 ].state)
  else
    alert('failed to decode data')
  end
else
  alert('http request failed ' .. tostring(err))
end

-- release unused resources
collectgarbage('collect')
Reply


Messages In This Thread
RE: Http Api command to Zennio Getface IP - by admin - 18.05.2018, 08:07

Forum Jump: