Adding a List Parameter to a Profile Using Lua
  • 04 Oct 2024
  • PDF

Adding a List Parameter to a Profile Using Lua

  • PDF

Article summary

ASCII configuration files can be designed flexibly and with dependencies by using the Lua scripting language within them.

Situation

A parameter is to be added to an existing profile using an ASCII configuration file containing a Lua script.

Solution

The problem when adding a list parameter to an existing configuration list is that it is necessary to know the number of already existing list entries if another parameter references to this parameter. If the number is unknown or the ASCII configuration is to be applied to different routers with a differing number of list entries, this can be solved using a Lua script to determine the number of existing list entries. We use the example of the Configuration Guide Dual Connection Check with Ping and Triggering an Action to show how to do this. This example uses an ASCII configuration file to add a timer and an event that uses this timer. To use this timer, the event must know the number of it.

Refer to the Lua 5.3 Reference Manual for more information about Lua.

Preparation of the ASCII configuration file

We’ve prepared the following ASCII configuration file for adding the timer and event of above example. Copy and paste it to your text editor or download it using the link below.

The ASCII configuration file will add a timer to an already existing list of timers using the function [last]. Then, an action will be added that uses this timer as a triggering event.

ASCII configuration file

events.timer.timer.add
events.timer.timer[last].active=1
events.timer.timer[last].description=Timer for dual ping check with Lua
events.timer.timer[last].type=interval
events.timer.timer[last].interval_hh=00
events.timer.timer[last].interval_mm=10

events.event_config.event.add
events.event_config.event[last].active=1
events.event_config.event[last].description=Dual ping check with Lua
events.event_config.event[last].event_type=ev_timer
-----LUA-----
cli("events.event_config.event[last].event_timer_name=timer"..cli("events.timer.timer.size").."")
-----LUA-----
events.event_config.event[last].event_action_type=act_ascii
events.event_config.event[last].event_action_ascii=CG_m3_lua_connection_check_script.txt

administration.profiles.activate

A short Lua script is used to determine the size of the timer list and use it to compose the timer name of the added timer. The double dots .. connect the first string events.event_config.event[last].event_timer_name=timer with the result returned from events.timer.timer.size and a last, empty string to form the whole command:

Lua script from ASCII configuration file

-----LUA-----
cli("events.event_config.event[last].event_timer_name=timer"..cli("events.timer.timer.size").."")
-----LUA-----

Router configuration

It is prerequisite that you have access to the web interface of the router.

  1. Open the user interface of the router: https://insys.icom

  2. Click in the AdministrationProfile menu in the ASCII configuration section on , select the Lua script just downloaded and click on SUBMIT.

  3. In order to apply an ASCII configuration file, click in the row of the configuration file (not the Lua script), then on Apply ASCII configuration and on APPLY ASCII CONFIGURATION.

This will add the timer and the event to your profile.

Result testing

  1. Change to the update EventsTimer menu to see the timer that has been added at the end of the list.

  2. Change to the update EventsEvents menu to see the event that has been added at the end of the list and open this event for editing () to see that above timer is used to trigger the event.


Was this article helpful?