Browse Source

Updated documentation

pull/5/head
Sebastian 3 years ago
parent
commit
75fe0d2637
Signed by: imo GPG Key ID: AFA10CBFE4391C0C
  1. 10
      docs/config.ld
  2. 246
      docs/data structures/dstructures.md.html
  3. 105
      docs/examples/jsonapi-demo.lua.html
  4. 42
      docs/examples/urlapi-demo.lua.html
  5. 516
      docs/index.html
  6. 13
      docs/manual/dstructures.md.html
  7. 13
      docs/manual/errors.md.html
  8. 159
      docs/modules/netio.html
  9. 288
      docs/modules/netio.json.html
  10. 546
      docs/modules/netio.jsonapi.html
  11. 79
      docs/modules/netio.telnet.html
  12. 141
      docs/modules/netio.url.html
  13. 80
      docs/modules/netio.urlapi.html
  14. 338
      docs/modules/web_core.html
  15. 32
      examples/demo.lua
  16. 36
      examples/jsonapi-demo.lua
  17. 19
      examples/urlapi-demo.lua

10
docs/config.ld

@ -3,11 +3,17 @@ title = 'lua-netio-api documentation'
description = 'Lua module to control NETIO smart sockets over their M2M API\'s'
use_markdown_titles = true
dir = '../docs'
file = '../src/netio.lua'
file = {
'../src/netio.lua',
'../src/netio/json.lua',
'../src/netio/url.lua',
'../src/netio/web_core.lua'
}
format = 'discount'
sort_modules = true
topics = { 'dstructures.md', 'errors.md' }
kind_names = { topic = 'Manual', script = 'Programs' }
examples = {
'../examples/demo.lua'
'../examples/jsonapi-demo.lua',
'../examples/urlapi-demo.lua'
}

246
docs/data structures/dstructures.md.html

