Rules

From wiki.netio-products.com
Jump to navigation Jump to search

Each Rule define the follow-up actions based on current DI / PAB/ WatchDog function state. There can be several Rules executed based on one PAB function (switch output if Current > 1000 mA + Send Alert to NETIO Cloud IF Current > 500 mA). One Rule can be executed based on combination of several PAB / WatchDog states.

Rules examples are available on page: https://wiki.netio-products.com/index.php?title=Rules_Complete_Examples

CONDITION

Rule conditions define when the action part of each Rule is executed. There can be multiple conditions for one Rule. In order to execute the action, all conditions have to be valid (AND operator) / at least one of the conditions have to be valid (OR operator). bootDelay parameter FW 4.0.0+ can be used to delay rule evaluation after power up (or internal periodic restart). This is useful for example for delay condition and alerts evaluation after PAB blocks are stabilized. (e.g. hysteresis or some delays). bootDelay parameter FW 4.0.0+ is specified in seconds [s]

Example:

{
 "conditions": {
   "bootDelay": 20,
   "operator": "OR",
   "WDT/test2/FAIL": true,
   "INPUTS/1/STATE": "off"
 },
 "actions": {
   "OUTPUTS/1/ACTION": 4
 }
}

Available forms of conditions

  • "PAB/PAB1_1/IN": true = PAB1_1 is in specified interval
  • "PAB/PAB_ZONE_1/ZONE": 1 = PAB_ZONE_1 is in zone 1
  • "PAB/CR13_PAB/DAY": true = daylight for current time on defined location (for use with DAYLIGHT-type PAB)
  • "WDT/WATCHDOG_1/FAIL": true = WATCHDOG_1 is in ERROR state
  • "OUTPUTS/1/STATE": "on" = Output 1 is currently ON (1)
  • "INPUTS/1/STATE": "off" = DI1 is currently OFF (0)
  • "SYSTEM/DEVICE_POWER_UP": true = device boot after power-cut (external power outage, lower-level system (MCU) firmware update)FW 4.0.0+
  • "SYSTEM/DEVICE_BOOT": true = device boot after soft restart (internal watchdog or periodic restart) - no Power Outage, state of outputs not changedFW 4.0.0+
  • "NETWORK/STATE": "down" = indicates network connection status, states: "up" - device is connected, "down" - device is not connectedFW 4.0.0+
  • "NETWORK/ETHERNET/STATE": "down" = indicates network connection status, states: "up" - device is connected, "down" - device is not connectedFW 4.0.0+
  • "NETWORK/WIFI/STATE": "down" = indicates network connection status, states: "up" - device is connected, "down" - device is not connectedFW 4.0.0+

FILTER (mask)

The filter field specifies when the Rule is active. It acts as a mask If filter in certain time is not true, the action wont be executed even when conditions are fulfilled. Multiple filters can be set for one rule. For the rule to be active all filters must be true.

Above that the FILTER can be applied (scheduler, DI (Digital Input) or DO (Output) state).

Available forms of filters

  • "SCHEDULE/TestSchedule/ACTIVE": true = TestSchedule is active
  • "OUTPUTS/1/STATE":"on" = Output 1 is ON


ACTION

ACTIONS part in the Rule contains list of several actions when condition(s) + filter(s) are valid.

The actions can change output states (turn OFF, turn ON, toggle, etc.) or trigger an Alarm state in NETIO Cloud. There is one Alarm state reserved per each one output in the NETIO Cloud premium (only). You can verify your configuration and check sending of the Output Alarm in the Device Log.

Available forms of actions

  • "OUTPUTS/1/ACTION": 0 = Turn OFF Output 1
  • "OUTPUTS/6/ACTION": 2 = Short OFF Output 6
  • "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}" = Set condition output value to the alarm (Turns the alarm ON or OFF based on condition evaluation)

Note: The variable ${COND_RESULT} contains output value of the given condition. It takes values 0 (condition not met) or 1 (condition met). It can be used for dynamic switching the alarm in Cloud ON/OFF depending on current state of the PAB.


Standard output actions per each output

  • 0 = TURN OFF
  • 1 = TURN ON
  • 2 = SHORT OFF
  • 3 = SHORT ON
  • 4 = TOGGLE - Changes the status from ON to OFF and vice versa
  • 5 = NOTHING (placeholder, DO NOT USE)

Structure

Variable Value Description
conditions Eg: `"PAB/PAB1_1/IN": true` Conditions definition. Relationship between conditions is defined by operator (AND/OR)
operator AND/OR Optional. Specifies relationship between conditions. AND = all conditions must apply at the same time. OR = at least one condition must apply. If missing, defaults to OR
filters Eg: "SCHEDULE/MY_SCHEDULE/ACTIVE": true Filter definition. For multiple filter conditions, the relationship between them is always AND
actions Eg: "CLOUD/OUTPUT/1/ALARM": "${COND_RESULT}" Actions definition. All actions defined here will be triggered when conditions (and filters) are met

Condition names are based on user-specified names and their types:

  • For PABs, the name has structure: PAB/pab_name/pab_output_value (TRUE/FALSE or int)
  • For WatchDogs, the name has structure: WDT/watchdog_name/FAIL

Sequence FW 4.0.0+

Sequences bring extended usability to ACTIONS. In addition to basic actions that are triggered right after certain condition (conditions) are met, sequence can be defined to enable repetitive actions.

Configuration variables

Variable Value Description
repeat int (0 to 1-MAX_INT) / true How many times should the sequence repeat. Set 0 or true for indefinitely (can only be turned off by disabling the rule).
actions Standard actions as defined in section ACTION
delay int [ms] in multiples of 100ms May be set along with actions to be executed. Defines time the sequence waits after performing the action. The value is rounded up to hundreds of miliseconds (e.g. 85ms -> 100ms, 235ms -> 300ms).

Example

This example triggers one-time action along with sequence of other actions and repeats 10-times after meeting certain condition.

Condition: WatchDog CR01_WDT fails (receives timeout from defined address)
One-time action: Restart output No. 2 (action 2 = short off/restart)
Sequence : Following steps repeat 10-times
  1. Turn output No. 1 ON
  2. Wait 10s
  3. Turn output No. 1 OFF
  4. Wait 2s
  5. Repeat
{
  "conditions": {
    "WDT/CR01_WDT/FAIL": true
  },
  "actions": {
    "OUTPUTS/1/ACTION": 2,
    "sequence":{
      "repeat": 10,
      "actions":[
        {"OUTPUTS/1/ACTION": 1, "delay":10000},
        {"OUTPUTS/1/ACTION": 0, "delay":2000}
      ]
    }
  }
}