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
#7
(18.05.2018, 08:07)admin Wrote: 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')

Hi Admin,

Thank you! 

It kinda works, but not 100%.

When triggering input1 nothing happens.
When triggering ext1.input1 port 2 goes to ON.
When triggering ext1.input2 nothing happens

Im not shure if it`s the Getface that is the problem or what? do you have an idea?

From current errors:

Test Script Getface 18.05.2018 10:21:51
Resident script:9: attempt to index field 'result' (a nil value)
stack traceback:


From Log:

Test Script Getface 18.05.2018 11:02:05
* table:
[1]
 * table:
  [state]
   * number: 0
  [port]
   * string: led_secured
[2]
 * table:
  [state]
   * number: 0
  [port]
   * string: relay1
[3]
 * table:
  [state]
   * number: 0
  [port]
   * string: output1
[4]
 * table:
  [state]
   * number: 0
  [port]
   * string: input1
[5]
 * table:
  [state]
   * number: 0
  [port]
   * string: ext1.relay1
[6]
 * table:
  [state]
   * number: 0
  [port]
   * string: ext1.relay2
[7]
 * table:
  [state]
   * number: 0
  [port]
   * string: ext1.input1
[8]
 * table:
  [state]
   * number: 0
  [port]
   * string: ext1.input2


BR Even.
Reply


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

Forum Jump: