

支援終止通知：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-edwsaa"></a>

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

此範例示範使用感應器資料偵測 AWS IoT Events應用程式事件。它顯示如何建立監控指定事件的偵測器模型，以便您可以觸發適當的動作。您可以建立多個感應器輸入、定義複雜的事件條件，以及設定漸進式回應機制。

```
{
    "detectorModelName": "EventDetectionSensorsAndApplications", 
    "detectorModelDefinition": {
        "states": [
            {
                "onInput": {
                    "transitionEvents": [], 
                    "events": []
                }, 
                "stateName": "Device_exception", 
                "onEnter": {
                    "events": [
                        {
                            "eventName": "Send_mqtt", 
                            "actions": [
                                {
                                    "iotTopicPublish": {
                                        "mqttTopic": "Device_stolen"
                                    }
                                }
                            ], 
                            "condition": "true"
                        }
                    ]
                }, 
                "onExit": {
                    "events": []
                }
            }, 
            {
                "onInput": {
                    "transitionEvents": [
                        {
                            "eventName": "To_in_use", 
                            "actions": [], 
                            "condition": "$variable.position != $input.AWS_IoTEvents_Blueprints_Tracking_DeviceInput.gps_position", 
                            "nextState": "Device_in_use"
                        }
                    ], 
                    "events": []
                }, 
                "stateName": "Device_idle", 
                "onEnter": {
                    "events": [
                        {
                            "eventName": "Set_position", 
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "position", 
                                        "value": "$input.AWS_IoTEvents_Blueprints_Tracking_DeviceInput.gps_position"
                                    }
                                }
                            ], 
                            "condition": "true"
                        }
                    ]
                }, 
                "onExit": {
                    "events": []
                }
            }, 
            {
                "onInput": {
                    "transitionEvents": [
                        {
                            "eventName": "To_exception", 
                            "actions": [], 
                            "condition": "$input.AWS_IoTEvents_Blueprints_Tracking_UserInput.device_id != $input.AWS_IoTEvents_Blueprints_Tracking_DeviceInput.device_id", 
                            "nextState": "Device_exception"
                        }
                    ], 
                    "events": []
                }, 
                "stateName": "Device_in_use", 
                "onEnter": {
                    "events": []
                }, 
                "onExit": {
                    "events": []
                }
            }
        ], 
        "initialStateName": "Device_idle"
    }
}
```