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(); } confChangedLogNote(false); // only outputs once if false and only if config is not saved //webSocket.sendTXT(num, "Test\n"); // if(confWeb.enableConsole && webSocket.connectedClients() > 0) { // char buf[40]; // sprintf(buf, "%u\n", millis()); // webSocket.broadcastTXT(buf); // } handleDisplayTimeout(); checkValuesChanged(); if (sysInfoEverySecond) logSysdata(); #ifdef ENABLE_FEATURE_WEB_CONSOLE_WEBSOCKETS clearValidSessionId(); #endif if (countMeasureInterval < confBas.measureInterval) countMeasureInterval++; else { countMeasureInterval = 0; measureTempHum(); thermostat(); } if(heatingPause > 0) { heatingPause--; publish_heatingPauseTime(); } if(heatingLockTime > 0) { heatingLockTime--; publish_heatingLockTime(); } if (countDisplayInterval < confBas.displayInterval) countDisplayInterval++; else { countDisplayInterval = 0; updateDisplay(); } if (doRestart) restart(); if (configChangedMqttConnResetRequired && !confCheckUnsaved()) { configChangedMqttConnResetRequired = false; mqttResetConnection(); } 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() { #ifdef ENABLE_FEATURE_NTP_TIME if (confTime.ntpEnable) { syncClock(); } #endif logSysdata(); confChangedLogNote(true); 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 } } }