Library to control outputs of NETIO 4 smart power sockets from NETIO products a.s. https://www.netio-products.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sebastian Huebner 7c2be0c7cf
netio_jsonapi_spec.lua: fixed tests
1 year ago
docs Found typo in docu 1 year ago
examples not useable 1 year ago
spec netio_jsonapi_spec.lua: fixed tests 1 year ago
src/netio jsonapi.lua: fixed typo in outputs methods 1 year ago
LICENSE LICENSE: added year and name 1 year ago
README.md updated README 1 year ago

README.md

lua-netio

Description

lua-netio is a library to control outputs of NETIO 4x smart power sockets from NETIO products a.s.. These Ethernet- or WiFi-connected power sockets can be accessed using a varity of protocols and M2M-API methods, including HTTP(s) CGI, Telnet, XML, JSON and many more.

Currently implemented:

  • JSON API

TODO

I’m not planing to implement the XML API, because in my opinion the JSON API is enough, but if someone want to contribute, do it :)

Example Usage

local Netio = require('netio.jsonapi')
local netio1 = Netio:new({
    url = 'http://netio-4.netio-products.com',
    port = 8080,
    user = 'write',
    pass= 'demo'
  })

local resp, err = netio1:outputs_info(1)
print('Current state of Output1 is ' .. resp.State)
resp, err = netio1:outputs_toggle(1)
print('State after toggle of Output1 is ' .. resp.State)

Documentation

Documentation was generated with LDoc and can be read here: https://imolein.github.io/lua-netio/

Dependencies

Tests

You need busted to run the tests.

busted spec/

Some tests might fail sporadically. That’s because I use the NETIO 4All demo URL, which sporadically rejects the commands silently and just return the status JSON object. If you take a look into the NETIO’s logfile, you see that the command is refected, but not why. You can change the URL to one of the another demo devices, but then the measure_info() method test will fail.