Difference between revisions of "Rules Complete Examples"

From wiki.netio-products.com
Jump to navigation Jump to search
(NR01 - WatchDog)
(Temperature out of limit - Output1 ON)
 
(49 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== NR01 - WatchDog (ping) to 1 IP address ==
+
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 WatchDog functionality is used to monitor connectivity to specified IP address (or URL) by sending PING request to it.
  
Line 6: Line 8:
 
===WatchDog definition===
 
===WatchDog definition===
  
WatchDog name: '''NR01_WDT'''
+
WatchDog name: '''CR01_WDT'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
   "target": "192.168.101.180",
+
   "target": "192.168.1.5",
 
   "pingInterval": 60,
 
   "pingInterval": 60,
 
   "timeout": 5,
 
   "timeout": 5,
 
   "maxTimeouts": 0,
 
   "maxTimeouts": 0,
 
   "timeToReboot": 120,
 
   "timeToReboot": 120,
   "maxRestarts": 0
+
   "maxRestarts": -1
 
}</nowiki>
 
}</nowiki>
  
 
===Rule definition===
 
===Rule definition===
 
   
 
   
Rule name: '''NR01_RULE'''
+
Rule name: '''CR01_RULE'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "WDT/NR01_WDT/FAIL": true
+
     "WDT/CR01_WDT/FAIL": true
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 32: Line 34:
 
}</nowiki>
 
}</nowiki>
  
== NR02 - Digital Inputs ==
+
== 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 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).
Line 38: Line 40:
 
===Rule definition===
 
===Rule definition===
  
Rule name: '''NR02_RULE'''
+
Rule name: '''CR02_RULE'''
  
 
  <nowiki>
 
  <nowiki>
Line 51: Line 53:
 
}</nowiki>
 
}</nowiki>
  
== NR03 - Load Watchdog ==
+
== 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.
 
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.
 
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.
Line 57: Line 59:
 
===PAB definition===
 
===PAB definition===
  
PAB name: '''NR03_PAB'''
+
PAB name: '''CR03_PAB'''
 
  <nowiki>
 
  <nowiki>
 
{
 
{
Line 69: Line 71:
 
===Rule definition===
 
===Rule definition===
  
Rule name: '''NR03_RULE'''
+
Rule name: '''CR03_RULE'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/NR03_PAB/IN": true
+
     "PAB/CR03_PAB/IN": true
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 81: Line 83:
 
}</nowiki>
 
}</nowiki>
  
== NR04 - Load Watchdog with alarm to Cloud ==
+
== 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.
 
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.
 
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.
Line 89: Line 91:
 
===PAB definition===
 
===PAB definition===
  
PAB name: '''NR04_PAB'''
+
PAB name: '''CR04_PAB'''
 
    
 
    
 
  <nowiki>
 
  <nowiki>
Line 103: Line 105:
 
===Rule definition===
 
===Rule definition===
  
Rule name: '''NR04_RULE'''
+
Rule name: '''CR04_RULE'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/NR04_PAB/IN": true
+
     "PAB/CR04_PAB/IN": true
   }
+
   },
 
   "actions": {
 
   "actions": {
 
     "OUTPUTS/1/ACTION": 2,
 
     "OUTPUTS/1/ACTION": 2,
Line 116: Line 118:
 
}</nowiki>
 
}</nowiki>
  
== NR05 - Load Watchdog with zones ==
+
== 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.
 
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:
 
Example is composed of one PAB that classifies the zones and three Rules for 3 separate actions. Actions do the following:
Line 125: Line 127:
 
===PAB definition===
 
===PAB definition===
  
PAB name: '''NR05_PAB'''
+
PAB name: '''CR05_PAB'''
  
 
  <nowiki>
 
  <nowiki>
Line 141: Line 143:
 
===Rules definitions===
 
===Rules definitions===
  
Rule 1 name: '''NR05_RULE_1'''
+
Rule 1 name: '''CR05_RULE_1'''
  
 
  <nowiki>
 
  <nowiki>
Line 155: Line 157:
 
}</nowiki>
 
}</nowiki>
  
