[Message Queue Service] How to receive message when call add home API

Developer Platform features usage and feedback.


Post Reply
Tran Manh Duy
Posts: 10

I downloaded Get Push Messages by Pulsar (Node.js SDK) : https://developer.tuya.com/en/docs/iot/ ... fmtxp8yscg.
To get the device log,

device.png

I follow the steps:

  • I run SDK
  • When the device status changes (online/offline/change temperature..)
    => I can get real-time device log and show it in the console following the above tutorial.
    222.png

For now, I'd like to get log data when calling the "homeCreate" event of "Home event" using the above SDK

home.png

I follow the steps:

  • Run SDK
  • Call "add home" API
    1111.png
    => But I cannot see any log after executing API success

Please let me know, How to get log data for "createHome" event using Node.js SDK
Thanks so much

panda-cat
Posts: 23

Re: [Message Queue Service] How to receive message when call add home API

First, you need to subscribe to the "homeCreate" event in the project "Message Service", and then authorize the project with the uid account source app or uid of the home you want to create. For the authorization process, please refer to: https://developer.tuya.com/en/docs/iot/ ... 71nu1sfmkl. Finally, call the interface to create a home with the corresponding uid and you will receive the home creation message. (There will be a delay in data synchronization during the authorization process, so you need to wait a few minutes after authorization.)

Tran Manh Duy
Posts: 10

Re: [Message Queue Service] How to receive message when call add home API

Hi Tuya team and panda cat
I follow the steps:

  • Step 1: Subscribe to the "homeCreate" event in the project "Message Service"
    add_create_home.png
  • Step 2: Authorize the project with the uid account source app
    link_app.png
  • Step 3: Call the interface to create a home -> execute API success
    call_api.png

Then, I checked the result, It's not been received message

result.png

Am I doing anything wrong at any step? Please let me know
Thanks

panda-cat
Posts: 23

Re: [Message Queue Service] How to receive message when call add home API

Since your scenario is not a device-type message, you can only use the production mode for now. In step 1, please use "Production Eviroment" and then subscribe to the "homeCreate" message. To receive messages, please use the server SDK and set the environment to env = MqEnv.PROD. For other information, please refer to: https://developer.tuya.com/en/docs/iot/ ... 09frvx48db and https://developer.tuya.com/en/docs/iot/ ... qcb6jb13rm

Tran Manh Duy
Posts: 10

Re: [Message Queue Service] How to receive message when call add home API

Hi panda-cat,

  • With env: TuyaWebsocket.env.TEST
    => I can only get the device log (online, offline, change status)

  • With env: TuyaWebsocket.env.PROD
    => I can only get home/room/user message log (create, update, delete )

So, I want to get both the device message log and home/room/user message log in an SDK project.
How to do it?
Is there an environment mode to get both?
Do I have to run 2 SDK projects to get 2 types of messages?

Please let me know the solution. Thanks

panda-cat
Posts: 23

Re: [Message Queue Service] How to receive message when call add home API

In the project's "Message Service -> Messaging Rules", you can turn off the "Test Environment", remove the configured test devices, and then enable only the "Production Environment" and subscribe to all the message types you need in it.

Tran Manh Duy
Posts: 10

Re: [Message Queue Service] How to receive message when call add home API

I get most of the messages log from the API following your support

But with the "Add a device in the room" API, I cannot get the message log

I follow the steps:

  • Step 1: Subscribe to all the message types

    add_product.png
  • Step 2: Call "Add a device in the room" API

    call_device_api.png

=> After executing API successfully, I cannot see any message log in the console
Are the steps true?
Please let me know how to get the message log of "Add a device in the room" API
Thanks

panda-cat
Posts: 23

Re: [Message Queue Service] How to receive message when call add home API

Sorry, there is no support for adding devices to the room so far. For specific supported message types, please refer to: https://developer.tuya.com/en/docs/iot/ ... qerli65a1u

Tran Manh Duy
Posts: 10

Re: [Message Queue Service] How to receive message when call add home API

I got it.
Thanks so much for supporting me

Post Reply