Examples of using iRidium API methods and functions
Language version: 1.5
Specification: ECMAScript Edition 3
Report an error
Examples of creating and editing driver settings with the help of iRidium API
Custom Server on the basis of the AV & Custom Systems driver can take client connections on the basis of AV & Custom Systems and third-party applications. It can also process data sent by the client and send commands to it.
Remember, the server launched in the i3 pro application works only until the application is launched and the server cannot store the database as the iRidium Server specialized solution.
Use of "the server on a client" is very limited. It can be used only for synchronization of some data between control panels, when installation of iRidium Server is not possible for some reason.
// TCP server on port 5678
// name, port, max connections
var name = server_name;
var port = 5678;
var max_clients = 10;
var tcp_device = IR.CreateDevice(IR.DEVICE_CUSTOM_SERVER_TCP, name, "", port, max_clients);
// start server
// inform when the server online
IR.AddListener(IR.EVENT_ONLINE, tcp_device, function(text)
IR.Log("Server is ONLINE");
// register connected client
IR.AddListener(IR.EVENT_ACCEPT, tcp_device, function(id)
IR.Log(tcp_device + " ACCEPT CLIENT "+id);
// process received data
IR.AddListener(IR.EVENT_RECEIVE_TEXT, tcp_device, function(text)
//IR.Log("INPUT DATA: "+text);
var strings = text.split('\r\n');
while(string = strings.shift())
var parts = string.split(":"); // parse the string with ":" devider
case "LOG": // if the first substring of received data = "LOG"
IR.GetItem("Page 1").GetItem("Item 1").GetState(0).Text = IR.GetVariable("System.Time.24")+" "+parts;
case "ERROR": // if the first substring = "ERROR"
IR.GetItem("Page 1").GetItem("Item 2").GetState(0).Text = IR.GetVariable("System.Time.24")+" "+parts;
case "DATABASE": // if the first substring = "DATABASE"
// start the server when project starts
start_tcp_server("Custom Server TCP");
Examples of controlling properties of pages, popups and graphic items with the help of iRidium API
The tweener specifies the variable value in the indicated segment calculated by some formula. It allows you to create animation with object movements on a particular segment of the indicated curve.
The tweener can be used for the gradual appearance of a popup from the screen side. Use the linear tweener for the popup to move straightforward.
TopTween("Popup 1", 820, 34, 250); // popup, X, Y, moving range from Top
// Creating Effects
var timer = 0;
var speed = 20; // showing speed
function TopTween(popup, X, Y, range)
IR.GetItem(popup).X = X;
var Tm = IR.SetInterval(1, function()
var Tween = IR.Tween("TWEEN_LINEAR", timer, 0, range, speed);
IR.GetItem(popup).Y = Y+Tween;
if (timer > speed) IR.ClearInterval(Tm); timer = 0;
You can set the font or change the font size for the item via the .FontId state property.
FontId - the font identifier. It stores the pointer to the font and the font size. You cannot change the font size separately.
Create a new font and assign it to the item state via FontId. For creation of new fonts it is important to use the identifiers which have not been used in the project (the editor creates its own system fonts using identifiers beginning with 1). For getting free id, your should use js method IR.FreeFontID
Indicate which font file must be used as a basis, what size must be set up. Assign a font identifier not used in the project before:
var Font=IR.FreeFontID; //Get free font ID
IR.CreateFont(Font, "tahoma.ttf", IR.GetItem("Страница 1").GetState(0).FontSize+10);//Create new font with new size and id
IR.GetItem("Страница 1").GetState(0).FontId=Font;//Set new font to the state
Sending of Push notifications to control panels. The notifications are sent by the server (there are no any other possibility to do it in v1.0.10).
1 "'Create groups of control panels"'
By default, none of control panels will receive Push notifications until you place it in the Group of panels that can get Push notifications.
The groups are set up on the web site, see the instructions.
Each group has an ID and name. That is the group ID you will use when indicating which panels have to get notifications.
2 "'Set up the script for sending notifications from the server"'
In the server project create a new script file. Add the condition for notification sending and the command for sending Push notifications in it. The condition for sending Push notifications can be change of any server variable - associated with the driver or a virtual one.
Example: send a notification when channel "Address 1" of the "KNX" driver takes value 1. The notification will be received by the group panels with ID = 1.
function sendPush (text, group)
IR.SendPush(text, "", group);
// text - message that will be displayed in notification
// group - group of Panels seted up in Cloud Object properties on iRidium Mobile web site
IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("KNX"), function(name, value)
if (name == "Address 1" && value == 1)
sendPush("Leakage in the kitchen! The water supply is turned off", 1);
No additional settings and scripts are required on the control panel with i3 pro. The panel will get notifications if it is in the specified group.