unsigned long lastRun = 0;
int count100ms = 0;
int countSeconds = 0;

void checkMillis() {
  if ( (millis() - lastRun) > 100 ) {
    lastRun = millis();
    every100ms();
  }
}

void every100ms() {
  if (count100ms < 10) count100ms++;
  else {
    count100ms = 0;
    everySecond();
  }

  checkSaveConfigTriggered();
  relais_handleImpulseTimeout();

}

void everySecond() {
  if (countSeconds < 60) countSeconds++;
  else {
    countSeconds = 0;
    everyMinute();
  }

  checkUseDomoticz();
}

void everyMinute() {
  publishStatus();
}


void publishStatus() {
  char outMsg[60];
  long upTime = millis() / 1000;
  sprintf(outMsg, "connected, reconnects: %d, uptime: %d, free heap: %d", mqttReconnects - 1, upTime, ESP.getFreeHeap());
  mqttclient.publish(mqtt_topic_out, outMsg, mqtt_outRetain);
}

