Here is an Example for Modbus Driver.
The Modbus structure is not an "event based". It sends the value from each Feedback to iRidium each second, so the TAG_CHANGE_EVENT fires every time for the same value. It is not good when you use TAG_CHANGE_EVENT to make some action like Show Popup when the channel goes to 1 (popup showed every second in this case).

You can use an additional condition which triggering channel only ones, when it changes value from X to Y.

Example: "Show Popup when the Modbus Feedback = 1"

var reject = 0; // it locks the condition when the value not really changes

IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("Modbus (TCP)"), function(name,value)
{
   if  (name == "Feedback 1" && value == 0) // feedback changes from 1 to 0
   {
      reject = 0; 
   }

  else if (name == "Command 2" && value == 1 && reject == 0) // feedback changes from 0 to 1 or it stays 1 for some time
  {
      IR.ShowPopup('Popup 1');
      reject = 1;
  }
});

OpenPopupOnChange.irpz

This article was helpful for 1 person. Is this article helpful for you?