Send string from dashboard to msg.payload

Hi

I want to write a string on the dashboard, which is normaly hardcoded in a msg.payload.
I'm a beginner and I don't know how to configure it.

Thank you very much for your help.

BR
Cedric

[{"id":"80f5f851.9c4388","type":"tab","label":"dashboard send PhoneNumber to ws","disabled":false,"info":""},{"id":"32c1cdd5.7d44e2","type":"function","z":"80f5f851.9c4388","name":"","func":"var Data = msg.payload.Data;\nmsg.payload.Data = Data;\n//var Sms = msg.payload.Sms;\n//msg.payload.Sms = Sms;\nvar Sms = msg.payload.Data.Sms;\nmsg.payload.Data.Sms = Sms;\nvar PhoneNumber = msg.payload.Data.Sms.PhoneNumber;\nmsg.payload.Data.Sms.PhoneNumber = PhoneNumber;\n\nmsg.payload = {\n \"RequestType\": \"SmsSend\",\n \"Data\": {\n \"Sms\": {\n \"PhoneNumber\" : PhoneNumber,\n \"Text\": \"Test content\"\n }\n }\n};\nreturn msg;\n","outputs":1,"noerr":0,"x":690,"y":320,"wires":[["dd3a2b88.5b37e8"]]},{"id":"2be7d3ca.a5da3c","type":"ui_text_input","z":"80f5f851.9c4388","name":"PhoneNumber","label":"","tooltip":"","group":"3c07d2a4.79ebbe","order":10,"width":0,"height":0,"passthru":true,"mode":"text","delay":"0","topic":"sms","x":280,"y":320,"wires":[["cea19871.299538"]]},{"id":"dd3a2b88.5b37e8","type":"debug","z":"80f5f851.9c4388","name":"PhoneNumber","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":860,"y":320,"wires":[]},{"id":"cea19871.299538","type":"change","z":"80f5f851.9c4388","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Data.Sms.PhoneNumber","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":320,"wires":[["32c1cdd5.7d44e2"]]},{"id":"3c07d2a4.79ebbe","type":"ui_group","z":"","name":"Ultrasonic Sensor Voltage","tab":"5912d7e1.fb9f28","order":1,"disp":true,"width":"7","collapse":false},{"id":"5912d7e1.fb9f28","type":"ui_tab","z":"","name":"Device Ultrasonic sensor","icon":"dashboard","order":8}]

Hi Cedric,

First of, I have a couple links of recommended reading for you to get started with:
https://nodered.org/docs/user-guide/messages
https://nodered.org/docs/user-guide/nodes

After reading those, do you have an idea to continue?
For future messages, it often helps if you include the (relevant part of the) flow you've made to a post. You can get it by going to the hamburger menu in Node-RED (3 horizontal lines) -> export -> copy the flow (double check if you're only copying the currently selected node or the part that you were actually trying to send), then add it to a post following the following instructions: How to share code or flow json

That way users helping you can import the exact code and look at it.

Hi

thank you Lena for your support.

I follow the instruction and I get "my solution"

Now I want to add a switch on the dashboard. The switch should trigger different strings.
When the switch is on the Text "switch on" should be add in my function.

When the switch is offthe Text "switch off" should be add in my function.

How can I add these msg.payload to the Text in the funtion?
With batch or join?
For join there can I configure the msg.part?

But at first the request for the status of the switch is not working.

Thank you for your help.

