Help with status LED´s on floor heating system (Controlled by ESP8266)

Hi:)

Well - I have this code, and I want to have 4 leds, that does the following:

1: showing that the system is powered

2: showing that the wifi is connected

3 showing that Mqtt is connected

4: showing when the unit recieves and sends MQTT messages.

The system is based on this project:

https://github.com/dkjonas/Wavin-AHC-9000-mqtt.

For now I have tried to attach 2 leds - one for MQTT connection and one just for showing that the sytem is powered.

my main code looks like this:

//LED Defines

#define LED D2      // Led in NodeMCU at pin GPIO16 (D0).
#define BRIGHT 350  //max led intensity (1-500)
#define INHALE 1250 //Inhalation time in milliseconds.
#define PULSE INHALE * 1000 / BRIGHT
#define REST 1000 //Rest Between Inhalations.

void loop()
{

  digitalWrite(D5, HIGH);  // Turn on white LED to indicate that the ESP is powered.

  if (WiFi.status() != WL_CONNECTED)
  {
    WiFi.mode(WIFI_STA);
    WiFi.begin(WIFI_SSID.c_str(), WIFI_PASS.c_str());

    if (WiFi.waitForConnectResult() != WL_CONNECTED)
      return;
  }

  if (WiFi.status() == WL_CONNECTED)
  {
    if (!mqttClient.connected())
    {
      String will = String(MQTT_PREFIX + mqttDeviceNameWithMac + MQTT_ONLINE);
      if (mqttClient.connect(mqttClientWithMac.c_str(), will.c_str(), 1, true, "False"))
      {
        digitalWrite(LED, HIGH); // Turn on blue LED when MQTT is connected
        digitalWrite(D4, LOW); // Turn on blue LED when MQTT is connected

        String setpointSetTopic = String(MQTT_PREFIX + mqttDeviceNameWithMac + "/+" + MQTT_SUFFIX_SETPOINT_SET);
        mqttClient.subscribe(setpointSetTopic.c_str(), 1);

        String modeSetTopic = String(MQTT_PREFIX + mqttDeviceNameWithMac + "/+" + MQTT_SUFFIX_MODE_SET);
        mqttClient.subscribe(modeSetTopic.c_str(), 1);

        mqttClient.publish(will.c_str(), (const uint8_t *)"True", 4, true);

        // Forces resending of all parameters to server
        resetLastSentValues();
      }
      else

      // Start Breathing LED

      {
        //ramp increasing intensity, Inhalation:
        for (int i = 1; i < BRIGHT; i++)
        {
          digitalWrite(LED, LOW);            // turn the LED on.
          delayMicroseconds(i * 10);         // wait
          digitalWrite(LED, HIGH);           // turn the LED off.
          delayMicroseconds(PULSE - i * 10); // wait
          delay(0);                          //to prevent watchdog firing.
        }
        //ramp decreasing intensity, Exhalation (half time):
        for (int i = BRIGHT - 1; i > 0; i--)
        {
          digitalWrite(LED, LOW);            // turn the LED on.
          delayMicroseconds(i * 10);         // wait
          digitalWrite(LED, HIGH);           // turn the LED off.
          delayMicroseconds(PULSE - i * 10); // wait
          i--;
          delay(0); //to prevent watchdog firing.
        }
        delay(REST); //take a rest...
      }

      {
        return;
      }
    }

    // Process incomming messages and maintain connection to the server
    if (!mqttClient.loop())
    {
      return;
    }

Can you help me - I have not done any coding before:(

4: showing when the unit recieves and sends MQTT messages.

Those are discrete events that happen VERY quickly. What do you mean by "on when the unit sends and receives messages"? You can't predict when a message will arrive, so you can't turn the LED before, and off after, a message arrives. You could turn the LED of before you send, and off afterwards, but you wouldn't likely ever see that happen.

There is no reason to turn the LED connected to D5 on on every pass through loop(). The microcontroller will not turn the LED off until you tell it to, so tell it to turn the LED in setup() and forget about it.

All that crap about "breathing" is distracting from seeing where to turn other LEDs on or off.