Get your own Node-RED in the cloud! Free for iotwithus.com users!

Problem:

I have a RF Remote that I want to use for my outdoor lamps but I don’t want to assign two buttons (ON button and OFF button) for this job. I want to have a single button to turn ON the lights as well as turn them OFF.

We do have multiple solutions for this one and I will show you one of them!

The logic behind is very simple:

  1. We have an input (but we don’t care about the value)
  2. Read the next value from a variable (or assign 0 if none)
  3. Set the payload  to the next value and assign the opposite value to the variable
  4. Output

First, create a new subflow using the menu on the top right corner.

From the top, add 1 input and 1 output node.

Import the nodes in this file to your subflow.

Link the input and the output nodes. It should look like this:

Test it:

In a flow, insert: a timestamp node, your toggle subflow and a debug node:

That’s it!