Controlling the Tasmota SonOff Switch with HTTP and Node-Red

http-requestTasmota devices can be controlled by both HTTP and MQTT.

If you don’t have an MQTT broker or don’t want to use one then you can still control your Tasmota devices using node-red.

To do this you need to use the http request node which is one of the core nodes.

The http request node can be used for.

  • Retrieving web pages from a website
  • Making API Requests
  • Sending and receiving JSON data to a website or API.
  • etc

The node will send a request and receive the response and it handles both the request and response.

In the HTTP request node you can set the:

  • Request Method -GET,POST etc
  • URL
  • SSL
  • Authentication
  • Proxy
  • Keep Alives
  • Return Data

As shown below:


The request method and URL as well as other settings, like content headers, can also be set in the preceding node for creating dynamic requests.

The output is usually a web page but for our Tasmota switch it is JSON. If we leave it as a string means we will need to convert it ourselves to a JavaScript Object.

Turning a Switch On and OFF Simple Flow

Below is a screen shot of the basic flow.


The flow is effectively two flows. The top flow using inject nodes to send the command. The inject node labelled ON looks like this:


You can see that we use the IP address of the switch and pass the command in the url. See controlling smart home devices using http.

The bottom node using dashboard buttons for on and off and also displays the status. The status is returned as a JSON string and needs to be converted to a JavaScript object to be displayed.


Video Controlling Tasmota Sonoff Switch using HTTP and Node-Red


Control Tasmota Switch with Node-Red HTTP

 Related Tutorials:


Please Let me Know if you found it Useful
[Total: 4 Average: 3.5]

Leave a Reply

Your email address will not be published. Required fields are marked *