Scenario orchestrations deployed at the edge enable quick response to local messages and can take proper effect in cases of network disconnections. This topic takes the following scenario as an example to describe how to configure scene rules: The Light device is turned off when the light detected by the LightSensor device is greater than or equal to 500 lumens. The Light device is turned on when the light is less than or equal to 200 lumens.

The following figure shows the process.

Scene orchestration example at the edge

Prerequisites

  • An edge instance is created. For more information, see Set up environments.
  • The LightSensor and Light devices are created by using official drivers. The devices are added to the edge instance. For more information, see Sample drivers.

Procedure

  1. Create a scene rule.
    1. On the Edge Instances page, find the edge instance that you have created in Prerequisites and click View in the Actions column.
    2. On the Instance Details page, click the Scenes tab and click Assign Scene.

      You can assign an existing scene rule to an edge instance. If no rules are available, perform the following two steps to create a new scene rule.

    3. In the Assign Scene dialog box, click Add Scene Orchestration. The Rules > Scenario Orchestration page appears. On the page, the Create Scene Orchestration dialog box is displayed.
      Create Scene Orchestration
    4. Create a scene rule named Rule_Light_Open. For more information, see Scene orchestrations on the cloud.
    5. After the rule is created, edit the scene rule, as shown in the following figure.
      Edit the first scene rule

      After editing the scene rule, click Next to go back to the Assign Scene dialog box.

      Note After you are redirected to the Rules > Scene Orchestration page from the Assign Scene dialog box on the Scenes tab of the Instance Details page, the Next button instead of Save is displayed at the bottom of the page for editing a scene rule. This allows you to go back to the Assign Scene dialog box after editing the rule. Then, you can assign the rule to the edge instance.
    6. Find the created scene rule, and click Assign in the Actions column. Assign the rule to the edge instance.
    7. In the Assign Scene dialog box, click Add Scene Orchestration to create a scene rule named Rule_Light_Close. The creation procedure is the same as that used to create the Rule_Light_Open scene rule.
    8. Edit the Rule_Light_Close scene rule, as shown in the following figure.
      Edit the second scene rule
  2. Deploy the edge instance.
    1. In the upper-right corner of the Instance Details page, click Deploy. In the message that appears, click OK to deploy the edge instance.
    2. If the status of the edge instance is Deployed, it indicates that the edge instance has been deployed. You can click View Logs to view the details of the deployment. You can also click View Deployment Logs in the upper-right corner of the Instance Details page to view deployment records.
      If the deployment fails, click the plus sign (+) that is followed by the resource name on the Deployment Details page to view the cause of the failure.View deployment details of the edge instance

      After the edge instance is deployed, the scene rules start to run at the edge. The rules monitor the environment, and trigger execution if required.

  3. View scene orchestration logs of the edge instance.
    Note If a scene rule runs on the cloud and at the edge, you can view the logs by choosing Rules > Scene Orchestration in the IoT Platform console.
    1. On the Scenes tab of the Instance Details page, find the target scene rule, and click Logs in the Actions column.
    2. On the Rule Execution Log page, click Details to view logs.View logs
  4. Optional. Go to the Instance Details page, click the Monitoring tab, and then click Scene Orchestration. You can view the metrics of a scene rule that is assigned to the edge instance as follows:
    Find the target rule, and click View in the Actions column.Scene Orchestration