Automatically Opening the Window upon High Gas Concentration
Scenarios
IoTDA can instruct a wireless window opener to open the window through a device linkage rule. The scenario is as follows: A gas detector reports the gas concentration value to the IoT platform. When the gas concentration exceeds a specific threshold, the preset device linkage rule is triggered. The platform delivers a window opening command to the wireless window opener, which then opens the window as instructed.
Creating a Gas Monitoring Product
- Log in to the IoTDA console.
- In the navigation pane, click Products. Click the drop-down list box above the product list, and select the resource space to which the new product belongs.
- Click Create Product in the upper right corner to create a gas monitoring product, set the parameters, and click Create.
Set Basic Info
Product Name
Enter a value, for example, gasdevice.
Protocol
Select MQTT.
Data Type
Select JSON.
Manufacturer
Customize the value.
Define Product Model
Product Model
Not selected
Industry
Customize the values.
Device Type
- On the Model Definition tab page, click Custom Model and configure the product model based on the table below.
Service data
Service
Service: gaslevel
Properties
Property Name: gaslevel
Mandatory: selected
Data Type: int
Access Permissions: Read
Value range: 0-100
Commands
Command Name: switch
Parameter Name: switch
Mandatory: selected
Data Type: string
Length: 1
Enumerated Values: on,off
Registering a Device
- In the navigation pane, choose . On the page displayed, click Individual Register in the upper right corner. On the page displayed, set device registration parameters and click OK. Register the gas monitoring device and record the device ID and secret.

Parameter
Description
Product
Select the product created in 4.
Node ID
Set the node ID to a string consisting of letters and numbers. The device ID (corresponding to the node ID) and secret generated after the registration are used for device access.
Device Name
The name can be customized.
Authentication Type
Select Secret.
Secret
Customize the secret used for device access. If no secret is specified, the platform automatically generates a secret.
- In the navigation pane, choose . On the page displayed, click Individual Register in the upper right corner. On the page displayed, set device registration parameters and click OK. Register a window opener device and record the device ID and secret.

Parameter
Description
Product
Select the product created in 4.
Node ID
Set the node ID to a string consisting of letters and numbers. The device ID (corresponding to the node ID) and secret generated after the registration are used for device access.
Device Name
The name can be customized.
Authentication Type
Select Secret.
Secret
Customize the secret used for device access. If no secret is specified, the platform automatically generates a secret.
Configuring a Device Linkage Rule
- In the navigation pane, choose , and click Create Rule in the upper right corner.
- Set the parameters based on the table below. The following parameter values are only examples. You can create your own rules by referring to User Guide. After setting the parameters, click Create Rule.

Parameter
Description
Rule Name
Specify the name of the rule to create, for example, windowswitch.
Activate Now
Select Activate Now.
When Effective
Select Always effective.
Description
Enter a description of the rule, for example, "Automatically opens the window when the gas concentration is higher than 6".
Set Trigger Conditions
- Click Add Condition.
- Select Triggered upon specified device.
- Select the device added in 1.
- Select gaslevel for Service Type, gaslevel for Property, > for Operation, and 6 for Value. Click Trigger Mode. In the dialog box displayed, set Trigger Suppression to Yes and Data Validity Period (s) to 300, click OK.
Set Actions
- Click Add Action.
- Select Deliver Commands, and select the device created in 2.
- Select windowswitch for Service Type, and on_off for Command. Click Configure Parameter. In the dialog box displayed, set switch to on, click OK.
Verifying the Configurations
Method 1:
You can use MQTT.fx to simulate device verification.
- Use MQTT.fx to simulate a gas detector and a window opener, and connect them to the platform. For details, see Using MQTT.fx to Experience Device Access.
- Open MQTT.fx that simulates the window opener to subscribe to commands delivered by the platform.
- Click the Subscribe tab.
- Enter Topic=$oc/devices/{device_id}/sys/commands/# of the command delivered by the subscription platform. (The value must be the same as the device ID obtained in 2.)
- Click Subscribe to deliver the subscription.

- Switch to MQTT.fx that simulates the gas detector to report properties.
- Click the Publish tab.
- Enter topic $oc/devices/{device_id}/sys/properties/report for property reporting. ({deviceId} must be the same as the device ID obtained in 1.)
- Report the property gaslevel with a value greater than 6. Example:
{ "services": [{ "service_id": "gaslevel", "properties": { "gaslevel": 45 } } ] } - Click Publish to report the property value.

- Switch to MQTT.fx that simulates the window opener and click the Subscribe tab. The command carrying switch with the value set to on delivered by the platform is received.

Method 2:
You can use a registered physical device to access the platform and enable the device to report the gaslevel greater than 6. The device receives a command carrying switch with the value set to on and automatically opens the window.
Last Article: Automatic Device Shutdown Upon High Temperature
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.