Button state in setup

Add details :
• NodeMCU
• IOS, Android
• Blynk server

Hi everyone!!!
How can I get the value of the button position when the code starts?
For example - I have a code

BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  //Action
  Serial.println("I'm trying to open/close the window");
  Serial.println(pinValue);
  if (lmw1 != 0 && pinValue == 0){
    Blynk.virtualWrite(V1,1);
    return;
  }  
  if (lmw2 != 0 && pinValue == 1){
    Blynk.virtualWrite(V1,0);
    return;
  } 
  if (pinValue == 1) {
    window_open_1();
  }
  if (pinValue == 0) {
    window_close_1();
  }  
}

if the device rebooted - i need to get the state of the button, but I don’t wont to run on start the procedures window_open_1 and window_close_1.
If I use synchronization, it will run the BLYNK_WRITE(V1) and the procedures will run again.But I need to get just state of the button.

Please, help me :smile:

Blynk.syncVirtual(V1);
and you have to put a flag in your blynk_write(V1) at the first blynk connexion
bool isFirstConnect = true;

BLYNK_CONNECTED() {
  if (isFirstConnect) {
    Blynk.syncVirtual(V1);
    isFirstConnect = false;
  }
}

This is not enough because I need to get the state of the button from bridge too :tired_face:

oh I think @Gunner could resolve that
:wink:

I hope so

take a look

Thanks. The problem is solved. Please close the topic

How? For others sake who view this.

you have to share , friend!