Difference between revisions of "Rules Complete Examples"

From wiki.netio-products.com
Jump to navigation Jump to search
(CRXXX - Negative load)
 
(59 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Example for PAB - RANGE ==
+
The concept of NETIO Conditions (PAB & WatchDog) & Rules is a set of prepared detections (Conditions) and Rules that act upon them. They are implemented directly in NETIO PDU devices.
The setting described below is intended to monitor a device connected to first output. The device is expected to have a certain load between 100W and 500W during working hours. If the consumption is too low or too high (i.e. outside the specified interval) for more than 10s, it is likely that the device works incorrectly and restart is needed to correct its state.
+
 
 +
== CR01 - WatchDog (ping) to 1 IP address | default in FW 3.2.3 ==
 +
The WatchDog functionality is used to monitor connectivity to specified IP address (or URL) by sending PING request to it.
 +
 
 +
The ping in this example is sent every 60s and waits 5s for the device to respond. If the ping fails, Watchdog returns <code>false</code> and restarts (ACTION: 2 = SHORT OFF) device connected to first output. After restart, it waits 120 seconds and starts monitoring again. If the device does not respond, WatchDog remains in ERROR state until next successful ping.
 +
 
 +
===WatchDog definition===
 +
 
 +
WatchDog name: '''CR01_WDT'''
 +
 
 +
<nowiki>
 +
{
 +
  "target": "192.168.1.5",
 +
  "pingInterval": 60,
 +
  "timeout": 5,
 +
  "maxTimeouts": 0,
 +
  "timeToReboot": 120,
 +
  "maxRestarts": -1
 +
}</nowiki>
 +
 
 +
===Rule definition===
 +
 +
Rule name: '''CR01_RULE'''
 +
 
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "WDT/CR01_WDT/FAIL": true
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 2
 +
  }
 +
}</nowiki>
 +
 
 +
== CR02 - Digital Inputs  (Push button to Toggle Outputs 1 and 2) | default in FW 3.2.3 ==
 +
 
 +
Rule is used for managing outputs in response to change of Digital Inputs (DI) state. Rule monitors state of first DI. When DI switches from OFF (0) to ON (1), Rule switches (toggles) Outputs 1 & 2 to their opposite states (ACTION 4 = TOGGLE).
 +
 
 +
===Rule definition===
 +
 
 +
Rule name: '''CR02_RULE'''
 +
 
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "INPUTS/1/STATE": "on"
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 4,
 +
    "OUTPUTS/2/ACTION": 4
 +
  }
 +
}</nowiki>
 +
 
 +
== CR03 - Load Watchdog (Restart device if it's more than 2 minutes in IDLE mode) | default in FW 3.2.3 ==
 +
Rule monitors load (Watts) on Output 1. If the load is between 1-20W for at least 2 minutes, it restarts (ACTION 2 = SHORT OFF) the output.
 +
Example uses PAB (Power Analysis Block) functionality to determine if measured value (load in our case) lies in given range for a period of time. When it does, defined Rule triggers device restart.
  
 
===PAB definition===
 
===PAB definition===
  
PAB name: '''Watch_out1_load'''
+
PAB name: '''CR03_PAB'''
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "type": "RANGE",
 
   "type": "RANGE",
 
   "source": "OUTPUTS/1/LOAD",
 
   "source": "OUTPUTS/1/LOAD",
   "lowerBound": 100,
+
   "lowerBound": 1,
   "upperBound": 500,
+
   "upperBound": 20,
   "timeHysteresis": 10
+
   "timeHysteresis": 120
 
}</nowiki>
 
}</nowiki>
  
===Rules definition===
+
===Rule definition===
  
''Note: We use the Schedules functionality in the filter to define working hours of the week. The device monitoring will only work at time set in the Schedule.
+
Rule name: '''CR03_RULE'''
 
 
Schedule name: '''Working_hours'''
 
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/Watch_out1_load/IN": 0
+
     "PAB/CR03_PAB/IN": true
  },
 
  "filters": {
 
    "SCHEDULE/Working_hours/ACTIVE": true
 
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 33: Line 83:
 
}</nowiki>
 
}</nowiki>
  
== Example for PAB - RANGE (multiple actions for one condition) ==
+
== CR04 - Load Watchdog with alarm to Cloud ==
Defined condition checks a device connected to output 4. The device is expected to have a maximum load of 600W. If the load is too high, we want to immediately turn off the device and send an alarm to Cloud.
+
Rule monitors load (Watts) on Output 1. If the load is between 1-20W for at least 30 minutes, it restarts (ACTION 2 = SHORT OFF) the output. In addition, it triggers an alarm in NETIO Cloud, which sends a notification to specified email address.
 +
This example needs a NETIO Cloud account with Premium version active for first output. There also has to be email notification enabled for the output.
 +
 
 +
Example uses PAB (Power Analysis Block) functionality to determine if measured value (load in our case) lies in given range for a period of time. When it does, defined Rule triggers device restart and sends alarm to Cloud.
  
 
===PAB definition===
 
===PAB definition===
  
PAB name: '''Watch_out4_load'''
+
PAB name: '''CR04_PAB'''
 
    
 
    
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "type": "RANGE",
 
   "type": "RANGE",
   "source": "OUTPUTS/4/LOAD",
+
   "source": "OUTPUTS/1/LOAD",
   "lowerBound": 0,
+
   "lowerBound": 1,
   "upperBound": 600
+
   "upperBound": 20,
 +
  "timeHysteresis": 1800
 
}</nowiki>
 
}</nowiki>
  
  
===Action definition===
+
===Rule definition===
 +
 
 +
Rule name: '''CR04_RULE'''
 +
 
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/Watch_out4_load/IN": 0
+
     "PAB/CR04_PAB/IN": true
   }
+
   },
 
   "actions": {
 
   "actions": {
     "OUTPUTS/4/ACTION": 0,
+
     "OUTPUTS/1/ACTION": 2,
 
     "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
 
     "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
 
   }
 
   }
 
}</nowiki>
 
}</nowiki>
  
== Example for PAB - ZONES ==
+
== CR05 - Load Watchdog with zones (indicate OFF / IDLE / RUN mode by switched on output)==
In this condition, the value of current at the output 2 is monitored. It is then classified to respective zone according to measured value. Depending on the zone in which is classified, different actions can be triggered:
+
Rule monitors load (Watts) on Output 1. Measured load is then classified to several zones defined with thresholds (limit values). Depending on the zone in which the measured load is currently located, different actions can be triggered. Load value has to be between defined threshold for at least 10seconds in order to be placed to respective zone.
* If the value of current is in zone 0, restart device on output 1
+
Example is composed of one PAB that classifies the zones and three Rules for 3 separate actions. Actions do the following:
* If the value of current is in zone 2, turn ON alarm in Cloud
+
* Output 1 load lower than 1W: Output 2 = ON
 +
* Output 1 load between 1-20W: Output 3 = ON
 +
* Output 1 load between 20-200W: Output 4 = ON
  
 
===PAB definition===
 
===PAB definition===
  
PAB name: '''Watch_out2_current'''
+
PAB name: '''CR05_PAB'''
  
 
  <nowiki>
 
  <nowiki>
Line 75: Line 134:
 
   "source": "OUTPUTS/2/CURRENT",
 
   "source": "OUTPUTS/2/CURRENT",
 
   "thresholds": [
 
   "thresholds": [
     50,
+
     1,
     150,
+
     20,
 +
    200
 
   ],
 
   ],
 
   "timeHysteresis": 10
 
   "timeHysteresis": 10
 
}</nowiki>
 
}</nowiki>
  
===Rules definition===
+
===Rules definitions===
  
Must be defined in two separate Rules because they contain different conditions:
+
Rule 1 name: '''CR05_RULE_1'''
* Rule name: '''Zone_restart'''
 
* Description: If the PAB is in zone 0 (0-49mA), restart the device at output 1
 
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/Watch_out2_current/ZONE": 0
+
     "PAB/NR05_PAB/ZONE": 0
 
   },
 
   },
 
   "actions": {
 
   "actions": {
     "OUTPUTS/1/ACTION": 2
+
     "OUTPUTS/2/ACTION": 1,
 +
    "OUTPUTS/3/ACTION": 0,
 +
    "OUTPUTS/4/ACTION": 0
 
   }
 
   }
 
}</nowiki>
 
}</nowiki>
  
 +
Rule 2 name: '''CR05_RULE_2'''
  
