Rules¶
Overview¶
Rules determine state changes based on an input signal. Each rule has logic to evaluate each new signal value to determine if a state has changed for the rule.
For example, a threshold type rule could evaluate if a value is now above a warning level and when detected create a warning state change event, going from Normal, OK
Warning
.
---
config:
theme: neutral
---
graph LR
Signal@{ shape: das, label: "Signal" }
d0@{ shape: framed-circle, label: "Data Point" }
d1@{ shape: framed-circle, label: "Data Point" }
d2@{ shape: framed-circle, label: "Data Point" }
d3@{ shape: sm-circ, label: "Data Point" }
Rule{Rule};
style Rule stroke-width:3px
DPC@{ shape: brace-r, label: "New Incoming Signal Values" }
EVENTC@{ shape: brace-l, label: "State Change Detected: Warning Level" }
DPC ~~~ d0
d0 e1@-.- d1 e2@-.- d2 e3@-.- Signal e4@-.- d3 e5@--> Rule
%%d3 eTS@-.-o ts
state_change@{ shape: f-circ }
style state_change fill:#fdd835,stroke:#fdd835
Rule e6@-.- | State<br>Change | state_change
state_change ~~~ EVENTC
e1@{ animate: true }
e2@{ animate: true }
e3@{ animate: true }
e4@{ animate: true }
e5@{ animate: true }
e6@{ animate: true }
Configuration¶
Rules are configured as a part of the Asset's signal data pipeline, always attached to a signal. The Asset Configuration allows editing the parameters / constants for the rule. Rules are a part of a templated asset and inherit the parameters from the template. (Note: Optional functionally allows overriding rule constants for assets linked to a template.) Solutions may implement solution level custom rules. (Note: Only the built-in threshold rules allow for displaying thresholds on dashboard panels.)
Signals technically may have multiple rules associated with them to look for different types of conditions (operational state, timeout, etc) and/or use different types of logic. Overall the rule states provide the current status for the specific signal and contribute to the overall status for an asset.
It's important to note that a single rule, like the off the shelf Threshold rule (more info below), can look for multiple threshold state level criteria and do not require separate rules. The most typical second rule is the off the shelf Timeout rule to look for a situation where the signal has not reported a value for some amount of time and would indicate a connection problem.
---
config:
theme: neutral
---
graph LR
Signal@{ shape: das, label: "Signal" }
d0@{ shape: f-circ, label: "Data Point" }
d1@{ shape: f-circ, label: "Data Point" }
d2@{ shape: f-circ, label: "Data Point" }
d3@{ shape: f-circ, label: "Data Point" }
style d0 fill:#DDD,stroke:#999,fill-opacity:0.1,stroke-dasharray:2
style d1 fill:#DDD,stroke:#999,fill-opacity:0.1,stroke-dasharray:2
style d2 fill:#DDD,stroke:#999,fill-opacity:0.1,stroke-dasharray:2
style d3 fill:#DDD,stroke:#999,fill-opacity:0.1,stroke-dasharray:2
Rule{Threshold Rule};
RuleTimeout{Timeout Rule};
DPC@{ shape: brace-r, label: "No new values.<br>Showing expected rate" }
EVENTC@{ shape: brace-l, label: "State Change Detected: Timeout" }
DPC ~~~ d0
d0 ~~~ d1 ~~~ d2 ~~~ Signal -.- d3 -.- Rule
d3 -.- RuleTimeout
state_change@{ shape: f-circ }
style state_change fill:#999,stroke:#999
RuleTimeout e6@-.- | State<br>Change | state_change
state_change ~~~ EVENTC
e6@{ animate: true }
Rule Logic¶
Rules are signal data event driven in that they run on each signal data point as soon as it enters the data pipeline (e.g. Sensor reading -> Device Channel -> Asset Signal -> Rule function). These functions, being event driven, evaluate the new value and return a decision on whether there is a state change based on previous last state of the rule. ExoSense includes several off the shelf rules (documented below) that have logic for common use cases like numeric thresholds
, a contains
check for string values, a boolean
check, an is equal to
numeric check, signal timeouts
and repeating values
. The ExoSense pipeline's rule functionality includes built-in support for sustained values such as over a time period, a count, or a count in a time period.
The off the shelf Timeout rule has extra built-in logic to 'timeout' when the rule has not received a new signal value for a specified amount of time. This timeout rule creates a special category of status that allows Timeout status to be showing on signals and assets.
Checks functionality runs before a Rule function's logic to "check" to see if a signal (the calling signal or any other) meets a criteria or if there is a specific time window to run / not run the rule. For more details: Rule & Transform Checks
Setting Up Useful Rules
A rule should have logic and the use of duration / time modifiers to ensure that a signal state is sustained. As an example, if a rule was used to look at a temperature value above a threshold, using a simple check (once) on each value likely is going to have edge cases where the temperature is fluctuating slightly above and below that threshold level. This would generate many state change events and result in calls to notifications, etc and a lot of unhappy users receiving false positive notifications.
A better scenario is to leverage the sustained count and/or time duration capabilities of rules which help ensure the level is accurate and sustained, reducing edge case fluctuations.
Examples of supported sustained functionality
- Count: 10 values in a row meet the criteria
- Duration: All values within 5 minutes have met the criteria
- Count in Duration: 10 values in 5 minutes meet the criteria
Check out info on Hysteresis
Recording Historical Data and Rules
Data that is recorded with historical timestamps (i.e. backfilling) using Device record
functionality should take into consideration the order of data and the impacts on the event drive pipeline rules.
- Signals that are typically backfilled historically or may not keep track of timestamp ordering may not want to use rules, it may not make sense. Consider filtering with Transforms and/or visualization of data along with post processing analytics.
- If you must backfill data and/or send data with a recorded timestamp while using Rules to trigger state change events, ensure the edge device firmware sends in chronological timestamp order.
Rule Actions¶
When a rule detects a new state, there are a number of outcomes and additional triggered activities.
Rule State Change Activities:
- Event Log - An event is recorded to the asset event log
- Status - The rule's status changes (which is used in the UI and API calls)
- Notifications - Notifications based on user subscriptions are sent out.
- Conditions - The condition service evaluates whether to create a new Condition based on the policy associated to the rule. (Advanced Feature)
- Actions - Action functions that have been connected to this rule will be triggered. (Advanced Feature)
The Using Rules Guide provides a step by step walk through of using rules in ExoSense.
---
config:
theme: neutral
---
graph LR
Signal@{ shape: das, label: "Signal" }
d3@{ shape: sm-circ, label: "Data Point" }
Rule{Rule};
style Rule stroke-width:3px
EventLog@{ shape: cyl, label: "Event Log<br>History" }
Signal e4@-.- d3 e5@--> Rule
state_change@{ shape: f-circ }
style state_change fill:#fdd835,stroke:#fdd835,fill-opacity:0.4;
Rule e6@-.- | State<br>Change | state_change
state_change e7@--> EventLog ~~~ ELC@{ shape: brace-l, label: "The state change information including level (e.g. Warning), is recorded." }
Rule --- Status@{ shape: curv-trap, label: "Updated Rule State: <br>OK -> Warning"} ~~~ SC@{ shape: brace-l, label: "Visualizations / API will use this state when evaluating Signal & Asset Statuses." }
style Status fill:#fdd835,stroke:#fdd835,fill-opacity:0.2
state_change e9@--> Notify@{ shape: subproc, label: "Notification<br>Subscriptions"}
state_change e10@--> Conditions@{ shape: subproc, label: "Condition<br>Management"}
Conditions ~~~ CC@{ shape: brace-l, label: "If Condition Policies are in use, check to see if new condition exists." }
state_change e11@--> Actions@{ shape: procs, label: "Action Functions"}
Actions ~~~ AC@{ shape: brace-l, label: "Triggers any Action functions attached to Rule" }
Notify--> Email["Email"]
Notify--> SMS["SMS"]
e4@{ animate: false }
e5@{ animate: false }
e6@{ animate: true }
e7@{ animate: true }
%%e8@{ animate: true }
e9@{ animate: true }
e10@{ animate: true }
e11@{ animate: true }
Rule Condition States¶
Rules generate status events which are logged in the Asset Log and affect the connected Signals status and the overall Asset Status. In the application, Critical status (shown as red) takes preference over Warning status (yellow), which takes preference over OK status (green).
Event Status (Severity) | System Color | Status Precedence | General Description |
---|---|---|---|
Ok | None | Event state associated as being normal or good. | |
Warning | > Ok | Event State used by some rules for noting that a signal state is not normal or close too bad. This should be monitored appropriately or preemptive action taken. | |
Critical | > Warning | Event State used by some rules for noting that a signal state is bad and action should be taken immediately. | |
Error | > Critical | There is an issue with the signal or rule that prevents the rule from actually determining the current state. Action is recommended. | |
Informational | None | Event State used by some rules to provide information but is not associated as good or bad. |
Quick Summary on 'Statuses'
- Precedence: Severity Ordering: Normal < Warning < Critical < Error
- Timeout: Other rule statuses will be available to see, but since we do not have new data this only provides indication of what the last state was before the timeout. Address why the signal is in Timeout as other rules are not longer getting data
- Informational: Is only informational, does not have any severity indication.
For more details: Asset and Signal Statuses
Timeout States¶
Timeout states for signals are handled separately. Any signal that has a timeout rule associated to it, will roll up to the overall Asset. If the signal is timed out, the asset will show a timeout icon throughout the application. Timeout states do not change the last known signal status. Dashboard panels that show signals will indicate when a specific signal is timed out.
Event Status | Precedence | General Description |
---|---|---|
Timeout | A timeout assumes we only know last state of signal. | The rule for the signal has detected that no value has been received past a given timeout period and therefore is in a timeout state. |
Not In Timeout | None | The rule for the signal has detected that the last value has been received within a given period and therefore is not in a timeout state. |
Notifications Messages¶
Rule status events are recorded to an Asset's event log. In addition, notifications are sent out based on a user's notification preference and subscriptions set up in their profile.
Rules may support additional custom messages that can be included in notifications. Each rule function supports this individually. The text entered in these fields is included in the notification messages sent out to users.
Notifications and Message Formats
Standard Rules¶
Threshold (Numeric type)¶
Allows user to configure the following thresholds for an input signal. If the value of the signal goes above / below these thresholds, the status changes \(critical take preference over warning\) and an event is created in the Asset log.
Overall Parameters
Parameter | Description |
---|---|
Name | The rule name used in the asset modify view. |
Extra details for when value does not match | Prefix text that is applied to Event messages \(Log, Notifications\) when there are no threshold parameters that are true. |
Parameters for each Contains Match
Parameter | Required? | Description |
---|---|---|
Operation | Required | The logical operator used in the threshold calculation |
A value to compare to | Required | The numeric threshold for the operation to compare to |
Duration Type | Required | See below for Duration options. Default is 'Sustained Duration'. |
Extra details for when value does match | Optional | Prefix text that is applied to Event messages \(Log, Notifications\) when this specific value has a match. |
Duration Options
Duration Option | Description |
---|---|
Once | When selected the function will only evaluate the last signal value with the operator and threshold value. |
Sustained Duration | [Default] When selected the function will evaluate based on a time Duration and Duration Units. The signal value threshold operation comparison must stay true for this time duration for a state change. |
Repeated | When selected the threshold operator function will evaluate based on the number of continuous \(**Count**\) times the threshold operator is true in a row. If this count condition is met, it will cause a state change. |
Repeated Over Time | When selected, both a Count \(number of times\) and Duration \(time period\) are used. The function will look for the specified matching threshold operator count within the given duration for a state change. |
Contains (String type)¶
A String signal type rule that will perform a substring search for the specified string value inside of the actual signal's last value.
For normalization of the strings, this rule uses the NFC (Canonical Decomposition, followed by Canonical Composition) as described https://www.unicode.org/reports/tr15/#Norm_Forms.
Note that this Rule function supports multiple match conditions, each with it's own event level.
Overall Parameters
Parameter | Description |
---|---|
Name | The rule name used in the asset modify view. |
Extra Notification Message text when no value matches | Prefix text that is applied to Event messages \(Log, Notifications\) when there are no matches for the contains values. |
Parameters for each Contains Match
Parameter | Required? | Description |
---|---|---|
The substring value to look for | Required | |
Alert level for a matching value | Required | |
Duration Type | Required | See below for Duration options. Default is 'Once'. |
Prefix Notification Message text when a match is found | Optional | Prefix text that is applied to Event messages \(Log, Notifications\) when this specific value has a match. |
Duration Options
Duration Option | Description |
---|---|
Once | Default Duration option. When selected the function will only evaluate the last signal value for a matching comparison. |
Sustained Duration | When selected the function will evaluate based on a time Duration. The signal value matching comparison must stay the same for this long for a state change. |
Repeated | When selected the function will evaluate based on the number of continuous \(**Count**\) times a matching comparison has been made. If this count condition is met, it will cause a state change. |
Repeated Over Time | When selected, both a Count \(number of times\) and Duration \(time period\) are used. The function will look for the specified matching comparisons count within the given duration for a state change. |
Boolean (Boolean type)¶
Evaluates a Boolean signal type and allows setting a status for true and for false values.
Parameters
Parameter | Required? | Description |
---|---|---|
The Alert Level for True | Required | The severity level of the event status state change created when the signal value is true . |
The Alert Level for False | Required | The severity level of the event status state change created when the signal value is false . |
Duration Type | Required | See below for Duration options. Default is 'Once'. |
Prefix Notification Message text when equal | Optional | Pre-fix text that is applied to Event messages (Log, Notifications) when the value is true. |
Prefix Notification Message text when not equal | Optional | Pre-fix text that is applied to Event messages (Log, Notifications) when the value is false. |
Duration Options
Duration Option | Description |
---|---|
Once | Default Duration Option. When selected the function will only evaluate the last signal value for a comparison. |
Sustained Duration | When selected the function will evaluate based on a time Duration. The signal value must stay the same for this long for a state change to occur. |
Repeated | When selected the function will evaluate based on the number of continuous \(**Count**\) times the same value has been sent. If this count condition is met, it will cause a state change. |
Repeated Over Time | When selected, both a Count \(number of times\) and Duration \(time period\) are used. The function will look for the specified count of the same value within the given duration for a state change. |
Is Equal To (Numeric type)¶
Allows a user to set a value to compare a numeric value against. If any match it will set the status to whichever status value was set for that comparison.
Parameters:
Parameter | Required? | Description |
---|---|---|
Value to compare to | Required | The value the rule will compare to the current signal value. |
The number of decimal places to check | Required | The function will compare the signal value to this many decimal places. Default is 1. |
The alert when equal | Required | The severity level of the event status state change created when there is an equal comparison. |
Duration Type | Required | See below for Duration options. Default is 'Once'. |
Prefix Notification Message text when equal | Optional | Pre-fix text that is applied to Event messages (Log, Notifications) when the comparison is true. |
Prefix Notification Message text when not equal | Optional | Pre-fix text that is applied to Event messages (Log, Notifications) when the comparison is false. |
Duration Options
Duration Option | Description |
---|---|
Once | Default Duration Option. When selected the function will only evaluate the last signal value for a comparison. |
Sustained Duration | When selected the function will evaluate based on a time Duration. The signal value must stay the same for this long for a state change. |
Repeated | When selected the function will evaluate based on the number of continuous \(**Count**\) times the same value has been sent. If this count condition is met, it will cause a state change. |
Repeated Over Time | When selected, both a Count \(number of times\) and Duration \(time period\) are used. The function will look for the specified count within the given duration for a state change. |
Timeout¶
The Timeout rule allows a user to set a maximum time period without a new value being received before it is considered to be in a timeout state. Once in the timeout state, the receipt of any new value would trigger an exit out of the timeout state. Both the entering and exiting of the timeout state generate an event in the asset log and can be subscribed-to for notifications.
Enabling the Timeout Features
The timeout Rule and visualization of timeout status in ExoSense are controlled a Feature Flag switch found on the Configuration page's Features tab. Note: Dashboard Panels can visualize a timeout using only the signal's timeout property. Timeout rules are not required for showing individual signal timeouts on dashboard panels.
Asset Timeout Rule
- Makes the Timeout Rule available in the asset configuration
Asset Timeout Visualization and Alerts
An asset will be shown in asset lists, group view, and maps with a timeout indicator if any signal that has a timeout rule is in the timeout state. Only one signal needs a timeout rule for this to occur. For application use cases where all signals our sourced from a single device, only 1 rule is typically necessary to get timeout states and alerts.
Parameters:
Parameter | Required? | Description |
---|---|---|
Timeout Interval | Required | The maximum time period without a new value received for the signal before entering the timeout state. The value is in minutes or hours. The minimum time is 1 minute. |
Extra details when timed out | Optional | Pre-fix text that is applied to Event messages (Log, Notifications) when **entering** the timeout state. |
Extra details for when timed in | Optional | Pre-fix text that is applied to Event messages (Log, Notifications) when **exiting** the timeout state. |
Timeout Rule configuration
A signal with both a timeout rule (shown in timeout state) and a threshold rule.
Timeout Rule vs Signal Timeout Property
The dashboard panels will use a Timeout Rule for showing a signal's timeout status. If none is found, it will use the Signal's Timeout property if it exists to show a timeout state. A signal timeout property is only visual, it does not generate a timeout event / notification.
Repeating Value¶
The Repeating Value
rule allows users to look for a situation where the sensor or controls or device firmware may be 'stuck' in which it continues to just send the same value over and over.
Parameters:
Parameter | Required ? | Description |
---|---|---|
The number of decimal places to check | Required | The function will compare the signal value to this many decimal places. Default is 1. |
The alert level when too many | Required | The severity level of the event status state change created when there is an equal comparison. |
Duration Type | Required | See below for Duration options. Default is repeated count of '5' times. |
Duration Options
Duration Option | Description |
---|---|
Once | Not Recommended. |
Sustained Duration | When selected the function will evaluate based on a time Duration. The signal value must stay the same for this long to trigger. |
Repeated | When selected the function will evaluate based on the number of continuous (Count) times the same value has been sent. If this count condition is met, it will trigger and cause a state change. |
Repeated Over Time | When selected, both a Count (number of times) and Duration (time period) are used. The function will look for the specified count within the given duration for a state change. |
Other Rules¶
ExoSense instances may have other rules added by administrators, built specifically for the instance or added from the IoT Marketplace. These rules will have their own descriptions, input and outputs, and constants.