 #define RELAY_PIN 12
 #define LED_PIN 13
 
+#define BETWEEN_RELAY_ACTIVE 5000
+
 IPAddress mqtt_server = MQTT_SERVER;
 
 char* subscribe_topic = "light/bedroomlight";
 long lastReconnectAttempt = 0;
 volatile bool bUpdated = false;
 volatile bool bRelayState = false;
+volatile bool bRelayReady = false; 
 String clientName;
+unsigned long lastRelayActionmillis;
 
 void ICACHE_RAM_ATTR callback(char* intopic, byte* inpayload, unsigned int length);
 


void loop()
{
  if (bUpdated)
  {
    change_light();
  }

  if (WiFi.status() == WL_CONNECTED)

void change_light()
{
  digitalWrite(RELAY_PIN, bRelayState);
}

void run_lightcmd_isr()
