Help Center> IoT Device Access> Best Practices> Device Access> Constant-Temperature Air Conditioner
Updated on 2024-04-29 GMT+08:00

Constant-Temperature Air Conditioner

Scenarios

Using a constant-temperature control system, you can adjust the default temperature of air conditioners (regardless of whether they are powered on). After being powered on, the air conditioners automatically run at the default temperature. This is achieved by using the device shadow of the IoT platform. For any connected air conditioner, you can set the device shadow on the application or IoTDA console to deliver the preset temperature to the air conditioner. The air conditioner automatically adjusts the temperature after receiving the property modification request.

Developing a Product

  1. Visit the IoTDA product page and click Access Console.
  2. In the navigation pane, click Products. Click the drop-down list in the upper right corner, and select the resource space to which the new product belongs.
  3. Click Create Product on the left to create a constant-temperature air conditioner product, set the parameters, and click OK.

    Basic Information

    Product Name

    Enter a value, for example, aircondition.

    Protocol

    Select MQTT.

    Data Type

    Select JSON.

    Industry

    Customize the values.

    Device Type

  4. After the product is created, click the corresponding product to access its details.
  5. On the Model Definition tab page, click Custom Model and configure the product model based on the table below.

    Service data

    Service

    Service ID: Enter temperature.

    Service Type: You are advised to set this parameter to the same value as Service ID.

    Property

    Property Name: Enter temperature.

    Data Type: Select Integer.

    Access Permissions: Select Read and Write.

    Length: Enter 1.

  6. In the navigation pane, choose Devices > All Devices, and click Individual Register. In the dialog box displayed, set the parameters based on the table below and click OK.

    Figure 1 Registering a device - MQTT

    Parameter

    Description

    Product

    Select the product created in 3.

    Node ID

    Set this parameter to the IMEI, MAC address, or serial number of the device. If the device is not a physical one, set this parameter to a custom character string that contains letters and digits.

    Device Name

    Customize the value.

    Authentication Type

    Select Secret.

    Secret

    Customize the secret used for device access. If the secret is left blank, the platform automatically generates a secret.

Configuring a Device Shadow

You can set a device shadow on the IoTDA console or by calling the API for configuring desired properties in a device shadow on the application side. This section describes how to set a device shadow on the IoTDA console.

  1. Log in to the IoTDA console, choose Devices > All Devices in the navigation pane, and click View in the row of the device registered in 6 to access its details.
  2. On the Device Shadow tab page, click Configure Property.
  3. In the dialog box displayed, enter the desired value of a property. In this example, the value of temperature is set to 25.

    Figure 2 Configuring a device shadow

Verifying the Configurations

Method 1:

You can use MQTT.fx to simulate device verification.

  1. Use MQTT.fx to simulate a constant-temperature air conditioner and connect it to the platform. For details, see Developing an MQTT-based Smart Street Light Online.
  2. On the Subscribe tab page, enter topic=$oc/devices/{device_id}/sys/shadow/get/response/# of the device shadow (replace {device_id} with the device ID in 6), and click Subscribe.

  3. On the Publish tab page, enter Topic=$oc/devices/{device_id}/sys/shadow/get/request_id={request_id} of the device shadow.
  4. Enter a request for obtaining the device shadow and click Publish.
    Example:
    {
    	"object_device_id": "40fe3542-f4cc-4b6a-98c3-61a49ba1acd4",
    	"service_id": temperature"
    }

  5. Click the Subscribe tab. The device shadow data delivered by the platform is displayed.

Method 2:

You can connect a physical device to the platform. The device will receive the device shadow configuration delivered by the platform and change the preset temperature accordingly.