@ -1,246 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>lua-netio-api documentation</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>lua-netio-api</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Status_table">Status table </a></li>
<li><a href="#Agent_table">Agent table </a></li>
<li><a href="#GlobalMeasure_table">GlobalMeasure table </a></li>
<li><a href="#Ouputs_table">Ouputs table </a></li>
</ul>
<h2>Data structures</h2>
<ul class="nowrap">
<li><strong>Returend data structures</strong></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/netio.jsonapi.html">netio.jsonapi</a></li>
<li><a href="../modules/netio.telnet.html">netio.telnet</a></li>
<li><a href="../modules/netio.urlapi.html">netio.urlapi</a></li>
</ul>
</div>
<div id="content">
<h1>Returend data structures</h1>
<p><a name="Status_table"></a></p>
<h2>Status table</h2>
<p>The <strong>Status</strong> table is returned by the <strong>info()</strong> method and contains all
informations which the API provides.</p>
<p><strong>Example:</strong></p>
<pre><code> {
Agent = {
DeviceName = "NETIO 4ALL Demo",
JSONVer = "2.1",
Model = "NETIO 4All",
NumOutputs = 4,
OemID = 0,
SerialNumber = "24:A4:2C:39:11:5A",
Time = "2018-08-15T18:44:28+01:00",
Uptime = 490866,
VendorID = 0,
Version = "3.1.0"
},
GlobalMeasure = {
EnergyStart = "2018-01-19T13:30:26+00:00",
Frequency = 50.1,
OverallPowerFactor = 0,
TotalCurrent = 0,
TotalEnergy = 2253,
TotalLoad = 0,
Voltage = 239.1
},
Outputs = { {
Action = 6,
Current = 0,
Delay = 5000,
Energy = 0,
ID = 1,
Load = 0,
Name = "output_1",
PowerFactor = 0,
State = 1
}, {
Action = 6,
Current = 0,
Delay = 5000,
Energy = 0,
ID = 2,
Load = 0,
Name = "output_2",
PowerFactor = 0,
State = 1
}, {
Action = 6,
Current = 0,
Delay = 5000,
Energy = 2081,
ID = 3,
Load = 0,
Name = "output_3",
PowerFactor = 0,
State = 0
}, {
Action = 6,
Current = 0,
Delay = 5000,
Energy = 172,
ID = 4,
Load = 0,
Name = "output_4",
PowerFactor = 0,
State = 1
} }
}
</code></pre>
<p><a name="Agent_table"></a></p>
<h2>Agent table</h2>
<p>The <strong>Agent</strong> table is returned by the <strong>general_info()</strong> method and contains the
<strong>Agent</strong> part of the <a href="#Status_table"><strong>Status</strong> table</a>.</p>
<p><strong>Example:</strong></p>
<pre><code> {
DeviceName = "NETIO 4ALL Demo",
JSONVer = "2.1",
Model = "NETIO 4All",
NumOutputs = 4,
OemID = 0,
SerialNumber = "24:A4:2C:39:11:5A",
Time = "2018-08-15T18:44:28+01:00",
Uptime = 490866,
VendorID = 0,
Version = "3.1.0"
}
</code></pre>
<p><a name="GlobalMeasure_table"></a></p>
<h2>GlobalMeasure table</h2>
<p>The <strong>GlobalMeasure</strong> table is returned by the <strong>measure_info()</strong> method and contains the
<strong>GlobalMeasure</strong> part of the <a href="#Status_table"><strong>Status</strong> table</a>.</p>
<p><strong>Example:</strong></p>
<pre><code> {
EnergyStart = "2018-01-19T13:30:26+00:00",
Frequency = 50.1,
OverallPowerFactor = 0,
TotalCurrent = 0,
TotalEnergy = 2253,
TotalLoad = 0,
Voltage = 239.1
}
</code></pre>
<p><a name="Ouputs_table"></a></p>
<h2>Ouputs table</h2>
<p>The <strong>Outputs</strong> table is returned by the <strong>outputs_info()</strong> method and contains the
<strong>Outputs</strong> part of the <a href="#Status_table"><strong>Status</strong> table</a>.</p>
<ul>
<li>If a specific output is given as parameter, only the nested table with the matching output ID is returned</li>
<li>The <strong>outputs_action()</strong> methods (<strong>outputs_on()</strong> etc.) return the complete outputs table</li>
</ul>
<p> <strong>Example:</strong></p>
<pre><code> {
{
Action = 6,
Current = 0,
Delay = 5000,
Energy = 0,
ID = 1,
Load = 0,
Name = "output_1",
PowerFactor = 0,
State = 1
}, {
Action = 6,
Current = 0,
Delay = 5000,
Energy = 0,
ID = 2,
Load = 0,
Name = "output_2",
PowerFactor = 0,
State = 1
}, {
Action = 6,
Current = 0,
Delay = 5000,
Energy = 2081,
ID = 3,
Load = 0,
Name = "output_3",
PowerFactor = 0,
State = 0
}, {
Action = 6,
Current = 0,
Delay = 5000,
Energy = 172,
ID = 4,
Load = 0,
Name = "output_4",
PowerFactor = 0,
State = 1
}
}
</code></pre>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-15 20:21:09 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

105
docs/examples/jsonapi-demo.lua.html

@ -0,0 +1,105 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>lua-netio-api documentation</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>lua-netio-api</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Examples</h2>
<ul class="nowrap">
<li><strong>jsonapi-demo.lua</strong></li>
<li><a href="../examples/urlapi-demo.lua.html">urlapi-demo.lua</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/netio.html">netio</a></li>
<li><a href="../modules/netio.json.html">netio.json</a></li>
<li><a href="../modules/netio.url.html">netio.url</a></li>
<li><a href="../modules/web_core.html">web_core</a></li>
</ul>
<h2>Manual</h2>
<ul class="nowrap">
<li><a href="../manual/dstructures.md.html">Returend data structures</a></li>
<li><a href="../manual/errors.md.html">Errors</a></li>
</ul>
</div>
<div id="content">
<h2>jsonapi-demo.lua</h2>
<pre>
<span class="comment">-- setup path to find the project src files
</span><span class="global">package</span>.path = <span class="string">'./src/?.lua;'</span> .. <span class="global">package</span>.path
<span class="keyword">local</span> Netio = <span class="global">require</span>(<span class="string">'netio.json'</span>)
<span class="keyword">local</span> inspect = <span class="global">require</span>(<span class="string">'inspect'</span>)
<span class="keyword">local</span> resp, err
<span class="comment">-- Initialize a Netio socket
</span><span class="keyword">local</span> netio1 = Netio.new({
url = <span class="string">'http://netio-4all.netio-products.com/'</span>,
port = <span class="number">8080</span>,
user = <span class="string">'write'</span>,
pass = <span class="string">'demo'</span>
})
<span class="global">print</span>(inspect(netio1))
<span class="comment">-- Whats the model name of the Netio we control?
</span>resp, err = netio1:general_info()
<span class="global">print</span>(<span class="string">'The Netio Model is '</span> .. resp.Model)
<span class="comment">-- Whats the state of output1?
</span>resp, err = netio1:outputs_info(<span class="number">1</span>)
<span class="global">print</span>(<span class="string">'Current state of output1: '</span> .. resp.State)
<span class="keyword">local</span> state = resp.State
<span class="comment">-- New we toggle output1 and check if the state has changed
</span>resp, err = netio1:outputs_toggle(<span class="number">1</span>)
<span class="keyword">if</span> resp[<span class="number">1</span>].State <span class="keyword">and</span> resp[<span class="number">1</span>].State ~= state <span class="keyword">then</span>
<span class="global">print</span>(<span class="string">'Successfully toggled output1.'</span>)
<span class="global">print</span>(<span class="string">' New state is: '</span> .. resp[<span class="number">1</span>].State)
<span class="keyword">elseif</span> <span class="keyword">not</span> resp[<span class="number">1</span>].State <span class="keyword">then</span>
<span class="global">print</span>(<span class="string">'Something went wrong: '</span> .. err)
<span class="keyword">end</span></pre>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-10-17 11:41:24 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

42
docs/examples/demo.lua.html → docs/examples/urlapi-demo.lua.html

