Edit node information

is it possible to set something up that will edit a switch node with new information automatically? so if a switch is setup to move traffic that contains "55555" is there some way i can change that "55555" to whatever a payload is without the need to manually change it? or is there a palette of some sort that would be able to do something like this.

The switch node can be configured with several rules as you probably know. So just add a new rule to the table. The node will check all rules (unless you change it to stop at the first match). You can also use jsonata or regex in the rules, which makes the node even more flexible. Further to that you can use jsonata and enviroment variables for handling the field that will be used against the rules. So plenty of flexibility. It is hard to imagine a use case that can not be fully covered by the switch node (or a combination of more than one). As a last resort you could rely on a function node in place of the switch node, but this is rarely needed.

the issue im running into is i have a software that to log out the operator clicks on their icon and it logs them out. there can be up to 4 operators logged in each with a specific id number. we have a total of 47 possible operators that could be logged in. so i have the coordinates of the 4 possible icon locations and an xdotool node that will click on the icon when it detects their rfid card become rescanned. the event of it being scanned sends a payload with their 5 digit id number.

what i wanted to set up is when they scan it the first time to log in it sets up a switch node for box 1 of 4 only allowing that operator to affect box 1. after the operator scans their id the second time it logs out of box 1 and opens the switch node to allow all traffic until it becomes filled again.

i have everything working, but finding a way to set the node that gatekeeps box 1 to dynamically deny and allow traffic is all i need now. if i do multiple rules then it allows any matches. but i want it so that only "12345" can be sent to box 1 until 12345 logs out and then its open for anyone to claim without the need for manual input (aside from ID scan)

i hope this made sense i am brainstorming and explaining at the same time.

Not fully clear to me but as you mentioned the words "block traffic" and "allow traffic" then I guess is doable. Those operations are easy an very convenient. I need a few minutes to read you post again and think over.

You could set a context variable to hold the "12345" and set the switch node to contains flow/global var. You would then just need to set the context variable with the string e.g."12345".

Flow.json example

[{"id":"7f37c68e.20b74","type":"inject","z":"30af2d3e.d94ea2","name":"contains 12345","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"contains 12345","payloadType":"str","x":140,"y":680,"wires":[["807343ad.9b27a"]]},{"id":"807343ad.9b27a","type":"switch","z":"30af2d3e.d94ea2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"id_pass","vt":"flow"}],"checkall":"true","repair":false,"outputs":1,"x":310,"y":720,"wires":[["16b4f86a.aba8f"]]},{"id":"286bf476.cc0304","type":"inject","z":"30af2d3e.d94ea2","name":"icontains 56789","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"contains 56789","payloadType":"str","x":150,"y":720,"wires":[["807343ad.9b27a"]]},{"id":"16b4f86a.aba8f","type":"debug","z":"30af2d3e.d94ea2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":720,"wires":[]},{"id":"6778f058.8ef1b","type":"inject","z":"30af2d3e.d94ea2","name":"pass 12345","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"12345","payloadType":"str","x":200,"y":800,"wires":[["b00d41f.64750c"]]},{"id":"e8350905.ba529","type":"inject","z":"30af2d3e.d94ea2","name":"pass 56789","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"56789","payloadType":"str","x":180,"y":840,"wires":[["b00d41f.64750c"]]},{"id":"b00d41f.64750c","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"set","p":"id_pass","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":820,"wires":[[]]}]

https://nodered.org/docs/user-guide/context

2 Likes

@E1cid , Works well. Good example of a gate keeper for flow control.

Just doe a little more context. There are 4 boxes. And 10 people. A random 4 of the 10 will log into the machine. Lets say the 4 people are bob(12345) mark(12895) joe(54321) and fred(34534). The numbers are what node red sees when they scan into the system.

Each person scans their id into an rfid scanner to login and it places them into box one. And the next into box two and so on. bob(12345 box 1) mark(12895 box 2) joe(54321 box 3) and fred(34534 box 4).

Now if joes switches with a new person joe rescans his id to log out. And open up box 3 for the new employee. The reason i cant just have 10 switch rules is because any of those four can log out at any time. And that 4 could be any of the 10 at any given time. In my case actually 47.

The boxes are physical locations on the screen thay the mouse moves to and executes commands to log them out.

So the thought has been if its possible take the payload from the login scan message, that holds the id number, have that placed into a rule, and when a second scan is seen it with that same id number it passes the message accordingly and then removes that rule from the switch allowing a new person to occupy box 3.

1 Like

just tested this, i think this can work!! thank you! i am going to play around with this.

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