0
Completed

Trigger with memory which sets up the last value of the variable

Ekaterina (head of support) 10 years ago in iRidium Script / AV and Driver scripts updated 9 years ago 1
The trigggers, which switch from 0 to their previous state, are frequently used for implementation of the Mute button and light control together with the main control item - Level. Triggers with memory alow you to get back to the last state used, not the default value of a standard trigger.

To creat a trigger with memory use the script used in the example of the project below:

KNX_SmartTrigger.irpz

The script works with any driver, not KNX only.
In order for it to work, set up connection with equipment, commands, channels, and buttons which will work as "smart" triggers. 

Such button has to be of the Button type and have feedback channel from the controlled address assigned to it to display the actual state. 

Then open the script editor - [JS] and create description of all "smart" triggers the same way it's done in the example.

For each trigger describe the following:
  • the name of the controlled driver 
  • the address where the trigger sends data (the command name, where the data is sent and the feedback channel name have to be the same in the driver settings)
  • the path to the trigger (page, item name)
  • the value for the trigger to "remember" by default. It is required at the project launch. If at launch the variable = 0, then the will be set up when clicking this value.
The trigger instance in the script file looks as follows:
trigger(IR.GetDevice("KNX Router (KNXnet/IP)"),    // driver          	
"Address 1",                               // KNX address (Command = Feedback) 
IR.GetItem("Page 1").GetItem("Item 2"),    // Trigger Button           	
50)                                        // the trigger value by default 
To create another trigger, copy only this block of data and change the necessary parameters - the item address, the KNX address, the driver name. The rest of the script file has to be left unchanged.