Writing and Reading Server Variables from JS

Server variables are Driver Tokens, Channels, Tags, as well as Virtual Channels and Virtual Tags. They can be changed and requested from control panels (send command, display feedback) and from script, located on the Server.



Server Variables are available for writing and reading with the help of the following systems IR.GetVariable(name) and IR.SetVariable(name, value) in Server script.



Server Variables for control panels look like commands and channels on any other driver. That's why API iRidium. Drivers methods can be used for them.



Writing value to the variable



1. Copy the full name of a variable from IRIDIUM SERVERtab.
2. Use IR.SetVariable method to write a value to the variable:




Constructor



IR.SetVariable(<span style="color: rgb(79, 129, 189);">"Server.Path.Name"</span>, value) OR IR.SetVariable(<span style="color: rgb(79, 129, 189);">"Server.Path.DriverName.Name"</span>, value)

At the inputValue Description
Server.Path.NameServer.Channels.Virtual 1type: string.
Full name of server variable
Server.Path.DriverName.NameServer.Channels.KNX.Dimmertype: string
Full name driver variable
Value100type: string, number, boolean
Value to write to the server variable
At the ouput
successtrueтип: boolean
successful writing

For example



SetVirtualvarJS.png
IR.AddListener(IR.EVENT_START, 0, function(){
    IR.SetVariable("Server.Channels.Virtual 1", 100);
});
                
Method can be applied to server channels and server tags.



IR.AddListener(IR.EVENT_START, 0, function()
{
    IR.SetVariable("Server.Channels.KNX.Dimmer", 100);
});


Read variable value



1. Copy the full name of a variable from IRIDIUM SERVERtab.
2. Use IR.SetVariable method to read a value to the variable: :




Constructor



IR.GetVariable(<span style="color: rgb(79, 129, 189);">"Server.Path.Name"</span>) or IR.GetVariable(<span style="color: rgb(79, 129, 189);">"Server.Path.DriverName.Name"</span>)

At the inputValue Description
Server.Path.NameServer.Channels.Virtual 1Type: string
Full name of server variable
Server.Path.DriverName.NameServer.Channels.KNX.DimmerType: string
Full name of driver variable
At the ouput
value100Type: string, number, boolean
value of server variable

For example



SetVirtualvarJS.png
IR.AddListener(IR.EVENT_START, 0, function(){
    IR.GetVariable("Server.Channels.Virtual 1");
});
Method can be applied to server channels and server tag
<img src="/s/attachments/15553/6/6264/7378ae4d008d7f713a563b990d29a74e.png">

IR.AddListener(IR.EVENT_START, 0, function(){
    IR.GetVariable("Server.Channels.KNX.Dimmer");
});

This article was helpful for 5 people. Is this article helpful for you?