0
Answered

Periodic Actions Server

Paolo Scarpetta 7 years ago in Server Solutions / Windows Server updated by Aleksandr Romanov (CTO) 7 years ago 6

I need to configurate Periodic Actions on Iridium Server, I saw a post but have some syntaxis error on it,

This is the post:

Periodic actions

To perform an action every day at some particular time (with the possibility to edit the time), it is required to create the script on the server.

Example 1: the simplest timer doesn't have a settings on client side. We are creating the list of needed timers on server, it is not possible to see the list of this timers on Client side or set the running time

// if your another JS files includes  "IR.SetGlobalListener()"  
// you have to add the code inside of previous IR.SetGlobalListener() and delete the listener from this file!
// if you are not sure that you are able to do it yourself please contact to support@iridiummobile.ru
IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function (name, value)
{
   if (name == "System.Time.Minutes")
   {
      // SET UP PERIODICAL ACTIONS:
      // start hour, start minute, duration of process (ms), channel full name, start value, stop value 
      // if you don't want to stop process, add "no" instead of stop value 
      check_timer (10, 45, 60000, "Server.Channels.KNX Router (KNXnet/IP).Pump 1", 1, 0);             // timer 1 
      check_timer (14, 30, 480000, "Server.Channels.KNX Router (KNXnet/IP).Pump 2", 1, "no");         // timer 2
                                                                                                      // you can add more
   } 
 
   // do not edit the other part, you need only to add the needed timers in above  
   function check_timer (hours, minutes, duration, channel, start_value, stop_value)
   {
      if (IR.GetVariable("System.Time.Hour") == hours && IR.GetVariable("System.Time.Minutes") == minutes) 
      { 
         function stop () 
         {
            IR.GetServer().Set(channel, stop_value);
            IR.Log("process at +"hours+":"+minutes+" stopped");
         }
         IR.GetServer().Set(channel, start_value);
         IR.Log("process at +"hours+":"+minutes+" started");
         if (stop_value != "no") 
         {
            IR.SetTimeout(duration, stop);
         }
      }
   }
});
 
IR.SubscribeTagChange("System.Time.Minutes");

//*NOTE: I just change the time and the name of my Channels, but didn´t work.
The name of my KNX Router is: KNX IP Router
And the channel is: Pergola0
Answered

Right, there was an error in script


// if your another JS files includes  "IR.SetGlobalListener()"  
// you have to add the code inside of previous IR.SetGlobalListener() and delete the listener from this file!
// if you are not sure that you are able to do it yourself please contact to support@iridiummobile.ru
IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function (name, value)
{
   if (name == "System.Time.Minutes")
   {
      // SET UP PERIODICAL ACTIONS:
      // start hour, start minute, duration of process (ms), channel full name, start value, stop value 
      // if you don't want to stop process, add "no" instead of stop value 
      check_timer (13, 55, 60000, "Server.Channels.KNX Router (KNXnet/IP).Pump 1", 1, 0);             // timer 1 
      check_timer (14, 30, 480000, "Server.Channels.KNX Router (KNXnet/IP).Pump 2", 1, "no");         // timer 2
                                                                                                      // you can add more
   } 
 
   // do not edit the other part, you need only to add the needed timers in above  
   function check_timer (hours, minutes, duration, channel, start_value, stop_value)
   {
      if (IR.GetVariable("System.Time.Hour") == hours && IR.GetVariable("System.Time.Minutes") == minutes) 
      { 
         function stop () 
         {
            IR.GetServer().Set(channel, stop_value);
            IR.Log("process at "+hours+":"+minutes+" stopped");
         }
         IR.GetServer().Set(channel, start_value);
         IR.Log("process at "+hours+":"+minutes+" started");
         if (stop_value != "no") 
         {
            IR.SetTimeout(duration, stop);
         }
      }
   }
});
 
IR.SubscribeTagChange("System.Time.Minutes");

With this correction the timer act well at the desired time but my relay didn´t work.

Maybe the reason is in the command settings, we can check if you send a project to support@iridiummobile.ru

But we have released a Schedulers for iRIdium Server that u can use without JS, please try:
http://dev.iridiummobile.net/Editor_Server_Tools/en#Schedule

http://dev.iridiummobile.net/Editor_Server_Tools/en#Routine

My Iridium Studio doesn´t has thats tools, I has the Version 1.0.8 (Is that the news one?)

Last version iRidium Setup is 1.1.2.479. Please update.