Is it possible to receive a payload from a button that is on an online site?
Or even localhost.
My idea is to hit the button on the site, and start production using a PLC
What do you mean by a button? Do you mean an actual real physical button or a button on a screen on a dashboard? If you mean a real physical button then how is it connected to the computer?
No, A button in a site.
What do you mean by 'a site'? It is very difficult to help if you don't give an clear description of what you are trying to do.
If you mean a button on the node-red dashboard controlling a PLC, then yes that can be done, provided the machine running node-red can communicate with the PLC in some way.
A WebSite, like this:http://www.treinamento48.shop/
Do you mean that actual website or a node-red dashboard that looks like that?
I should not have to keep guessing what you mean. Do you mean that you want to develop a website using node-red that looks like that website and controls a PLC then why did you not ask that? The answer is yes, as I said above.
Have you actually done any research before coming here and making me spend time answering your vague questions?
No, you don't understand, I'm developing that web site, and I want to press one of those buttons, and when they're pressed they'll send a payload to node-red, and I don't know if it's possible to connect that button with node- red
If you had said that in the first place it would have helped.
You need to get a message, indicating the button has been pressed, from the website to node-red. A good way to do that is using mqtt, but you could use an http end point if you preferred.
Thanks for this information.
This is actually fairly easy to implement, though there are security implications. When I'm doing stuff like this, I use an http node set to listen for POST requests and set the button on the website to hit that http endpoint using the formaction attribute.
At the very minimum, your node-red instance should be password protected, as it will need to be exposed to the internet for this to work. In my production environment I take it a bit further by presenting the node-red gui on a non-standard directory and use a different port for HTTP activity, as well as hiding everything behind a load balancer (citrix netscaler) with rules set to drop any http requests except those explicitly defined.
VocĂŞ pode me enviar um dos seus fluxos?
Here's a quick and ugly example. [{"id":"b3bbf79a69d76bc3","type":"http in","z":"0847275de270f654","name":"","url":"/test","method":"post","upload":false,"swaggerDoc":"","x":260,"y":160,"wires":[["9911453f76d228d4","61853a2b7947ac11"]]},{"id":"9911453f76d228d4","type":"debug","z":"0847275de270f654","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":325,"y":220,"wires":[],"l":false},{"id":"f576432140a4ddba","type":"http response","z":"0847275de270f654","name":"","statusCode":"","headers":{},"x":730,"y":140,"wires":[]},{"id":"5962bf8b9cc41b21","type":"http in","z":"0847275de270f654","name":"","url":"buttonpage","method":"get","upload":false,"swaggerDoc":"","x":240,"y":120,"wires":[["7217178eb784f9e0"]]},{"id":"7217178eb784f9e0","type":"template","z":"0847275de270f654","name":"HTML in here","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n\t<div>\n\t<form action=\"http://localhost:1880/test\" method=\"post\" class=\"buttonBox\">\n <button type=\"submit\" name=\"action\" value=\"testValue\">\n\t\t\t\t\t<div style=\"font-size:15vmin;\">\n\t\t\t\t\t\tDo a thing\n\t\t\t\t\t</div>\n\t\t\t\t</button>\n\t\t\t</form>\n\t</div>\n</html>","output":"str","x":420,"y":120,"wires":[["f576432140a4ddba"]]},{"id":"61853a2b7947ac11","type":"change","z":"0847275de270f654","name":"redirect back to main page after submit","rules":[{"t":"set","p":"headers.location","pt":"msg","to":"localhost:1880/buttonpage","tot":"str"},{"t":"set","p":"statusCode","pt":"msg","to":"303","tot":"str"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":160,"wires":[["f576432140a4ddba"]]}]
It assumes you are hosting the website via node-red itself, but you can host the site elsewhere and just change the URL in the http redirect if you want.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.