void scheduler_checkMillis() { if ((millis() - lastMillis_100ms) >= 100) { lastMillis_100ms = millis(); scheduler_every100ms(); } if ((millis() - lastMillis_1s) >= 1000) { lastMillis_1s = millis(); scheduler_everySecond(); } if ((millis() - lastMillis_1m) >= 60000) { lastMillis_1m = millis(); scheduler_everyMinute(); } } void scheduler_every100ms() { //checkSaveConfigTriggered(); } void scheduler_everySecond() { conf_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); // } #ifdef ENABLE_LCD_I2C display_handleTimeout(); #endif #ifdef FIRMWARE_VARIANT_THERMOSTAT thermostat_checkValuesChanged(); #endif if (sysInfoEverySecond) log_sysdata(); #ifdef ENABLE_FEATURE_WSCONSOLE clearValidSessionId(); #endif if ( countMeasureInterval < confSens.measureInterval || (confSens.measureInterval == 0 && countMeasureInterval < 15) ) { // default of 15s if confSens.measureInterval was set to 0 countMeasureInterval++; } else { countMeasureInterval = 0; #ifdef ENABLE_SENSORS_ONEWIRE oneWireSensors_getData(); #endif #ifdef ENABLE_SENSOR_DHT22 if (confSens.DHT_enable) DHT_measureTempHum(); #endif #ifdef FIRMWARE_VARIANT_THERMOSTAT thermostat_mainFunction(); #endif } #ifdef FIRMWARE_VARIANT_THERMOSTAT if(thermostat_heatingPause > 0) { thermostat_heatingPause--; thermostat_publish_heatingPauseTime(); } if(thermostat_heatingLockTime > 0) { thermostat_heatingLockTime--; thermostat_publish_heatingLockTime(); } #endif // FIRMWARE_VARIANT_THERMOSTAT #ifdef ENABLE_LCD_I2C if (display_overrideInterval > 0) { if (display_countInterval < display_overrideInterval) display_countInterval++; else { display_countInterval = 0; display_overrideInterval = 0; display_update(); } } else { if (display_countInterval < confDisplay.displayInterval) display_countInterval++; else { display_countInterval = 0; display_update(); } } #endif // ENABLE_LCD_I2C if (system_doRestart) { restart(); } if(system_restartAtMillis > 0 && millis() > system_restartAtMillis) { restart(); } if (configChangedMqttConnResetRequired && !confCheckUnsaved()) { configChangedMqttConnResetRequired = false; mqttResetConnection(); } if ((millis() - system_pendingRestart_lastMillis) > 3000) { system_pendingRestart = false; } // if ( preset != pendingPreset) { // if ( (millis() - pendingPreset_millis) > pendingPreset_timeout ) { // preset = pendingPreset; // } // } #ifdef ENABLE_I2C_PORTEXPANDER portexpander_readInputs(); //portexpander_toggleOutputs(); #endif #ifdef FIRMWARE_VARIANT_HEATCONTROL heatcontrol_mainFunction(); #endif } // scheduler_everySecond() void scheduler_everyMinute() { #ifdef ENABLE_FEATURE_NTP_TIME if (confTime.ntpEnable) { syncClock(); } #endif log_sysdata(); conf_confChangedLogNote(true); if (confMqtt.mqtt_enable) { if (!confMqtt.mqtt_willRetain) { mqtt_publishConnectMsg(); } mqtt_publishStatus(); if (confMqtt.mqtt_enable_heartbeat) { mqttPublishHeartbeat(); } if (confMqtt.mqtt_outPubInterval > 0 && outPubInterval_states_count >= confMqtt.mqtt_outPubInterval) { outPubInterval_states_count = 0; #ifdef FIRMWARE_VARIANT_THERMOSTAT thermostat_publishCurrentValues(true); // true forces publishing #endif #ifdef FIRMWARE_VARIANT_HEATCONTROL heatcontrol_publish_sw_disableControl_heating(); heatcontrol_publish_sw_disableControl_pump(); heatcontrol_publish_in_heat_active(); heatcontrol_publish_in_heat_request(); heatcontrol_publish_out_heat(); heatcontrol_publish_out_pump(); heatcontrol_publish_lockTime(); heatcontrol_publish_pumpBacklash(); heatcontrol_publish_testMode(); heatcontrol_publish_heatCurve_current(); heatcontrol_publish_lockActive(); heatcontrol_pump_forceRunAfterTimeout(); #endif } else { outPubInterval_states_count++; #ifdef FIRMWARE_VARIANT_THERMOSTAT thermostat_publishCurrentValues(false); // false publishes only changed values #endif } 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 (confSens.DHT_enable) DHT_logCurrentData(); } } // scheduler_everyMinute()