HTTP API works, websockets not quite as expected. WHY?

Who is willing to help me with the following:

  • I’m using NODE RED and Blynk WS by @gab.lau running on local Blynk server 0.36.3.
  • I created some test project with some ZeRGBa widget, a button, terminal and eventor
  • I created also a simple flow with NODE RED dashboard RGB control to duplicate the ZeRGBa widget and a switch.

And now:

  • If I use NODE RED dashboard controls connected through @gab.lau nodes, widget in app gets updated instantly and accordingly, but hardware can’t see those changes
  • If I use HTTP API widget in app gets updated instantly and accordingly, AND hardware reacts according to changes
  • setting in app directly off course works without any issue

Why is that? What am I missing?? :thinking:

Hi Marcin,

this is your architecture (and mine too):
blynk1

Blynk.virtualWrite(V4, 255);
virtual write command from “device 1” update the app, not node-red:
blynk2

WidgetBridge nodered(V20);

BLYNK_CONNECTED() {
  nodered.setAuthToken('ABCDEF1'); // Place the AuthToken of the second hardware here
}

//somewhere in the code
nodered.virtualWrite(V4, 255);

nodered.virtualWrite(V4, 255);
if you want to update nodered you must use a bridge command on “device 1” and do a virtual write to “device 2”
blynk3

same thing if you modify an app widget, you must “manual” update with bridge command the node-red dashboard
blynk4

Of course if you change a value from nodered, you must update Arduino device with a bridge + VirtualWrite command too

Is it clear now?
The alternative is to use the syncVirtual or syncAll command on node-red in polling (every one minute) to receive the updated values from the blynk server

P.S. :
At the moment the library for nodered is a client (device) library, I could try to write a library that connects to the server as an app …

2 Likes

The point is I don’t have to use a bridge (neither I’m using it at all), and the nodered ws nodes are updated correctly!. (look at ZeRGBa pin values under node - these are read). It is so weird, that I’m wondering, if there is some issue in websockets implementation inside Blynk Server. Look at my flow connections, which are working perfectly fine:

In the above flow, the ZeRGBa node catches the V0 values correctly, regardless they are set with app or node-red dashboard. No bridge! Hardware reacts accordingly, value gets updated in app.Nothing but Heaven on Earth! :wink: But if I replace the HTTP node with ws write, the value gets updated (in app I see the color changing as a response to node-red dashboard action), but the hardware does nothing. Is it expected behaviour? I’m not saying there is anything wrong wit ws nodes - they are changing the value on Blynk Server. But in the contrary to HTTP API, the server doesn’t “notify” the hardware about the change.

@marvin7 Do you have more then one zeRGBa Widget? There is another topic with 2nd zeRGBa issues that appear Node-Red related as it can’t seem to be duplicated otherwise.

I don’t understand Node-Red, so I can’t be certain there is any relation to this issues except the widget.

No, only one widget, but will take a look at it anyway as soon as I will be back home.
Currently the mixed mode I’m using seems to work.

I checked the linked topic, but it seems to be related to some issue/error in Blynk “ecosystem”. My “problem” is “by design”, I think, yet still leads to unexpected (?) behaviour. I don’t know WHY it behavies even differently than @gab.lau explained (although I do understand the explanations), as almost everything works EXCEPT updating the hardware (when using the ws write node)
I always thought that after the widget in app gets updated, it triggers the hardware event, which is clearly not the case.

I don’t think you’re using Node-Red and the Blynk ws contrib in the best way.
My ESP devices don’t run any Blynk code at all. They simply connect to Wi-Fi then receive/send/ process MQTT messages. All the Blynk interaction takes place in Node-Red and this approach works really well.

Pete.

I know @PeteKnight, I’m using MQTT too as a nodes for NODE-RED. But this particular device I’d like to leave on native Blynk firmware (and protocol). The reason for that is the security… It is (it will be - only testing stage now) outside my LAN, on GSM modem. I do have port forwarding only for Blynk server. It’s specific communication “subsystem” makes me believe it is secure enough to leave it open to the outside “world”. I just know too little to do the same with Mosquitto, although in spare time (not much left) I do try to learn more about it.
Currently there are two options I’m testing:

  • Use HTTP API as an output, which just works
  • Use blynk ws nodes and VP’s state syncing, as pointed by @gab.lau. This approach works well too, although requires triggering.

Either way IT WILL BE WORKING, just need put it all together. Currently it is just a “nice” programmable RGB LED. But why the widgets in app are updated without triggering the hardware BLYNK_WRITE remains unknown to me… Still, I think I can live with it :wink: