BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Node Red and Blynk


#1

Hi guys!

I’m experimenting with Sonoff Basic and Blynk via node red and I’m stuck trying to sync both.

I managed to turn on/off the sonoff (tasmota flashed) with blynk app. My problem is I don’t get how can I set a button in Blynk app to change when I turn Sonoff On or Off in other ways, and not get into a loop.

Any thoughts?


#2

Since you are using Node-Red, not sure how much of this will be applicable… but this is my example for a simple Blynk and Physical button mesh with Sonoff Basic


#3

It is easy to get into a loop, but if you’re careful about how you do your coding and flow logic then you can avoid problems.
I have to say that I don’t use Tasmota, it’s a bit too bloated and far too complex for anything that I need, so I’m not really familiar with the MQTT messages that it can send.

The basic principal should be that when you recieve an MQTT message from the Sonoff tosay that it’s ON, a similar message needs to be sent to your Blynk switch widget to ensure that it stays synchronised. That update to the Blynk Switch will create a new Node-Red event, but provided that you’re distinguishing between ON and OFF events in your code flow then it shouldn’t be a problem.

If you’re suffering from the electronic version of ‘switch bounce’ then a delay node with a short delay in it (50ms maybe) should solve the problem. You may also want to look at the RBE node to ensure that new messages are only sent when the payload value changes.

It really all depends on what you’re getting from Tasmota and how you’ve structured your flow. Post some details and we’ll be happy to give you some feedback.

Pete.


#4

Thank you!

I think RBE is what I need.

I have a blynk-ws-in-write for V3 that fires on/off on sonoff MQTT. The problem is I don’t know how to sync the blynk button when the MQTT changes via, for example, physical button without entering a loop.

No bounce problems at all, btw.


#5

I already showed one method for scanning the physical button, then using flags and virtualWrite for feedback and synchronization. Using a Hardware interrupt might also work instead of a timer… but untested on the Sonoff


#6

Just made it with the RBE node :smiley:

I’ll try you code some time, for now I want to experiment with Tasmota.

Thanks guys!