Blynk disconnects the relay when Wifi disconnects

Hello Blynk users,
I’m using blynk for the past 5 years and its been excellent and now the new 2.0 Blynk is better than before.
I’m using it for my home automation and there has been no issues untill this update. Everytime when wifi disconnects the relay turns off turning everything blackout and when wifi is back on the blynk sync automatically and everything back to normal.
But this hadn’t happened before in the old blynk server as when the wifi disconnects the relay stays on the default value and wont turns off.

for example, I have a automation to turn on light at 6 PM and turns off at 9 PM.

IN NEW BLYNK :
The relay turns on at 6 PM and wifi disconnected at 8 PM and within seconds the relay turns off even though the the switch is on in the blynk server.

IN OLD BLYNK:
The relay turns on at 6 PM and wifi disconnects at 8 PM and the light won’t even turns off now. even after 9 PM the light wont be disconnected, it turns off after wifi is cconnected back and it becomes normal.

I have attached the below below for your reference.

#define BLYNK_TEMPLATE_ID "TMPL8KUCs-ix"
#define BLYNK_DEVICE_NAME "HALL"

#define BLYNK_FIRMWARE_VERSION "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
//#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
//#define USE_WEMOS_D1_MINI

#include "BlynkEdgent.h"

BLYNK_WRITE(V1)
{
  if (param.asInt() == 1)
  {
    digitalWrite(05, HIGH);
  }
  else
  {
    digitalWrite(05, LOW);
  }
}
BLYNK_WRITE(V2)
{
  if (param.asInt() == 1)
  {
    digitalWrite(04, HIGH);
  }
  else
  {
    digitalWrite(04, LOW);
  }
}
BLYNK_WRITE(V3)
{
  if (param.asInt() == 1)
  {
    digitalWrite(00, HIGH);
  }
  else
  {
    digitalWrite(00, LOW);
  }
}
BLYNK_WRITE(V4)
{
  if (param.asInt() == 1)
  {
    digitalWrite(02, HIGH);
  }
  else
  {
    digitalWrite(02, LOW);
  }
}
BLYNK_WRITE(V5)
{
  if (param.asInt() == 1)
  {
    digitalWrite(14, HIGH);
  }
  else
  {
    digitalWrite(14, LOW);
  }
}
BLYNK_WRITE(V6)
{
  if (param.asInt() == 1)
  {
    digitalWrite(12, HIGH);
  }
  else
  {
    digitalWrite(12, LOW);
  }
}
BLYNK_WRITE(V7)
{
  if (param.asInt() == 1)
  {
    digitalWrite(13, HIGH);
  }
  else
  {
    digitalWrite(13, LOW);
  }
}
BLYNK_WRITE(V8)
{
  if (param.asInt() == 1)
  {
    digitalWrite(15, HIGH);
  }
  else
  {
    digitalWrite(15, LOW);
  }
}
BLYNK_CONNECTED()
{
  Blynk.syncAll();  
}

