Send HTML form action from Node Red

Good day everyone,
I have a networked projector that I am trying to connect to my home automation (Dell 7609WU). It has a simple web interface that uses an HTML form post to turn on and off the projector. While inspecting the html I found this code for the submit action
image

== $0 ...many other buttons and things.... == $0

image

and the power off function is similar.
Is there any way that I can send these requests from Node Red? I do not have much experiece with php or backend development. Any help will be much appreciated!

Try this first in a browser to see if it works:
http://YourProjectorIp/tgi/status.tgi&PJSTATE=1&DSP_SOURCE=121

If this is working it's not that difficult to implant this in NR.

@ChrisDeVilliers You don't need PHP or any serious backend development knowledge/skill to serve a form or receive data from Node-Red.

You can use a get API to serve the HTML form which will post the data to another API on submit (post endpoint) created inside your Node-Red instance.

I have prepared a sample flow. Hope it'd help.

[{"id":"50aa3bac.85f094","type":"template","z":"cf35282d.677b78","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"<!DOCTYPE html>\n<html>\n<body>\n\n<h2>HTML Forms</h2>\n\n<form action=\"/users.js\" method=\"post\">\n  <label for=\"fname\">First name:</label><br>\n  <input type=\"text\" id=\"fname\" name=\"fname\" value=\"John\"><br>\n  <label for=\"lname\">Last name:</label><br>\n  <input type=\"text\" id=\"lname\" name=\"lname\" value=\"Doe\"><br><br>\n  <input type=\"submit\" value=\"Submit\">\n</form> \n\n<p>If you click the \"Submit\" button, the form-data will be sent to a page called \"/action_page.php\".</p>\n\n</body>\n</html>","output":"str","x":300,"y":180,"wires":[["c188911f.179ed"]]},{"id":"3899d94e.d47046","type":"http response","z":"cf35282d.677b78","name":"","statusCode":"","headers":{},"x":490,"y":300,"wires":[]},{"id":"fb731926.862c88","type":"http in","z":"cf35282d.677b78","name":"","url":"/users","method":"get","upload":false,"swaggerDoc":"","x":120,"y":180,"wires":[["50aa3bac.85f094"]]},{"id":"83ede080.8a946","type":"http in","z":"cf35282d.677b78","name":"","url":"/users.js","method":"post","upload":false,"swaggerDoc":"","x":130,"y":300,"wires":[["cd09c56b.60f778"]]},{"id":"cd09c56b.60f778","type":"function","z":"cf35282d.677b78","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":300,"wires":[["3899d94e.d47046","5b596a7.b7d4094"]]},{"id":"c188911f.179ed","type":"http response","z":"cf35282d.677b78","name":"","statusCode":"","headers":{},"x":490,"y":180,"wires":[]},{"id":"5b596a7.b7d4094","type":"debug","z":"cf35282d.677b78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":450,"y":360,"wires":[]}]

Best,
-Ravi

1 Like

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