Help Center/ IoT Device Access/ Best Practices/ Device Management/ Managing Indoor Air Conditioners Using Custom Topics
Updated on 2024-11-04 GMT+08:00

Managing Indoor Air Conditioners Using Custom Topics

Scenarios

Custom topics apply to MQTT devices connected to IoTDA. Topics for message reporting and message delivery can be customized. Applications can implement different service logic processing based on topics. Custom topics can also be used in the scenario where a device cannot report properties or receive delivered commands defined in the product model.

In this example, an application receives data reported by a device and determines whether to turn on or off the indoor air conditioner.

Prerequisites

Customizing a Topic

For details, see Custom Topic Communications.

Message Reporting

  1. Visit the IoTDA service page and click Access Console. Click the target instance card.
  2. In the navigation pane, choose Devices > All Devices, locate the target device, and click View to access its details page.
  3. Click the Message Trace tab, click Start Trace, and set the trace duration as required.
  4. Use the MQTT.fx simulator to simulate a device to report a custom topic message. For details, see Quick Device Access.

    For devices connected using the IoT Device SDK or native MQTT protocol, you need to set the custom topic name reported by the device in the device program.

  5. On the Message Trace page, view the custom topic messages reported by the device.
    Figure 1 Viewing message trace
  6. An application obtains the custom topic message reported by the device through data forwarding. For details, see Data Forwarding. You can also refer to Forwarding Device Data to OBS for Long-Term Storage.

Message Delivery

In this example, the Postman is used to deliver an instruction for starting the indoor air conditioner.

  1. Use the MQTT.fx simulator to subscribe to a custom topic.

    • Ensure that the device operation permissions contain the subscription function when you create a custom topic. For details, see Custom Topic Communications.
    • For devices connected using the IoT Device SDK or native MQTT protocol, you need to set the name of the custom topic to which the device subscribes in the device program.
  2. Use the Postman to simulate the application to call the API Delivering a Message to a Device to deliver a command for starting the indoor air conditioner.

  3. Call the API Querying Device Messages to check whether the command is delivered. If the command is delivered, the indoor air conditioner will be started.