void setup()
{
  pinMode(05, OUTPUT);
  pinMode(04, OUTPUT);
  pinMode(00, OUTPUT);
  pinMode(02, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(15, OUTPUT);
  digitalWrite(05, HIGH);
  digitalWrite(04, HIGH);
  digitalWrite(00, HIGH);
  digitalWrite(02, HIGH);
  digitalWrite(14, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
  digitalWrite(15, HIGH);
  delay(100);


  BlynkEdgent.begin();
}

void loop()
{
  BlynkEdgent.run();
}```




Blynkedgent.h
```extern "C" {
  #include "user_interface.h"

  void app_loop();
}

#include "Settings.h"
#include <BlynkSimpleEsp8266_SSL.h>

#ifndef BLYNK_NEW_LIBRARY
#error "Old version of Blynk library is in use. Please replace it with the new one."
#endif

#if !defined(BLYNK_TEMPLATE_ID) || !defined(BLYNK_DEVICE_NAME)
#error "Please specify your BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME"
#endif

#include "BlynkState.h"
#include "ConfigStore.h"
#include "ResetButton.h"
#include "ConfigMode.h"
#include "Indicator.h"
#include "OTA.h"
#include "Console.h"

inline
void BlynkState::set(State m) {
  if (state != m && m < MODE_MAX_VALUE) {
    DEBUG_PRINT(String(StateStr[state]) + " => " + StateStr[m]);
    state = m;

    // You can put your state handling here,
    // i.e. implement custom indication
  }
}

void printDeviceBanner()
{
  Blynk.printBanner();
  DEBUG_PRINT("--------------------------");
  DEBUG_PRINT(String("Product:  ") + BLYNK_DEVICE_NAME);
  DEBUG_PRINT(String("Firmware: ") + BLYNK_FIRMWARE_VERSION " (build " __DATE__ " " __TIME__ ")");
  if (configStore.getFlag(CONFIG_FLAG_VALID)) {
    DEBUG_PRINT(String("Token:    ...") + (configStore.cloudToken+28));
  }
  DEBUG_PRINT(String("Device:   ") + BLYNK_INFO_DEVICE + " @ " + ESP.getCpuFreqMHz() + "MHz");
  DEBUG_PRINT(String("MAC:      ") + WiFi.macAddress());
  DEBUG_PRINT(String("Flash:    ") + ESP.getFlashChipRealSize() / 1024 + "K");
  String coreVer = ESP.getCoreVersion();
  coreVer.replace("_", ".");
  DEBUG_PRINT(String("ESP core: ") + coreVer);
  DEBUG_PRINT(String("ESP SDK:  ") + ESP.getSdkVersion());
  DEBUG_PRINT(String("Boot Ver: ") + ESP.getBootVersion());
  DEBUG_PRINT(String("Boot Mode:") + ESP.getBootMode());
  DEBUG_PRINT(String("FW info:  ") + ESP.getSketchSize() + "/" + ESP.getFreeSketchSpace() + ", MD5:" + ESP.getSketchMD5());
  DEBUG_PRINT(String("Free mem: ") + ESP.getFreeHeap());
  DEBUG_PRINT("--------------------------");
}

void runBlynkWithChecks() {
  Blynk.run();
  if (BlynkState::get() == MODE_RUNNING) {
    if (!Blynk.connected()) {
      if (WiFi.status() == WL_CONNECTED) {
        BlynkState::set(MODE_CONNECTING_CLOUD);
      } else {
        BlynkState::set(MODE_CONNECTING_NET);
      }
    }
  }
}

class Edgent {

public:
  void begin()
  {
    indicator_init();
    button_init();
    config_init();
    console_init();

    printDeviceBanner();

    if (configStore.getFlag(CONFIG_FLAG_VALID)) {
      BlynkState::set(MODE_CONNECTING_NET);
    } else if (config_load_blnkopt()) {
      DEBUG_PRINT("Firmware is preprovisioned");
      BlynkState::set(MODE_CONNECTING_NET);
    } else {
      BlynkState::set(MODE_WAIT_CONFIG);
    }
  }

  void run() {
    app_loop();
    switch (BlynkState::get()) {
    case MODE_WAIT_CONFIG:       
    case MODE_CONFIGURING:       enterConfigMode();    break;
    case MODE_CONNECTING_NET:    enterConnectNet();    break;
    case MODE_CONNECTING_CLOUD:  enterConnectCloud();  break;
    case MODE_RUNNING:           runBlynkWithChecks(); break;
    case MODE_OTA_UPGRADE:       enterOTA();           break;
    case MODE_SWITCH_TO_STA:     enterSwitchToSTA();   break;
    case MODE_RESET_CONFIG:      enterResetConfig();   break;
    default:                     enterError();         break;
    }
  }

};

Edgent BlynkEdgent;
BlynkTimer edgentTimer;

void app_loop() {
    edgentTimer.run();
    edgentConsole.run();
} ```

@Mahesh015 Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

Yeah Done Pete and thanks for the Info.

I’d start by reading this…

and either resolving the pin conflicts that you appear to have, or stop using the Edgent example and go back to static provisioning.

You should also read the Blynk IoT documentation for Blynk.syncAll() because it doesn’t work the same was that it did in Legacy.

But, TBH the ESP8266 based boards don’t have enough useable pins to support 8 outputs reliably, so you’d be better switching to an ESP32.

Pete.