// constexpr uint32_t RUNTIME_FAN {1000 * 60 *  5}; // milliseconds * seconds * minutes
// constexpr uint32_t IDLETIME_FAN {1000 * 60 * 55}; // milliseconds * seconds * minutes

// Demo - Auslösung 2 x pro Minute
constexpr uint32_t RUNTIME_FAN {1000 * 5}; // milliseconds * seconds * minutes
constexpr uint32_t IDLETIME_FAN {1000 * 25}; // milliseconds * seconds * minutes

enum class Status : byte {idle, start, running};

void setup() {
  Serial.begin(115200);
  Serial.println("Start...");
}

void loop() {
  static Status status {Status::idle};
  static uint32_t timeStamp {0};
  fan(status, timeStamp, millis());
}

void fan(Status &st, uint32_t &ts,uint32_t nm) { 
  switch(st) {
    case Status::idle: 
      if (nm - ts  >= IDLETIME_FAN) {
        ts = nm;
        st = Status::start;
      }
      break;
    case Status::start: 
      Serial.println("Starte Lüfter");
      // digitalWrite(PinFanRoom, HIGH);
      st = Status::running;
      break;
    case Status::running:
      if (nm - ts >= RUNTIME_FAN) {
        Serial.println("Stoppe Lüfter. Warte auf nächsten Start");
        // digitalWrite(PinFanRoom, LOW);
        ts = nm;
        st = Status::idle;
      }
      break;
  }
}