It depends on the scenario you are talking about.
Do you have an example that you can describe where you need your ESP to get the latest Blynk server value on startup?
As far as I’m concerned, here are really two different possible situations that need different approaches…
-
ESP goes offline then back online again, and you want to sync the latest Blynk server value
-
Node-Red goes offline then back online again and you want to sync the latest Blynk server value
In situation (1) you might have a command like an on/off status and you want to set a relay that tye ESP device is controlling to the correct status. In this case, the on/off message would have been sent from Node-Red to the ESP device via MQTT.
If the message was sent with the “Retain” flag set to true then that MQTT message value will be retained on your MQTT server.

When you reboot your ESP device it wil connect to the MQTT server and when it subscribes to the topic which relates to this on/off message it will automatically be sent the latest value, and your device will respond to that and set your relay to the correct state.
In Scenario (2) you’ll want to know what the current widget state that controls this relay is set to, as it could have changed while your Node-Red server was offline.
You can use the Sync/SyncAll node in the Blynk IoT contrib to fetch this from the Blynk server, and you can trigger that with an Inject node set to trigger at startup after x seconds.

If you use the SyncAll option (which I don’t recommend) then you have to be careful that your datastream is set-up to respond to this request, by checking the “Sync with latest server value every time device connects to the cloud" option in the Datastream Advanced settings for each virtual datastream you wish to sync.
Pete.