Skip to content

Instantly share code, notes, and snippets.

@JakWai01
Last active May 7, 2023 15:11
Show Gist options
  • Save JakWai01/1447b4c5564c8ccd77222df44a7fd578 to your computer and use it in GitHub Desktop.
Save JakWai01/1447b4c5564c8ccd77222df44a7fd578 to your computer and use it in GitHub Desktop.
{
"detectorModelName": "sensorDetectorModel",
"detectorModelDefinition": {
"states": [
{
"stateName": "Normal",
"onEnter": {
"events": [
{
"eventName": "init",
"condition": "true",
"actions": [
{
"setVariable": {
"variableName": "moistureThresholdBreached",
"value": "0"
}
}
]
}
]
},
"onInput": {
"transitionEvents": [
{
"eventName": "Overpressurized",
"condition": "$input.moistureInput.sensorData.moisture > 70",
"actions": [
{
"setVariable": {
"variableName": "moistureThresholdBreached",
"value": "$variable.moistureThresholdBreached + 3"
}
}
],
"nextState": "Dangerous"
}
]
}
},
{
"stateName": "Dangerous",
"onEnter": {
"events": [
{
"eventName": "Moisture Threshold Breached",
"condition": "$variable.MoistureThresholdBreached > 1",
"actions": [
{
"sns": {
"targetArn": "arn:aws:sns:us-east-1:123456789012:overMoisturedAction"
}
}
]
}
]
},
"onInput": {
"events": [
{
"eventName": "OverMoisturized",
"condition": "$input.MoistureInput.sensorData.moisture > 70",
"actions": [
{
"setVariable": {
"variableName": "moistureThresholdBreached",
"value": "3"
}
}
]
},
{
"eventName": "Moisture Okay",
"condition": "$input.MoistureInput.sensorData.moisture <= 70",
"actions": [
{
"setVariable": {
"variableName": "moistureThresholdBreached",
"value": "$variable.moistureThresholdBreached - 1"
}
}
]
}
],
"transitionEvents": [
{
"eventName": "BackToNormal",
"condition": "$input.MoistureInput.sensorData.moisture <= 70 && $variable.moistureThresholdBreached <= 1",
"nextState": "Normal"
}
]
},
"onExit": {
"events": [
{
"eventName": "Normal Moisture Restored",
"condition": "true",
"actions": [
{
"sns": {
"targetArn": "arn:aws:sns:us-east-1:123456789012:moistureClearedAction"
}
}
]
}
]
}
}
],
"initialStateName": "Normal"
},
"key" : "sensor",
"roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment