Message Push Mode

The Aqara developer platform supports proactively pushing devices or linkage related data to third-party applications through the following two methods to meet users' requirements for message real-time and message persistence.

Get messages based on message queue


The message queue is currently based on the open source rocketmq for related transformations. The Aqara developer platform will push messages to MQ, subscribe to the required messages for consumption processing. Lumi will keep the messages generated in the last 12 hours in MQ to provide third-party applications for consumption processing.

Get messages based on HTTP

The Aqara developer platform obtains messages by calling the http service address provided by a third party. After the push address configuration is completed, the service address that receives the push message will be verified from time to time to ensure the reliability of the service address and the message receiving response mechanism Accuracy. At the same time, statistics on push failures will also be made. For example, when the failure rate of push messages exceeds 5% within 5 minutes, the third-party application will be notified by SMS or email to process in time, otherwise it will be suspended after half an hour after the notification is sent. If you need to re-enable it, please re-enable the push function in Console to receive push messages again.

Lumi will keep messages about push failures in the last 12 hours and provide API for query.

Request Demo

Request URL: The message receiving address configured on the message push page. (Login to Aqara Developer Platform-Console, Application Management-Message push settings page), example:

Request Method: HTTP POST (application/json)

Request header parameters:

Name Type Is required? Description
token String Yes A valid accessToken for the authorized account
time String Yes Request time
nonce String Yes Request a random number to guarantee the uniqueness of the request
appkey String No Request the signature key
If the configuration is turned on, it will be returned.
sign String No Request signature
If the configuration is turned on, it will be returned.

Signature rules:

  1. The parameters(appkey, nonce, token, time) requested by the head are first sorted according to the ASCII code, and then spliced.

    Splice method: appkey=xxx&nonce=xxx&time=xxx&token=xxx

  2. Splice appSecret with the string generated in the second step.

    Example: appkey=xxx&nonce=xxx&time=xxx&appSecret

  3. Do lowercase processing for the string generated in the second step.

  4. MD5 32-bit for the character generated in the third step, and the generated number is the value of Sign.

Note: Sign is not enabled by default. If you need to enable signature, you need to configure appKey (signature Key) and appSecret (signature secret key) on Aqara Developer Platform -Console, Application Management-Message push settings page.

------------------------------------Step 1: splicing header parameters ---------------------
------------------------------------Step 2: Splicing appSecret parameters ------------------
------------------------------------Step 3: Lowercase the string ---------------------------
------------------------------------Step 4: MD5 32-bit encryption --------------------------

Request Body parameters: For details, please refer to the "message push format" page.

Response Format


Note: When the third-party system receives the pushed HTTP message, please return it according to the above example. If the return format does not meet the requirements, the Aqara system will consider the third-party receiving message system service abnormal, and will stop performing the third-party system under certain conditions.

Configuration method

  1. Log in to Aqara Developer Platform, enter Console in the upper right corner;

  2. Click Application Management, create an application, and enter the application details;

  3. Select the "Message Push Settings" page and fill in the configuration information as needed;

    • Subscription mode: Supports "All reception mode" and "User-defined subscription mode".

      "All receiving mode" means that after the configuration is complete, all the device data of the authorized account will be pushed to the third-party server, and the information subscribed through the "subscribe resource" interface will automatically become invalid, and the subscription interface will refuse access.

      "User-defined subscription mode" refers to subscribing to specified device resource data through the "subscribe resource" interface, and only pushes the data to a third-party server.

    • Push Channel: Supports "Message Queue Push" and "HTTP Push".

    • Push configuration address: If the "Push Channel" is configured when "HTTP Push" is selected, enter the address of the server that needs to receive messages, and verify that the server is connected.

    • Key ID: If the "Push Channel" is configured when "Message Queue Push" is selected, select the corresponding key ID.

    • Push Status: After the push configuration address is verified successfully, you can set whether push is enabled or not.

    • Remarks: Fill in the remarks of the message push.

  4. Save the configuration.

Java Demo


import org.apache.rocketmq.acl.common.AclClientRPCHook;
import org.apache.rocketmq.acl.common.SessionCredentials;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.MessageExt;

import java.util.List;

 * @Author: zzm
 * @Date: 2021/5/27 10:41
public class MqConsumer {

    private final String mqAddress = "";
    private final String appId = "06699244921c39c91e012252";
    private final String keyId = "K.761236781237217";
    private final String appKey = "cqLCZDxt4PgMOPrFyHVYReygeyX1z2rP";

    public static void main(String[] args) {
        MqConsumer mqConsumer = new MqConsumer();

        try {
        } catch (Exception e) {

    public void start() throws MQClientException {

        AclClientRPCHook acl = new AclClientRPCHook(new SessionCredentials(keyId, appKey));
        DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(appId, acl, new AllocateMessageQueueAveragely());

//        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
//        consumer.setConsumeTimestamp(UtilAll.timeMillisToHumanString3(
//                System.currentTimeMillis() - (1000 * 10 * 1)));

        consumer.setConsumeTimestamp(UtilAll.timeMillisToHumanString3(System.currentTimeMillis() - 1000 * 60 * 10));

        consumer.subscribe(appId, "*");

        consumer.registerMessageListener(new MessageListenerConcurrently() {

            public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
                try {
                    for (MessageExt messageExt : msgs) {
                        String topic = messageExt.getTopic();
                        String tag = messageExt.getTags();
                        String msg = new String(messageExt.getBody());

              "******device info******{}", msg);
                } catch (Exception e) {

                return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;


Copyright © 2023 Lumi United Technology Co., Ltd. all right reserved,powered by GitbookFile Modify: 2024-04-24 15:18:24

results matching ""

    No results matching ""