Web Sockets - update on starting the App?

TZAPU has made a new version of the Node-Red nodes for Websockets. I am running a local server on a Raspberry Pi and generally it works.

It works in that you can:

  1. Update a button from Node-Red by injecting 0 or 1 - and the APP will show the changed state.
  2. Get an output to Node-Red from an APP button when pressed.

So everything works well EXCEPT… and very importantly…

Send from Node-Red a 0 to the button on the App and it turns off. Send from Node-Red a 1 to the App button and it turns ON… BUT… STOP the APP, send a 0 to turn the button OFF… start the APP - and the button DOES NOT reflect the new state of the button.

The app does not seem to request status when it starts…

But surely the server should know the state of the buttons and inform the app when it connects?

Is this the fault of the APP, the Nodes or the Blynk local server and how do we fix it?

@scargill

Hello. You need to use Blynk.virtualWrite on button press if you need sate syncing.
For instance, let’s assume you have button on V1 pin. And on your hardware you have interrupt function for physical button. So when you click physical button you need also call

Blynk.virtualWrite(V1, valueToSetOnApp);

This works for sliders also.

I tested this on Android (5.11 and 4.2) - if you turn the App off (or kill the task) - and make a change remotely- then when you turn it on - the App is updated - that is obviously the correct function.

However, if you merely stop the App with the square button top right of the App, make a change and then use the right arrow top right of the App to start it again - any changes made in the meantime remotely are NOT reflected in the APP.

My conclusion: The local BLYNK server must be operating correctly because it is storing any changes made in, say Node-Red, and when starting the App up (ie logging in) those changes are available - but simply pausing the App with the square icon top right - making a change and then using the start indicator top right to start the App again -the changes are NOT reflected. This surely can only be a problem with the APP - and as IOS seems to work - just with the Android version of the APP? Tested on a Chinese phone Android 4.22 and a Google Nexus 10 tablet with the latest Android 5.11

@scargill I can’t talk for IOS but the stop and play buttons are surely that. Stop the app and nothing changes as you have stopped it, whereas exiting the app with it running means it keeps working, no?

This is very corner case but in total @scargill is right. Even app was stopped server anyway stores latest value so it is logical to restore this state on application run. I will do quick fix on server soon and this will be available in 0.12.5.

@scargill released 0.12.5 with fix. Please let me know if that works for you.

A post was split to a new topic: Show the status of the buttons from Blynk on Node-Red