Abstract:This scenario mainly describes that the device can interact with the Internet of Things platform through LWM2M protocol. Users can create device linkage rules on the console or through the application side interface, forward the attributes reported by the device, and send them to other specified devices under commands through the rule engine of the Internet of Things platform.

Scene description

When the gas detector finds that the gas concentration exceeds the standard, it will automatically open the window with wireless window pusher to play the role of ventilation.

This scenario mainly describes that the device can interact with the Internet of Things platform through LWM2M protocol. Users can create device linkage rules on the console or through the application side interface, forward the attributes reported by the device, and send them to other specified devices under commands through the rule engine of the Internet of Things platform.

Core knowledge: product model, codec plug-in, attribute reporting, command issuing, MQTT protocol, device linkage rules.

Scene: the process

Process explanation:

1. Create anti-gas leakage products: The Internet of Things platform manages batch equipment with the granularity of products. The creation and management of products can be achieved through the API interface or console provided by the platform.

2. Upload product model and codec plug-in: NB equipment uses LWM2M protocol to transmit binary code flow message, and the platform needs to perform corresponding codec conversion to communicate with it. A product model defines the basic attributes and commands of a device. Product models and codecs can be developed from the console, developed offline and uploaded from templates, or imported from the common product library.

3. Registering gas detector and window pusher equipment: The platform provides API interfaces on the application side to register equipment, or batch registration through the console. The registered device ID uniquely identifies the interaction between the device and the platform. Two kinds of equipment can be registered here, one is for gas detection equipment, one is for pushing the window equipment.

4. Create device linkage rules: Users can create rules on the console, specify device linkage rules, set trigger conditions, and perform actions to forward the specified devices.

5. Gas detection value attribute reporting: NB equipment refers to equipment integrated with NB module, which integrates Huawei IOT Tiny SDK. Instructions are transmitted to the platform in binary code, which will be decoded by codec plug-in.

6. Regular device linkage: the IoTDA platform will conduct regular filtering according to the attribute value reported by the gas detector, and then convert the attribute value into a command and send it to the wireless window push device.

7. Order to open the window: the platform sends the command to the wireless window pusher, notifying to open the window for ventilation.

Best practices

The scene that

Gas safety is related to the life and property safety of thousands of households. Based on the device access service provided by Huawei Internet of Things platform, this example triggers the device linkage rule to automatically open the window opener. The specific scenario is that the gas monitor will report the gas concentration value to the Internet of Things platform. When the gas concentration exceeds the standard, the set device linkage rules will be triggered. The Internet of Things platform will issue the command to open the window to the wireless window push device, and the wireless window push device will open the window automatically after receiving the command.

Create gas monitoring products

1. Log in to the official website of Huawei Cloud to access device access services.

2. Click Use Now to access the device access console.

3. In the navigation tree on the left, click Product and select the resource space to which the new product belongs from the drop-down list box in the lower right corner.

4. Click Create Product in the upper right corner to create a gas concentration monitoring product, set the parameters, and click Create Now.

5. On the Function Definition page, click Custom Function and configure the product model by referring to the following table.

Registered plant

1. Choose Device > Device Registration, click Register Device, and set parameters by referring to the following table. Register gas concentration monitoring equipment and record equipment ID and key.

2. Choose Device > Device Registration, click Register Device, and set parameters by referring to the following table. Register the window push device and record the device ID and key.

Configure device linkage rules

1. On the navigation bar, click Rules. In the upper left corner of the drop-down list box, select the resource space (the same resource space as step 3) and click Create Rule in the upper right corner.

2. On the page that is displayed, select Device Linkage.

3. Configure device linkage rules by referring to the following table.

Verify operation

Method one:

You can simulate device validation using MQTT.fx.

1. Mqtt. FX was used to simulate gas detector equipment and window pusher respectively, and connected to the Internet of Things platform. For details, see Accessing the MqTT. fx Experience Device.

2. Open mqtt. fx of the simulated window puller and subscribe to the command issued by the platform.

  • Select the Subscribe TAB.
  • Enter Topic=$OC /devices/{device_id}/sys/commands/# (the same as the device ID obtained in Step 2). .
  • Click “Subscribe” button to complete platform command delivery subscription.

3. Switch to MQTT.fx, which simulates gas detection, and report the property.

  • Select the Publish TAB.
  • Enter the Topic reported by the attributes: $oc/devices/{device_id}/sys/properties/report ({deviceId} must be the same as the deviceId obtained in step 1.) .
  • One gasLevel attribute greater than 6 is reported.

Sample:

{
    "services": [{
            "service_id": "gaslevel"."properties": {
                "gaslevel": 45}}]}Copy the code

  • Click the “Publish” button to report the property value.

4. Switch to mqtt. fx of the analog window push and select the “Subscribe” TAB. You can see that the command whose switch value is on is received from the platform.

Method 2:

You can use the actual device access platform registered during device access service configuration to report data whose GASLevel is greater than 6. The device receives a command with the “switch” value set to “on” and automatically opens the window.


Click to follow, the first time to learn about Huawei cloud fresh technology ~