# How can i get the payload from a mariaDB to a switch node

**URL:** <https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160>\
**Category:** General\
**Created:** [4 May 2021 10:40 UTC](https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160 "2021-05-04T10:40:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpbillund](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tpbillund/32/37410_2.png) [@tpbillund](https://discourse.nodered.org/u/tpbillund)\
**Post date:** [4 May 2021 10:40 UTC](https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160/1 "2021-05-04T10:40:38Z")

</div>

Hi  
I am getting a status from a MariaDB, and when I add a debug node it give me the status.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1f73e23184d2bd05f3f362959802507dd6f2ab68.png)

If I add a Switch node between the "Alarm" and "Debug" with the data:  
== armed  
== disarmed

Then I don't get any status to the Debug node. How can I get the status inside the switch node, and if armed then go one way, if disarmed go another way from the switch node?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [4 May 2021 10:43 UTC](https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160/2 "2021-05-04T10:43:48Z")

</div>

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

In short

- add a debug node after the `alarm` node
- use the copy path button as described above
- paste that into the switch node `property`
- add your `==` comparitors

* * *

Lots of folk miss out on these nice touches, I often recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point & full of nice tips.

---

<div class="post-metadata">

**Author:** ![tpbillund](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tpbillund/32/37410_2.png) [@tpbillund](https://discourse.nodered.org/u/tpbillund)\
**Post date:** [4 May 2021 11:38 UTC](https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160/3 "2021-05-04T11:38:05Z")

</div>

Hi  
I know, but I am only getting this without the switch node.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9e103505ce1233608bf197747e8bf39f2eb9cf5d.png)

and nothing with the switch node.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [4 May 2021 11:40 UTC](https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160/4 "2021-05-04T11:40:36Z")

</div>

> [@tpbillund](#):
>
> I know

You know what

- how to copy the path?
- how to setup a switch?

Did you click the "copy path" button? Paste what gets copied to the clipboard into a reply

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [4 May 2021 11:51 UTC](https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160/5 "2021-05-04T11:51:01Z")

</div>

Like I said, use the copy path button to set the property of the switch node...

 ![TCBN1nMRpY](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/4/841907d625b76ea744128ac6b6f18e29066e5683.gif)

Working demo...

 ![yqCUDwRJ9j](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b2930f4be39681eebb6a1cc230bf5c1fbf954451.gif)

```auto
[{"id":"eb4f36e6.99ee28","type":"inject","z":"b872cb4b.5a6448","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1560,"y":500,"wires":[["5996ddc4.3a43a4"]]},{"id":"5996ddc4.3a43a4","type":"function","z":"b872cb4b.5a6448","name":"alarm (fake DB call)","func":"var state = ((new Date()).getSeconds() % 2) == 0 ? \"disarmed\" : \"armed\"\nmsg.payload = [\n { status: state}\n]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1580,"y":560,"wires":[["99f1346c.b4a398","169fa35.0baf15d","fb94acac.45248"]]},{"id":"99f1346c.b4a398","type":"switch","z":"b872cb4b.5a6448","name":"","property":"payload[0].status","propertyType":"msg","rules":[{"t":"eq","v":"armed","vt":"str"},{"t":"eq","v":"disarmed","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1770,"y":560,"wires":[["8ad0987f.573b98"],["dc361739.8ae068"]]},{"id":"169fa35.0baf15d","type":"debug","z":"b872cb4b.5a6448","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1570,"y":620,"wires":[]},{"id":"8ad0987f.573b98","type":"debug","z":"b872cb4b.5a6448","name":"armed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1970,"y":540,"wires":[]},{"id":"dc361739.8ae068","type":"debug","z":"b872cb4b.5a6448","name":"disarmed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1980,"y":580,"wires":[]},{"id":"fb94acac.45248","type":"change","z":"b872cb4b.5a6448","name":"move to payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].status","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1800,"y":640,"wires":[["66cdbb8f.f92b24"]]},{"id":"66cdbb8f.f92b24","type":"debug","z":"b872cb4b.5a6448","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1990,"y":640,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![tpbillund](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tpbillund/32/37410_2.png) [@tpbillund](https://discourse.nodered.org/u/tpbillund)\
**Post date:** [4 May 2021 11:52 UTC](https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160/6 "2021-05-04T11:52:27Z")

</div>

Sorry I misread your message.  
Can they do it now.

msg.payload  
Should be:  
msg.payload.0.status

I lie down flat on the floor, very sorry.

---

<div class="post-metadata">

**Author:** ![tpbillund](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tpbillund/32/37410_2.png) [@tpbillund](https://discourse.nodered.org/u/tpbillund)\
**Post date:** [4 May 2021 11:54 UTC](https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160/7 "2021-05-04T11:54:40Z")

</div>

And then you came with a "visual solution" thx. and again Sorry!! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 May 2021 11:55 UTC](https://discourse.nodered.org/t/how-can-i-get-the-payload-from-a-mariadb-to-a-switch-node/45160/8 "2021-05-18T11:55:13Z")

</div>

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