How to hardware read value of Virtualpin?

Hi

I has a code
void Update_state() { if (timer.isEnabled(Timer_Socket_1_id)) { Blynk.virtualWrite(V12, 1); } else { Blynk.virtualWrite(V12, 0); } delay(5); if (timer.isEnabled(Timer_Socket_2_id)) { Blynk.virtualWrite(V13, 1); } else { Blynk.virtualWrite(V13, 0); } delay(5); if (timer.isEnabled(Timer_Socket_3_id)) { Blynk.virtualWrite(V15, 1); } else { Blynk.virtualWrite(V15, 0); } delay(5); if (timer.isEnabled(Timer_Socket_4_id)) { Blynk.virtualWrite(V16, 1); } else { Blynk.virtualWrite(V16, 0); } delay(5); if (digitalRead(Socket_1_Pin) == HIGH) { Blynk.virtualWrite(V2, 1); } else { Blynk.virtualWrite(V2, 0); } delay(5); if (digitalRead(Socket_2_Pin) == HIGH) { Blynk.virtualWrite(V3, 1); } else { Blynk.virtualWrite(V3, 0); } delay(5); if (digitalRead(Socket_3_Pin) == HIGH) { Blynk.virtualWrite(V5, 1); } else { Blynk.virtualWrite(V5, 0); } delay(5); if (digitalRead(Socket_4_Pin) == HIGH) { Blynk.virtualWrite(V6, 0); } else { Blynk.virtualWrite(V6, 1); } delay(5); terminal1.print("All state updated"); terminal1.println(); terminal1.flush(); }
this code use to update value of hardware to app, because my hardware sometime still working but not connect to Blynk server, so I write a code like this and set interval or put in BLYNK_CONNECTED().
I care about many virtualWrite call in time, is there anyway to read a value of VirtualPin, than compare with value of hardware, if difference than call virtualWrite? or some way else to avoid flood server or make my nodeMCU hang?

You can do sync http://docs.blynk.cc/#blynk-main-operations-state-syncing-for-hardware when hardware connects to network.

I tried sync, but I still confuse about sync, sync will write value store on Blynk server to hardware and app, right? But my hardware still working and do something when disconnect to Blynk server, than no new value update to server.
Example: I use RTC hardware to set time to turn off light at 3AM, turn On light at 4AM. When 2AM, internet is droped, and hardware disconnect to server, than reconnect at 3:30AM, with sync it will turn On the light in stead of 4AM, right?

Yes. You need to handle such case in your code. We can’t do anything here. This is your logic and you have to define how it should work.

ok, thanks for your help
anyway, only way to get VPin’s value is use HTTP GET like example HTTP API READ PIN?

You can use sync command whenever you need it and for any pin you need - Blynk.syncVirtual(pin)

How I get value of pin after sync?

Blynk.syncVirtual(V1);    
BLYNK_WRITE(V1) {
    param.asInt();
}

Wow, thanks, I think only read value from BLYNK_WRITE when I push button on app