 
 void loop()
 {
+  if ((millis() - lastRelayActionmillis) > BETWEEN_RELAY_ACTIVE)
+  {
+    bRelayReady = true;
+  }
+  else
+  {
+    bRelayReady = false;
+  }
+
   if (bUpdated)
   {
-    change_light();
+    if (bRelayReady)
+    {
+      change_light();
+      lastRelayActionmillis = millis();
+      bUpdated = false;
+    }
+    else
+    {
+      bUpdated = false;
+    }
   }
 
   if (WiFi.status() == WL_CONNECTED)

  pinMode(RELAY_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  attachInterrupt(BUTTON_PIN, run_lightcmd_isr, RISING);

  ticker.attach(0.2, tick);

  ArduinoOTA.setPassword(OTA_PASSWORD);
  ArduinoOTA.onStart([]()
  {
    ticker.attach(0.1, tick);
  });
  ArduinoOTA.onEnd([]()
  {
    ticker.attach(0.2, tick);
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total)
  {
