Decision Rule
Decision-Rule is the event-based engine that trigger Actions following matching Conditions. Engine is watching for fact matching conditions on payloads coming from datapoint POST, and handle Action(s) according to rules.
The fact is actually the payload POSTed to datapoint endpoint. This contains some attributes that can be used in the matching Conditions
- user_id
- environment
- dtepoch
- value
- flow
- datetime
Conditions supports combination by using all and any boolean operators. This give the ability for Rules to match multiple complex Conditions.
The following Condition will match when a datapoint is POSTed to flow_id cb518da8-xxxx-xxxx-xxxx-95b3b2bbfd8f and only when the environment is "development".
{
"all": [
{
"fact": "environment",
"operator": "equal",
"value": "development"
},
{
"fact": "flow",
"operator": "equal",
"value": "cb518da8-xxxx-xxxx-xxxx-95b3b2bbfd8f"
}
]
}
Operators allows to compare the value of Facts and so determine when the Rule is matching Conditions.
- isDayTime: will match only when data-timestamp according to geolocalization is during daylight.
{"all":[{"fact":"dtepoch","operator":"isDayTime","value":true}]}
- lastEventGreaterThanInclusive: will match only when last event occurs more than the threashold value in seconds.
{"all":[{"fact":"value","operator":"lastEventGreaterThanInclusive","value":3600}]}
- lastEventLessThanInclusive: will match only when last event occurs less than the threashold value in seconds.
{"all":[{"fact":"value","operator":"lastEventLessThanInclusive","value":3600}]}
- anomalyGreaterThanInclusive: will match only when measured value is greater than predicted value.
{"all":[{"fact":"value","operator":"anomalyGreaterThanInclusive","value":1234}]}
- anomalyLessThanInclusive: will match only when measured value is less than predicted value.
{"all":[{"fact":"value","operator":"anomalyLessThanInclusive","value":1234}]}
- changeGreaterThanInclusive: will match only when the difference in time with previous value is greater than threashold value in seconds
{"all":[{"fact":"value","operator":"changeGreaterThanInclusive","value":1234}]}
- changeLessThanInclusive: will match only when the difference between in time with previous value is less than threashold value in seconds
{"all":[{"fact":"value","operator":"changeLessThanInclusive","value":1234}]}
- sentimentScoreGreaterThanInclusive: Compare the value (must be set as string) with the sentiment score
{"all":[{"fact":"value","operator":"sentimentScoreGreaterThanInclusive","value":2}]}
- sentimentScoreLessThanInclusive: Compare the value (must be set as string) with the sentiment score
{"all":[{"fact":"value","operator":"sentimentScoreLessThanInclusive","value":-1}]}
- distanceGreaterThan: Return true when the distance (in meters) from the object is farest from the lat/lon defined in payload position.
{"all":[{"fact":"value","operator":"distanceGreaterThan","value":100}]}
- distanceLessThan: Return true when the distance (in meters) from the object is closer from the lat/lon defined in payload position.
{"all":[{"fact":"value","operator":"distanceLessThan","value":100}]}
- All logical Math operators listed: https://github.com/CacheControl/json-rules-engine/blob/master/docs/rules.md#operators
- mqttPublish
- mqttCommand
- httpWebhook
- serial
- sms: TODO
- Ifttt: TODO
- slackMessage: TODO
- Please contact us by openning a new issue if any other Actions would be relevant to you.
t6 Technical Api Documentation. Please refers to CONTRIBUTING.md in case you would like to help :-)
- Installing t6
- Internal errors
- Repository structure
- Six main Resources
- Other Resources
- Datapoints
- Users
- UIs 💥 not detailed
- Mqtt Topic 💥 not detailed
- Referentials
- Technical Api Documentation 🔗
- TWA Application Screenshots
- t6 Security policy
- Advanced t6 concepts