Changing the device on the Device Selector (Widget) resets all input widgets to 0

always, when I change device in device selector, all my input widgets reset to 0, but it does not change on board, only value in app

4x NODEMCU V3
android 8.0.0 miui 10.2.1.0
Blynk server
Latest Blynk Library

//#define BLYNK_PRINT Serial

//------------------PINS---------------------------![blynk|204x500](upload://zePw5O8ZH6xW6uUAYpqBSO9OvP3.png) 
#define r1 D3 //D3  COOL            Компрессор
#define r2 D4 //D4  HUM             Увлажнитель
#define r3 D5 //D5  DRY             Осушитель
#define r4 D0 //D0  cirk            Циркуляция 
#define r5 D7 //D7  recirk          Рециркуляция

#define DHTPIN D6 //D6
#define DHTTYPE DHT22
//-------------------------------------------------

//---------------------SETTINGS--------------------
#define delta 1
//-------------------------------------------------


//----------------LIBS-----------------------------
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <LCD_1602_RUS.h>
#include <DHT.h>
#include <DHT_U.h>
//-------------------------------------------------


//--------------WIFI-------------------------------
char auth[] = "**************************";

char ssid[] = "blynk";
char pass[] = "***********";

//char ssid[] = "agalatovo";
//char pass[] = "*************";

//char ssid[] = "22481";
//char pass[] = "************";
//-------------------------------------------------


//------------VARS---------------------------------

unsigned long cm = 0;
unsigned long pm_cirk = 0;
unsigned long pm_cirk_on = 0;
unsigned long pm_recirk = 0;
unsigned long pm_recirk_on = 0;

int interval_cirk = 30;
int interval_recirk = 12;
int time_cirk = 10;
int time_recirk = 15;

bool dhw = false;
int Auto = 1;
float t = 0;
float h = 0;
float wt = 13;
float wh = 75;
String st = "";

bool ledst = false;
bool cool = false;
bool dry = false;
bool hum = false;
bool cirk = false;
bool recirk = false;
//-------------------------------------------------



//--------------OBJECTS----------------------------
BlynkTimer timer;
LCD_1602_RUS lcd(0x27, 20, 4);
DHT dht(DHTPIN, DHTTYPE);
WidgetLED led1(V15);
WidgetLED led2(V1);
//-------------------------------------------------



//------------AUTOMATION---------------------------
void myTimerEvent()
{




  Serial.print(Auto);
  Serial.print("   ");
  Serial.print(wt);
  Serial.print("   ");
  Serial.println(wh);





  
  cm = millis();
  if(ledst){
  led1.on();
  }
  else{
  led1.off();
  }
  ledst = !ledst;
  //--------------ЦИРКУЛЯЦИЯ-------------------------
  if (!cirk & (cm - pm_cirk >= interval_cirk * 60000)) {
    pm_cirk_on = cm;
    cirk = true;
  }
  if (cirk & (cm - pm_cirk_on >= time_cirk * 60000)) {
    pm_cirk = cm;
    cirk = false;
  }
  //-------------------------------------------------


  //--------------РЕЦИРКУЛЯЦИЯ-----------------------
  if (!recirk & (cm - pm_recirk >= interval_recirk * 3600000)) {
    pm_recirk_on = cm;
    recirk = true;
  }
  if (recirk & (cm - pm_recirk_on >= time_recirk * 60000)) {
    pm_recirk = cm;
    recirk = false;
  }
  //-------------------------------------------------



  //-------------------------------------------------
  h = dht.readHumidity();
  t = dht.readTemperature();
  if (isnan(h) || isnan(t)) {
    dhw = false;
  }

  else {
    dhw = true;
    Blynk.virtualWrite(V3, h);
    Blynk.virtualWrite(V4, t);
  }

  //lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(L"Сост:");
  lcd.print(st);

  lcd.setCursor(0, 1);
  lcd.print(L"Темп:");
  lcd.print(t);
  if (Auto) {
    lcd.print(" -> ");
    lcd.print(wt);
  }
  else {
    lcd.print("          ");
  }

  lcd.setCursor(0, 2);
  lcd.print(L"Влаж:");
  lcd.print(h);

  if (Auto) {
    lcd.print(" -> ");
    lcd.print(wh);
  }
  else {
    lcd.print("          ");
  }

  lcd.setCursor(0, 3);
  lcd.print(L"К:");
  lcd.print(cool);
  lcd.print(L" У:");
  lcd.print(hum);
  lcd.print(L" О:");
  lcd.print(dry);
  lcd.print(L" Ц:");
  lcd.print(cirk);
  lcd.print(L" РЦ:");
  lcd.print(recirk);

  if (Auto & dhw) {
    led2.on();
    if (Blynk.connected()) st = "AUTO           ";
    else st = "OFFLINE AUTO";
    //-------------Temp---------------------------------
    if (t < (wt - delta)) {
      cool = false;    //если температура меньше чем (Т заданная - дельта), включить компрессор
    }

    if (t > (wt)) {
      cool = true;  //если температура больше чем Т заданная, выключить компрессор
    }
    //-------------------------------------------------

    //------------Hud----------------------------------
    if (h < (wh - delta)) {
      hum = true;
      dry = false;   //если влажность меньше чем (H заданная - дельта), включить увлажнитель
    }

    if (h > (wh - delta) & h < (wh + delta)) {
      hum = false;
      dry = false;
    }

    if (h > (wh + delta)) {
      hum = false;
      dry = true;    //если влажность больше чем (H заданная + дельта), включить осушитель
    }
    //-------------------------------------------------
  }
  else {
led2.off();

    if (!dhw) st = "SENS ERR       ";
    else  st = "OFF            ";


    cool = false;
    dry = false;
    hum = false;
  }
  //------------RELAY--------------------------------
  digitalWrite(r1, !cool);
  digitalWrite(r2, !hum);
  digitalWrite(r3, !dry);
  digitalWrite(r4, !cirk);
  digitalWrite(r5, !recirk);
  //-------------------------------------------------
}

