Integrating NodeRED and Tasker

Make Home Automation great again!

NodeRED is easy and powerful. Currently, I’m running the NodeRED server on my RaspberryPi Zero connected to the router directly. It handles my light setup, but what I have been missing for a while is a way to make the NodeRED talk to Tasker. Finally, I found a great way how to integrate NodeRED and Tasker. If you have a Raspberry Pi you can start your NodeRED server in moments. It’s a fantastic and versatile tool with a great support.

NodeRED and Tasker integration

This is not a NodeRED tutorial so I would expect you to have a minimal knowledge of it. It’s very easy to start with and I was shocked how long I have ignored NodeRED in my automating efforts.

The write-up is still useful, however, there is an even better way of interacting with Tasker and NodeRED using Join Node and Join app – please see a detailed tutorial.

I shared recently a setup where I would text my work friend Helen, who sits near AC control unit, each time the temperature near my desk drops below 20°C. I’m not a horrible person, I sit directly underneath the AC unit. The profile would then continue to annoy Helen every minute until the temperature is over 20°C again.
NodeRED and TaskerThe whole process was automated in NodeRED and Tasker sent an SMS message only when prompted. Temperature readouts were submitted by an ESP32 with DHT11 temp sensor hooked up to it.
Here is how to make your mobile (and Tasker) work with NodeRED.

NodeRED to Tasker

NodeRED and TaskerYou can send an AutoRemote message to your mobile from a web browser via a link. This link is a web request that contains a message and usually looks like this:

https://autoremotejoaomgcd.appspot.com/sendmessage?key=YOUR_KEY&message=THIS%20IS%20THE%20MESSAGE

Note that spaces in between the messages are encoded with %20. This means we can send the message to Tasker simply by a web request. Fortunately, NodeRED comes with a node HTTP REQUEST – we and use HTTP POST to pass the message and the argument. The argument (also called payload) is encased in {{{….}}} and placed at the end of the URL.

https://autoremotejoaomgcd.appspot.com/sendmessage?key=YOUR_KEY&message={{{payload}}}
NodeRED and Tasker
HTTP REQUEST output node

In the example, I’m using an input node to insert a msg.payload with a click of a button, but you can link this with any other node that passes the message as payload.

Tasker to NodeRED

NodeRED and TaskerWhile we can’t simply reverse the process, but can use the HTTP POST action in Tasker to return the message. Local IP (or a DNS) specified with a default port 1880 is our server configuration. The POST request should contain a topic – which is a path (/test) where the request will be sent to. The attributes are formatted in a similar fashion to a JSON file where we pass a set of keys=values.

NodeRED and Tasker
HTTP POST Tasker action

The HTTP REQUEST input node has to have the same topic specified in the node config menu. In addition to this, an HTTP RESPONSE node needs to be linked preventing our Tasker HTTP POST action from timing out. It will notify Tasker that our message has been successfully received.

NodeRED and Tasker
HTTP REQUEST input node

Conclusion

As you can see the message flow is nearly instant, which allows the setup to be used for switches. NodeRED and Tasker will become my interface of choice when trying to get a Raspberry Pi to have a conversation with the Android device.

Support NotEnoughTech
A lot of time and effort goes into keeping NotEnoughTech alive! If my work helped you out, consider buying me a coffee or check out exclusive rewards available to Patreon supporters.
SHARE