Use Huawei Cloud IoT with zero code and zero hardware, and monitor devices in real time based on device linkage

This article is shared from Huawei Cloud Community "One-click protection, real-time insight: Huawei Cloud IoT device linkage, intelligent perception of device status changes, and accurate triggering of alarm notifications [Play with Huawei Cloud IoT with zero code and zero hardware]" , author: Zhou Zhou's Wonderful Programming .

Preface

Previously we have experienced three aspects: device access, device control and long-term data storage. ( Walking on the cloud: Five steps to use the device simulator to connect to the Huawei Cloud IoT platform . With one click on the cloud, you can adjust the room temperature as you like: experience future-style constant temperature air conditioning cloud control, enjoy a personalized and comfortable life , and cloud-linked future. Unlimited storage: Huawei Cloud IoT platform joins hands with OBS to build a new paradigm for real-time flow and long-term archiving of device data ).

Now, we are about to enter the final experimental stage, focusing on an important function in IoT applications- device linkage . The experiment will monitor equipment status changes in real time and send notifications. The IoT platform can realize intelligent monitoring and instant response to key equipment, provide equipment managers with real-time equipment status information, and ensure efficient and stable operation of equipment.

In this experiment, we will take an IoT gateway as an example to demonstrate how to use the rule engine function provided by Huawei Cloud IoT Device Access Service to set conditions to trigger rules. When the online and offline status of the gateway device changes, the platform automatically triggers an alarm. The alarm will be canceled after the equipment returns to normal, and these status changes will be promptly notified to designated managers via email or SMS.

Monitor device status changes and send notifications

Scene description

In the IoT scenario, some devices have important application scenarios, such as IoT gateways, etc., and device managers need to sense the online and offline status of these devices.

The device access service provides a rule engine function to meet this requirement. You can use simple operations to realize that when the device status meets a certain condition, the IoT platform triggers a specified action to notify you.

Assume that there are a batch of gateway devices under the gateway product of an enterprise, and about 400 sub-devices are mounted on a single gateway device. Users need to pay attention to the status of this batch of gateway devices in real time to ensure that the sub-devices report data normally. At the same time, due to the gateway device and the Internet of Things The platform establishes a connection through the 4G network. There is a problem of frequent alarms due to network jitter. Therefore, users think that going online after a short period of offline is a normal scenario and do not want to perceive this scenario.

Through the following example, you can monitor all gateway devices under this gateway product and report an alarm through the IoT platform after the offline duration reaches 5 minutes. The alarm will be restored after the device comes online for 1 minute, and an email or SMS notification will be sent to the specified mobile phone number.

docking process

  1. Configure device access services: Create IoT products and devices, create linkage rules, and send alarms to application operation and maintenance management services after devices go online and offline and meet specific conditions.

  2. Configure message notification service: Create SMS or email subscription.

  3. Configure application operation and maintenance management services: create alarm rules, process alarms reported by the device access service, and send SMS or email notifications through the message notification service.

Configure device access service

Create a product model, register the device, and set device linkage rules in the device access service, so that when the device is offline for 5 minutes, an alarm is reported to the application operation and maintenance management platform, and the alarm is restored 1 minute after the device goes online.

Access the device access service and click "Use Now" to enter the device access console.

Select "Products" in the left navigation bar and click "Create Product" on the left side of the page to create a product based on the MQTT protocol. After filling in the parameters, click "Confirm" to complete the creation of the product.

image.png