//-------------------------------------------------





BLYNK_CONNECTED() {
  Blynk.syncAll();
}


BLYNK_WRITE(V5)
{
  wt = param.asFloat();
}

BLYNK_WRITE(V6)
{
  wh = param.asFloat();
}


//-------------TIMING------------------------------
BLYNK_WRITE(V8)
{
  interval_cirk = param.asInt();
}
BLYNK_WRITE(V9)
{
  time_cirk = param.asInt();
}
BLYNK_WRITE(V10)
{
  interval_recirk = param.asInt();
}
BLYNK_WRITE(V11)
{
  time_recirk = param.asInt();
}
//-------------------------------------------------



BLYNK_WRITE(V0)
{
  Auto = param.asInt();
}



void setup()
{


  //-------------------------------------------------
  pinMode(r1, OUTPUT);
  pinMode(r2, OUTPUT);
  pinMode(r3, OUTPUT);
  pinMode(r4, OUTPUT);
  pinMode(r5, OUTPUT);
  digitalWrite(r1, 1);
  digitalWrite(r2, 1);
  digitalWrite(r3, 1);
  digitalWrite(r4, 1);
  digitalWrite(r5, 1);
  pinMode(DHTPIN, INPUT);
  //-------------------------------------------------


  //---------------------INIT------------------------
  Serial.begin(9600);
  dht.begin();
  lcd.init();
  lcd.backlight();
  lcd.clear();
  timer.setInterval(1000L, myTimerEvent);
  lcd.setCursor(3, 2);
  lcd.print(L"Подключение...");
  WiFi.begin(ssid, pass);
  Blynk.config(auth);
  Blynk.connect(30);
  cm = millis();
  pm_cirk = cm;
  pm_recirk = cm;
  //-------------------------------------------------






}

void loop()
{
  Blynk.run();
  timer.run();
}

Yes, this is on purpose and a popup warning tells you it will happen :wink: This is because each board type will have differing pin amounts, numbering and support (AKA Analog, PWM) and the App needs to know what is a valid pin to use when directly controlling the pins.

If you switch to Virtual Pins, then the board type will not matter and the vPin setting will not change even if you change board type (but again it will not matter with vPins).

I use only Vpins

I think you’re talking at cross purposes here.
The message that @Gunner describes happens when you try to change the type of board assigned to a device.
@Slava_Gll is talking about the Device Selector widget.

With the Device Selector widget, you need to be using different Auth codes on each of your 4 NodeMCUs. Is that how you have it set up?
Does each device use exactly the same VPins?

Pete.

1 Like

Of course, all devices on their own auth’s, all Vpins are same

Ahhh… that word widget makes all the difference :slight_smile:

I think I now understand… but since I rarely use that widget, this is gust a guess…

It is probably supposed to change to the default 0 as the display widget hasn’t yet received a update from the server for the newly assigned device.

Now whether the act of changing such is supposed to trigger a server sync or not is a developer question.