Rule 2 name: '''NR05_RULE_2'''
+
Rule 2 name: '''CR05_RULE_2'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/NR05_PAB/ZONE": 1
+
     "PAB/CR05_PAB/ZONE": 1
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 169: Line 171:
 
}</nowiki>
 
}</nowiki>
  
Rule 3 name: '''NR05_RULE_3'''
+
Rule 3 name: '''CR05_RULE_3'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/NR05_PAB/ZONE": 2
+
     "PAB/CR05_PAB/ZONE": 2
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 183: Line 185:
 
}</nowiki>
 
}</nowiki>
  
== NR06 - WatchDog for 2 IPs ==
+
== 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.
 
The WatchDog functionality is used to monitor connectivity to specified IP address (or URL) by sending PING request to it.
  
Line 189: Line 191:
 
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.
 
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 ERORR state, the Rule is triggered which then restarts Output 1.
+
In case both of the defined WatchDogs are in ERROR state, the Rule is triggered which then restarts Output 1.
  
 
===WatchDogs definition===
 
===WatchDogs definition===
  
WatchDog name: '''NR06_WDT_1'''
+
WatchDog name: '''CR06_WDT_1'''
  
 
  <nowiki>
 
  <nowiki>
Line 200: Line 202:
 
   "pingInterval": 30,
 
   "pingInterval": 30,
 
   "timeout": 5,
 
   "timeout": 5,
   "maxTimeouts": 5
+
   "maxTimeouts": 5,
 +
  "timeToReboot": 120,
 +
  "maxRestarts": -1
 
}</nowiki>
 
}</nowiki>
  
WatchDog name: '''NR06_WDT_2'''
+
WatchDog name: '''CR06_WDT_2'''
  
 
  <nowiki>
 
  <nowiki>
Line 210: Line 214:
 
   "pingInterval": 60,
 
   "pingInterval": 60,
 
   "timeout": 5,
 
   "timeout": 5,
   "maxTimeouts": 5
+
   "maxTimeouts": 5,
 +
  "timeToReboot": 120,
 +
  "maxRestarts": -1
 
}</nowiki>
 
}</nowiki>
  
 
===Rule definition===
 
===Rule definition===
 
   
 
   
Rule name: '''NR06_RULE'''
+
Rule name: '''CR06_RULE'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "operator": "AND"
+
     "operator": "AND",
     "WDT/NR06_WDT_1/FAIL": true
+
     "WDT/CR06_WDT_1/FAIL": true,
     "WDT/NR06_WDT_2/FAIL": true
+
     "WDT/CR06_WDT_2/FAIL": true
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 229: Line 235:
 
}</nowiki>
 
}</nowiki>
  
== NR07 - Synchronized outputs states during working hours ==
+
== 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.
 
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 definition===
  
Schedule name: '''NR07_SCHEDULE'''
+
Schedule name: '''CR07_SCHEDULE'''
  
 
[[File:NR07_Schedule.png|NR070 Schedule]]
 
[[File:NR07_Schedule.png|NR070 Schedule]]
Line 240: Line 246:
 
===Rule definition===
 
===Rule definition===
  
Rule name: '''NR07_RULE'''
+
Rule name: '''CR07_RULE'''
  
 
  <nowiki>
 
  <nowiki>
Line 248: Line 254:
 
   },
 
   },
 
   "filters": {
 
   "filters": {
     "SCHEDULE/NR07_SCHEDULE/ACTIVE": true
+
     "SCHEDULE/CR07_SCHEDULE/ACTIVE": true
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 255: Line 261:
 
}</nowiki>
 
}</nowiki>
  
== NR08 - Load Watchdog -> Turn output ON after period of time ==
+
== 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 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.).
Line 265: Line 271:
 
===PAB definition===
 
===PAB definition===
  
PAB name: '''NR08_PAB'''
+
PAB name: '''CR08_PAB'''
 
  <nowiki>
 
  <nowiki>
 
{
 
{
Line 277: Line 283:
 
===Rule definition===
 
===Rule definition===
  
Rule name: '''NR08_RULE'''
+
Rule name: '''CR08_RULE'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/NR08_PAB/IN": true
+
     "PAB/CR08_PAB/IN": true
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 289: Line 295:
 
}</nowiki>
 
}</nowiki>
  
