Appendix¶
In this section some important CEP use cases have been described.
Use Case 1¶
Operation Sequences¶
1)Home Owner and family leave on a vacation. 2)Before they leave the home the owner Forgets to check the tap in bathtub that is leaking (hot water tap)
Rule Statement¶
The requirement is to detect and trigger a water leakage alert If Humidity from bathroom sensor is greater than 70% for 30 minutes and home security status is ‘LOCKED’
Sensors Used¶
Humidity sensor attached with bathroom
Home security status checking sensor
CEP Rule Used¶
WaterLeakageAlertRule
The following is the create rule JSON for the rule:
{
"ruleName": "WaterLeakageAlertRule",
"selectClause": "avg(s2.humidity) OVER (PARTITION BY s2.feature) as avgHumidity,s2.feature as feature,s1.securityStatus as securitystatus,s1.starttime as s1time,s2.starttime as s2time",
"whereClause": "avgHumidity > 70 AND securitystatus = 'LOCKED'",
"joinClause": "(s1.feature = s2.feature) AND abs(s1.starttime - s2.starttime) <= 60",
"groupByField": "feature",
"triggerInterval": "60",
"windowDuration": "60",
"input": [
{
"alias": "s1",
"topic": "test1",
"properties": [
"securityStatus"
]
},
{
"alias": "s2",
"topic": "test2",
"properties": [
"humidity"
]
}
],
"output": "waterleakgaeop"
}
Use Case 2¶
Operation Sequences¶
1)It is a week day and Home Owner has gone to office. Home owner family goes out for shopping. 2)Before they leave home owner family sets the temperature at @ 60 Degrees Farenheit,locks the door and leave the gas stove switched on. 3)We want to detect potential Hazard(fire) Alert.
Rule Statement¶
The requirement is to detect and trigger a fire alert If home security status is ‘LOCKED’ and difference between home ac temp value and temp from kitchen sensor is greater than 20F
Sensors Used¶
Home AC temp sensor
Kitchen sensor
Home security status checking sensor
CEP Rule Used¶
FireAlertRule
The following is the create rule JSON for the rule:
{
"ruleName": "FireAlertRule",
"selectClause": "s1.securityStatus as securitystatus,(s2.homeactemp - s3.kitchentemp) as tempdiff,s1.feature as feature,s1.starttime as s1time,s2.starttime as s2time,s3.starttime as s3time",
"joinClause": "(s1.feature = s2.feature) AND abs(s1.starttime - s2.starttime) <= 30,(s2.feature = s3.feature) AND abs(s2.starttime - s3.starttime) <= 30",
"groupByField": "feature",
"whereClause": "tempdiff > 20 AND securitystatus = 'LOCKED'",
"triggerInterval": "60",
"windowDuration": "60",
"input": [
{
"alias": "s1",
"topic": "test1",
"properties": [
"securityStatus"
]
},
{
"alias": "s2",
"topic": "test2",
"properties": [
"homeactemp"
]
},
{
"alias": "s3",
"topic": "test3",
"properties": [
"kitchentemp"
]
}
],
"output": "firealertop"
}
Note
CEP rules are the basic building blocks. Based on use cases they can be wired as shown in the use cases.