* Rule name: '''Zone_alarm'''
+
<nowiki>
* Description: If the PAB is in zone 2 (150+ mA), send alarm to Cloud
+
{
 +
  "conditions": {
 +
    "PAB/CR05_PAB/ZONE": 1
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/2/ACTION": 0,
 +
    "OUTPUTS/3/ACTION": 1,
 +
    "OUTPUTS/4/ACTION": 0
 +
  }
 +
}</nowiki>
 +
 
 +
Rule 3 name: '''CR05_RULE_3'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/Watch_out2_current/ZONE": 2
+
     "PAB/CR05_PAB/ZONE": 2
 
   },
 
   },
 
   "actions": {
 
   "actions": {
     "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
+
     "OUTPUTS/2/ACTION": 0,
 +
    "OUTPUTS/3/ACTION": 0,
 +
    "OUTPUTS/4/ACTION": 1
 
   }
 
   }
} </nowiki>
+
}</nowiki>
 +
 
 +
== CR06 - WatchDog for 2 IPs (Verify IP connectivity outage with 2 IPs)==
 +
The WatchDog functionality is used to monitor connectivity to specified IP address (or URL) by sending PING request to it.
 +
 
 +
In this example, we monitor two IPs and we want to restart device connected to Output 1 if none of the addresses reply.
 +
The ping for both IPs is sent every 30s and waits 5s for device to respond. There are 5 consecutive timeouts tolerated before the ping is considered as failed. When the ping fails, Watchdog returns <code>false</code> and remains in ERROR state.
 +
 
 +
In case both of the defined WatchDogs are in ERROR state, the Rule is triggered which then restarts Output 1.
  
== Watchdog example ==
+
===WatchDogs definition===
  
The Watchdog monitors specified IP address. The ping is sent every 60s and waits 5s for the device to respond. If the ping fails twice in a row, Watchdog returns <code>false</code> and restarts the device. After restart, it waits 120 seconds and starts monitoring again. This cycle repeats a total of 3 times, and if the device does not respond even once, the Watchdog remains in ERROR state.
+
WatchDog name: '''CR06_WDT_1'''
  
===Watchdog definition===
+
<nowiki>
 +
{
 +
  "target": "192.168.1.51",
 +
  "pingInterval": 30,
 +
  "timeout": 5,
 +
  "maxTimeouts": 5,
 +
  "timeToReboot": 120,
 +
  "maxRestarts": -1
 +
}</nowiki>
  
Watchdog name: '''Watch_101_180'''
+
WatchDog name: '''CR06_WDT_2'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
   "target": "192.168.101.180",
+
   "target": "192.168.1.52",
 
   "pingInterval": 60,
 
   "pingInterval": 60,
 
   "timeout": 5,
 
   "timeout": 5,
   "maxTimeouts": 2,
+
   "maxTimeouts": 5,
 
   "timeToReboot": 120,
 
   "timeToReboot": 120,
   "maxRestarts": 3
+
   "maxRestarts": -1
 
}</nowiki>
 
}</nowiki>
 
  
 
===Rule definition===
 