Rule name: '''NR08_RULE_ALT'''
+
Rule name: '''CR08_RULE_ALT'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/NR08_PAB/IN": true
+
     "PAB/CR08_PAB/IN": true
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 301: Line 307:
 
}</nowiki>
 
}</nowiki>
  
== NR09 - Digital Inputs with Schedule ==
+
== 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).
 
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).
Line 308: Line 314:
 
===Schedule definition===
 
===Schedule definition===
  
Schedule name: '''NR09_SCHEDULE'''
+
Schedule name: '''CR09_SCHEDULE'''
  
 
===Rule definition===
 
===Rule definition===
  
Rule name: '''NR09_RULE'''
+
Rule name: '''CR09_RULE'''
  
 
  <nowiki>
 
  <nowiki>
Line 320: Line 326:
 
   },
 
   },
 
   "filters": {
 
   "filters": {
     "SCHEDULE/NR09_SCHEDULE/ACTIVE": false
+
     "SCHEDULE/CR09_SCHEDULE/ACTIVE": false
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 327: Line 333:
 
}</nowiki>
 
}</nowiki>
  
== NRXX - Total load (8QS)==
+
== 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>
 
  <nowiki>
 
{
 
{
Line 350: Line 386:
 
}</nowiki>
 
}</nowiki>
  
== NRXXX - Negative load ==
+
== CR12 - Negative load ==
 +
CR12_PAB
 +
 
 
  <nowiki>
 
  <nowiki>
 
{
 
{
Line 371: Line 409:
 
   }
 
   }
 
}</nowiki>
 
}</nowiki>
 +
 +
 +
== CR13 - Actions based on daylight <sup><code>FW 4.0.0+</code></sup>==
 +
Turns output ON/OFF based on sunrise/sunset times of set location.
 +
In this example, output 1 gets turned on one hour before (-60 minutes) sunrise and turns off one hour (60 minutes) after sunset. Location is se for NETIO Products headquarters (U pily 103, Prague, CZ). Elevation is set as 247 meters, above sea level.
 +
 +
=== PAB definition ===
 +
PAB name: '''CR13_PAB'''
 +
 +
<nowiki>
 +
{
 +
  "type": "DAYLIGHT",
 +
  "longitude": "14.4129433E",
 +
  "latitude": "50.0058144N",
 +
  "altitude": 247,
 +
  "sunriseDelay": -60,
 +
  "sunsetDelay": 60
 +
}
 +
</nowiki>
 +
 +
=== Rule definition ===
 +
Rule name: '''CR13_RULE'''
 +
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "PAB/CR13_PAB/DAY": true
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": "${COND_RESULT}"
 +
  }
 +
}
 +
</nowiki>
 +
 +
== CR14 - Actions based on Power-UP <sup><code>FW 4.0.0+</code></sup>==
 +
 +
This example describes rule that evaluates after device start-up. Generally, there are 2 options for setting up conditions:
 +
* SYSTEM/DEVICE_POWER_UP - device boot after power-cut
 +
 +
Condition in rule description below reacts to device boot after power-cut. When device first starts after regaining power, it sends alarm to output 1 in NETIO Cloud service.
 +
 +
=== Rule definition ===
 +
Rule name: '''CR14_RULE'''
 +
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "SYSTEM/DEVICE_POWER_UP": true
 +
  },
 +
  "actions": {
 +
    "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
 +
  }
 +
}
 +
</nowiki>
 +
 +
== CR15 - Sunrise/sunset addaptive schedule with deep night off  <sup><code>FW 4.0.1+</code></sup>==
 +
Control output ON/OFF based on sunrise/sunset times of set location and combine it with standard schedule using rules.
 +
 +
In this example, output 1 gets turned on every day at 6:00 and switch off 30 minutes after sunrise and gets on again 30 minutes before sunset and turns off at midnight. This is an example of combination PAB output with standard schedule and mask the result of PAB with intervals defined in schedule.
 +
 +
Following combination creates dynamic variable input with static scheduler overlay and the behaviour can be simply chosen by logical equations.
 +
 +
=== 1. Configure schedule ===
 +
Create a schedule with name "christmas_off" and create intervals 00:00 to 06:00 every day. No need to activate the scheduler for any output. Just define it.
 +
 +
[[File:CR15 schedule christmas off.png]]
 +
 +
=== 2. Create sunrise/sunset PAB ===
 +
 +
Following PAB will have <code>true</code> result during the day between sunrise with 30 minutes delay and 30 minutes before sunset set for location of NETIO Products headquarters (U pily 103, Prague, CZ). Elevation is set as 247 meters, above sea level. This result will be used in condition in rules to detect sunrise and sunset.
 +
 +
PAB name: '''daylight'''
 +
 +
<nowiki>
 +
{
 +
  "type": "DAYLIGHT",
 +
  "longitude": "14.4129433E",
 +
  "latitude": "50.0058144N",
 +
  "altitude": 247,
 +
  "sunriseDelay": 30,
 +
  "sunsetDelay": -30
 +
}
 +
</nowiki>
 +
 +
=== 3. Create RULE for output ON ===
 +
 +
In this rule is definition when the output 1 should be enabled (ON). It is combination of two conditions of PAB and scheduler.
 +
 +
'''This code is saying:''' When is night ( day is false = <code>"PAB/daylight/DAY": false,</code>) and in paralel schedule is not active (set to be off = <code>"SCHEDULE/christmas_off/ACTIVE": false</code>) the result is <code>true</code> and following action (set output 1 to ON <code>"OUTPUTS/1/ACTION": 1</code>) is executed.
 +
 +
RULE name: '''outON'''
 +
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "operator": "AND",
 +
    "PAB/daylight/DAY": false,
 +
    "SCHEDULE/christmas_off/ACTIVE": false
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 1
 +
  }
 +
}
 +
</nowiki>
 +
 +
=== 4. Create RULE for output OFF ===
 +
 +
In this rule is definition when the output 1 should be disabled (OFF). It is again combination of two conditions of PAB and scheduler.
 +
 +
'''This code is saying:''' When it is day now ( day is true = <code>"PAB/daylight/DAY": true,</code>) or the schedule is active (set to be on = <code>"SCHEDULE/christmas_off/ACTIVE": true</code>) the result is <code>true</code> and following action (set output 1 to OFF <code>"OUTPUTS/1/ACTION": 0</code>) is executed.
 +
 +
RULE name: '''outOFF'''
 +
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "operator": "OR",
 +
    "PAB/daylight/DAY": true,
 +
    "SCHEDULE/christmas_off/ACTIVE": true
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 0
 +
  }
 +
}
 +
</nowiki>
 +
 +
== CR16 - Digital Inputs - External Switch ON/OFF  <sup><code>FW 4.0.0+</code></sup>==
 +
Rule is used for managing outputs status in response to change of Digital Inputs (DI) state. Typical example of this solution is connection of external switch ON/OFF into Digital Input (IN) with consequence outputs action.
 +
 +
 +
=== External Switch OFF - All Outputs OFF ===
 +
Rule name: '''CR16_RULE'''
 +
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "INPUTS/1/STATE": "off"
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 0,
 +
    "OUTPUTS/2/ACTION": 0
 +
  }
 +
}
 +
</nowiki>
 +
 +
=== External Switch ON  - All Outputs ON ===
 +
Rule name: '''CR16_RULE''' 
 +
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "INPUTS/1/STATE": "on"
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 1,
 +
    "OUTPUTS/2/ACTION": 1
 +
      }
 +
}
 +
</nowiki>
 +
 +
=== External Switch ON - All outputs ON with individual Power Up Sequence ===
 +
Rule name: '''CR16_RULE'''
 +
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "INPUTS/1/STATE": "on"
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 0,
 +
    "sequence": {
 +
      "repeat": 1,
 +
      "actions": [
 +
        {
 +
          "OUTPUTS/1/ACTION": 1,
 +
          "delay": 1000
 +
        },
 +
        {
 +
          "OUTPUTS/2/ACTION": 1,
 +
          "delay": 3000
 +
        }
 +
      ]
 +
    }
 +
  }
 +
}
 +
 +
</nowiki>
 +
 +
== CR17 - Digital Inputs - Connection of NETIO T1 Sensor  <sup><code>FW 5.0.3+</code></sup>==
 +
Rule is used for managing outputs status in response to temperature metering connected into Digital Inputs (DI). Typical example of this solution is the temperature metering in server room. In case temperature hits specified temperature, the air-condition (AC) will turn ON.
 +
 +
=== Temperature measurement - condition definition temperature range (15-45)℃ ===
 +
NETIO T1 Sensor connected into INPUT n.2
 +
 +
Rule name: '''CR17_TEMP'''
 +
 +
<nowiki>
 +
{
 +
"source":"INPUTS/2/TEMP",
 +
"type":"RANGE",
 +
"upperBound":45,
 +
"lowerBound":15,
 +
"timeHysteresis":1
 +
}
 +
</nowiki>
 +
 +
===  Temperature out of spec  - Output1 ON===
 +
Rule name: '''CR17_RULE_1'''
 +
<nowiki>
 +
{
 +
  "conditions":{
 +
    "PAB/CR15_TEMP/IN":false
 +
  },
 +
  "actions":{
 +
    "OUTPUTS/1/ACTION":1
 +
  }
 +
}
 +
</nowiki>
 +
===  Temperature in spec - Output1 OFF===
 +
Rule name: '''CR17_RULE_2'''
 +
<nowiki>
 +
{
 +
  "conditions":{
 +
    "PAB/CR15_TEMP/IN":true
 +
  },
 +
  "actions":{
 +
    "OUTPUTS/1/ACTION":0
 +
  }
 +
}
 +
</nowiki>

Latest revision as of 08:18, 29 July 2024

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.

Contents

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
  }
}


CR13 - Actions based on daylight FW 4.0.0+

Turns output ON/OFF based on sunrise/sunset times of set location. In this example, output 1 gets turned on one hour before (-60 minutes) sunrise and turns off one hour (60 minutes) after sunset. Location is se for NETIO Products headquarters (U pily 103, Prague, CZ). Elevation is set as 247 meters, above sea level.

PAB definition

PAB name: CR13_PAB

{
  "type": "DAYLIGHT",
  "longitude": "14.4129433E",
  "latitude": "50.0058144N",
  "altitude": 247,
  "sunriseDelay": -60,
  "sunsetDelay": 60
}

Rule definition

Rule name: CR13_RULE

{
  "conditions": {
    "PAB/CR13_PAB/DAY": true
  },
  "actions": {
    "OUTPUTS/1/ACTION": "${COND_RESULT}"
  }
}

CR14 - Actions based on Power-UP FW 4.0.0+

This example describes rule that evaluates after device start-up. Generally, there are 2 options for setting up conditions:

  • SYSTEM/DEVICE_POWER_UP - device boot after power-cut

Condition in rule description below reacts to device boot after power-cut. When device first starts after regaining power, it sends alarm to output 1 in NETIO Cloud service.

Rule definition

Rule name: CR14_RULE

{
  "conditions": {
    "SYSTEM/DEVICE_POWER_UP": true
  },
  "actions": {
    "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
  }
}

CR15 - Sunrise/sunset addaptive schedule with deep night off FW 4.0.1+

Control output ON/OFF based on sunrise/sunset times of set location and combine it with standard schedule using rules.

In this example, output 1 gets turned on every day at 6:00 and switch off 30 minutes after sunrise and gets on again 30 minutes before sunset and turns off at midnight. This is an example of combination PAB output with standard schedule and mask the result of PAB with intervals defined in schedule.

Following combination creates dynamic variable input with static scheduler overlay and the behaviour can be simply chosen by logical equations.

1. Configure schedule

Create a schedule with name "christmas_off" and create intervals 00:00 to 06:00 every day. No need to activate the scheduler for any output. Just define it.

CR15 schedule christmas off.png

2. Create sunrise/sunset PAB

Following PAB will have true result during the day between sunrise with 30 minutes delay and 30 minutes before sunset set for location of NETIO Products headquarters (U pily 103, Prague, CZ). Elevation is set as 247 meters, above sea level. This result will be used in condition in rules to detect sunrise and sunset.

PAB name: daylight

{
  "type": "DAYLIGHT",
  "longitude": "14.4129433E",
  "latitude": "50.0058144N",
  "altitude": 247,
  "sunriseDelay": 30,
  "sunsetDelay": -30
}

3. Create RULE for output ON

In this rule is definition when the output 1 should be enabled (ON). It is combination of two conditions of PAB and scheduler.

This code is saying: When is night ( day is false = "PAB/daylight/DAY": false,) and in paralel schedule is not active (set to be off = "SCHEDULE/christmas_off/ACTIVE": false) the result is true and following action (set output 1 to ON "OUTPUTS/1/ACTION": 1) is executed.

RULE name: outON

{
  "conditions": {
    "operator": "AND",
    "PAB/daylight/DAY": false,
    "SCHEDULE/christmas_off/ACTIVE": false
  },
  "actions": {
    "OUTPUTS/1/ACTION": 1
  }
}

4. Create RULE for output OFF

In this rule is definition when the output 1 should be disabled (OFF). It is again combination of two conditions of PAB and scheduler.

This code is saying: When it is day now ( day is true = "PAB/daylight/DAY": true,) or the schedule is active (set to be on = "SCHEDULE/christmas_off/ACTIVE": true) the result is true and following action (set output 1 to OFF "OUTPUTS/1/ACTION": 0) is executed.

RULE name: outOFF

{
  "conditions": {
    "operator": "OR",
    "PAB/daylight/DAY": true,
    "SCHEDULE/christmas_off/ACTIVE": true
  },
  "actions": {
    "OUTPUTS/1/ACTION": 0
  }
}

CR16 - Digital Inputs - External Switch ON/OFF FW 4.0.0+

Rule is used for managing outputs status in response to change of Digital Inputs (DI) state. Typical example of this solution is connection of external switch ON/OFF into Digital Input (IN) with consequence outputs action.


External Switch OFF - All Outputs OFF

Rule name: CR16_RULE

{
  "conditions": {
    "INPUTS/1/STATE": "off"
  },
  "actions": {
    "OUTPUTS/1/ACTION": 0,
    "OUTPUTS/2/ACTION": 0
  }
}

External Switch ON - All Outputs ON

Rule name: CR16_RULE

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

External Switch ON - All outputs ON with individual Power Up Sequence

Rule name: CR16_RULE

{
  "conditions": {
    "INPUTS/1/STATE": "on"
  },
  "actions": {
    "OUTPUTS/1/ACTION": 0,
    "sequence": {
      "repeat": 1,
      "actions": [
        {
          "OUTPUTS/1/ACTION": 1,
          "delay": 1000
        },
        {
          "OUTPUTS/2/ACTION": 1,
          "delay": 3000
        }
      ]
    }
  }
}


CR17 - Digital Inputs - Connection of NETIO T1 Sensor FW 5.0.3+

Rule is used for managing outputs status in response to temperature metering connected into Digital Inputs (DI). Typical example of this solution is the temperature metering in server room. In case temperature hits specified temperature, the air-condition (AC) will turn ON.

Temperature measurement - condition definition temperature range (15-45)℃

NETIO T1 Sensor connected into INPUT n.2

Rule name: CR17_TEMP

{
 "source":"INPUTS/2/TEMP",
 "type":"RANGE",
 "upperBound":45,
 "lowerBound":15,
 "timeHysteresis":1
}

Temperature out of spec - Output1 ON

Rule name: CR17_RULE_1

{
  "conditions":{
    "PAB/CR15_TEMP/IN":false
  },
  "actions":{
    "OUTPUTS/1/ACTION":1
  }
}

Temperature in spec - Output1 OFF

Rule name: CR17_RULE_2

{
  "conditions":{
    "PAB/CR15_TEMP/IN":true
  },
  "actions":{
    "OUTPUTS/1/ACTION":0
  }
}