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

I am getting a status from a MariaDB, and when I add a debug node it give me the status.

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?

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.


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. The videos are done by the developers of node-red. They're nice & short and to the point & full of nice tips.

I know, but I am only getting this without the switch node.

and nothing with the switch node.

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

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

Working demo...

[{"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":[]}]

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

Should be:

I lie down flat on the floor, very sorry.

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

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