void checkMillis() { if ( (millis() - lastRun) > 100 ) { lastRun = millis(); every100ms(); } } void every100ms() { if (count100ms < 10) count100ms++; else { count100ms = 0; everySecond(); } //checkSaveConfigTriggered(); } void everySecond() { if (countSeconds < 60) countSeconds++; else { countSeconds = 0; everyMinute(); } //webSocket.sendTXT(num, "Test\n"); // if(confWeb.enableConsole && webSocket.connectedClients() > 0) { // char buf[40]; // sprintf(buf, "%u\n", millis()); // webSocket.broadcastTXT(buf); // } handleDisplayTimeout(); checkValuesChanged(); clearValidSessionId(); if (countMeasureInterval < confBas.measureInterval) countMeasureInterval++; else { countMeasureInterval = 0; measureTempHum(); thermostat(); } if (countDisplayInterval < confBas.displayInterval) countDisplayInterval++; else { countDisplayInterval = 0; updateDisplay(); } if (doRestart) restart(); if ( (millis() - pendingRestart_lastMillis) > 3000 ) pendingRestart = false; // if ( preset != pendingPreset) { // if ( (millis() - pendingPreset_millis) > pendingPreset_timeout ) { // preset = pendingPreset; // } // } } unsigned int outPubInterval_states_count = 0; unsigned int outPubInterval_sensors_count = 0; void everyMinute() { updateUptime(); buildUptimeString(); if(confTime.ntpEnable) { updateTimeFromNTP(); } logSysdata(); if(confMqtt.mqtt_enable) { if(!confMqtt.mqtt_willRetain) mqttPublishConnectMsg(); mqttPublishStatus(); if(confMqtt.mqtt_enable_heartbeat) mqttPublishHeartbeat(); if(confMqtt.mqtt_outPubInterval > 0 && outPubInterval_states_count >= confMqtt.mqtt_outPubInterval) { outPubInterval_states_count = 0; publishCurrentThermostatValues(true); // true forces publishing } else { outPubInterval_states_count++; publishCurrentThermostatValues(false); // false publishes only changed values } if(confMqtt.mqtt_outPubInterval_sensors > 0 && outPubInterval_sensors_count >= confMqtt.mqtt_outPubInterval_sensors) { outPubInterval_sensors_count = 0; publishCurrentSensorValues(true); // true forces publishing } else { outPubInterval_sensors_count++; publishCurrentSensorValues(false); // false publishes only changed values } } // if(WifiInApMode) { // if( (millis() - WifiApModeStartedAt) > WIFI_AP_MODE_TIMEOUT ) { // // } // } // Serial.print("WiFi Status: "); // Serial.println(WiFi.status()); }