Asynchronous Lua scripts#
myGPIOd reads on startup the folder defined by lua_async_dir. Each file with the extension .lua is loaded and registered as Lua file.
This files can be called with the lua_async action.
Note
These Lua scripts are executed in a new thread and therefore do not have access to data structures from the main thread. Use this type of scripts for longer running actions.
Custom lua functions#
myGPIOd registers custom lua functions to provide access to the actions. The functions return true on success, else false as first value.
Lua function |
Description |
|---|---|
|
Toggle the value of the GPIO in given timeout and interval. |
|
Returns the GPIO state:
|
|
Sets the state of an output GPIO. |
|
Toggles the state of an output GPIO. |
|
Submits a HTTP request and waits for the response.
Set |
|
Returns the current value of tracked input event. |
|
Runs a mpd protocol command and returns the output. |
|
Calls the myGPIOd api to execute a script and waits for the response. |
|
Executes an executable or script and returns the output. |
Example lua file#
local rc, resp_header, resp_body = http("GET", "http://test.lan/", nil, nil)
print(resp_body)