Use one switch to control multiple lights

#1

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
thanks

0 Likes

#2

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

#3

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:

[{"id":"2d878d4c.e51e12","type":"join","z":"1535d28d.7fd35d","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"/","joinerType":"str","accumulate":false,"timeout":"2","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":490,"y":600,"wires":[["b025cafa.c402f8"]]},{"id":"89c55db4.6f8d2","type":"debug","z":"1535d28d.7fd35d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":600,"wires":[]},{"id":"3e5e15b9.af44ca","type":"inject","z":"1535d28d.7fd35d","name":"","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":580,"wires":[["2d878d4c.e51e12"]]},{"id":"27f9be51.24f442","type":"inject","z":"1535d28d.7fd35d","name":"","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":620,"wires":[["2d878d4c.e51e12"]]},{"id":"b025cafa.c402f8","type":"switch","z":"1535d28d.7fd35d","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"},{"t":"eq","v":"ON/OFF/ON","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":650,"y":600,"wires":[["89c55db4.6f8d2"],["89c55db4.6f8d2"],["89c55db4.6f8d2"]]}]
1 Like

#4

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...

0 Likes

#5

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

#6

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

1 Like