Sample rules

Sample rules are provided out-of-the-box for the following rules. These rules can be edited and imported using the Rule Import API.
  • Time Drift Determination
  • Water Meter Alarms
  • Water Meter Validations 1
  • Water Meter Validations 2
  • Water Meter Validations 3
  • Daily Average
  • Water Meter Consumption Anomaly
  • Water Meter Estimation
  • Meter Reading Value Extraction

Time Drift Determination

This rule raises an alarm when the time reported by the device in response to a read operation on the resource 3333/0/5506 has drifted more than 10 seconds from the time in IMPACT IoT server.

Water Meter Alarms

This rule raises an alarm when either the empty pipe alarm (10274/0/6025) or daughter board failure alarms (10282/0/6025) are raised by the device. The rule currently works only when the Event Type (10274/0/6011 or 10282/0/6011) is set to Alarm Current State (1).

The decoded CBOR value of these observation resources is assumed as follows for Event Type = Alarm Current State (1):

[Event Code (16-bit integer),Event Type (8-bit Integer),Alarm Timestamp (32-bit unsigned integer),Alarm State (8-bit Integer)]

Example:

[10274,1,1665995897,1]

Where:

  • Event Type is 1 for Alarm Current State. Refer to 10274/0/6011 or 10282/0/6011 for other values.
  • Alarm State is 1 for true and 0 for false.

Water Meter Validations 1

This rule raises an alert when validations fail on the water meter reading resource (10266/0/6029).

The decoded CBOR value of this observation resource is assumed as :
[Interval Data Instance ID/ Class (16-bit integer),Timestamp of first Interval (32-bit integer),Interval Period in seconds (32-bit integer),Number of intervals in Payload (16-bit integer),Number of Values Per Interval (8-bit integer),...,Interval N Value N], 
with the last item in the array referring to the current reading of the water meter.

Example:

[2,1665995897,86400,1,1,...,10]

The following validations are performed:

  • Invalid decoded value - CBOR decoding errors, where the value was not decoded correctly to an array. This is checked by verifying that the value is an array, and has at least one element in it.
  • Non-numeric value - The last item in the array (the reading) is a numeric value.
  • Value is zero or negative - The last item in the array (the reading) is a positive value.

Water Meter Validations 2

This rule raises an alert when validations fail on the water meter reading resource (10266/0/6029).
Note: This rule assumes that the observation on the resource is sent only once per day. This value is configured in "advanceInSec".
Note: This rule uses a WINDOW size of 2 days, to capture latest 2 values and compare them. This value is configured in "sizeInSec".

Refer to Water Meter Validations 1 rule for the decoded CBOR value of this observation resource assumption.

The following validations are performed:

  • Time less than previous - Incorrect water meter functionality, where the time (Second item in the decoded array) reported in the latest payload is earlier than the previous one.
  • Value less than previous - Incorrect water meter functionality, where the reading (Last item in the decoded array) reported in the latest payload is less than the previous one.

Water Meter Validations 3

This rule raises an alert when validations fail on the water meter reading resource (10266/0/6029).

Note: This rule assumes that the observation on the resource is sent only once per day. This value is configured in "advanceInSec".
Note: This rule uses a WINDOW size of 3 days, to capture latest 3 values and calculate the actual consumption of two days. Consumption is calculated as reading on the day minus the reading on the day before. This window size value is configured in "sizeInSec".

Refer to Water Meter Validations 1 rule for the decoded CBOR value of this observation resource assumption.

The following validations are performed:

  • Consumed value X% different from previous - Sudden increase or decrease in consumption by X%. This is done by comparing the consumption of the last day against the consumption of the day before.

    The X in the rule is set to 50%.

Daily Average

This rule calculates moving average over N days.
Note: This rule is used as input for other rules.

Refer to the following Water Meter Consumption Drop rule.

Water Meter Consumption Anomaly

This rule raises an alert when there is a large variation in the average consumption. This is calculated by comparing the recently calculated average consumption against the average consumption calculated X days ago. The rule raises an alert if the variation is more than Y%. The average consumption is calculated as a moving average over a sample of N days.

In the sample rule, days across which consumption is compared (X days) is set to 3 days (259200 seconds), configured in "sizeInSec". And the variation (Y%) is set to 50%.
Note: This rule assumes that the observation on the resource is sent only once per day. This value is configured in "advanceInSec".
Note: The moving average calculation of N days is from the Daily Average rule above.

Water Meter Estimation

This rule calculates the water meter reading estimations. This is calculated by considering the previous readings observed for N days and calculate estimated meter readings. The estimation is calculated for the value present in the resource (10266/0/6029). In the sample rule, for a window of 1 day is provided which can be extended to N days.

Meter Reading Value Extraction

This rule extracts the observation values from the data emitted with CBOR format. The reading value is present at the last element in the array as shown below, which is value 10.

Example:

[2,1665995897,86400,1,1,...,10]