This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UK OpenPlotter Build
#6
So to the first of my new PCBs

I have decided to use ESPeasy for general control, as its easy to flash and config is fast.

I had been pondering for a while how best to connect an esp8266 to a relay board. If you use the pins on the esp, you can get some chatter on the relays when the board is powered up. Also I wanted to get as much bang for my buck on the pcb board creation, so I have tried to make my boards multi use. This board uses an MCP23017 port expander for the main GPIO control, giving it plenty of IO.

So its first purpose is to be soldered directly to a 8 port relay board for control:
   

This provides a nice and simple means of joining these boards together.

Software is simple to setup, the esp8266 is flashed with espEasy and then you connect to its wifi and do the basic config. The MCP23017 is a standard part in this, so its easy to then control it via mqtt.

The other intended use of this board is for remote switch input, with LED feedback to the switches. I'll detail that when its up and running.

For now these are simply controlled using a Node red dashboard of buttons:

Code:
[{"id":"615cbe95.58533","type":"ui_button","z":"c9f6640b.fd0eb8","name":"Relay8","group":"c8b522c8.2b1f7","order":4,"width":0,"height":0,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":1110,"y":980,"wires":[["31263838.b87a58"]]},{"id":"a95c8fa6.6af2d","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"8 On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":910,"wires":[["615cbe95.58533"]]},{"id":"838e7297.98c0a","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"8 Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1050,"wires":[["615cbe95.58533"]]},{"id":"31263838.b87a58","type":"function","z":"c9f6640b.fd0eb8","name":"","func":"context.set('state',context.get('state')||\"closed\");\n\nfunction updateNodeStatus(color, txt) {\n    node.status({\n    \tfill : color,\n    \tshape : \"dot\",\n    \ttext : txt\n    });\n}\n\nvar state = context.get('state');\nvar color = '';\n\nswitch (state) {\n    case 'OFF':\n        state = 'ON';\n        color = 'green';\n        msg.payload = \"0\";\n        break;\n    case 'ON':\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n    default:\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n}\n\ncontext.set('state',state);\nupdateNodeStatus(color,msg.payload);\nnode.send(msg);","outputs":"1","noerr":0,"x":1270,"y":980,"wires":[["c48eaa8c.8ec318"]]},{"id":"49315bcc.b4bde4","type":"switch","z":"c9f6640b.fd0eb8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":980,"wires":[["a95c8fa6.6af2d"],["838e7297.98c0a"]]},{"id":"4e3ffeee.fa75d","type":"mqtt in","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/8","qos":"2","datatype":"auto","broker":"320c126d.0259be","x":350,"y":980,"wires":[["49315bcc.b4bde4"]]},{"id":"c48eaa8c.8ec318","type":"mqtt out","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/8","qos":"","retain":"","broker":"320c126d.0259be","x":1500,"y":980,"wires":[]},{"id":"1f67032e.918ded","type":"ui_button","z":"c9f6640b.fd0eb8","name":"Relay7","group":"c8b522c8.2b1f7","order":4,"width":0,"height":0,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":1110,"y":1210,"wires":[["89b9e7a8.b79578"]]},{"id":"fc00c87a.5412f8","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"7 On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1140,"wires":[["1f67032e.918ded"]]},{"id":"a199a686.5a9f08","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"7 Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1280,"wires":[["1f67032e.918ded"]]},{"id":"89b9e7a8.b79578","type":"function","z":"c9f6640b.fd0eb8","name":"","func":"context.set('state',context.get('state')||\"closed\");\n\nfunction updateNodeStatus(color, txt) {\n    node.status({\n    \tfill : color,\n    \tshape : \"dot\",\n    \ttext : txt\n    });\n}\n\nvar state = context.get('state');\nvar color = '';\n\nswitch (state) {\n    case 'OFF':\n        state = 'ON';\n        color = 'green';\n        msg.payload = \"0\";\n        break;\n    case 'ON':\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n    default:\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n}\n\ncontext.set('state',state);\nupdateNodeStatus(color,msg.payload);\nnode.send(msg);","outputs":"1","noerr":0,"x":1270,"y":1210,"wires":[["874d1e86.255d3"]]},{"id":"d49dd5f9.a663e8","type":"switch","z":"c9f6640b.fd0eb8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":1210,"wires":[["fc00c87a.5412f8"],["a199a686.5a9f08"]]},{"id":"1106fc99.34b9d3","type":"mqtt in","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/7","qos":"2","datatype":"auto","broker":"320c126d.0259be","x":350,"y":1210,"wires":[["d49dd5f9.a663e8"]]},{"id":"874d1e86.255d3","type":"mqtt out","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/7","qos":"","retain":"","broker":"320c126d.0259be","x":1500,"y":1210,"wires":[]},{"id":"f5a8d0ab.b1c0c","type":"ui_button","z":"c9f6640b.fd0eb8","name":"Relay6","group":"c8b522c8.2b1f7","order":4,"width":0,"height":0,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":1110,"y":1460,"wires":[["f7984428.057f68"]]},{"id":"11e97dd6.2b3b92","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"6 On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1390,"wires":[["f5a8d0ab.b1c0c"]]},{"id":"f58fc023.a6af3","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"6 Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1530,"wires":[["f5a8d0ab.b1c0c"]]},{"id":"f7984428.057f68","type":"function","z":"c9f6640b.fd0eb8","name":"","func":"context.set('state',context.get('state')||\"closed\");\n\nfunction updateNodeStatus(color, txt) {\n    node.status({\n    \tfill : color,\n    \tshape : \"dot\",\n    \ttext : txt\n    });\n}\n\nvar state = context.get('state');\nvar color = '';\n\nswitch (state) {\n    case 'OFF':\n        state = 'ON';\n        color = 'green';\n        msg.payload = \"0\";\n        break;\n    case 'ON':\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n    default:\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n}\n\ncontext.set('state',state);\nupdateNodeStatus(color,msg.payload);\nnode.send(msg);","outputs":"1","noerr":0,"x":1270,"y":1460,"wires":[["4a54c242.39666c"]]},{"id":"c29b5581.570608","type":"switch","z":"c9f6640b.fd0eb8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":1460,"wires":[["11e97dd6.2b3b92"],["f58fc023.a6af3"]]},{"id":"a80e7f3a.72d9d","type":"mqtt in","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/6","qos":"2","datatype":"auto","broker":"320c126d.0259be","x":350,"y":1460,"wires":[["c29b5581.570608"]]},{"id":"4a54c242.39666c","type":"mqtt out","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/6","qos":"","retain":"","broker":"320c126d.0259be","x":1500,"y":1460,"wires":[]},{"id":"e77b2ef4.c7b74","type":"ui_button","z":"c9f6640b.fd0eb8","name":"Relay5","group":"c8b522c8.2b1f7","order":4,"width":0,"height":0,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":1110,"y":1660,"wires":[["779c4c92.b651f4"]]},{"id":"6eb41f58.55d3a","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"5 On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1590,"wires":[["e77b2ef4.c7b74"]]},{"id":"503ebbb4.935f14","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"5 Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1730,"wires":[["e77b2ef4.c7b74"]]},{"id":"779c4c92.b651f4","type":"function","z":"c9f6640b.fd0eb8","name":"","func":"context.set('state',context.get('state')||\"closed\");\n\nfunction updateNodeStatus(color, txt) {\n    node.status({\n    \tfill : color,\n    \tshape : \"dot\",\n    \ttext : txt\n    });\n}\n\nvar state = context.get('state');\nvar color = '';\n\nswitch (state) {\n    case 'OFF':\n        state = 'ON';\n        color = 'green';\n        msg.payload = \"0\";\n        break;\n    case 'ON':\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n    default:\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n}\n\ncontext.set('state',state);\nupdateNodeStatus(color,msg.payload);\nnode.send(msg);","outputs":"1","noerr":0,"x":1270,"y":1660,"wires":[["d472d85.b539d28"]]},{"id":"d6acefe2.45692","type":"switch","z":"c9f6640b.fd0eb8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":1660,"wires":[["6eb41f58.55d3a"],["503ebbb4.935f14"]]},{"id":"198ae572.5aa26b","type":"mqtt in","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/5","qos":"2","datatype":"auto","broker":"320c126d.0259be","x":350,"y":1660,"wires":[["d6acefe2.45692"]]},{"id":"d472d85.b539d28","type":"mqtt out","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/5","qos":"","retain":"","broker":"320c126d.0259be","x":1500,"y":1660,"wires":[]},{"id":"3dadf747.f4d3e8","type":"ui_button","z":"c9f6640b.fd0eb8","name":"Relay4","group":"c8b522c8.2b1f7","order":4,"width":0,"height":0,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":1110,"y":1880,"wires":[["2071a267.eef0fe"]]},{"id":"fbf296aa.5dd468","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"4 On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1810,"wires":[["3dadf747.f4d3e8"]]},{"id":"e8048c5c.cf18b","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"4 Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1950,"wires":[["3dadf747.f4d3e8"]]},{"id":"2071a267.eef0fe","type":"function","z":"c9f6640b.fd0eb8","name":"","func":"context.set('state',context.get('state')||\"closed\");\n\nfunction updateNodeStatus(color, txt) {\n    node.status({\n    \tfill : color,\n    \tshape : \"dot\",\n    \ttext : txt\n    });\n}\n\nvar state = context.get('state');\nvar color = '';\n\nswitch (state) {\n    case 'OFF':\n        state = 'ON';\n        color = 'green';\n        msg.payload = \"0\";\n        break;\n    case 'ON':\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n    default:\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n}\n\ncontext.set('state',state);\nupdateNodeStatus(color,msg.payload);\nnode.send(msg);","outputs":"1","noerr":0,"x":1270,"y":1880,"wires":[["30f7b1d2.4137de"]]},{"id":"328303f6.ba10ec","type":"switch","z":"c9f6640b.fd0eb8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":1880,"wires":[["fbf296aa.5dd468"],["e8048c5c.cf18b"]]},{"id":"eacdc9f0.93f458","type":"mqtt in","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/4","qos":"2","datatype":"auto","broker":"320c126d.0259be","x":350,"y":1880,"wires":[["328303f6.ba10ec"]]},{"id":"30f7b1d2.4137de","type":"mqtt out","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/4","qos":"","retain":"","broker":"320c126d.0259be","x":1500,"y":1880,"wires":[]},{"id":"377719db.62a2b6","type":"ui_button","z":"c9f6640b.fd0eb8","name":"Relay3","group":"c8b522c8.2b1f7","order":4,"width":0,"height":0,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":1110,"y":2080,"wires":[["957e12f4.6c2f"]]},{"id":"24cba247.71475e","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"3 On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2010,"wires":[["377719db.62a2b6"]]},{"id":"cbb511b0.4792e","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"3 Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2150,"wires":[["377719db.62a2b6"]]},{"id":"957e12f4.6c2f","type":"function","z":"c9f6640b.fd0eb8","name":"","func":"context.set('state',context.get('state')||\"closed\");\n\nfunction updateNodeStatus(color, txt) {\n    node.status({\n    \tfill : color,\n    \tshape : \"dot\",\n    \ttext : txt\n    });\n}\n\nvar state = context.get('state');\nvar color = '';\n\nswitch (state) {\n    case 'OFF':\n        state = 'ON';\n        color = 'green';\n        msg.payload = \"0\";\n        break;\n    case 'ON':\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n    default:\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n}\n\ncontext.set('state',state);\nupdateNodeStatus(color,msg.payload);\nnode.send(msg);","outputs":"1","noerr":0,"x":1270,"y":2080,"wires":[["c9c2773e.2a6ff8"]]},{"id":"52b49a19.acb794","type":"switch","z":"c9f6640b.fd0eb8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":2080,"wires":[["24cba247.71475e"],["cbb511b0.4792e"]]},{"id":"58cdf85.86dc508","type":"mqtt in","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/3","qos":"2","datatype":"auto","broker":"320c126d.0259be","x":350,"y":2080,"wires":[["52b49a19.acb794"]]},{"id":"c9c2773e.2a6ff8","type":"mqtt out","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/3","qos":"","retain":"","broker":"320c126d.0259be","x":1500,"y":2080,"wires":[]},{"id":"b6e8c6f5.9527e8","type":"ui_button","z":"c9f6640b.fd0eb8","name":"Relay2","group":"c8b522c8.2b1f7","order":4,"width":0,"height":0,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":1110,"y":2280,"wires":[["93de750.887db88"]]},{"id":"9201dbda.c4a978","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"2 On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2210,"wires":[["b6e8c6f5.9527e8"]]},{"id":"3cf4b630.fe7dda","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"2 Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2350,"wires":[["b6e8c6f5.9527e8"]]},{"id":"93de750.887db88","type":"function","z":"c9f6640b.fd0eb8","name":"","func":"context.set('state',context.get('state')||\"closed\");\n\nfunction updateNodeStatus(color, txt) {\n    node.status({\n    \tfill : color,\n    \tshape : \"dot\",\n    \ttext : txt\n    });\n}\n\nvar state = context.get('state');\nvar color = '';\n\nswitch (state) {\n    case 'OFF':\n        state = 'ON';\n        color = 'green';\n        msg.payload = \"0\";\n        break;\n    case 'ON':\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n    default:\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n}\n\ncontext.set('state',state);\nupdateNodeStatus(color,msg.payload);\nnode.send(msg);","outputs":"1","noerr":0,"x":1270,"y":2280,"wires":[["eb91729e.f5a2c"]]},{"id":"ea22f5bf.ed5948","type":"switch","z":"c9f6640b.fd0eb8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":2280,"wires":[["9201dbda.c4a978"],["3cf4b630.fe7dda"]]},{"id":"4ec34f5c.6994e","type":"mqtt in","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/2","qos":"2","datatype":"auto","broker":"320c126d.0259be","x":350,"y":2280,"wires":[["ea22f5bf.ed5948"]]},{"id":"eb91729e.f5a2c","type":"mqtt out","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/2","qos":"","retain":"","broker":"320c126d.0259be","x":1500,"y":2280,"wires":[]},{"id":"f52ce2a1.07ef","type":"ui_button","z":"c9f6640b.fd0eb8","name":"Relay1","group":"c8b522c8.2b1f7","order":4,"width":0,"height":0,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":1110,"y":2480,"wires":[["ca3e9140.bdcb4"]]},{"id":"deb78380.35823","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"1 On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2410,"wires":[["f52ce2a1.07ef"]]},{"id":"b4cd233e.f7e2a","type":"change","z":"c9f6640b.fd0eb8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"1 Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2550,"wires":[["f52ce2a1.07ef"]]},{"id":"ca3e9140.bdcb4","type":"function","z":"c9f6640b.fd0eb8","name":"","func":"context.set('state',context.get('state')||\"closed\");\n\nfunction updateNodeStatus(color, txt) {\n    node.status({\n    \tfill : color,\n    \tshape : \"dot\",\n    \ttext : txt\n    });\n}\n\nvar state = context.get('state');\nvar color = '';\n\nswitch (state) {\n    case 'OFF':\n        state = 'ON';\n        color = 'green';\n        msg.payload = \"0\";\n        break;\n    case 'ON':\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n    default:\n        state = 'OFF';\n        color = 'red';\n        msg.payload = \"1\";\n        break;\n}\n\ncontext.set('state',state);\nupdateNodeStatus(color,msg.payload);\nnode.send(msg);","outputs":"1","noerr":0,"x":1270,"y":2480,"wires":[["fa376694.99eaa8"]]},{"id":"d8f3414c.28a5b","type":"switch","z":"c9f6640b.fd0eb8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":2480,"wires":[["deb78380.35823"],["b4cd233e.f7e2a"]]},{"id":"688e6ef5.1ee0e","type":"mqtt in","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/1","qos":"2","datatype":"auto","broker":"320c126d.0259be","x":350,"y":2480,"wires":[["d8f3414c.28a5b"]]},{"id":"fa376694.99eaa8","type":"mqtt out","z":"c9f6640b.fd0eb8","name":"","topic":"StarRelay/mcpgpio/1","qos":"","retain":"","broker":"320c126d.0259be","x":1500,"y":2480,"wires":[]},{"id":"c8b522c8.2b1f7","type":"ui_group","z":"","name":"Relays","tab":"21a6bafb.b2a3c6","order":1,"disp":true,"width":"6","collapse":false},{"id":"320c126d.0259be","type":"mqtt-broker","z":"","name":"OpenPlotter","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"21a6bafb.b2a3c6","type":"ui_tab","z":"","name":"Control","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
Reply


Messages In This Thread
UK OpenPlotter Build - by northwind - 2020-02-24, 05:32 PM
RE: UK OpenPlotter Build - by Sailoog - 2020-02-24, 05:37 PM
RE: UK OpenPlotter Build - by PaddyB - 2020-02-24, 05:50 PM
RE: UK OpenPlotter Build - by northwind - 2020-02-24, 06:01 PM
RE: UK OpenPlotter Build - by northwind - 2020-02-26, 02:43 PM
RE: UK OpenPlotter Build - by northwind - 2020-02-27, 07:09 PM
RE: UK OpenPlotter Build - by Max1947 - 2020-06-20, 09:34 PM
RE: UK OpenPlotter Build - by SYWindveer - 2020-06-24, 10:10 PM
RE: UK OpenPlotter Build - by st599 - 2020-09-04, 09:43 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)