@ -26,16 +26,23 @@
<br/>
<h1>lua-netio-api</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Examples</h2>
<ul class="nowrap">
<li><strong>demo.lua</strong></li>
<li><a href="../examples/jsonapi-demo.lua.html">jsonapi-demo.lua</a></li>
<li><strong>urlapi-demo.lua</strong></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../index.html">netio</a></li>
<li><a href="../modules/netio.html">netio</a></li>
<li><a href="../modules/netio.json.html">netio.json</a></li>
<li><a href="../modules/netio.url.html">netio.url</a></li>
<li><a href="../modules/web_core.html">web_core</a></li>
</ul>
<h2>Manual</h2>
<ul class="nowrap">
@ -47,47 +54,34 @@
<div id="content">
<h2>demo.lua</h2>
<h2>urlapi-demo.lua</h2>
<pre>
<span class="comment">-- setup path to find the project src files
</span><span class="global">package</span>.path = <span class="string">'./src/?.lua;./src/?/init.lua;'</span> .. <span class="global">package</span>.path
<span class="keyword">local</span> Netio = <span class="global">require</span>(<span class="string">'netio'</span>)
<span class="keyword">local</span> Netio = <span class="global">require</span>(<span class="string">'netio.url'</span>)
<span class="comment">-- Initialize two sockets, one using the URL API and one the JSON API
</span>
<span class="keyword">local</span> socket1 = Netio.new({
<span class="comment">-- Initialize a Netio socket
</span><span class="keyword">local</span> netio1 = Netio.new({
url = <span class="string">'http://netio-4all.netio-products.com/'</span>,
port = <span class="number">8080</span>
})
<span class="keyword">local</span> socket2 = Netio.new({
url = <span class="string">'http://netio-4all.netio-products.com/'</span>,
port = <span class="number">8080</span>,
user = <span class="string">'write'</span>,
pass = <span class="string">'demo'</span>,
api = <span class="string">'json'</span>
})
<span class="comment">-- We toggle output 1 of socket1
</span><span class="keyword">local</span> ok, err = socket1:outputs_toggle(<span class="number">1</span>)
<span class="comment">-- We toggle output 1 of the socket
</span><span class="keyword">local</span> ok, err = netio1:outputs_toggle(<span class="number">1</span>)
<span class="keyword">if</span> ok <span class="keyword">then</span>
<span class="global">print</span>(<span class="string">'Toggled output 1 of socket1 via URL API'</span>)
<span class="global">print</span>(<span class="string">'Toggled output 1 of via URL API'</span>)
<span class="keyword">else</span>
<span class="global">print</span>(err)
<span class="keyword">end</span>
<span class="comment">-- We can get info from the socket, using the JSON API
</span><span class="keyword">local</span> s2model = <span class="global">assert</span>(socket2:general_info()[<span class="string">'Model'</span>])
<span class="global">print</span>(<span class="string">'Model name of socket2 is '</span> .. s2model)</pre>
<span class="keyword">end</span></pre>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-10-16 16:13:11 </i>
<i style="float:right;">Last updated 2018-10-17 11:41:24 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

516
docs/index.html

@ -27,15 +27,14 @@
<h1>lua-netio-api</h1>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><strong>netio</strong></li>
<li><a href="modules/netio.html">netio</a></li>
<li><a href="modules/netio.json.html">netio.json</a></li>
<li><a href="modules/netio.url.html">netio.url</a></li>
<li><a href="modules/web_core.html">web_core</a></li>
</ul>
<h2>Manual</h2>
<ul class="nowrap">
@ -44,515 +43,64 @@
</ul>
<h2>Examples</h2>
<ul class="nowrap">
<li><a href="examples/demo.lua.html">demo.lua</a></li>
<li><a href="examples/jsonapi-demo.lua.html">jsonapi-demo.lua</a></li>
<li><a href="examples/urlapi-demo.lua.html">urlapi-demo.lua</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>netio</code></h1>
<p>Implements two of three available Web API's:</p>
<ul>
<li><a href="https://www.netio-products.com/files/download/sw/version/JSON---description-of-NETIO-M2M-API-interface_1-2-0.pdf">Protocol version: JSON API Version 2.0</a>(PDF)</li>
<li><a href="https://www.netio-products.com/files/download/sw/version/URL-API---description-of-NETIO-M2M-API-interface---PDF_1-1-0.pdf">Protocol version: URL API Version 1.0</a>(PDF)</li>
</ul>
<pre>
<span class="keyword">local</span> Netio = <span class="global">require</span>(<span class="string">'netio'</span>)
<span class="keyword">local</span> netio1 = Netio.new({
url = <span class="string">'http://netio-4all.netio-products.com'</span>,
port = <span class="number">8080</span>,
user = <span class="string">'write'</span>,
pass = <span class="string">'demo'</span>,
api = <span class="string">'json'</span>
})
<span class="keyword">local</span> output1 = netio1:outputs_info(<span class="number">1</span>)
<span class="keyword">for</span> k, v <span class="keyword">in</span> <span class="global">pairs</span>(output1) <span class="keyword">do</span>
<span class="global">print</span>(k, v)
<span class="keyword">end</span>
</pre>
<h2>Lua module to control NETIO smart sockets over their M2M API's</h2>
<p> The <strong>URL API</strong> is write-only, so you can't read informations about the outputs etc with it.</p>
<p> You have to use the <strong>JSON API</strong> for that.</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#instance:outputs_action">instance:outputs_action (ids, action[, delay=5])</a></td>
<td class="summary">Perform actions on output's (<strong>JSON</strong>, <strong>URL</strong>)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#instance:outputs_off">instance:outputs_off (ids)</a></td>
<td class="summary">Switch outputs off (<strong>JSON</strong>, <strong>URL</strong>)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#instance:outputs_on">instance:outputs_on (ids)</a></td>
<td class="summary">Switch outputs on (<strong>JSON</strong>, <strong>URL</strong>)</td>
</tr>
<h2>Modules</h2>
<table class="module_list">
<tr>
<td class="name" nowrap><a href="#instance:outputs_shortoff">instance:outputs_shortoff (ids, delay)</a></td>
<td class="summary">Switch outputs off for a specific timeframe (<strong>JSON</strong>, <strong>URL</strong>)</td>
<td class="name" nowrap><a href="modules/netio.html">netio</a></td>
<td class="summary">lua-netio is a library to control outputs of NETIO 4x smart power sockets from NETIO products a.s.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#instance:outputs_shorton">instance:outputs_shorton (ids, delay)</a></td>
<td class="summary">Switch outputs on for a specific timeframe (<strong>JSON</strong>, <strong>URL</strong>)</td>
<td class="name" nowrap><a href="modules/netio.json.html">netio.json</a></td>
<td class="summary">Implements the JSON API: <a href="https://www.netio-products.com/files/download/sw/version/JSON---description-of-NETIO-M2M-API-interface_1-2-0.pdf">Protocol version: JSON API Version 2.0</a>(PDF)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#instance:outputs_toggle">instance:outputs_toggle (ids)</a></td>
<td class="summary">Invert the outputs state (<strong>JSON</strong>, <strong>URL</strong>)</td>
<td class="name" nowrap><a href="modules/netio.url.html">netio.url</a></td>
<td class="summary">Implements the URL API: <a href="https://www.netio-products.com/files/download/sw/version/URL-API---description-of-NETIO-M2M-API-interface---PDF_1-1-0.pdf">Protocol version: URL API Version 1.0</a>(PDF)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#instance:info">instance:info ()</a></td>
<td class="summary">Get all status informations from the device (<strong>JSON</strong>)</td>
<td class="name" nowrap><a href="modules/web_core.html">web_core</a></td>
<td class="summary">Some methods which are used in URL and JSON API</td>
</tr>
</table>
<h2>Manual</h2>
<table class="module_list">
<tr>
<td class="name" nowrap><a href="#instance:general_info">instance:general_info ()</a></td>
<td class="summary">Get device informations
like serial number, firmware version etc.</td>
<td class="name" nowrap><a href="manual/dstructures.md.html">dstructures.md</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="#instance:outputs_info">instance:outputs_info ([id])</a></td>
<td class="summary">Get output informations
about a specific or all outputs (<strong>JSON</strong>)</td>
<td class="name" nowrap><a href="manual/errors.md.html">errors.md</a></td>
<td class="summary"></td>
</tr>
</table>
<h2>Examples</h2>
<table class="module_list">
<tr>
<td class="name" nowrap><a href="#instance:measure_info">instance:measure_info ()</a></td>
<td class="summary">Get global metering informations
like voltage, frequency et cetera (<strong>JSON</strong>)</td>
<td class="name" nowrap><a href="examples/jsonapi-demo.lua.html">jsonapi-demo.lua</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="#new">new (opts)</a></td>
<td class="summary">Create new instance</td>
<td class="name" nowrap><a href="examples/urlapi-demo.lua.html">urlapi-demo.lua</a></td>
<td class="summary"></td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "instance:outputs_action"></a>
<strong>instance:outputs_action (ids, action[, delay=5])</strong>
</dt>
<dd>
Perform actions on output's (<strong>JSON</strong>, <strong>URL</strong>)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">ids</span>
<span class="types"><span class="type">int</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
The output ID where you want to perform the action. If you want to perform the same action on multiple outputs, the ID's have to be in a table
</li>
<li><span class="parameter">action</span>
<span class="types"><span class="type">int</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The action you want to perform (<strong>0</strong> or <strong>'off'</strong>, <strong>1</strong> or <strong>'on'</strong>, <strong>2</strong> or <strong>'soff'</strong>, <strong>3</strong> or <strong>'son'</strong>, <strong>4</strong> or <strong>'toggle'</strong>, <strong>5</strong> or <strong>'nochange'</strong>, <strong>6</strong> or <strong>'ignore'</strong>)
</li>
<li><span class="parameter">delay</span>
<span class="types"><span class="type">int</span></span>
Define delay for <strong>shorton</strong> and <strong>shortoff</strong> in seconds
(<em>default</em> 5)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a>, <span class="type">boolean</span> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Ouputs_table">Outputs table</a> (<strong>JSON</strong>) or <strong>true</strong> (<strong>URL</strong>)</li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="comment">-- possible usecases
</span><span class="keyword">local</span> resp = output_action(<span class="number">1</span>, <span class="number">2</span>, <span class="number">2</span>) <span class="comment">-- Switch off output 1 for 2 seconds
</span><span class="keyword">local</span> resp = output_action({<span class="number">1</span>, <span class="number">2</span>}, <span class="number">2</span>, <span class="number">2</span>) <span class="comment">-- Switch off output 1 and 2 for 2 seconds
</span><span class="keyword">local</span> resp = output_action({ {id=<span class="number">1</span>, action=<span class="number">2</span>, delay=<span class="number">2</span>}, {id=<span class="number">2</span>, action=<span class="number">2</span>}, {id=<span class="number">3</span>, action=<span class="number">4</span>} }) <span class="comment">-- Switch off ouput 1 for 2 seconds and output 2 for 5 (default if no value is given) and toggle output 3</span></pre>
</ul>
</dd>
<dt>
<a name = "instance:outputs_off"></a>
<strong>instance:outputs_off (ids)</strong>
</dt>
<dd>
Switch outputs off (<strong>JSON</strong>, <strong>URL</strong>)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">ids</span>
<span class="types"><span class="type">int</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Output ID/ID's
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a>, <span class="type">boolean</span> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Ouputs_table">Outputs table</a> (<strong>JSON</strong>) or <strong>true</strong> (<strong>URL</strong>)</li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> resp = netio1:output_off(<span class="number">1</span>)</pre>
</ul>
</dd>
<dt>
<a name = "instance:outputs_on"></a>
<strong>instance:outputs_on (ids)</strong>
</dt>
<dd>
Switch outputs on (<strong>JSON</strong>, <strong>URL</strong>)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">ids</span>
<span class="types"><span class="type">int</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Output ID/ID's
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a>, <span class="type">boolean</span> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Ouputs_table">Outputs table</a> (<strong>JSON</strong>) or <strong>true</strong> (<strong>URL</strong>)</li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> resp = netio1:output_on(<span class="number">1</span>)</pre>
</ul>
</dd>
<dt>
<a name = "instance:outputs_shortoff"></a>
<strong>instance:outputs_shortoff (ids, delay)</strong>
</dt>
<dd>
Switch outputs off for a specific timeframe (<strong>JSON</strong>, <strong>URL</strong>)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">ids</span>
<span class="types"><span class="type">int</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Output ID/ID's
</li>
<li><span class="parameter">delay</span>
<span class="types"><span class="type">int</span></span>
Delay between off and on in seconds
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a>, <span class="type">boolean</span> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Ouputs_table">Outputs table</a> (<strong>JSON</strong>) or <strong>true</strong> (<strong>URL</strong>)</li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> resp = netio1:output_shortoff(<span class="number">1</span>)</pre>
</ul>
</dd>
<dt>
<a name = "instance:outputs_shorton"></a>
<strong>instance:outputs_shorton (ids, delay)</strong>
</dt>
<dd>
Switch outputs on for a specific timeframe (<strong>JSON</strong>, <strong>URL</strong>)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">ids</span>
<span class="types"><span class="type">int</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Output ID/ID's
</li>
<li><span class="parameter">delay</span>
<span class="types"><span class="type">int</span></span>
Delay between on and off in seconds
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a>, <span class="type">boolean</span> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Ouputs_table">Outputs table</a> (<strong>JSON</strong>) or <strong>true</strong> (<strong>URL</strong>)</li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> resp = netio1:output_shorton(<span class="number">1</span>)</pre>
</ul>
</dd>
<dt>
<a name = "instance:outputs_toggle"></a>
<strong>instance:outputs_toggle (ids)</strong>
</dt>
<dd>
Invert the outputs state (<strong>JSON</strong>, <strong>URL</strong>)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">ids</span>
<span class="types"><span class="type">int</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Output ID/ID's
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a>, <span class="type">boolean</span> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Ouputs_table">Outputs table</a> (<strong>JSON</strong>) or <strong>true</strong> (<strong>URL</strong>)</li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> resp = netio1:output_toggle(<span class="number">1</span>)</pre>
</ul>
</dd>
<dt>
<a name = "instance:info"></a>
<strong>instance:info ()</strong>
</dt>
<dd>
Get all status informations from the device (<strong>JSON</strong>)
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Status_table">Status table</a></li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> info = netio1:info()</pre>
</ul>
</dd>
<dt>
<a name = "instance:general_info"></a>
<strong>instance:general_info ()</strong>
</dt>
<dd>
Get device informations
like serial number, firmware version etc. (<strong>JSON</strong>)
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Agent_table">Agent table</a></li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> info = netio1:general_info()</pre>
</ul>
</dd>
<dt>
<a name = "instance:outputs_info"></a>
<strong>instance:outputs_info ([id])</strong>
</dt>
<dd>
Get output informations
about a specific or all outputs (<strong>JSON</strong>)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">id</span>
<span class="types"><span class="type">int</span></span>
Output ID
(<em>optional</em>)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Ouputs_table">Outputs table</a></li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> outputs = netio1:output_info()
<span class="keyword">local</span> output1 = netio1:output_info(<span class="number">2</span>)</pre>
</ul>
</dd>
<dt>
<a name = "instance:measure_info"></a>
<strong>instance:measure_info ()</strong>
</dt>
<dd>
Get global metering informations
like voltage, frequency et cetera (<strong>JSON</strong>)
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#GlobalMeasure_table">GlobalMeasure table</a></li>
<li>
<span class="types"><span class="type">nil</span> or <a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
error message</li>
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> info = netio1:measure_info()</pre>
</ul>
</dd>
<dt>
<a name = "new"></a>
<strong>new (opts)</strong>
</dt>
<dd>
Create new instance
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">opts</span> options table with arguments
<ul>
<li><span class="parameter">url</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
URL of the netio you want to speak with
</li>
<li><span class="parameter">port</span>
<span class="types"><span class="type">int</span></span>
Additional port (can also be written directly into the URL)
(<em>optional</em>)
</li>
<li><span class="parameter">user</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Name of the user, who has the right to read and/or write to the API
(<em>optional</em>)
</li>
<li><span class="parameter">pass</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The password of the user
(<em>optional</em>)
</li>
<li><span class="parameter">api</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
specify which API should be used (<strong>json</strong> or <strong>url</strong>)
(<em>default</em> 'url')
</li>
</li></ul>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">object</span></span>
Instance table
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> Netio = <span class="global">require</span>(<span class="string">'netio'</span>)
<span class="keyword">local</span> socket_url_api = Netio.new({
url = <span class="string">'http://netio.de'</span>,
pass = <span class="string">'demo'</span>
})
<span class="keyword">local</span> socket_json_api = Netio.new({
url = <span class="string">'http://netio.de'</span>,
user = <span class="string">'demo'</span>,
pass = <span class="string">'demo'</span>,
api = <span class="string">'json'</span>
})</pre>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-10-16 16:13:11 </i>
<i style="float:right;">Last updated 2018-10-17 11:41:24 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

13
docs/manual/dstructures.md.html

@ -26,6 +26,9 @@
<br/>
<h1>lua-netio-api</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
@ -43,11 +46,15 @@
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../index.html">netio</a></li>
<li><a href="../modules/netio.html">netio</a></li>
<li><a href="../modules/netio.json.html">netio.json</a></li>
<li><a href="../modules/netio.url.html">netio.url</a></li>
<li><a href="../modules/web_core.html">web_core</a></li>
</ul>
<h2>Examples</h2>
<ul class="nowrap">
<li><a href="../examples/demo.lua.html">demo.lua</a></li>
<li><a href="../examples/jsonapi-demo.lua.html">jsonapi-demo.lua</a></li>
<li><a href="../examples/urlapi-demo.lua.html">urlapi-demo.lua</a></li>
</ul>
</div>
@ -247,7 +254,7 @@ informations which the API provides.</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-10-16 16:13:11 </i>
<i style="float:right;">Last updated 2018-10-17 11:41:24 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

13
docs/manual/errors.md.html

@ -26,6 +26,9 @@
<br/>
<h1>lua-netio-api</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
@ -36,11 +39,15 @@
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../index.html">netio</a></li>
<li><a href="../modules/netio.html">netio</a></li>
<li><a href="../modules/netio.json.html">netio.json</a></li>
<li><a href="../modules/netio.url.html">netio.url</a></li>
<li><a href="../modules/web_core.html">web_core</a></li>
</ul>
<h2>Examples</h2>
<ul class="nowrap">
<li><a href="../examples/demo.lua.html">demo.lua</a></li>
<li><a href="../examples/jsonapi-demo.lua.html">jsonapi-demo.lua</a></li>
<li><a href="../examples/urlapi-demo.lua.html">urlapi-demo.lua</a></li>
</ul>
</div>
@ -67,7 +74,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-10-16 16:13:11 </i>
<i style="float:right;">Last updated 2018-10-17 11:41:24 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

159
docs/modules/netio.html

@ -0,0 +1,159 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>lua-netio-api documentation</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>lua-netio-api</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><strong>netio</strong></li>
<li><a href="../modules/netio.json.html">netio.json</a></li>
<li><a href="../modules/netio.url.html">netio.url</a></li>
<li><a href="../modules/web_core.html">web_core</a></li>
</ul>
<h2>Manual</h2>
<ul class="nowrap">
<li><a href="../manual/dstructures.md.html">Returend data structures</a></li>
<li><a href="../manual/errors.md.html">Errors</a></li>
</ul>
<h2>Examples</h2>
<ul class="nowrap">
<li><a href="../examples/jsonapi-demo.lua.html">jsonapi-demo.lua</a></li>
<li><a href="../examples/urlapi-demo.lua.html">urlapi-demo.lua</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>netio</code></h1>
<p>lua-netio is a library to control outputs of NETIO 4x smart power sockets from NETIO products a.s.</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#new">new (opts)</a></td>
<td class="summary">Create new instance.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "new"></a>
<strong>new (opts)</strong>
</dt>
<dd>
Create new instance.
It invokes the new() function of the submodule, specified via <strong>opts.api</strong>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">opts</span> options table with arguments
<ul>
<li><span class="parameter">url</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
URL or IP of the Netio socket you want to speak with
</li>
<li><span class="parameter">port</span>
<span class="types"><span class="type">int</span></span>
Additional port (can also be written directly into the URL)
(<em>optional</em>)
</li>
<li><span class="parameter">user</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Name of the user, who has the right to read and/or write to the API
(<em>optional</em>)
</li>
<li><span class="parameter">pass</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The password of the user
(<em>optional</em>)
</li>
<li><span class="parameter">api</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
specify which API should be used (<strong>json</strong> or <strong>url</strong>)
(<em>default</em> 'url')
</li>
</li></ul>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">object</span></span>
Instance table
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> Netio = <span class="global">require</span>(<span class="string">'netio'</span>)
<span class="keyword">local</span> socket_url_api = Netio.new({
url = <span class="string">'http://netio.de'</span>,
pass = <span class="string">'demo'</span>
})
<span class="keyword">local</span> socket_json_api = Netio.new({
url = <span class="string">'http://netio.de'</span>,
user = <span class="string">'demo'</span>,
pass = <span class="string">'demo'</span>,
api = <span class="string">'json'</span>
})</pre>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-10-17 11:41:24 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

288
docs/modules/netio.json.html

@ -0,0 +1,288 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>lua-netio-api documentation</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>lua-netio-api</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/netio.html">netio</a></li>
<li><strong>netio.json</strong></li>
<li><a href="../modules/netio.url.html">netio.url</a></li>
<li><a href="../modules/web_core.html">web_core</a></li>
</ul>
<h2>Manual</h2>
<ul class="nowrap">
<li><a href="../manual/dstructures.md.html">Returend data structures</a></li>
<li><a href="../manual/errors.md.html">Errors</a></li>
</ul>
<h2>Examples</h2>
<ul class="nowrap">
<li><a href="../examples/jsonapi-demo.lua.html">jsonapi-demo.lua</a></li>
<li><a href="../examples/urlapi-demo.lua.html">urlapi-demo.lua</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>netio.json</code></h1>
<p>Implements the JSON API: <a href="https://www.netio-products.com/files/download/sw/version/JSON---description-of-NETIO-M2M-API-interface_1-2-0.pdf">Protocol version: JSON API Version 2.0</a>(PDF)</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#instance:info">instance:info ()</a></td>
<td class="summary">Get all status informations from the device</td>
</tr>
<tr>
<td class="name" nowrap><a href="#instance:general_info">instance:general_info ()</a></td>
<td class="summary">Get device informations
like serial number, firmware version etc.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#instance:outputs_info">instance:outputs_info ([id])</a></td>
<td class="summary">Get output informations
about a specific or all outputs</td>
</tr>
<tr>
<td class="name" nowrap><a href="#instance:measure_info">instance:measure_info ()</a></td>
<td class="summary">Get global metering informations
like voltage, frequency et cetera</td>
</tr>
<tr>
<td class="name" nowrap><a href="#new">new (opts)</a></td>
<td class="summary">Creates new instance.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "instance:info"></a>
<strong>instance:info ()</strong>
</dt>
<dd>
Get all status informations from the device
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a> or <span class="type">nil</span></span>
<a href="../manual/dstructures.md.html#Status_table">Status table</a></li>
<li>
<span class="types"><span class="type">nil</span> or <a class=