How to read the state of ui-switch in node red

[{"id":"f4ce26f0.22055","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"ec3347d0.94006","type":"mqtt in","z":"f4ce26f0.22055","name":"","topic":"RFID","qos":"1","datatype":"utf8","broker":"3d22a2f.7bec8de","x":110,"y":380,"wires":[["8f06369a.7fb86","38335e07.d3944a"]]},{"id":"386fc529.c39e9a","type":"mysql","z":"f4ce26f0.22055","mydb":"38417304.575e9c","name":"","x":450,"y":540,"wires":[["3b5df68b.3ef092"]]},{"id":"a9497623.eb7a78","type":"template","z":"f4ce26f0.22055","name":"","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SELECT rfidno FROM rfid1 \nWHERE rfidno='{{payload}}';","output":"str","x":300,"y":540,"wires":[["386fc529.c39e9a","d1329fd6.f801a"]]},{"id":"3b5df68b.3ef092","type":"switch","z":"f4ce26f0.22055","name":"","property":"payload","propertyType":"msg","rules":[{"t":"empty"},{"t":"nempty"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":540,"wires":[["69c0acd5.fcc094"],["951e3461.d81718"]]},{"id":"69c0acd5.fcc094","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"CR_FAIL","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":440,"wires":[["fc20bb4d.9f3b9","8f218188.f7c7d"]]},{"id":"951e3461.d81718","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"CR_SUCCESS","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":640,"wires":[["27049bf1.bb8dd4","fc20bb4d.9f3b9","b00f41b0.3c09e8","207d854c.6e3b7a"]]},{"id":"fc20bb4d.9f3b9","type":"mqtt out","z":"f4ce26f0.22055","name":"","topic":"MATCH","qos":"1","retain":"true","broker":"fbdb7651.19a7c8","x":840,"y":540,"wires":[]},{"id":"b00f41b0.3c09e8","type":"ui_switch","z":"f4ce26f0.22055","name":"","label":"Open","tooltip":"","group":"ea12b474.8ed4d8","order":0,"width":"0","height":"0","passthru":false,"decouple":"false","topic":"","style":"","onvalue":"DR1_ON","onvalueType":"str","onicon":"","oncolor":"green","offvalue":"--","offvalueType":"str","officon":"","offcolor":"red","x":990,"y":460,"wires":[["5ce2abd2.941efc","c3692e2b.d200f","a50be4e.b626518","aab163c7.75e118"]]},{"id":"207d854c.6e3b7a","type":"ui_switch","z":"f4ce26f0.22055","name":"","label":"Close","tooltip":"","group":"ea12b474.8ed4d8","order":0,"width":"0","height":"0","passthru":false,"decouple":"false","topic":"","style":"","onvalue":"DR1_OFF","onvalueType":"str","onicon":"","oncolor":"green","offvalue":"--","offvalueType":"str","officon":"","offcolor":"red","x":990,"y":520,"wires":[["5ce2abd2.941efc","c3692e2b.d200f","39d4a815.398a2"]]},{"id":"81999de5.5133f","type":"template","z":"f4ce26f0.22055","name":"update_template","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"UPDATE rfid1 \nSET Door_Status='{{payload}}'\nWHERE rfidno='{{id}}';\n","output":"str","x":1410,"y":540,"wires":[["15c8e7a2.fd3328","a9bdcf4.c362e3"]]},{"id":"15c8e7a2.fd3328","type":"mysql","z":"f4ce26f0.22055","mydb":"38417304.575e9c","name":"","x":1610,"y":520,"wires":[["42a36416.b6dfe4"]]},{"id":"8f06369a.7fb86","type":"debug","z":"f4ce26f0.22055","name":"MQTT_IN Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":330,"y":380,"wires":[]},{"id":"8f218188.f7c7d","type":"debug","z":"f4ce26f0.22055","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":400,"wires":[]},{"id":"27049bf1.bb8dd4","type":"debug","z":"f4ce26f0.22055","name":"Debug2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":780,"y":720,"wires":[]},{"id":"d1329fd6.f801a","type":"debug","z":"f4ce26f0.22055","name":"Debug23","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":440,"y":640,"wires":[]},{"id":"a9bdcf4.c362e3","type":"debug","z":"f4ce26f0.22055","name":"Debug_template","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1640,"y":580,"wires":[]},{"id":"42a36416.b6dfe4","type":"debug","z":"f4ce26f0.22055","name":"Debug_rfid","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1790,"y":520,"wires":[]},{"id":"38335e07.d3944a","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"id","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":540,"wires":[["a9497623.eb7a78","22c52ccd.ccbc14"]]},{"id":"5ce2abd2.941efc","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"id","pt":"msg","to":"id","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":540,"wires":[["b2da095c.0a12d8","81999de5.5133f"]]},{"id":"b2da095c.0a12d8","type":"debug","z":"f4ce26f0.22055","name":"Debug_change2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1260,"y":600,"wires":[]},{"id":"22c52ccd.ccbc14","type":"debug","z":"f4ce26f0.22055","name":"Debug_tchange1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":410,"y":760,"wires":[]},{"id":"afbcc853.de993","type":"mqtt out","z":"f4ce26f0.22055","name":"","topic":"CustomerID/SiteID/DeviceType/OPEN1","qos":"1","retain":"false","broker":"fbdb7651.19a7c8","x":1640,"y":320,"wires":[]},{"id":"3be4106.f2615f","type":"mqtt out","z":"f4ce26f0.22055","name":"","topic":"CustomerID/SiteID/DeviceType/CLOSE1","qos":"2","retain":"true","broker":"fbdb7651.19a7c8","x":1500,"y":380,"wires":[]},{"id":"c3692e2b.d200f","type":"ui_text","z":"f4ce26f0.22055","group":"ea12b474.8ed4d8","order":0,"width":0,"height":0,"name":"","label":"Status","format":"{{msg.payload}}","layout":"row-spread","x":1230,"y":480,"wires":[]},{"id":"81b2f6d6.8b4398","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"CustomerID = 0210001/SiteID = 00000001/DeviceType = 1/Config = OPEN1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":320,"wires":[["afbcc853.de993"]]},{"id":"39d4a815.398a2","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"CustomerID = 0210001/SiteID = 00000001/DeviceType = 1/Config = CLOSE1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1200,"y":380,"wires":[["3be4106.f2615f"]]},{"id":"a50be4e.b626518","type":"debug","z":"f4ce26f0.22055","name":"Debug_open","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":380,"wires":[]},{"id":"e4f2d028.994ea","type":"debug","z":"f4ce26f0.22055","name":"switch debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1190,"y":260,"wires":[]},{"id":"aab163c7.75e118","type":"switch","z":"f4ce26f0.22055","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"DR1_ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1150,"y":320,"wires":[["81b2f6d6.8b4398","e4f2d028.994ea"]]},{"id":"3d22a2f.7bec8de","type":"mqtt-broker","z":"","name":"","broker":"tcp://mqtt.eclipse.org","port":"1883","clientid":"NCS_Client03","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"38417304.575e9c","type":"MySQLdatabase","z":"","name":"","host":"127.0.0.1","port":"3306","db":"rfid","tz":""},{"id":"fbdb7651.19a7c8","type":"mqtt-broker","z":"","name":"","broker":"tcp://mqtt.eclipse.org","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":false,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ea12b474.8ed4d8","type":"ui_group","z":"","name":"Door 1","tab":"45bf936.9ba396c","order":2,"disp":true,"width":"6","collapse":false},{"id":"45bf936.9ba396c","type":"ui_tab","z":"","name":" NCS_Door Controller Panel","icon":"door controller","order":1,"disabled":false,"hidden":false}]

1 - Can you explain to me why you have one dashboard switch for 'Open' and another for 'Close'? Why are you not using one dashboard switch and have one side of the switch return 'Open' and the other side return 'Cose'?

2 - Why are you hard coding the customer ID in the change node? Are you only ever going to have one customer?

3 - Do you realize that anyone with access to the dashboard can flip eithor switch and mqtt message with the hard coded customer number will be sent?

I have not hardcoded i am giving from terminal by running mqtt c code

yes Sir that thing we want that only entered rfid person can access the dashboard.

I have done this.

Please open the two change nodes indicated in this image

and (1) tell me what they are doing. (2) what happens if someone presses one of the two switches on the dashboard without using the RFID reader? (try it out and see what happens)

what have you done? are you saying you have removed one of the switches? Please be clear.
If you have changed the flow, and show me what has changed.

So what thoughts do you have to control this? What have you tried?

After looking at your flow again, I have another question:
Have you ever worked with MQTT before and do you expect your data to be private?

these two change nodes help to send my own messages to mqtt out when ever sitch is toggled

to control tdashboard only by entered rfid i dont know how to can i put security in dashboard

yes i want no other RFID person can control the switches

[{"id":"f4ce26f0.22055","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"ec3347d0.94006","type":"mqtt in","z":"f4ce26f0.22055","name":"","topic":"RFID","qos":"1","datatype":"utf8","broker":"3d22a2f.7bec8de","x":110,"y":380,"wires":[["8f06369a.7fb86","38335e07.d3944a"]]},{"id":"386fc529.c39e9a","type":"mysql","z":"f4ce26f0.22055","mydb":"38417304.575e9c","name":"","x":450,"y":540,"wires":[["3b5df68b.3ef092"]]},{"id":"a9497623.eb7a78","type":"template","z":"f4ce26f0.22055","name":"","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SELECT rfidno FROM rfid1 \nWHERE rfidno='{{payload}}';","output":"str","x":300,"y":540,"wires":[["386fc529.c39e9a","d1329fd6.f801a"]]},{"id":"3b5df68b.3ef092","type":"switch","z":"f4ce26f0.22055","name":"","property":"payload","propertyType":"msg","rules":[{"t":"empty"},{"t":"nempty"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":540,"wires":[["69c0acd5.fcc094"],["951e3461.d81718"]]},{"id":"69c0acd5.fcc094","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"CR_FAIL","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":440,"wires":[["fc20bb4d.9f3b9","8f218188.f7c7d"]]},{"id":"951e3461.d81718","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"CR_SUCCESS","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":640,"wires":[["27049bf1.bb8dd4","fc20bb4d.9f3b9","b00f41b0.3c09e8"]]},{"id":"fc20bb4d.9f3b9","type":"mqtt out","z":"f4ce26f0.22055","name":"","topic":"MATCH","qos":"1","retain":"true","broker":"fbdb7651.19a7c8","x":840,"y":540,"wires":[]},{"id":"b00f41b0.3c09e8","type":"ui_switch","z":"f4ce26f0.22055","name":"","label":"Open/Close","tooltip":"","group":"ea12b474.8ed4d8","order":0,"width":"0","height":"0","passthru":false,"decouple":"false","topic":"","style":"","onvalue":"DR1_ON","onvalueType":"str","onicon":"","oncolor":"green","offvalue":"DR_OFF","offvalueType":"str","officon":"","offcolor":"red","x":1010,"y":460,"wires":[["5ce2abd2.941efc","c3692e2b.d200f","a50be4e.b626518","aab163c7.75e118"]]},{"id":"81999de5.5133f","type":"template","z":"f4ce26f0.22055","name":"update_template","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"UPDATE rfid1 \nSET Door_Status='{{payload}}'\nWHERE rfidno='{{id}}';\n","output":"str","x":1410,"y":540,"wires":[["15c8e7a2.fd3328","a9bdcf4.c362e3"]]},{"id":"15c8e7a2.fd3328","type":"mysql","z":"f4ce26f0.22055","mydb":"38417304.575e9c","name":"","x":1610,"y":520,"wires":[["42a36416.b6dfe4"]]},{"id":"8f06369a.7fb86","type":"debug","z":"f4ce26f0.22055","name":"MQTT_IN Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":330,"y":380,"wires":[]},{"id":"8f218188.f7c7d","type":"debug","z":"f4ce26f0.22055","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":400,"wires":[]},{"id":"27049bf1.bb8dd4","type":"debug","z":"f4ce26f0.22055","name":"Debug2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":780,"y":720,"wires":[]},{"id":"d1329fd6.f801a","type":"debug","z":"f4ce26f0.22055","name":"Debug23","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":440,"y":640,"wires":[]},{"id":"a9bdcf4.c362e3","type":"debug","z":"f4ce26f0.22055","name":"Debug_template","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1640,"y":580,"wires":[]},{"id":"42a36416.b6dfe4","type":"debug","z":"f4ce26f0.22055","name":"Debug_rfid","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1790,"y":520,"wires":[]},{"id":"38335e07.d3944a","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"id","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":540,"wires":[["a9497623.eb7a78","22c52ccd.ccbc14"]]},{"id":"5ce2abd2.941efc","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"id","pt":"msg","to":"id","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":540,"wires":[["b2da095c.0a12d8","81999de5.5133f"]]},{"id":"b2da095c.0a12d8","type":"debug","z":"f4ce26f0.22055","name":"Debug_change2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1260,"y":600,"wires":[]},{"id":"22c52ccd.ccbc14","type":"debug","z":"f4ce26f0.22055","name":"Debug_tchange1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":410,"y":760,"wires":[]},{"id":"afbcc853.de993","type":"mqtt out","z":"f4ce26f0.22055","name":"","topic":"CustomerID/SiteID/DeviceType/OPEN1","qos":"1","retain":"false","broker":"fbdb7651.19a7c8","x":1640,"y":320,"wires":[]},{"id":"3be4106.f2615f","type":"mqtt out","z":"f4ce26f0.22055","name":"","topic":"CustomerID/SiteID/DeviceType/CLOSE1","qos":"2","retain":"true","broker":"fbdb7651.19a7c8","x":1500,"y":380,"wires":[]},{"id":"c3692e2b.d200f","type":"ui_text","z":"f4ce26f0.22055","group":"ea12b474.8ed4d8","order":0,"width":0,"height":0,"name":"","label":"Status","format":"{{msg.payload}}","layout":"row-spread","x":1230,"y":480,"wires":[]},{"id":"81b2f6d6.8b4398","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"CustomerID = 0210001/SiteID = 00000001/DeviceType = 1/Config = OPEN1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":320,"wires":[["afbcc853.de993"]]},{"id":"39d4a815.398a2","type":"change","z":"f4ce26f0.22055","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"CustomerID = 0210001/SiteID = 00000001/DeviceType = 1/Config = CLOSE1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1200,"y":380,"wires":[["3be4106.f2615f"]]},{"id":"a50be4e.b626518","type":"debug","z":"f4ce26f0.22055","name":"Debug_open","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":380,"wires":[]},{"id":"e4f2d028.994ea","type":"debug","z":"f4ce26f0.22055","name":"switch debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1190,"y":260,"wires":[]},{"id":"aab163c7.75e118","type":"switch","z":"f4ce26f0.22055","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"DR1_ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1150,"y":320,"wires":[["81b2f6d6.8b4398","e4f2d028.994ea"]]},{"id":"3d22a2f.7bec8de","type":"mqtt-broker","z":"","name":"","broker":"tcp://mqtt.eclipse.org","port":"1883","clientid":"NCS_Client03","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"38417304.575e9c","type":"MySQLdatabase","z":"","name":"","host":"127.0.0.1","port":"3306","db":"rfid","tz":""},{"id":"fbdb7651.19a7c8","type":"mqtt-broker","z":"","name":"","broker":"tcp://mqtt.eclipse.org","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":false,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ea12b474.8ed4d8","type":"ui_group","z":"","name":"Door 1","tab":"45bf936.9ba396c","order":2,"disp":true,"width":"6","collapse":false},{"id":"45bf936.9ba396c","type":"ui_tab","z":"","name":" NCS_Door Controller Panel","icon":"door controller","order":1,"disabled":false,"hidden":false}]

there were two parts to my question,
1 - Have you ever worked with MQTT before
and
2- do you expect your data to be private

does your 'yes' apply to the first part, second part or both?

yes is for 2nd
little bit i know but not industrial knowledge i have on mqtt this is my first project as a fresher i am learning sir.

If you expect your (mqtt) data to be private then you should not be using a public mqtt broker where anyone could capture the data you are sending and/or send data using the same topics that you use possibly causing issued in your flows.

Have you written a design document for the task you are attempting to doing?

So is the node-red dashboard going to be next to the RFID reader and the door to be opened/closed?

What is the need for having the dashboard in the first place? If someone has a valid RFID card, why not just unlock the door and record the users ID and the time of the event?

Actually Sir I want that person can get to have feel of UI Dashboard by which he can access by app or something

I have to ask, is this just an experimental project for you to learn NR, MySQL, MQTT etc or is this a real attempt to have some security to get thru the door?

The reason I'm asking is I see all kinds of holes in your current process. For example:

You want to open the door and youI have a valid RFID card and touch it to the reader. Now you have to take out your phone and open a browser and type in the html address of the NR dashboard and press the switch that opens the door. But you left your phone in your car so you leave to get it.

Someone else sees you leave and they open the dashboard on their phone and press the switch to get in. The door opens using YOUR ID! Anything that happens after that will look like you were the one that did it.

Is this what you think should happen?