Module web_core
Some methods which are used in URL and JSON API
Functions
instance:outputs_action (ids, action[, delay=5]) | Perform actions on output's |
instance:outputs_off (ids) | Switch outputs off |
instance:outputs_on (ids) | Switch outputs on |
instance:outputs_shortoff (ids, delay) | Switch outputs off for a specific timeframe |
instance:outputs_shorton (ids, delay) | Switch outputs on for a specific timeframe |
instance:outputs_toggle (ids) | Invert the outputs state |
Functions
- instance:outputs_action (ids, action[, delay=5])
-
Perform actions on output's
Parameters:
- ids int or table 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
- action int or string The action you want to perform (0 or 'off', 1 or 'on', 2 or 'soff', 3 or 'son', 4 or 'toggle', 5 or 'nochange', 6 or 'ignore')
- delay int Define delay for shorton and shortoff in seconds (default 5)
Returns:
- table, boolean or nil Outputs table (JSON) or true (URL)
- nil or string error message
Usage:
-- possible usecases local resp = output_action(1, 2, 2) -- Switch off output 1 for 2 seconds local resp = output_action({1, 2}, 2, 2) -- Switch off output 1 and 2 for 2 seconds local resp = output_action({ {id=1, action=2, delay=2}, {id=2, action=2}, {id=3, action=4} }) -- Switch off ouput 1 for 2 seconds and output 2 for 5 (default if no value is given) and toggle output 3
- instance:outputs_off (ids)
-
Switch outputs off
Parameters:
- ids int or table Output ID/ID's
Returns:
- table, boolean or nil Outputs table (JSON) or true (URL)
- nil or string error message
Usage:
local resp = netio1:output_off(1)
- instance:outputs_on (ids)
-
Switch outputs on
Parameters:
- ids int or table Output ID/ID's
Returns:
- table, boolean or nil Outputs table (JSON) or true (URL)
- nil or string error message
Usage:
local resp = netio1:output_on(1)
- instance:outputs_shortoff (ids, delay)
-
Switch outputs off for a specific timeframe
Parameters:
- ids int or table Output ID/ID's
- delay int Delay between off and on in seconds
Returns:
- table, boolean or nil Outputs table (JSON) or true (URL)
- nil or string error message
Usage:
local resp = netio1:output_shortoff(1)
- instance:outputs_shorton (ids, delay)
-
Switch outputs on for a specific timeframe
Parameters:
- ids int or table Output ID/ID's
- delay int Delay between on and off in seconds
Returns:
- table, boolean or nil Outputs table (JSON) or true (URL)
- nil or string error message
Usage:
local resp = netio1:output_shorton(1)
- instance:outputs_toggle (ids)
-
Invert the outputs state
Parameters:
- ids int or table Output ID/ID's
Returns:
- table, boolean or nil Outputs table (JSON) or true (URL)
- nil or string error message
Usage:
local resp = netio1:output_toggle(1)