Planon IoT : IoT Platform - Developer's Guide : Rules Endpoints : Rules/Post : Request – Rules/Post – conditions Properties
Request – Rules/Post – conditions Properties
Property
Type
Description
Mandatory
conditions
Array
Specifies the condition(s) that triggers the Rule. Conditions can be defined at three levels, as follows –
Device level (for one or more Devices).
Product level applies to all the Devices of this Product.
Application ID level. This level applies for all Devices for a given customer.
For example, a condition could be defined at the Product level for refrigerators and there are 50 refrigerators of this Product. The Rule triggers the sending of a text message if the refrigerator temperature exceeds 15 degrees. This means that every refrigerator (meaning each of the 50 refrigerators) belonging to this Product whose temperature exceeds 15 degrees will send a text message.
To define that multiple conditions must exist in a Device at the same time (AND) in order to trigger the Rule, then define multiple conditions in the same Rule. This only works at the Device level.
“conditions”: [
{
“id”: null,
“appIdForRule”: null,
“productId”: null,
“eventName”: “Temperature”,
“typeCode”: 7,
“threshold”: “19”,
“operator”: “>”,
“durationInMinutes”: 3,
“conditionCount”: 0,
“isRelative”: false,
“type”: “Threshold”,
“name”: “Temp > 19 for 3 minutes”,
“ruleTarget”: “Device Level Rule”,
“targetId”: “Axonize.Common.Models.NonSql.DeviceNode”,
“eventProductId”: null,
“devices”: [
{
“id”: “583ee9fa4e41868148e409bd”,
“name”:
“BT Temp 3”
}],”locationConditionSettings”: null
}
],
“ruleRecurrenceSettings”: null
}
Y
conditions/id
String
A unique identifier of this condition generated by IoT Platform and returned in the Rules/Post response.
N
conditions/ appIdForRule
String
Specifies the Application ID(s) to which the condition applies. You must have permissions to access this Application.
Specifying a value here means that the Rule applies to the Application ID level.
N
conditions/productId
String
Specifies the Product ID(s) to which the condition applies. You must have permission to access this Product.
Specifying a value here means that the Rule applies to the Product level.
N
conditions/ eventName
String
The name of the Event of the Application ID/Product/Device on which to apply the condition.
IoT Platform works on a combination of eventName and typeCode (described below).
N
conditions/typeCode
Integer
The type code to which the condition applies.
IoT Platform works on a combination of eventName and typeCode (described above).
If eventName is not specified, then the condition applies to all events with the typeCode specified here, regardless of their eventName.
Y
conditions/threshold
String
The value to which to compare the reading value.
conditions/operator
String
The operator for the condition, which must be appropriate for the data type.
Numeric operators are shown below –
“>”:
“<“:
“=”:
“!=”:
“>=”:
“<=”:
String operators are shown below –
“=”
“!=”
N
conditions/ durationInMinutes
Integer
Specifies how long a condition must continuously exist on a Device before the Rule is triggered.
For example, a Rule can specify that an SMS is sent after 5 minutes (duration) if the temperature of a refrigerator is over 20°. In this case, the temperature must be over 20° for the entire 5 minutes in order for the SMS to be sent.
Duration conditions can only be used at the Device level.
N
conditions/ conditionCount
Integer
Specifies the number of times that the condition must occur consecutively in order to trigger the Rule.
Consecutively means that each consecutive reading received by IoT Platform meets the condition.
For example, a Rule can specify that a temperature must be over 20 degrees in four consecutive readings.
N
conditions/isRelative
Boolean
Set this value to True to indicate that the condition is met if the latest reading differs (based on operator described above) from the first reading by more than the value in the threshold property (described above).
Before this Rule has ever been triggered for a specific Device, the first reading is the anchor. This means that the first reading is the value compared to which all the latest readings are compared.
After the Rule is triggered for a specific Device, the reading that triggered the Rule becomes the new anchor against which all future readings are compared.
N
conditions/type
String
This property can have one of the following values –
Threshold – Indicates that the condition is triggered based on Threshold (this is the default).
Location – Indicates that the condition is triggered based on Location (as described in locationConditionSettings below).
Instantaneous – Indicates that the condition is an instantaneous one.
Property – Indicates that the condition is triggered when comparing a reading value to a property or setting value. When using this value, the name of the property to which you want to compare should be placed in the conditions/threshold property. The condition and the condition name should reference the reading to which you want to compare.
PropertyAndStatic – Indicates that the condition is triggered when comparing between a property/ setting and a static value that you provide in the conditions/threshold described above. This condition is evaluated every time the property or setting is changed. For example, if fan speed is set to High. When using this condition type, the conditions/typecode should be set to 70000.
Reading – Compare between the input reading to other reading (Need to define field readingCondition if you choose this type)
N
conditions/name
String
Specifies the name of the condition.
Y
conditions/ruleTarget
String
A calculated value that indicates the level to which the condition applies. This property can have one of the following values –
Device Level Rule
App Level Rule
Product Level Rule
N
conditions/targetId
tring
A read-only value that specifies the IDs (Application ID, Product ID, Device ID[s]) to which the condition applies.
N
conditions/eventProductId
For internal use only.
N
conditions/devices
Array
Specifies the Device(s) to which the condition applies, including its ID and name (name is optional).
{
“id” : ” 599463f13f8c96478014f1c0 “,
“name” : “Fridge20”
}
Specifying a value here means that the Rule applies to the Device level.
N
conditions/locationConditionSettings
Object
Specifies the geo-fence location for which the condition applies. For example, the location of the Device must be within the circle created by a geo‑fence around a particular point.
When specifying a value here, you cannot also specify an operator or threshold.
locationConditionSettings:{shouldBeInside: true, latitude: “32.0910665”, longitude: “34.78774490000001”, radius: 0.5}
N
conditions/locationConditionSettings/ shouldBeInside
Boolean
When shouldbeinside is True, the Rule is triggered when the Device is located inside the circle created by the geo-fence circle (described below).
When shouldbeinside is False, the Rule is triggered when a Device is outside the geo-fence circle.
conditions/locationConditionSettings/latitude
The latitude of the center of the geo-fence.
conditions/locationConditionSettings/longitude
The longitude of the center of the geo-fence.
conditions/locationConditionSettings/radius
Double
The radius of the geo-fence around the latitude/longitude center of the circle described above.
condition/readingCondition
RuleReadingCondition
Specify reading condition
Y
condition/relativeOperation
RelativeOperation
Specify constant operation for the condition
Condition/relativeOperation/relativeOperator
Enum
Specify the operator:
Plus
Minus
Multiple
Division
Percent
Condition/relativeOperation/relativeModifier
Double
Specify the modifier