===Rule definition===
 
   
 
   
Rule name: '''Watch_101_180_restart'''
+
Rule name: '''CR06_RULE'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "WDT/Watch_101_180/FAIL": true
+
    "operator": "AND",
 +
     "WDT/CR06_WDT_1/FAIL": true,
 +
    "WDT/CR06_WDT_2/FAIL": true
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 144: Line 235:
 
}</nowiki>
 
}</nowiki>
  
== Example for Digital Inputs ==
+
== CR07 - Synchronized outputs states during working hours ==
 +
Rule keeps track of first output state and when it changes, it switches output 2 to the same state. However, we want this synchronization only to work during working hours. We define the time with Schedule functionality and use it as a filter (mask) in Rules. Schedule can be defined manually or imported as a configuration file.
 +
 
 +
===Schedule definition===
 +
 
 +
Schedule name: '''CR07_SCHEDULE'''
 +
 
 +
[[File:NR07_Schedule.png|NR070 Schedule]]
 +
 
 +
===Rule definition===
 +
 
 +
Rule name: '''CR07_RULE'''
 +
 
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "OUTPUTS/1/STATE": "on"
 +
  },
 +
  "filters": {
 +
    "SCHEDULE/CR07_SCHEDULE/ACTIVE": true
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/2/ACTION": "${COND_RESULT}"
 +
  }
 +
}</nowiki>
 +
 
 +
== CR08 - Load Watchdog -> Turn output ON after period of time ==
 +
 
 +
In this example we want to measure load on output 1 and indicate when the power is abnormally low for a period of time by switching device on Output 2 ON (could be control light, sound alarm etc.).
 +
 
 +
In PAB we define indication for low power usage (1-20W) that is measured for period of 30 minutes (1800 seconds).
 +
In Rule we define switching Output 2 = ON (ACTION 1 = TURN ON) based on fulfilled PAB condition. This set up counts with human interaction after the Rule action gets processed. (e.g. restarting/replacing device on Output 1 and turning Output 2 OFF).
 +
It is possible to alter this behavior in such a way that the control light (Output 2) turns automatically OFF when load on Output 1 returns to standard values, i.e. higher than 20W (device gets repaired/replaced) or drops to 0W (device was removed or Output 1 turned OFF). This setup is defined in Rule '''NR08_ALT'''
  
Rule monitors state of digital input (DI) No. 1. When DI switches to ON (1), it sends alarm to Cloud for Output 1. When DI switches back to OFF, the alarm turns off as well.
+
===PAB definition===
 +
 
 +
PAB name: '''CR08_PAB'''
 +
<nowiki>
 +
{
 +
  "type": "RANGE",
 +
  "source": "OUTPUTS/1/LOAD",
 +
  "lowerBound": 1,
 +
  "upperBound": 20,
 +
  "timeHysteresis": 1800
 +
}</nowiki>
  
 
===Rule definition===
 
===Rule definition===
  
Rule name: '''PAB_INPUT1'''
+
Rule name: '''CR08_RULE'''
 +
 
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "PAB/CR08_PAB/IN": true
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/2/ACTION": 1
 +
  }
 +
}</nowiki>
 +
 
 +
Rule name: '''CR08_RULE_ALT'''
 +
 
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "PAB/CR08_PAB/IN": true
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/2/ACTION": "${COND_RESULT}"
 +
  }
 +
}</nowiki>
 +
 
 +
== CR09 - Digital Inputs with Schedule ==
 +
 
 +
Examples shows usage when we want to detect switching of Digital Input to ON state (1) but to (not) react only during specified hours (e.g. outside of working hours).
 +
Reaction hours are defined with Schedule functionality. Schedule can be defined manually or imported as a configuration file.
 +
 
 +
===Schedule definition===
 +
 
 +
Schedule name: '''CR09_SCHEDULE'''
 +
 
 +
===Rule definition===
 +
 
 +
Rule name: '''CR09_RULE'''
  
 
  <nowiki>
 
  <nowiki>
Line 156: Line 324:
 
   "conditions": {
 
   "conditions": {
 
     "INPUTS/1/STATE": "on"
 
     "INPUTS/1/STATE": "on"
 +
  },
 +
  "filters": {
 +
    "SCHEDULE/CR09_SCHEDULE/ACTIVE": false
 
   },
 
   },
 
   "actions": {
 
   "actions": {
     "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
+
    "OUTPUTS/1/ACTION": 2
 +
  }
 +
}</nowiki>
 +
 
 +
== CR10 - TURN OFF Output 1 before midnight ==
 +
Rule in a combination with Schedule can be used to ensure a specified output will be turned off at the end of the day (or any other time).
 +
Schedule in this application is '''NOT''' assigned to the output and acts only as a "trigger" for launching the Rule action.
 +
 
 +
===Schedule definition===
 +
 
 +
Schedule name: '''off_before_midnight'''
 +
 
 +
Schedule configuration: Schedule is configured to have '''intervals every day from 23:59 to 24:00'''. In this configuration, the output turns of at 23:59.
 +
 
 +
[[File:cr10_schedule.png|CR10 Schedule]]
 +
 
 +
===Rule definition===
 +
 
 +
Rule name: '''CR10_RULE'''
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "SCHEDULE/off_before_midnight/ACTIVE": true
 +
  },
 +
  "filters": {
 +
    "OUTPUTS/1/STATE": "on"
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 0
 +
  }
 +
}</nowiki>
 +
 
 +
== CR11 - Total load (8QS)==
 +
CR11_PAB
 +
 
 +
<nowiki>
 +
{
 +
  "type": "RANGE",
 +
  "source": "OUTPUTS/TOTAL/LOAD",
 +
  "lowerBound": 30,
 +
  "upperBound": 100,
 +
  "timeHysteresis": 3
 +
}</nowiki>
 +
 
 +
 
 +
  <nowiki>
 +
{
 +
  "conditions": {
 +
    "operator": "OR",
 +
    "PAB/total_outputs/IN": true
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 4,
 +
     "CLOUD/OUTPUT/1/ALARM": 1
 +
  }
 +
}</nowiki>
 +
 
 +
== CR12 - Negative load ==
 +
CR12_PAB
 +
 
 +
<nowiki>
 +
{
 +
  "type": "RANGE",
 +
  "source": "OUTPUTS/1/LOAD",
 +
  "lowerBound": -400,
 +
  "upperBound": 0,
 +
  "timeHysteresis": 2
 +
}</nowiki>
 +
 
 +
 
 +
  <nowiki>
 +
{
 +
  "conditions": {
 +
    "PAB/negative/IN": true
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/3/ACTION": 4,
 +
    "OUTPUTS/4/ACTION": 4
 
   }
 
   }
 
}</nowiki>
 
}</nowiki>

Latest revision as of 15:58, 18 February 2022

The concept of NETIO Conditions (PAB & WatchDog) & Rules is a set of prepared detections (Conditions) and Rules that act upon them. They are implemented directly in NETIO PDU devices.

CR01 - WatchDog (ping) to 1 IP address | default in FW 3.2.3

The WatchDog functionality is used to monitor connectivity to specified IP address (or URL) by sending PING request to it.

The ping in this example is sent every 60s and waits 5s for the device to respond. If the ping fails, Watchdog returns false and restarts (ACTION: 2 = SHORT OFF) device connected to first output. After restart, it waits 120 seconds and starts monitoring again. If the device does not respond, WatchDog remains in ERROR state until next successful ping.

WatchDog definition

WatchDog name: CR01_WDT

{
  "target": "192.168.1.5",
  "pingInterval": 60,
  "timeout": 5,
  "maxTimeouts": 0,
  "timeToReboot": 120,
  "maxRestarts": -1
}

Rule definition

Rule name: CR01_RULE

{
  "conditions": {
    "WDT/CR01_WDT/FAIL": true
  },
  "actions": {
    "OUTPUTS/1/ACTION": 2
  }
}

CR02 - Digital Inputs (Push button to Toggle Outputs 1 and 2) | default in FW 3.2.3

Rule is used for managing outputs in response to change of Digital Inputs (DI) state. Rule monitors state of first DI. When DI switches from OFF (0) to ON (1), Rule switches (toggles) Outputs 1 & 2 to their opposite states (ACTION 4 = TOGGLE).

Rule definition

Rule name: CR02_RULE

{
  "conditions": {
    "INPUTS/1/STATE": "on"
  },
  "actions": {
    "OUTPUTS/1/ACTION": 4,
    "OUTPUTS/2/ACTION": 4
  }
}

CR03 - Load Watchdog (Restart device if it's more than 2 minutes in IDLE mode) | default in FW 3.2.3

Rule monitors load (Watts) on Output 1. If the load is between 1-20W for at least 2 minutes, it restarts (ACTION 2 = SHORT OFF) the output. Example uses PAB (Power Analysis Block) functionality to determine if measured value (load in our case) lies in given range for a period of time. When it does, defined Rule triggers device restart.

PAB definition

PAB name: CR03_PAB

{
  "type": "RANGE",
  "source": "OUTPUTS/1/LOAD",
  "lowerBound": 1,
  "upperBound": 20,
  "timeHysteresis": 120
}

Rule definition

Rule name: CR03_RULE

{
  "conditions": {
    "PAB/CR03_PAB/IN": true
  },
  "actions": {
    "OUTPUTS/1/ACTION": 2
  }
}

CR04 - Load Watchdog with alarm to Cloud

Rule monitors load (Watts) on Output 1. If the load is between 1-20W for at least 30 minutes, it restarts (ACTION 2 = SHORT OFF) the output. In addition, it triggers an alarm in NETIO Cloud, which sends a notification to specified email address. This example needs a NETIO Cloud account with Premium version active for first output. There also has to be email notification enabled for the output.

Example uses PAB (Power Analysis Block) functionality to determine if measured value (load in our case) lies in given range for a period of time. When it does, defined Rule triggers device restart and sends alarm to Cloud.

PAB definition

PAB name: CR04_PAB

{
  "type": "RANGE",
  "source": "OUTPUTS/1/LOAD",
  "lowerBound": 1,
  "upperBound": 20,
  "timeHysteresis": 1800
}


Rule definition

Rule name: CR04_RULE

{
  "conditions": {
    "PAB/CR04_PAB/IN": true
  },
  "actions": {
    "OUTPUTS/1/ACTION": 2,
    "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
  }
}

CR05 - Load Watchdog with zones (indicate OFF / IDLE / RUN mode by switched on output)

Rule monitors load (Watts) on Output 1. Measured load is then classified to several zones defined with thresholds (limit values). Depending on the zone in which the measured load is currently located, different actions can be triggered. Load value has to be between defined threshold for at least 10seconds in order to be placed to respective zone. Example is composed of one PAB that classifies the zones and three Rules for 3 separate actions. Actions do the following:

  • Output 1 load lower than 1W: Output 2 = ON
  • Output 1 load between 1-20W: Output 3 = ON
  • Output 1 load between 20-200W: Output 4 = ON

PAB definition

PAB name: CR05_PAB

{
  "type": "ZONES",
  "source": "OUTPUTS/2/CURRENT",
  "thresholds": [
    1,
    20,
    200
  ],
  "timeHysteresis": 10
}

Rules definitions

Rule 1 name: CR05_RULE_1

{
  "conditions": {
    "PAB/NR05_PAB/ZONE": 0
  },
  "actions": {
    "OUTPUTS/2/ACTION": 1,
    "OUTPUTS/3/ACTION": 0,
    "OUTPUTS/4/ACTION": 0
  }
}

Rule 2 name: CR05_RULE_2

{
  "conditions": {
    "PAB/CR05_PAB/ZONE": 1
  },
  "actions": {
    "OUTPUTS/2/ACTION": 0,
    "OUTPUTS/3/ACTION": 1,
    "OUTPUTS/4/ACTION": 0
  }
}

Rule 3 name: CR05_RULE_3

{
  "conditions": {
    "PAB/CR05_PAB/ZONE": 2
  },
  "actions": {
    "OUTPUTS/2/ACTION": 0,
    "OUTPUTS/3/ACTION": 0,
    "OUTPUTS/4/ACTION": 1
  }
}

CR06 - WatchDog for 2 IPs (Verify IP connectivity outage with 2 IPs)

The WatchDog functionality is used to monitor connectivity to specified IP address (or URL) by sending PING request to it.

In this example, we monitor two IPs and we want to restart device connected to Output 1 if none of the addresses reply. The ping for both IPs is sent every 30s and waits 5s for device to respond. There are 5 consecutive timeouts tolerated before the ping is considered as failed. When the ping fails, Watchdog returns false and remains in ERROR state.

In case both of the defined WatchDogs are in ERROR state, the Rule is triggered which then restarts Output 1.

WatchDogs definition

WatchDog name: CR06_WDT_1

{
  "target": "192.168.1.51",
  "pingInterval": 30,
  "timeout": 5,
  "maxTimeouts": 5,
  "timeToReboot": 120,
  "maxRestarts": -1
}

WatchDog name: CR06_WDT_2

{
  "target": "192.168.1.52",
  "pingInterval": 60,
  "timeout": 5,
  "maxTimeouts": 5,
  "timeToReboot": 120,
  "maxRestarts": -1
}

Rule definition

Rule name: CR06_RULE

{
  "conditions": {
    "operator": "AND",
    "WDT/CR06_WDT_1/FAIL": true,
    "WDT/CR06_WDT_2/FAIL": true
  },
  "actions": {
    "OUTPUTS/1/ACTION": 2
  }
}

CR07 - Synchronized outputs states during working hours

Rule keeps track of first output state and when it changes, it switches output 2 to the same state. However, we want this synchronization only to work during working hours. We define the time with Schedule functionality and use it as a filter (mask) in Rules. Schedule can be defined manually or imported as a configuration file.

Schedule definition

Schedule name: CR07_SCHEDULE

NR070 Schedule

Rule definition

Rule name: CR07_RULE

{
  "conditions": {
    "OUTPUTS/1/STATE": "on"
  },
  "filters": {
    "SCHEDULE/CR07_SCHEDULE/ACTIVE": true
  },
  "actions": {
    "OUTPUTS/2/ACTION": "${COND_RESULT}"
  }
}

CR08 - Load Watchdog -> Turn output ON after period of time

In this example we want to measure load on output 1 and indicate when the power is abnormally low for a period of time by switching device on Output 2 ON (could be control light, sound alarm etc.).

In PAB we define indication for low power usage (1-20W) that is measured for period of 30 minutes (1800 seconds). In Rule we define switching Output 2 = ON (ACTION 1 = TURN ON) based on fulfilled PAB condition. This set up counts with human interaction after the Rule action gets processed. (e.g. restarting/replacing device on Output 1 and turning Output 2 OFF). It is possible to alter this behavior in such a way that the control light (Output 2) turns automatically OFF when load on Output 1 returns to standard values, i.e. higher than 20W (device gets repaired/replaced) or drops to 0W (device was removed or Output 1 turned OFF). This setup is defined in Rule NR08_ALT

PAB definition

PAB name: CR08_PAB

{
  "type": "RANGE",
  "source": "OUTPUTS/1/LOAD",
  "lowerBound": 1,
  "upperBound": 20,
  "timeHysteresis": 1800
}

Rule definition

Rule name: CR08_RULE

{
  "conditions": {
    "PAB/CR08_PAB/IN": true
  },
  "actions": {
    "OUTPUTS/2/ACTION": 1
  }
}

Rule name: CR08_RULE_ALT

{
  "conditions": {
    "PAB/CR08_PAB/IN": true
  },
  "actions": {
    "OUTPUTS/2/ACTION": "${COND_RESULT}"
  }
}

CR09 - Digital Inputs with Schedule

Examples shows usage when we want to detect switching of Digital Input to ON state (1) but to (not) react only during specified hours (e.g. outside of working hours). Reaction hours are defined with Schedule functionality. Schedule can be defined manually or imported as a configuration file.

Schedule definition

Schedule name: CR09_SCHEDULE

Rule definition

Rule name: CR09_RULE

{
  "conditions": {
    "INPUTS/1/STATE": "on"
  },
  "filters": {
    "SCHEDULE/CR09_SCHEDULE/ACTIVE": false
  },
  "actions": {
    "OUTPUTS/1/ACTION": 2
  }
}

CR10 - TURN OFF Output 1 before midnight

Rule in a combination with Schedule can be used to ensure a specified output will be turned off at the end of the day (or any other time). Schedule in this application is NOT assigned to the output and acts only as a "trigger" for launching the Rule action.

Schedule definition

Schedule name: off_before_midnight

Schedule configuration: Schedule is configured to have intervals every day from 23:59 to 24:00. In this configuration, the output turns of at 23:59.

CR10 Schedule

Rule definition

Rule name: CR10_RULE

{
  "conditions": {
    "SCHEDULE/off_before_midnight/ACTIVE": true
  },
  "filters": {
    "OUTPUTS/1/STATE": "on"
  },
  "actions": {
    "OUTPUTS/1/ACTION": 0
  }
}

CR11 - Total load (8QS)

CR11_PAB

{
  "type": "RANGE",
  "source": "OUTPUTS/TOTAL/LOAD",
  "lowerBound": 30,
  "upperBound": 100,
  "timeHysteresis": 3
}


 
{
  "conditions": {
    "operator": "OR",
    "PAB/total_outputs/IN": true
  },
  "actions": {
    "OUTPUTS/1/ACTION": 4,
    "CLOUD/OUTPUT/1/ALARM": 1
  }
}

CR12 - Negative load

CR12_PAB

{
  "type": "RANGE",
  "source": "OUTPUTS/1/LOAD",
  "lowerBound": -400,
  "upperBound": 0,
  "timeHysteresis": 2
}


 
{
  "conditions": {
    "PAB/negative/IN": true
  },
  "actions": {
    "OUTPUTS/3/ACTION": 4,
    "OUTPUTS/4/ACTION": 4
  }
}