jsonapi-demo.lua
package.path = './src/?.lua;' .. package.path
local Netio = require('netio.json')
local inspect = require('inspect')
local resp, err
local netio1 = Netio.new({
url = 'http://netio-4all.netio-products.com/',
port = 8080,
user = 'write',
pass = 'demo'
})
print(inspect(netio1))
resp, err = netio1:general_info()
print('The Netio Model is ' .. resp.Model)
resp, err = netio1:outputs_info(1)
print('Current state of output1: ' .. resp.State)
local state = resp.State
resp, err = netio1:outputs_toggle(1)
if resp[1].State and resp[1].State ~= state then
print('Successfully toggled output1.')
print(' New state is: ' .. resp[1].State)
elseif not resp[1].State then
print('Something went wrong: ' .. err)
end