[{"id":"8f4069de.4584f8","type":"tab","label":"dashboard send PhoneNumber to ws","disabled":false,"info":""},{"id":"54b3c884.9694f8","type":"function","z":"8f4069de.4584f8","name":"","func":"var Data = msg.payload;\n//var Text = msg.payload.Data.Sms.Text;\n\nmsg.payload = {\n  \"RequestType\": \"SmsSend\",\n  \"Data\": {\n    \"Sms\": {\n      \"PhoneNumber\" : Data,\n      \"Text\": \"Text\",\n    }\n  }\n};\nreturn msg;\n\n//\"Guid\": \"69c6ee52-7bae-4000-b19f-88153d926a77\",\n//  \"MessageId\": \"string\",","outputs":1,"noerr":0,"x":1254.0001125335696,"y":285.99986362457287,"wires":[["9b3190ac.67b77"]]},{"id":"25f8e3b0.5faf0c","type":"change","z":"8f4069de.4584f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Data.Sms.PhoneNumber","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":714.0000762939455,"y":285.99986362457287,"wires":[["54b3c884.9694f8"]]},{"id":"567b584f.0a1c38","type":"ui_text_input","z":"8f4069de.4584f8","name":"PhoneNumber","label":"PhoneNumber","tooltip":"","group":"f990197b.29b4b8","order":10,"width":0,"height":0,"passthru":true,"mode":"text","delay":"0","topic":"sms","x":480.00009918212913,"y":285.99992108345043,"wires":[["25f8e3b0.5faf0c"]]},{"id":"1230280f.44dd48","type":"change","z":"8f4069de.4584f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Data.Sms.Text","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":762.0001029968262,"y":739.9999685287476,"wires":[["e13c0031.31609"]]},{"id":"a83631f3.25643","type":"ui_text_input","z":"8f4069de.4584f8","name":"Switch on","label":"Switch on","tooltip":"","group":"f990197b.29b4b8","order":10,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"sms","x":556.000072479248,"y":739.9999685287476,"wires":[["1230280f.44dd48"]]},{"id":"bff63c0c.20fb7","type":"status","z":"8f4069de.4584f8","name":"","scope":["43e62a7.a391ed4"],"x":336.00007247924805,"y":739.9999685287476,"wires":[["a83631f3.25643","25be9964.e5fdd6"]]},{"id":"43e62a7.a391ed4","type":"ui_switch","z":"8f4069de.4584f8","name":"","label":"switch","tooltip":"","group":"f990197b.29b4b8","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":325.5682144165039,"y":610.7783451080322,"wires":[[]]},{"id":"e13c0031.31609","type":"join","z":"8f4069de.4584f8","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1053.5681724548338,"y":688.5624608993529,"wires":[["54b3c884.9694f8"]]},{"id":"2104a001.4d812","type":"change","z":"8f4069de.4584f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Data.Sms.Text","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":764.0285301208496,"y":894.0113592147827,"wires":[["e13c0031.31609"]]},{"id":"a05e3eb9.9b60c","type":"ui_text_input","z":"8f4069de.4584f8","name":"Switch off","label":"Switch off","tooltip":"","group":"f990197b.29b4b8","order":10,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"sms","x":558.0284996032715,"y":894.0113592147827,"wires":[["2104a001.4d812"]]},{"id":"8c7e7c64.d7639","type":"batch","z":"8f4069de.4584f8","name":"","mode":"count","count":10,"overlap":0,"interval":10,"allowEmptySequence":false,"topics":[{"topic":""}],"x":1045.5852813720703,"y":594.8692598342896,"wires":[[]]},{"id":"86676a24.827b08","type":"status","z":"8f4069de.4584f8","name":"","scope":["43e62a7.a391ed4"],"x":346.0284996032715,"y":898.0113592147827,"wires":[[]]},{"id":"9b3190ac.67b77","type":"debug","z":"8f4069de.4584f8","name":"function","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1501.5625457763672,"y":287.65901374816895,"wires":[]},{"id":"a8de3082.db296","type":"comment","z":"8f4069de.4584f8","name":"or ","info":"","x":1025.5624694824219,"y":640.9259996414185,"wires":[]},{"id":"7f0e167.340ece8","type":"comment","z":"8f4069de.4584f8","name":"I want to add","info":"","x":325.57948303222656,"y":558.9488410949707,"wires":[]},{"id":"6462ef47.0f8b","type":"comment","z":"8f4069de.4584f8","name":"My solution","info":"","x":429.57948303222656,"y":232.94886875152588,"wires":[]},{"id":"25be9964.e5fdd6","type":"debug","z":"8f4069de.4584f8","name":"status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":551.5738220214843,"y":821.3181304931638,"wires":[]},{"id":"f990197b.29b4b8","type":"ui_group","z":"","name":"test switch","tab":"50f5f1b7.91df7","order":1,"disp":true,"width":"7","collapse":false},{"id":"50f5f1b7.91df7","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.