Alexa not discover new devices

i have a Echodot gen4 and that's work good , after some days it's not working , i'm use Nodemcu
please help me
this is my code :
(And this is your code with code tags - use them next time. It's the </> button on the menu. Thanks! Moderator.
And remove the extra blank lines too.)

#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>




#endif
#include <Espalexa.h>
// define the GPIO connected with Relays
#define RelayPin1 5//D1
#define RelayPin2 4 //D2


// prototypes
boolean connectWifi();


//callback functions
void firstLightChanged(uint8_t brightness);
void fan(uint8_t brightness);




// WiFi Credentials
const char* ssid = "Abdullah_Fibber";
const char* password = "18181818";


// device names
String Device_1_Name = "Room light";
String Device_2_Name = "fan";




boolean wifiConnected = false;


Espalexa espalexa;


void setup()
{
Serial.begin(115200);


pinMode(RelayPin1, OUTPUT);
pinMode(RelayPin2, OUTPUT);



// Initialise wifi connection
wifiConnected = connectWifi();


if (wifiConnected)
{
  // Define your devices here.
  espalexa.addDevice(Device_1_Name, firstLightChanged); //simplest definition, default state off
  espalexa.addDevice(Device_2_Name, fan); 


  espalexa.begin();
}
else
{
  while (1)
  {
    Serial.println("Cannot connect to WiFi. Please check data and reset the ESP.");
    delay(2500);
  }
}
}


void loop()
{
espalexa.loop();
delay(1);
}


//our callback functions
void firstLightChanged(uint8_t brightness)
{
//Control the device
if (brightness == 255)
  {
    digitalWrite(RelayPin1, LOW);
    Serial.println("Device1 ON");
  }
else
{
  digitalWrite(RelayPin1, HIGH);
  Serial.println("Device1 OFF");
}
}
void fan(uint8_t brightness)
{
//Control the device 
if (brightness == 255)
  {
    digitalWrite(RelayPin2, LOW);
    Serial.println("Device2 ON");
  }
else
{
  digitalWrite(RelayPin2, HIGH);
  Serial.println("Device2 OFF");
}
}




// connect to wifi – returns true if successful or false if not
boolean connectWifi()
{
boolean state = true;
int i = 0;


WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("Connecting to WiFi");


// Wait for connection
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED) {
  delay(500);
  Serial.print(".");
  if (i > 20) {
    state = false; break;
  }
  i++;
}
Serial.println("");
if (state) {
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}
else {
  Serial.println("Connection failed.");
}
return state;
}

I did not understand, explain to me again

john2030:
i have a Echodot gen4 and that's work good , after some days it's not working , i'm use Nodemcu
please help me
this is my code :
(And this is your code with code tags - use them next time. It's the </> button on the menu. Thanks! Moderator.
And remove the extra blank lines too.)

#ifdef ARDUINO_ARCH_ESP32

#include <WiFi.h>

#endif
#include <Espalexa.h>
// define the GPIO connected with Relays
#define RelayPin1 5//D1
#define RelayPin2 4 //D2

// prototypes
boolean connectWifi();

//callback functions
void firstLightChanged(uint8_t brightness);
void fan(uint8_t brightness);

// WiFi Credentials
const char* ssid = "Abdullah_Fibber";
const char* password = "18181818";

// device names
String Device_1_Name = "Room light";
String Device_2_Name = "fan";

boolean wifiConnected = false;

Espalexa espalexa;

void setup()
{
Serial.begin(115200);

pinMode(RelayPin1, OUTPUT);
pinMode(RelayPin2, OUTPUT);

// Initialise wifi connection
wifiConnected = connectWifi();

if (wifiConnected)
{
 // Define your devices here.
 espalexa.addDevice(Device_1_Name, firstLightChanged); //simplest definition, default state off
 espalexa.addDevice(Device_2_Name, fan);

espalexa.begin();
}
else
{
 while (1)
 {
   Serial.println("Cannot connect to WiFi. Please check data and reset the ESP.");
   delay(2500);
 }
}
}

void loop()
{
espalexa.loop();
delay(1);
}

//our callback functions
void firstLightChanged(uint8_t brightness)
{
//Control the device
if (brightness == 255)
 {
   digitalWrite(RelayPin1, LOW);
   Serial.println("Device1 ON");
 }
else
{
 digitalWrite(RelayPin1, HIGH);
 Serial.println("Device1 OFF");
}
}
void fan(uint8_t brightness)
{
//Control the device
if (brightness == 255)
 {
   digitalWrite(RelayPin2, LOW);
   Serial.println("Device2 ON");
 }
else
{
 digitalWrite(RelayPin2, HIGH);
 Serial.println("Device2 OFF");
}
}

// connect to wifi – returns true if successful or false if not
boolean connectWifi()
{
boolean state = true;
int i = 0;

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("Connecting to WiFi");

// Wait for connection
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED) {
 delay(500);
 Serial.print(".");
 if (i > 20) {
   state = false; break;
 }
 i++;
}
Serial.println("");
if (state) {
 Serial.print("Connected to ");
 Serial.println(ssid);
 Serial.print("IP address: ");
 Serial.println(WiFi.localIP());
}
else {
 Serial.println("Connection failed.");
}
return state;
}

what is meaning tages ??? , i don't understand !

Code tags:

@john2030, please stop cross-posting. Other threads removed.

john2030:
i have a Echodot gen4 and that's work good , after some days it's not working , i'm use Nodemcu
please help me

You appear to be connecting to your router using DHCP and maybe the lease time for the connection is expiring after a few days.
You could try adding a check for a valid WiFi connection in loop() and reconnecting if not. I have included the WiFi connect routine I use on an ESP32 below that you can maybe adapt to your needs.

bool wifiConnect(bool verbose = false)
{
  uint8_t count = 0;                                        // Initialize timout count
  
  if(verbose){Serial.print(F("Attempting WiFi connection..."));}
  
  if(WiFi.status() != WL_CONNECTED)                         // Wifi already connected?
  {
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);                             // Try to restart Wifi
    while (WiFi.status() != WL_CONNECTED)
    {
      if(verbose){Serial.print(".");}
      delay(1000);
      count++;                                              // Increment connection attempt count
      if(count > 10)
      {
        if(verbose){Serial.println(F("Failed."));}
        return false;                                       // Error exit if to long to connect
      }
    }
  }
  if(verbose){  
    Serial.println(F(" Connected."));
    Serial.print(F("IP address: "));
    Serial.println(WiFi.localIP());
  }
  return true;
}