how to can i store msg.payload in node red
Hi, if you want a sensible answer, I would suggest you provide additional info. E.g...
- Where you want to store msg.payload?
- What is inside msg.payload?
1)i want to msg.payload to store in a variable and then after wards i will be using that var to Subcriber Topic.
2) msg.payload has user input string.(CR_SUCCESS).
You can store msg.payload in a var in a function node like this...
var my_var = msg.payload;
I assume you mean subscribe an MQTT topic? You cannot dynamically subscribe to an MQTT topic.
yes sir i have a gateway code where sub call is there.
sir.in my code one user case is there where i am publishing twice on a topic (FOB ID and TAG ID).
what is solved:
- individual cases of both ID are working i.e if entered id is in my DB then print CR_SUCCESS to the SUB Topic otherwise CR_FAIL.
what not working:
- 3rd case is not working i.e i am taking 2 inputs one is FOB and other is TAG and similarly match both simultaneously with my DB and Print statement to SUB.
where the problem coming:
- as i am entering FOB ,then msg.payload is storing CR_SUCCESS(suppose user entered right ID)but as soon as i am entering TAG again it is showing me CR_SUCCESS(suppose i entered wrong TAG ).why???
I have remembered you were asking about this same project a couple months ago here: Copying my Door control status back to my Mysql databse
You also have this thread from earlier today: How to calculate 2 msg.id coming from 2 pub different topics simulataneously
If you have two separate messages arriving from MQTT nodes and you need to compare them, you need to get both values into a single message. I pointed you at a recipe for doing that here: How to calculate 2 msg.id coming from 2 pub different topics simulataneously
It is not clear if you have tried anything we have suggested. If there is something you are not sure about, please ask - but please read the material we point you at first.
Sir thank you answering this,but sir in this task 1 ) and 2) is completed only 3)is remaining.please suggest?
That is impossible for us to say as you have not shared any specific details of your application.
Thank you sir,for your help,it means alot for me
Now the output is coming as required.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.