Sonoff T0 switch and nodered

Guys,

my situation is, have sonoff T0 switch that activate/diactivate my main light, but i have also a led strip that is placed and activated by a sonoff switch, all flashed with tasmota and visible with mqtt

What i want, i normally only use my led strip above my bench, but when i go away i want to push the t0 switch to deactivate the sonoff ledstrips, but when i push and my main light is alreadt off it goes on, is there somthing possible?

You need to provide more information.

What does your flow do?
How are you seperating the msgs from the two switches?
How are you keeping track of the status of each light?

It would be helpful - if your flow is not too large - to supply a copy of the flow (read this first)

[{"id":"eae0672e.14ad28","type":"tab","label":"Switches","disabled":false,"info":""},{"id":"7d1b3eaa.2492a","type":"switch","z":"eae0672e.14ad28","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":470,"y":120,"wires":[["832d9499.e8b088"]]},{"id":"fb213706.abe6b8","type":"mqtt in","z":"eae0672e.14ad28","name":"Main light","topic":"switch-1/stat/POWER","qos":"1","datatype":"auto","broker":"c1374cde.87a82","x":60,"y":120,"wires":[["7d1b3eaa.2492a"]]},{"id":"c694836a.36333","type":"mqtt in","z":"eae0672e.14ad28","name":"motionHK","topic":"zigbee2mqtt/0x680ae2fffe36ddc8","qos":"0","datatype":"json","broker":"c1374cde.87a82","x":60,"y":180,"wires":[["552dbd0e.09aba4"]]},{"id":"552dbd0e.09aba4","type":"change","z":"eae0672e.14ad28","name":"","rules":[{"t":"move","p":"payload.occupancy","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":180,"wires":[["89522436.4d5508","9bd15be2.da99d8"]]},{"id":"89522436.4d5508","type":"switch","z":"eae0672e.14ad28","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":180,"wires":[["3ced05c1.e8f8ba"],["4b66b3fe.682afc"]]},{"id":"3ced05c1.e8f8ba","type":"change","z":"eae0672e.14ad28","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":160,"wires":[["832d9499.e8b088"]]},{"id":"4b66b3fe.682afc","type":"change","z":"eae0672e.14ad28","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":200,"wires":[["d253db4b.de5968"]]},{"id":"d253db4b.de5968","type":"trigger","z":"eae0672e.14ad28","op1":"","op2":"OFF","op1type":"nul","op2type":"str","duration":"2","extend":false,"units":"min","reset":"ON","bytopic":"all","name":"","x":850,"y":220,"wires":[["1dcbc70a.dffa59","832d9499.e8b088","9bd15be2.da99d8"]]},{"id":"1dcbc70a.dffa59","type":"mqtt out","z":"eae0672e.14ad28","name":"","topic":"switch-1/cmnd/POWER","qos":"","retain":"","broker":"c1374cde.87a82","x":930,"y":160,"wires":[]},{"id":"832d9499.e8b088","type":"mqtt out","z":"eae0672e.14ad28","name":"Ledstrip Hobbykamer","topic":"switch_1/cmnd/POWER","qos":"2","retain":"true","broker":"c1374cde.87a82","x":920,"y":300,"wires":[]},{"id":"9bd15be2.da99d8","type":"debug","z":"eae0672e.14ad28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":280,"wires":[]},{"id":"c1374cde.87a82","type":"mqtt-broker","z":"","name":"Hassio","broker":"192.168.2.23","port":"1883","clientid":"Admin","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Is this enough info, i am really new on Node red, so all is a learning curve

Your topic is not entirely clear to me, but if i understand correctly:

  • 2 lights, 1 main light, 1 ledstrip
  • when you leave, the led strip turns off but the the main light is toggled instead of OFF ?

Made a video showing what i mean
https://youtu.be/A8Kxj1DB6Oc

I understand where you want to go, but looking at your flow:

Screenshot 2020-03-05 at 11.37.06

These mqtt nodes are both going to the same topic.
What is the debug output of the Main Light when you press the button and when it is switched automatically.

For the occupancy part, you can reduce the flow by using this:

[{"id":"6e260d04.00bb5c","type":"mqtt in","z":"788a0bf5.383e84","name":"motionHK","topic":"zigbee2mqtt/0x680ae2fffe36ddc8","qos":"0","datatype":"json","broker":"37a13171.cc203e","x":84,"y":192,"wires":[["9efc0527.d0588"]]},{"id":"6b3610c9.564d","type":"trigger","z":"788a0bf5.383e84","op1":"","op2":"OFF","op1type":"nul","op2type":"str","duration":"2","extend":false,"units":"min","reset":"ON","bytopic":"all","name":"","x":406,"y":192,"wires":[["28eecb4f.35ebfc","e3758948.00fdf"]]},{"id":"28eecb4f.35ebfc","type":"mqtt out","z":"788a0bf5.383e84","name":"Ledstrip Hobbykamer","topic":"switch_1/cmnd/POWER","qos":"2","retain":"true","broker":"37a13171.cc203e","x":628,"y":192,"wires":[]},{"id":"9efc0527.d0588","type":"change","z":"788a0bf5.383e84","name":"occupancy","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.occupancy ? \"ON\" : \"OFF\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":238,"y":192,"wires":[["6b3610c9.564d"]]},{"id":"37a13171.cc203e","type":"mqtt-broker","z":"","name":"Hassio","broker":"192.168.2.23","port":"1883","clientid":"Admin","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

These node one is Switch_1 and the other switch-1 :slight_smile:

when i manual push the switch on or off

5-3-2020 11:47:36node: 9bd15be2.da99d8
switch-1/stat/POWER : msg.payload : string[2]
"ON"
5-3-2020 11:47:40node: 9bd15be2.da99d8
switch-1/stat/POWER : msg.payload : string[3]
"OFF"

the main light is only going off by send a message dure no motion

Really clear.....what is switch 1 and what is switch 1 ?

switch-1/cmnd/POWER is mainlight
switch_1/cmnd/POWER is ledstrip

Btw your flow is awesome, that makes it so clean, many thanks

So you have two switches that use the topics:
switch-1/stat/POWER (main light switch)
switch-1/cmnd/POWER (led switch)

What is the secong MQTT-in (motionHK) is that a motion detector?

You might want to change (if you can) the main topics of the two devices to 'main_light' and 'wb_leds' (wb = workbench) so instead of switch-1/stat/POWER you would get main_light/stat/POWER and instead of switch-1/cmnd/POWER you would use 'wb_leds/cmnd/POWER'

thanks doing that now, i understand to start now to make it easy before upgrading my complete house

Helps to answer all questions...

So the switch-node that filters for "OFF" you don't really need.

I would recommend to give it descriptive names:

hobby-kamer/main-switch/ (it is not the light itself, it controls lights)
hobby-kamer/led-strip-switch/

etc.

side-note, you can actually send these commands from tasmota directly with rules.

the motion sensor is a ikea one connected to zigbee2mqtt

Motion sensor sends this, true or false, and my mqtt only reacts on (ON or OFF) now the led strip is not reacting

zigbee2mqtt/0x680ae2fffe36ddc8 : msg.payload : Object
{ occupancy: true, linkquality: 120, update_available: false, requested_brightness_level: 76, requested_brightness_percent: 30 … }

So weird, changed the names in tasmota and also in the nodes, but now the led strip is not reacting in this flow, my google assist command flow activate the led strip

[{"id":"e99b366b.adc088","type":"change","z":"eae0672e.14ad28","name":"occupancy","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.occupancy ? \"ON\" : \"OFF\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":220,"wires":[["5ee5229.75f54dc","9bd15be2.da99d8"]]}]

tasmota

When i do a test command works then Light goes on

You need to start with connecting debug nodes (output: complete msg object) everywhere.