Click here (https://obs-pipeline.obs.cn-north-4.myhuaweicloud.com/sdkDeploy/Profile_01.zip) to obtain a sample product model file, as shown in the figure after decompression:

image.png

Find the newly added product and click "Product" to enter the product details interface.

On the "Model Definition" page of product details, click "Upload Model File", load the product model file in the pop-up page, and then click "OK".

image.png

After the upload is successful, it will appear as shown below:

image.png

Select "Device > Device Registration" in the left navigation bar, click "Register Device" in the upper right corner, and fill in the device registration parameters. After completing the filling, click "OK". Please save the "Device ID" and "Device Key" returned after successful registration. I have already registered it in previous articles, so I won’t go into details here.

image.png

Select "Rules > Device Linkage" in the left navigation bar and click the "Create Rule" button in the upper right corner. (You need to select the resource space to which you belong before creating a rule)

image.png

Refer to the parameter description in the following table, fill in the rule content, and create the gateway offline and online alarm reporting rules. The following parameter values ​​are only examples. You can refer to the user guide to create your own alarm rules. After completing the filling, click "Create Rule".

image.png

In the same way, create a recovery alarm again.

image.png

【Notice】

  • The alarm name, level, and dimensions are combined to identify an AOM (Application Operation Management) alarm. The restored alarm and the reported alarm need to maintain the same alarm attributes, otherwise the alarm recovery fails.

  • Device status monitoring has flow control restrictions. Excessive monitoring of devices will trigger flow control and cause device offline alarms to fail to be reported. For details, please refer to Usage Limits.

Configure message notification service

Create a topic in the message notification service and add a subscription, which can be called by the application operation and maintenance management service to send emails or text messages.

Log in to the official Huawei Cloud website and access the message notification service ( https://www.huaweicloud.com/product/smn.html  ).

image.png

Go to the "Theme Management > Theme" page and click "Create Theme".

image.png

Enter a topic name, such as "Test_1", and click "OK".

image.png

Enter the "Topic Management > Subscription" page and click "Add Subscription".

image.png

Fill in your subscription information. Click "OK" after completing the filling.

image.png

Configure application operation and maintenance management services

Create alarm rules and alarm action rules in the application operation and maintenance management service. When the device access service meets the conditions to report an alarm, the reported alarm will be processed and an email or SMS will be sent.

Log in to the official Huawei Cloud website and access the application operation and maintenance management service ( https://www.huaweicloud.com/product/aom.html).

image.png

Go to the "Alarm > Alarm Action Rules" page and click "Create Alarm Action Rule".

image.png

Enter the name of the alarm action rule, such as "Test_1", select the topic "Test_1" created in the configuration message notification service, and click "OK".

image.png

Enter the "Alarm > Alarm Rules" page and click "Add Alarm".

image.png

Enter the rule name, such as "Gateway_Status_Change_Alarm_Rule", select "Event Alarm Rules > Custom Events", select "IoTDA" as the alarm source, and select the custom attribute "event_name=Gateway Status Change" for the monitoring object (the content after "=" is the alarm name) , select "Trigger immediately" for the triggering strategy, select direct alert for the alarm method, select the action rule created in step 4 for the action rule, and click "Create now" in the lower right corner.

image.png

Verify operation

After the device is offline for 5 minutes:

Select "Monitor Operations > Current Alarms" in the left navigation bar, click "Go to AOM", jump to the application operation and maintenance management service, and there is an important alarm named "Gateway Status Change".

After the device goes online for 1 minute:

The device's "Gateway Status Change" important alarm is restored and can be viewed in historical alarms.

image.png

Conclusion

So far, we have completed the comprehensive exploration and practice of device linkage functions in IoT applications. By monitoring equipment status changes in real time and sending notifications, we not only achieve intelligent monitoring and immediate response to key equipment such as IoT gateways, but also ensure that equipment managers can grasp equipment status information in real time, effectively improving equipment operation and maintenance efficiency and Business continuity.

Through this series of experiments, we have deeply experienced the power of Huawei Cloud IoT device linkage function. It not only simplifies the complexity of device status monitoring and alarm management, but also closely integrates with message notification services and application operation and maintenance management services. , providing equipment managers with real-time and accurate equipment status information and alarm notification services. This complete set of solutions is not only suitable for monitoring key equipment such as IoT gateways, but can also be widely used in various IoT devices and scenarios to help enterprises achieve intelligence and automation in equipment management, effectively improving business operation efficiency and service quality. . In the future practice of IoT applications, the Huawei Cloud IoT device linkage function will become an important tool for enterprises to achieve efficient device management and intelligent operation and maintenance, providing strong support for enterprises to gain competitive advantages in the IoT era.

Click to follow and learn about Huawei Cloud’s new technologies as soon as possible~

 

The pirated resources of "Qing Yu Nian 2" were uploaded to npm, causing npmmirror to have to suspend the unpkg service. Zhou Hongyi: There is not much time left for Google. I suggest that all products be open source. Please tell me, time.sleep(6) here plays a role. What does it do? Linus is the most active in "eating dog food"! The new iPad Pro uses 12GB of memory chips, but claims to have 8GB of memory. People’s Daily Online reviews office software’s matryoshka-style charging: Only by actively solving the “set” can we have a future. Flutter 3.22 and Dart 3.4 release a new development paradigm for Vue3, without the need for `ref/reactive `, no need for `ref.value` MySQL 8.4 LTS Chinese manual released: Help you master the new realm of database management Tongyi Qianwen GPT-4 level main model price reduced by 97%, 1 yuan and 2 million tokens
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4526289/blog/11184899