

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

# Configuration simple pour embarquer et faire fonctionner les appareils
<a name="managedintegrations-sdk-v2-cookbook-ss"></a>

Configurez vos appareils pour qu'ils soient intégrés à votre hub d'intégrations gérées en créant un objet géré et en le connectant à votre hub. Cette section décrit les étapes à suivre pour terminer le processus d'intégration de l'appareil à l'aide d'une configuration simple.

## Conditions préalables
<a name="managedintegrations-sdk-v2-cookbook-ss-prereq"></a>

Effectuez les étapes suivantes avant de tenter d'intégrer un appareil :
+ Intégrez un appareil central au hub d'intégrations gérées.
+ Installez la dernière version de AWS CLI depuis le manuel [Managed Integrations AWS CLI Command Reference](https://docs.aws.amazon.com/cli/latest/reference/iot-managed-integrations/)
+ Abonnez-vous aux notifications d'événements [DEVICE\$1LIFE\$1CYCLE](managedintegrations-notifications.md#managedintegrations-notification-setup).

**Topics**
+ [Conditions préalables](#managedintegrations-sdk-v2-cookbook-ss-prereq)
+ [Étape 1 : créer un casier d'identifiants](#managedintegrations-sdk-v2-cookbook-credential-locker)
+ [Étape 2 : ajoutez le casier d'identifiants à votre hub](#managedintegrations-sdk-v2-cookbook-add-to-hub)
+ [Étape 3 : Créez un objet géré avec des informations d'identification.](#managedintegrations-sdk-v2-cookbook-ss-create-managed-thing)
+ [Étape 4 : Branchez l'appareil et vérifiez son état.](#managedintegrations-sdk-v2-cookbook-ss-check-device-status)
+ [Étape 5 : Obtenir les fonctionnalités de l'appareil](#managedintegrations-sdk-v2-cookbook-ss-check-device-capabilities)
+ [Étape 6 : Envoyer une commande à l'objet géré](#managedintegrations-sdk-v2-cookbook-ss-control-device)
+ [Étape 7 : supprimer l'objet géré de votre hub](#managedintegrations-sdk-v2-cookbook-clean-up)

## Étape 1 : créer un casier d'identifiants
<a name="managedintegrations-sdk-v2-cookbook-credential-locker"></a>

Créez un casier d'informations d'identification pour votre appareil. 

**Pour créer un casier d'informations d'identification**
+ Utilisez la commande `create-credential-locker`. L'exécution de cette commande déclenchera la création de toutes les ressources de fabrication, y compris la paire de clés de configuration Wi-Fi et le certificat de l'appareil.

  **Exemple create-credential-locker**

  ```
  aws iot-managed-integrations create-credential-locker \
    --name "DEVICE_NAME"
  ```

  **Réponse :**

  ```
  {    
    "Id": "LOCKER_ID"
    "Arn": "arn:aws:iotmanagedintegrations:AWS_REGION:AWS_ACCOUNT_ID:credential-locker/LOCKER_ID
    "CreatedAt": "2025-06-09T13:58:52.977000+08:00"
  }
  ```

  Pour plus d'informations, consultez la [create-credential-locker](https://docs.aws.amazon.com/cli/latest/reference/iot-managed-integrations/create-credential-locker.html)commande dans le manuel de *référence des AWS CLI commandes* des intégrations gérées.

## Étape 2 : ajoutez le casier d'identifiants à votre hub
<a name="managedintegrations-sdk-v2-cookbook-add-to-hub"></a>

Ajoutez le casier d'identifiants à votre hub.

**Pour ajouter un casier d'identifiants à votre hub**
+ Utilisez la commande suivante pour ajouter un casier d'informations d'identification à votre hub.

  ```
  aws iotmi --region AWS_REGION --endpoint AWS_ENDPOINT update-managed-thing \
  --identifier "HUB_MANAGED_THING_ID" --credential-locker-id "LOCKER_ID"
  ```

## Étape 3 : Créez un objet géré avec des informations d'identification.
<a name="managedintegrations-sdk-v2-cookbook-ss-create-managed-thing"></a>

Créez un objet géré avec les informations d'identification de votre appareil. Chaque appareil doit être géré par lui-même.

**Pour créer un objet géré**
+ Utilisez la `create-managed-thing` commande pour créer un objet géré pour votre appareil.

  **Exemple create-managed-thing**

  ```
  #ZWAVE: 
  aws iot-managed-integrations create-managed-thing --role DEVICE \
  --authentication-material '900137947003133...' \ #auth material from zwave qr code
  --authentication-material-type ZWAVE_QR_BAR_CODE \
  --credential-locker-id ${locker_id}
  
  #ZIGBEE:
  aws iot-managed-integrations create-managed-thing --role DEVICE \
  --authentication-material 'Z:286...$I:A4DC00.' \ #auth material from zigbee qr code
  --authentication-material-type ZIGBEE_QR_BAR_CODE \
  --credential-locker-id ${locker_id}
  ```
**Note**  
Il existe des commandes distinctes pour les appareils Z-wave et Zigbee.

  **Réponse :**

  ```
  {    
    "Id": "DEVICE_MANAGED_THING_ID"
    "Arn": "arn:aws:iotmanagedintegrations:AWS_REGION:AWS_ACCOUNT_ID:managed-thing/DEVICE_MANAGED_THING_ID"
    "CreatedAt": "2025-06-09T13:58:52.977000+08:00"
  }
  ```

  Pour plus d'informations, consultez la [create-managed-thing](https://docs.aws.amazon.com/cli/latest/reference/iot-managed-integrations/create-managed-thing.html)commande dans le manuel de *référence des AWS CLI commandes* des intégrations gérées.

## Étape 4 : Branchez l'appareil et vérifiez son état.
<a name="managedintegrations-sdk-v2-cookbook-ss-check-device-status"></a>

**Branchez l'appareil et vérifiez son état.**
+ Utilisez la `get-managed-thing` commande pour vérifier l'état de votre appareil. ProvisioningStatus L'objet que vous gérez doit être ACTIVÉ. Pour plus d'informations ProvisioningStatus, consultez la section [Approvisionnement des appareils](https://docs.aws.amazon.com/iot-mi/latest/devguide/device-provisioning.html).

  **Exemple get-managed-thing**

  ```
  #KINESIS NOTIFICATION:
  {
      "version": "1.0.0",
      "messageId": "4ac684bb7f4c41adbb2eecc1e7991xxx",
      "messageType": "DEVICE_LIFE_CYCLE",
      "source": "aws.iotmanagedintegrations",
      "customerAccountId": "12345678901",
      "timestamp": "2025-06-10T05:30:59.852659650Z",
      "region": "us-east-1",
      "resources": ["XXX"],
      "payload": {
          "deviceDetails": {
              "id": "1e84f61fa79a41219534b6fd57052XXX",
              "arn": "XXX",
              "createdAt": "2025-06-09T06:24:34.336120179Z",
              "updatedAt": "2025-06-10T05:30:59.784157019Z"
          },
          "status": "ACTIVATED"
      }
  }
  aws iot-managed-integrations get-managed-thing \
  --identifier :"DEVICE_MANAGED_THING_ID"
  ```

  **Réponse :**

  ```
  {    
    "Id": "DEVICE_MANAGED_THING_ID"
    "Arn": "arn:aws:iotmanagedintegrations:AWS_REGION:AWS_ACCOUNT_ID:managed-thing/MANAGED_THING_ID"
    "CreatedAt": "2025-06-09T13:58:52.977000+08:00"
  }
  ```

  Pour plus d'informations, consultez la [get-managed-thing](https://docs.aws.amazon.com/cli/latest/reference/iot-managed-integrations/get-managed-thing.html)commande dans le manuel de *référence des AWS CLI commandes* des intégrations gérées.

## Étape 5 : Obtenir les fonctionnalités de l'appareil
<a name="managedintegrations-sdk-v2-cookbook-ss-check-device-capabilities"></a>

Utilisez la `get-managed-thing-capabilities` commande pour obtenir l'ID de votre terminal et afficher la liste des actions possibles pour votre appareil.

**Pour obtenir les fonctionnalités d'un appareil**
+ Utilisez la `get-managed-thing-capabilities` commande et notez l'ID du point de terminaison.

  **Exemple get-managed-thing-capabilties**

  ```
  aws iotmi get-managed-thing-capabilities \
  --identifier "DEVICE_MANAGED_THING_ID"
  ```

  **Réponse :**

  ```
  {    
      "ManagedThingId": "1e84f61fa79a41219534b6fd57052cbc",
      "CapabilityReport": {
          "version": "1.0.0",
          "nodeId": "zw.FCB10009+06",
          "endpoints": [
              {
                  "id": "ENDPOINT_ID"
                  "deviceTypes": [
                      "On/Off Switch"
                  ],
                  "capabilities": [
                      {
                          "id": "matter.OnOff@1.4",
                          "name": "On/Off",
                          "version": "6",
                          "properties": [
                              "OnOff"
                          ],
                          "actions": [
                              "Off",
                              "On"
                          ],
                          "events": []
                      }
                      ...
  }
  ```

  Pour plus d'informations, consultez la [get-managed-thing-capabilities](https://docs.aws.amazon.com/cli/latest/reference/iot-managed-integrations/get-managed-thing-capabilities.html)commande dans le manuel de *référence des AWS CLI commandes* des intégrations gérées.

## Étape 6 : Envoyer une commande à l'objet géré
<a name="managedintegrations-sdk-v2-cookbook-ss-control-device"></a>

Utilisez la `send-managed-thing-command` commande pour envoyer une commande d'action à bascule à votre objet géré.

**Pour envoyer une commande à votre objet géré**
+ Utilisez la `send-managed-thing-command` commande pour envoyer une commande à votre objet géré.

  **Exemple send-managed-thing-command**

  ```
  json=$(jq -cr '.|@json') <<EOF
  [
    {
      "endpointId": "1",
      "capabilities": [
        {
          "id": "matter.OnOff@1.4",
          "name": "On/Off",
          "version": "1",
          "actions": [
            {
              "name": "Toggle",
              "parameters": {}
            }
          ]
        }
      ]
    }
  ]
  EOF
  aws iot-managed-integrations send-managed-thing-command \
  --managed-thing-id "DEVICE_MANAGED_THING_ID" --endpoints "ENDPOINT_ID"
  ```
**Note**  
Cet exemple utilise jq cli to, mais vous pouvez également transmettre la chaîne entière`endpointId`.

  **Réponse :**

  ```
  {    
  "TraceId": "TRACE_ID"
  }
  ```

  Pour plus d'informations, consultez la [send-managed-thing-command](https://docs.aws.amazon.com/cli/latest/reference/iot-managed-integrations/send-managed-thing-command.html)commande dans le manuel de *référence des AWS CLI commandes* des intégrations gérées.

## Étape 7 : supprimer l'objet géré de votre hub
<a name="managedintegrations-sdk-v2-cookbook-clean-up"></a>

Nettoyez votre hub en supprimant l'élément géré.

**Pour supprimer un objet géré**
+ Utilisez la `delete-managed-thing` commande pour supprimer un objet géré du hub de votre appareil.

  **Exemple delete-managed-thing**

  ```
  aws iot-managed-integrations delete-managed-thing \
  --identifier "DEVICE_MANAGED_THING_ID"
  ```

  Pour plus d'informations, consultez la [delete-managed-thing](https://docs.aws.amazon.com/cli/latest/reference/iot-managed-integrations/delete-managed-thing.html)commande dans le manuel de *référence des AWS CLI commandes* des intégrations gérées.
**Note**  
Si l'appareil est bloqué dans un `DELETE_IN_PROGRESS` état, ajoutez le `--force` drapeau au`delete-managed-thing command`.
**Note**  
Pour les appareils Z-wave, vous devez mettre l'appareil en mode couplage après avoir exécuté la commande.