

支援終止通知：2026 年 5 月 20 日， AWS 將終止對 的支援 AWS IoT Events。2026 年 5 月 20 日之後，您將無法再存取 AWS IoT Events 主控台或 AWS IoT Events 資源。如需詳細資訊，請參閱[AWS IoT Events 終止支援](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-end-of-support.html)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 範例：使用 建置簡單的警示 AWS IoT Events
<a name="iotevents-examples-bsa"></a>

此偵測器模型是 AWS IoT Events 主控台提供的其中一個範本。為方便起見，它包含在這裡。

```
{
    "detectorModelDefinition": {
        "states": [
            {
                "onInput": {
                    "transitionEvents": [
                        {
                            "eventName": "not_fixed", 
                            "actions": [], 
                            "condition": "timeout(\"snoozeTime\")", 
                            "nextState": "Alarming"
                        }, 
                        {
                            "eventName": "reset", 
                            "actions": [], 
                            "condition": "$input.AWS_IoTEvents_Blueprints_Simple_Alarm_Input.command == \"reset\"", 
                            "nextState": "Normal"
                        }
                    ], 
                    "events": [
                        {
                            "eventName": "DND", 
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "dnd_active", 
                                        "value": "1"
                                    }
                                }
                            ], 
                            "condition": "$input.AWS_IoTEvents_Blueprints_Simple_Alarm_Input.command == \"dnd\""
                        }
                    ]
                }, 
                "stateName": "Snooze", 
                "onEnter": {
                    "events": [
                        {
                            "eventName": "Create Timer", 
                            "actions": [
                                {
                                    "setTimer": {
                                        "seconds": 120, 
                                        "timerName": "snoozeTime"
                                    }
                                }
                            ], 
                            "condition": "true"
                        }
                    ]
                }, 
                "onExit": {
                    "events": []
                }
            }, 
            {
                "onInput": {
                    "transitionEvents": [
                        {
                            "eventName": "out_of_range", 
                            "actions": [], 
                            "condition": "$input.AWS_IoTEvents_Blueprints_Simple_Alarm_Input.value > $variable.threshold", 
                            "nextState": "Alarming"
                        }
                    ], 
                    "events": [
                        {
                            "eventName": "Create Config variables", 
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "threshold", 
                                        "value": "$input.AWS_IoTEvents_Blueprints_Simple_Alarm_Input.threshold"
                                    }
                                }
                            ], 
                            "condition": "$variable.threshold != $variable.threshold"
                        }
                    ]
                }, 
                "stateName": "Normal", 
                "onEnter": {
                    "events": [
                        {
                            "eventName": "Init", 
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "dnd_active", 
                                        "value": "0"
                                    }
                                }
                            ], 
                            "condition": "true"
                        }
                    ]
                }, 
                "onExit": {
                    "events": []
                }
            }, 
            {
                "onInput": {
                    "transitionEvents": [
                        {
                            "eventName": "reset", 
                            "actions": [], 
                            "condition": "$input.AWS_IoTEvents_Blueprints_Simple_Alarm_Input.command == \"reset\"", 
                            "nextState": "Normal"
                        }, 
                        {
                            "eventName": "acknowledge", 
                            "actions": [], 
                            "condition": "$input.AWS_IoTEvents_Blueprints_Simple_Alarm_Input.command == \"acknowledge\"", 
                            "nextState": "Snooze"
                        }
                    ], 
                    "events": [
                        {
                            "eventName": "Escalated Alarm Notification", 
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-west-2:123456789012:escalatedAlarmNotification"
                                    }
                                }
                            ], 
                            "condition": "timeout(\"unacknowledgeTIme\")"
                        }
                    ]
                }, 
                "stateName": "Alarming", 
                "onEnter": {
                    "events": [
                        {
                            "eventName": "Alarm Notification", 
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-west-2:123456789012:alarmNotification"
                                    }
                                }, 
                                {
                                    "setTimer": {
                                        "seconds": 300, 
                                        "timerName": "unacknowledgeTIme"
                                    }
                                }
                            ], 
                            "condition": "$variable.dnd_active != 1"
                        }
                    ]
                }, 
                "onExit": {
                    "events": []
                }
            }
        ], 
        "initialStateName": "Normal"
    }, 
    "detectorModelDescription": "This detector model is used to detect if a monitored device is in an Alarming State.", 
    "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole", 
    "key": "alarmId" 
}
```