Difference between revisions of "Rules Complete Examples"

From wiki.netio-products.com
Jump to navigation Jump to search
Line 31: Line 31:
 
}</nowiki>
 
}</nowiki>
  
== Example for PAB - RANGE ==
+
== NR02 - Digital Inputs ==
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.
+
 
 +
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: '''NR02_RULE'''
 +
 
 +
<nowiki>
 +
{
 +
  "conditions": {
 +
    "INPUTS/1/STATE": "on"
 +
  },
 +
  "actions": {
 +
    "OUTPUTS/1/ACTION": 4,
 +
    "OUTPUTS/2/ACTION": 4
 +
  }
 +
}</nowiki>
 +
 
 +
== NR03 - Current Watchdog ==
 +
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: '''NR03_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.
 
  
Schedule name: '''Working_hours'''
+
Rule name: '''NR03_RULE'''
  
 
  <nowiki>
 
  <nowiki>
 
{
 
{
 
   "conditions": {
 
   "conditions": {
     "PAB/Watch_out1_load/IN": 0
+
     "PAB/NR03_PAB/IN": true
  },
 
  "filters": {
 
    "SCHEDULE/Working_hours/ACTIVE": true
 
 
   },
 
   },
 
   "actions": {
 
   "actions": {
Line 142: Line 157:
 
   }
 
   }
 
} </nowiki>
 
} </nowiki>
 
== Example for Digital Inputs ==
 
 
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.
 
 
===Rule definition===
 
 
Rule name: '''RULE_DI'''
 
 
<nowiki>
 
{
 
  "conditions": {
 
    "INPUTS/1/STATE": "on"
 
  },
 
  "actions": {
 
    "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
 
  }
 
}</nowiki>
 
  
 
== Example for devices without measurements ==
 
== Example for devices without measurements ==

Revision as of 15:02, 23 November 2021

NR01 - WatchDog

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 the next successful ping.

Watchdog definition

WatchDog name: NR01_WDT

{
  "target": "192.168.101.180",
  "pingInterval": 60,
  "timeout": 5,
  "maxTimeouts": 0,
  "timeToReboot": 120
}

Rule definition

Rule name: NR01_RULE

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

NR02 - Digital Inputs

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: NR02_RULE

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

NR03 - Current Watchdog

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: NR03_PAB

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

Rule definition

Rule name: NR03_RULE

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

Example for PAB - RANGE (multiple actions for one condition)

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.

PAB definition

PAB name: Watch_out4_load

{
  "type": "RANGE",
  "source": "OUTPUTS/4/LOAD",
  "lowerBound": 0,
  "upperBound": 600
}


Action definition

{
  "conditions": {
    "PAB/Watch_out4_load/IN": 0
  }
  "actions": {
    "OUTPUTS/4/ACTION": 0,
    "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
  }
}

Example for PAB - ZONES

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:

  • If the value of current is in zone 0, restart device on output 1
  • If the value of current is in zone 2, turn ON alarm in Cloud

PAB definition

PAB name: Watch_out2_current

{
  "type": "ZONES",
  "source": "OUTPUTS/2/CURRENT",
  "thresholds": [
    50,
    150,
  ],
  "timeHysteresis": 10
}

Rules definition

Must be defined in two separate Rules because they contain different conditions:

  • Rule name: Zone_restart
  • Description: If the PAB is in zone 0 (0-49mA), restart the device at output 1
{
  "conditions": {
    "PAB/Watch_out2_current/ZONE": 0
  },
  "actions": {
    "OUTPUTS/1/ACTION": 2
  }
}


  • Rule name: Zone_alarm
  • Description: If the PAB is in zone 2 (150+ mA), send alarm to Cloud
{
  "conditions": {
    "PAB/Watch_out2_current/ZONE": 2
  },
  "actions": {
    "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}"
  }
} 

Example for devices without measurements

Defined rule keeps output 1 state the same as output 3

Rule definition

Rule name: RULE_OUT

{
  "conditions": {
    "OUTPUTS/3/STATE": "on"
  },
  "actions": {
    "OUTPUTS/1/ACTION": "${COND_RESULT}"
  }
}