Use one switch to control multiple lights

Hi, i have home assistant with nodered and some sonoff basic flashed with tasmota, i use GPIO pins to control the relays but by switchtopic (mqtt, not directly) and i want to create a flow based in how many times i turn the switch on or off (its a switch not a press button) for example:
on - ceiling light
on/off/on - desk light
is it possible ? i've searched a lot on internet and found anything

If tasmota already in use, then I suggest to replace switch with pushbutton and then you can use the "long press" (HOLD command) option.

1 Like

What about using a Join node with a timeout (you could also use multiple join nodes in parallel with # of message parts / timeout to not have to wait for the timeout before sending). Then feed it to a switch node that evaluates the joined string looking for the combination in question. Something like this:

1 Like

thanks, i have one regular wall switch and one pushbutton attatched to the sonoff basic, the switch is just to be a regular switch like without any sonoff stuff, and the push i've already changed the topic to control another sonoff and im itself
But i want to keep the wall switch and make it "more clever" than just control one light...

Thanks a lot, im going to try it, im a bit newbie on node red automation but i think i can make it, soon i'l give you some feedback
Again thanks, apreciate your help

1 Like

Sorry for taking a while to answer but this was what i've been looking for, thanks !! really appreciate it

1 Like

Hi, this is working pretty good in the last months, but now i was thinking about the solution to dont have to wait for a timeout and i didnt understand the part of the multiple join to dont have to wait for the timeout.
my switch only outputs "TOGGLE" payload
do you have any idea in how to do it ?

@moita Had to think back to when I looked at this. My original thought was that you could setup a separate join for each set of sequences by the # of changes that would be involved (i.e. you'd have one that waited for 2 toggles - on/off, you could have one waiting for 3 toggles - on/off/on, etc) all wired in parallel. Thinking it back over I don't think this would create any improvement over the current approach since you'd still have to figure out how not to send the single toggle or the double toggle if you were doing a triple.

Maybe you can try shortening the timeout to see if you still can get 3 toggles in but decrease the delay for a single toggle?

1 Like

Thanks, thats the point i've reached too, i decreased the delay to 0.3 and the toggles too, i have single toggle to one light and double to another light.
i did this a month ago or so to decrease the timeout, and actually its pretty fast.
But i was looking for a faster method, anyway i think thats it, thanks again !

1 Like