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

**URL:** <https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538>\
**Category:** General\
**Created:** [22 July 2020 10:28 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538 "2020-07-22T10:28:36Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [22 July 2020 13:34 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/21 "2020-07-22T13:34:49Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 July 2020 15:50 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/22 "2020-07-22T15:50:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 06:08 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/23 "2020-07-23T06:08:12Z")

</div>

> [@zenofmud](#):
>
> Why are you hard coding the customer ID in the `change` node? Are you only ever going to have one customer?

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

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 06:48 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/24 "2020-07-23T06:48:49Z")

</div>

> [@zenofmud](#):
>
> 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?

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

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 06:49 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/25 "2020-07-23T06:49:09Z")

</div>

> [@zenofmud](#):
>
> 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'?

I have done this.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 July 2020 08:16 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/27 "2020-07-23T08:16:52Z")

</div>

> [@shipra](#):
>
> > [@zenofmud](#):
> >
> > Why are you hard coding the customer ID in the `change` node? Are you only ever going to have one customer?
> 
> I have not hardcoded i am giving from terminal by running mqtt c code

Please open the two change nodes indicated in this image

 ![shipra-hardcoded-changenode](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e64ccc527fdc0dbf59ce54787f47b0018bbc571f.png)

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)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 July 2020 08:19 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/28 "2020-07-23T08:19:20Z")

</div>

> [@shipra](#):
>
> > [@zenofmud](#):
> >
> > 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'?
> 
> I have done this.

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.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 July 2020 08:20 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/29 "2020-07-23T08:20:44Z")

</div>

> [@shipra](#):
>
> > [@zenofmud](#):
> >
> > 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?
> 
> yes Sir that thing we want that only entered rfid person can access the dashboard.

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 July 2020 08:43 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/30 "2020-07-23T08:43:48Z")

</div>

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?`

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 09:40 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/31 "2020-07-23T09:40:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 09:41 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/32 "2020-07-23T09:41:41Z")

</div>

> [@zenofmud](#):
>
> So what thoughts do you have to control this?

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

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 09:42 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/33 "2020-07-23T09:42:37Z")

</div>

> [@zenofmud](#):
>
> `Have you ever worked with MQTT before and do you expect your data to be private?`

yes i want no other RFID person can control the switches

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 09:43 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/34 "2020-07-23T09:43:41Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 July 2020 09:54 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/35 "2020-07-23T09:54:04Z")

</div>

> [@shipra](#):
>
> > [@zenofmud](#):
> >
> > `Have you ever worked with MQTT before and do you expect your data to be private?`
> 
> yes i want no other RFID person can control the switches

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?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 10:40 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/36 "2020-07-23T10:40:05Z")

</div>

> [@zenofmud](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 July 2020 10:47 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/37 "2020-07-23T10:47:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 10:55 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/38 "2020-07-23T10:55:01Z")

</div>

![processed](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/206da0ae011d6d0c724cf45d71c4bb2cc8e4311b.jpeg)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 July 2020 11:03 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/39 "2020-07-23T11:03:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [23 July 2020 11:06 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/40 "2020-07-23T11:06:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 July 2020 11:30 UTC](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538/41 "2020-07-23T11:30:55Z")

</div>

> [@shipra](#):
>
> 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?

[Previous page](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538.md?page=1)

[Next page](https://discourse.nodered.org/t/how-to-read-the-state-of-ui-switch-in-node-red/30538.md?page=3)
