Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ IoT Device Access/ Best Practices/ Device Linkage/ Triggering Alarms and Sending Email or SMS Notifications

Triggering Alarms and Sending Email or SMS Notifications

Updated on 2024-12-31 GMT+08:00

Introduction

Many IoT devices run 24 hours a day. Device administrators do not need to know the real-time device status. They only need to be notified of certain statuses.

IoT Device Access provides the rule engine function to meet this requirement. You can set rules to enable the platform to send a notification when the data reported by a device meets a certain condition.

Example Scenario

In this example, when the battery level reported by the device is lower than 20%, the IoT platform reports an alarm and sends an email or SMS notification to the specified mobile number.

The procedure is as follows:

1. Simple Message Notification (SMN) : Subscribe to notification channels.

2. IoTDA: Define product models, create devices, and configure linkage rules.

3. Perform verification.

Figure 1 Example

Configuring SMN

On the Simple Message Notification (SMN) console, create a topic and add a subscription for the IoT Device Access service to invoke to send emails or SMS messages.

  1. Log in to Huawei Cloud and access Simple Message Notification (SMN).
  2. Click Access Console. If you have not subscribed to SMN, subscribe to it first.
  3. Choose Topic Management > Topics page, and click Create Topic.
  4. Enter the topic name, for example, Test_1, and click OK.
    Figure 2 Creating a topic - SMN
  5. Choose Topic Management > Subscriptions, and click Add Subscription.
  6. Enter the subscription information and click OK.
    Figure 3 Adding a subscription - SMN
    Table 1 Parameters for adding a subscription

    Parameter

    Description

    Topic Name

    Select the topic created in 4.

    Protocol

    • To send an email notification, select Email.
    • To send an SMS notification, select SMS.

    Endpoint

    • If Protocol is set to Email, enter the email address for receiving notifications.
    • If Protocol is set to SMS, enter the mobile number for receiving notifications.

    To add multiple endpoints, place one endpoint in a line. A maximum of 10 lines can be entered.

Configuring IoTDA

Using IoT Device Access, you can create a product model, register a device, and set a device linkage rule. When the device reports specific data, an alarm is triggered and an email or SMS notification is sent.

  1. Visit the IoTDA product page and click Access Console. Click the target instance card.
  2. In the navigation pane, choose Products.

    Note: The product model and device used in this document are only examples. You can use your own product model and device.

  3. Click Create Product to create a product using MQTT. Set the parameters and click OK.
    Table 2 Parameters for creating a product

    Basic Information

    Product Name

    Enter a value, for example, MQTT_Device.

    Protocol

    Select MQTT.

    Data Type

    Select JSON.

    Industry

    Set the parameters as required.

    Device Type

  4. Click here to download a sample product model.
  5. Click the created product. The product details page is displayed.
  6. On the Basic Information tab page, click Import from Local. In the displayed dialog box, load the local product model and click OK.
    Figure 4 Uploading a model file
  7. In the navigation pane, choose Devices > All Devices. On the displayed page, click Register Device. On the displayed page, set device registration parameters. Click OK. Save the device ID and secret returned after the registration is successful.
    Figure 5 Registering a device - MQTT
    Table 3 Parameters for registering a device

    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.

  8. In the navigation pane, choose Rules > Device Linkage, and click Create Rule. (Before creating a rule, select the resource space to which the rule will belong.)
  9. 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.
    Figure 6 Creating a linkage rule - BatteryProperty
    Table 4 Parameters for creating a linkage rule

    Parameter

    Description

    Rule Name

    Enter a name, such as Battery_Low_Mail or Battery_Low_SMS.

    Activate upon creation

    Select Activate upon creation.

    Effective Period

    Select Always effective.

    Description

    Provide a description of the rule, for example, "When the battery level reported by a device is lower than 20%, an alarm is reported and a notification is sent."

    Set Triggers

    1. Click Add Trigger.
    2. Select Device Property.
    3. Select the product added in 3, select Assign Device, and then select the device added in 7.
    4. Select Battery for Select service, batteryLevel for Select property, < as the operation, and enter 20. Click Trigger Mode. In the dialog box displayed, set Trigger Strategy to Repetition suppression and Data Validity Period (s) to 3600, and click OK.

    Set Actions

    Add an alarm.

    1. Click Add Action.
    2. Select Report alarms.
    3. Set the alarm severity to Minor, alarm isolation level to Device, Alarm Name to Low battery level, and Description to The battery level is lower than 20%. Check and replace the battery in time. Click OK.

    Add a notification.

    1. Click Add Action.
    2. Select Send notifications.
    3. Select the region where SMN is available, for example, cn-north-4. When you create a rule for connecting to SMN for the first time, a cloud service access authorization window will be displayed based on the cloud service to connect and region. Configure cloud service access authorization as prompted. (You can log in to the SMN console and view the information in the upper left corner.)
    4. Select the topic created when configuring SMN for Topic Name.
      • If Protocol corresponding to the topic is Email, set Message Title to an email title, for example, [Huawei IoT Platform] Low Battery Warning, and set Message Content to information similar to You have a device with less than 20% charge, please log in to the Huawei IoT Platform for details.
      • If Protocol corresponding to the topic is SMS, left Message Title unspecified, and set Message Content to information similar to You have a device with less than 20% charge, please log in to the Huawei IoT Platform for details.

Verifying the Configurations

  • You can use a registered physical device to access the platform and enable the device to report the battery level less than 20.
  • You can also use a simulator to simulate a device to report the battery level less than 20. For details, see Developing an MQTT-based Simulated Smart Street Light Online.
  • You can also use a virtual device for online debugging and enable the device to report the battery level less than 20.

Expected result:

  • In the navigation pane on the left, choose O&M > Device Alarms. Click Application Operations Management (AOM) to go to the AOM console. A minor alarm is generated indicating that the device battery is low.
  • If you have subscribed to email notification, the mailbox receives an email indicating that the device battery is low.
  • If you have subscribed to SMS notification, the mobile phone receives an SMS notification indicating that the battery level is low.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback