Trouble with MQTT automation creating endless loops

I just put the switches into the wall, and came to realize that the bulbs in the fixtures (up way high) are not for use with dimmers... quick trip to store in order

I have taken this opportunity to flash tasmota onto many switches and install them in the walls, so I can test all of the flows in situ rather than sitting on my desk with no output!

Will report back, thanks again

I suspect that the spurious Zeros (which I assume are there otherwise I don't see how the slider could end up at the bottom) are not produced by my flow but that there is something odd going on with the devices. So I suspect that @JGKK's flow will suffer from the same problem. I may be wrong though, I often am.

I am also not understanding where the zero-setting is coming from, nor am I seeing any zeroes in the debug. I wonder if the switch firmware is having as adverse reaction.

At any rate, I just got back with dimmable LED bulbs and will test in real life shortly!

EDIT

while I'm wholly disappointed with the coloration of the new bulbs... I now have feedback!

this may be difficult to explain, but here goes:

local dimming on switch A, slowly... let's say four seconds from 0-100
maybe 2-3sec in, when I've gotten to 75%, I get what appears to be backfeed from another switch
the light fixture itself, not the switch (controlled by switchA) will briefly change to what switchB is displaying, before flashing back to my local dimming progress.

does that make sense?

@JGKK
I merged your two setups with each other and now I have a very nice and smooth operation of all slides

@reverendalc
Should work with your dimmers I believe, just cut the wire coming from the "Simulate mqtt result". BTW you mentioned earlier that you also wanted the intermediate levels displayed simultaneously on your dimmers in the same "group" while sweeping and not only the final level. But isn't that really something for the lab on your desk? In reality those dimmers would likely be installed in different areas so nobody would really care I guess. It's only on the dimmer you actually operate I think it will be nice to see the "sweeping value". But thats only my personal thoughts

[{"id":"8c0695cc.00b06","type":"function","z":"993670cc.78716","name":"propagate","func":"const dimmerList = [\"dimmer1\",\"dimmer2\",\"dimmer3\",\"dimmer4\"];\nlet receiving = context.get(\"receiving\") || false;\nlet source = context.get(\"source\");\nfunction propagate (value, items, noSend) {\n    items.forEach(item => {\n        if (item !== noSend) {\n            node.send({payload:value, topic:`cmnd/lighting/${item}/dimmer`});\n        }\n    });\n}\nif (!receiving) {\n    context.set(\"receiving\", true);\n    const splitTopic = msg.topic.split(\"/\");\n    context.set(\"source\", splitTopic[2]);\n    const propTimeout = setTimeout(()=>{\n        context.set(\"receiving\",false);\n    },50);\n    context.set(\"propTimeout\", propTimeout);\n    propagate(msg.payload, dimmerList, splitTopic[2]);\n} else if (msg.topic === source) {\n    let propTimeout = context.get(\"propTimeout\");\n    clearTimeout(propTimeout);\n    propTimeout = setTimeout(()=>{\n        context.set(\"receiving\",false);\n    },50);\n    context.set(\"propTimeout\", propTimeout);\n    propagate(msg.payload, dimmerList, source);\n}\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":500,"y":640,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"416297ac.416c28","type":"function","z":"993670cc.78716","name":"simulate mqtt result","func":"const item = msg.topic.split(\"/\")[2];\nmsg.topic = `stat/lighting/${item}/RESULT`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":780,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"417bea16.36c454","type":"mqtt in","z":"993670cc.78716","name":"","topic":"stat/lighting/dimmer2/RESULT","qos":"2","datatype":"auto","broker":"75eba16c.094f9","x":220,"y":480,"wires":[["bcfa6aa7.88a0c8","8c0695cc.00b06"]]},{"id":"e9b35332.1d5a","type":"mqtt in","z":"993670cc.78716","name":"","topic":"stat/lighting/dimmer3/RESULT","qos":"2","datatype":"auto","broker":"75eba16c.094f9","x":220,"y":530,"wires":[["6f336d29.2e1b94","8c0695cc.00b06"]]},{"id":"4bfe3f8b.b3359","type":"mqtt in","z":"993670cc.78716","name":"","topic":"stat/lighting/dimmer4/RESULT","qos":"2","datatype":"auto","broker":"75eba16c.094f9","x":220,"y":580,"wires":[["a06a2712.1c9d88","8c0695cc.00b06"]]},{"id":"7fae6d38.769ed4","type":"mqtt in","z":"993670cc.78716","name":"","topic":"stat/lighting/dimmer1/RESULT","qos":"2","datatype":"auto","broker":"75eba16c.094f9","x":220,"y":430,"wires":[["326e9d52.c798c2","8c0695cc.00b06"]]},{"id":"326e9d52.c798c2","type":"ui_slider","z":"993670cc.78716","name":"","label":"Dimmer nbr 1","tooltip":"","group":"793bb66e.729588","order":0,"width":0,"height":0,"passthru":false,"outs":"all","topic":"cmnd/lighting/dimmer1/dimmer","min":0,"max":"100","step":"1","x":510,"y":430,"wires":[["c8a26100.2b77b","dd00a578.a91738"]]},{"id":"bcfa6aa7.88a0c8","type":"ui_slider","z":"993670cc.78716","name":"","label":"Dimmer nbr 2","tooltip":"","group":"793bb66e.729588","order":0,"width":0,"height":0,"passthru":false,"outs":"all","topic":"cmnd/lighting/dimmer2/dimmer","min":0,"max":"100","step":"1","x":510,"y":480,"wires":[["e0ceb8b9.0493e8","9e298d71.55882"]]},{"id":"6f336d29.2e1b94","type":"ui_slider","z":"993670cc.78716","name":"","label":"Dimmer nbr 3","tooltip":"","group":"793bb66e.729588","order":0,"width":0,"height":0,"passthru":false,"outs":"all","topic":"cmnd/lighting/dimmer3/dimmer","min":0,"max":"100","step":"1","x":510,"y":530,"wires":[["30657a.3fa04a86","93658961.fa0e58"]]},{"id":"a06a2712.1c9d88","type":"ui_slider","z":"993670cc.78716","name":"","label":"Dimmer nbr 4","tooltip":"","group":"793bb66e.729588","order":0,"width":0,"height":0,"passthru":false,"outs":"all","topic":"cmnd/lighting/dimmer4/dimmer","min":0,"max":"100","step":"1","x":510,"y":580,"wires":[["9f3c9741.d4a428","2393443a.e2e00c"]]},{"id":"4a8dbd0c.d1b6e4","type":"mqtt out","z":"993670cc.78716","name":"","topic":"","qos":"0","retain":"","broker":"75eba16c.094f9","x":850,"y":780,"wires":[]},{"id":"c6caca.a0c78538","type":"mqtt in","z":"993670cc.78716","name":"","topic":"cmnd/lighting/dimmer1/dimmer","qos":"2","datatype":"auto","broker":"75eba16c.094f9","x":230,"y":710,"wires":[["416297ac.416c28"]]},{"id":"f72bed4f.2188c","type":"mqtt in","z":"993670cc.78716","name":"","topic":"cmnd/lighting/dimmer2/dimmer","qos":"2","datatype":"auto","broker":"75eba16c.094f9","x":230,"y":760,"wires":[["416297ac.416c28"]]},{"id":"384466b7.68013a","type":"mqtt in","z":"993670cc.78716","name":"","topic":"cmnd/lighting/dimmer3/dimmer","qos":"2","datatype":"auto","broker":"75eba16c.094f9","x":230,"y":810,"wires":[["416297ac.416c28"]]},{"id":"ca70d4cc.4c88b8","type":"mqtt in","z":"993670cc.78716","name":"","topic":"cmnd/lighting/dimmer4/dimmer","qos":"2","datatype":"auto","broker":"75eba16c.094f9","x":230,"y":860,"wires":[["416297ac.416c28"]]},{"id":"c8a26100.2b77b","type":"delay","z":"993670cc.78716","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":680,"y":430,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"dd00a578.a91738","type":"trigger","z":"993670cc.78716","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"200","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":850,"y":430,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"e0ceb8b9.0493e8","type":"delay","z":"993670cc.78716","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":680,"y":480,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"9e298d71.55882","type":"trigger","z":"993670cc.78716","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"200","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":850,"y":480,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"9f3c9741.d4a428","type":"delay","z":"993670cc.78716","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":680,"y":580,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"2393443a.e2e00c","type":"trigger","z":"993670cc.78716","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"200","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":850,"y":580,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"30657a.3fa04a86","type":"delay","z":"993670cc.78716","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":680,"y":530,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"93658961.fa0e58","type":"trigger","z":"993670cc.78716","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"200","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":850,"y":530,"wires":[["4a8dbd0c.d1b6e4"]]},{"id":"75eba16c.094f9","type":"mqtt-broker","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"online","birthQos":"0","birthPayload":"BULB-1/LWT","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"offline","willQos":"0","willPayload":"BULB-1/LWT"},{"id":"793bb66e.729588","type":"ui_group","name":"Slider","tab":"4fefac8f.7fa254","order":1,"disp":false,"width":"6","collapse":false},{"id":"4fefac8f.7fa254","type":"ui_tab","name":"Slider","icon":"dashboard","disabled":false,"hidden":false}]

Add a debug node showing what is coming out of the mqtt node and another showing what is going into the other mqtt node. Give them names and set them to log to the console. Run node-red-log, or start node-red in a terminal, so you can see the log. Then do your four second swipe test and you should be able to see from the log what happened.

@krambriw
The way my home is laid out, I can see both stairwell switches from the top of the stairs. My upstairs hall has three switches, all of which are visible at the same time, because thereā€™s a toggle outside of the bedroom doors. Furthermore, please remember that only switch A is in physical control of the light fixture, so unless real-time slider info is published, you do not get real-time response from the fixture.

I will gather some debug outputs, and I will happily test additional flows.

I think I will require some sort of logic to make sure that messages arenā€™t recycled between the switches too, Iā€™ll post a video also.

Thanks a million

That isn't necessary. What matters is the debug data showing what is going in and out of the mqtt nodes when it goes wrong.

Don't try and fix it until you know exactly what is happening.

it very well may be necessary to equate what the debug is showing to what is happening in real life.

you've all sufficiently big-timed me here, and I lack the requisite knowledge to (even try to) take myself further. at this point I'm just importing flows and trying to learn how they work, and reporting back

If the debug does not show any unexpected values then whatever is happening is not a node-red issue. If you tell us that the slider goes to zero then we will believe you.

OP - check the Tasmota wiki and the Forums - i am sure they recently introduced exactly this feature into a recent build of Tasmota - essentially putting 3 swtches into a sync state.

Here you go

https://tasmota.github.io/docs/Device-Groups/

Craig

FASCINATING! I am running the latest Tasmota on the majority of my devices, save for the dimmers themselves. I had to use a custom scripted firmware of 9.0.0.3 (because I'm not smart enough to do it myself) on the dimmers, but the rest of my simple on/off switches are all running 9.2.0. funnily enough, the node-red power state automation that I wrote works perfectly for the simple toggle switches.

I know that this isn't a Tasmota forum, but do you know if upgrading the firmware OTA on my dimmers will overwrite the scripting for their serial interface?

I'm ecstatic to read that's a feature now, as I've been struggling to understand why this hasn't been a thing

Its been a feature for a while now (since 8.3)

Those dimmers you were using look pretty generic - i am sure if you go to the blackadder site and put them in you will find that they have a template for them (they look like the Martin Jerry ones)

If you have a standard Tasmota build it SHOULD not overwrite your scripts - if you have a custom build then all bets are off

Craig

@craigcurtin
thanks for that, I'll have to read up on device groups.

it sounds like it should be in my 9.0.0.3 switches already... I'm using a custom firmware (derived from the blakadder template and script) due to a few oversights in the script.

very valuable info, and if my fledgling understanding is correct, it may very well turn this thread into a fool's errand -;

Yep it basically does a whole heap of stuff behind the scenes for you using UDP broadcasts (so only thing to watch for is VLANs on your home network)

Minimize everything that you need to do to synch everything together

Craig

@craigcurtin

thanks for pointing me toward that.

@Colin and krambriw and JGKK (who I don't have enough rep to call out)
as I feared, it works perfectly, and I have misused all of your time and expertise. I apologize for leading you all on this wild goose chase, but I'll leave the thread with this:

I have learned very much from each and every one of you
I look forward to picking your brains with my next harebrained node-red scheme.

cheers to all!

Glad it is all working - at least you learnt a lot on the way through !!

Craig

So are you using customer firmware - or just a custom template ?

Craig

well... it's a binary which has a modified version of the blakadder template (better LED scenario) and then a custom script. the serial buffer has 47char limit and the blakadder script doesn't honor that, resulting in glitchy performance on long swipes... also, the LED array has been customized to illuminate one LED to indicate the dimmer level even when the switch is off.

I snagged it from cocoontech

one last thing, @JGKK, what is a penislampe?
image

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.