05.12.2022, 13:33
webrequest library (experimental) allows making configurator web requests from Lua scripts. This library is meant for advanced users as it's possible to break some parts of the system by making a request with missing or incorrect variables. You can use browser developer tools (F12) to inspect network requests that are sent to the UI to figure out the correct function arguments.
General usage:
General usage:
Code:
webrequest = require('webrequest')
res, err = webrequest(mod, act, vars)
- mod (string, required) - requested module name
- act (string, required) - requested action name
- vars (table, optional) - request argument variables
Code:
-- create a backup
-- data variable contains backup (ZIP) contents as a binary string
webrequest = require('webrequest')
data = webrequest('general', 'backup')
Code:
-- toggle scheduler ID 1 status (active/inactive)
webrequest = require('webrequest')
vars = {
data = { id = 1 }
}
webrequest('schedulers', 'status', vars)
Code:
-- get a list of modbus device profiles
webrequest = require('webrequest')
vars = {
plugin = 'modbus',
request = 'profile-list'
}
res = webrequest('general', 'plugin', vars)
log(res)