This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Lua webrequest library (FW 2022 and later)
#1
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:
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)
Reply


Messages In This Thread
Lua webrequest library (FW 2022 and later) - by admin - 05.12.2022, 13:33

Forum Jump: