diff --git a/interface/src/project/DashboardDevices.tsx b/interface/src/project/DashboardDevices.tsx index 693ca740e..abbb07b18 100644 --- a/interface/src/project/DashboardDevices.tsx +++ b/interface/src/project/DashboardDevices.tsx @@ -420,33 +420,35 @@ const DashboardDevices: FC = () => { )} - - {(tableList: any) => ( - <> -
- - - {LL.DESCRIPTION()} - {LL.TYPE(0)} - -
- - {tableList.map((device: Device) => ( - - - - - - {device.n} -   ({device.e}) - - {device.tn} - - ))} - - - )} -
+ {coreData.connected && ( + + {(tableList: any) => ( + <> +
+ + + {LL.DESCRIPTION()} + {LL.TYPE(0)} + +
+ + {tableList.map((device: Device) => ( + + + + + + {device.n} +   ({device.e}) + + {device.tn} + + ))} + + + )} +
+ )} ); diff --git a/interface/src/project/Help.tsx b/interface/src/project/Help.tsx index 0392de750..52cf0e14c 100644 --- a/interface/src/project/Help.tsx +++ b/interface/src/project/Help.tsx @@ -111,7 +111,7 @@ const Help: FC = () => { {'github.com/emsesp/EMS-ESP32'} - + @proddy @MichaelDvP diff --git a/lib/framework/FSPersistence.h b/lib/framework/FSPersistence.h index 41819fc83..434ab78ee 100644 --- a/lib/framework/FSPersistence.h +++ b/lib/framework/FSPersistence.h @@ -68,7 +68,10 @@ class FSPersistence { return false; } - // serialize the data to the file +// serialize the data to the file +#ifdef EMSESP_DEBUG + Serial.println("Writing settings to " + String(_filePath)); +#endif serializeJson(jsonDocument, settingsFile); settingsFile.close(); return true; diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 30602656a..d6ff921a6 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -4226,7 +4226,7 @@ void Thermostat::register_device_values() { #if defined(EMSESP_STANDALONE_DUMP) // if we're just dumping out values, create a single dummy hc - register_device_values_hc(std::make_shared(1, this->model())); // hc=1 + register_device_values_hc(std::make_shared(1, this->model())); // hc=1 #endif } diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index c9c6bc6a5..f62fa278b 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -1755,7 +1755,7 @@ void EMSdevice::mqtt_ha_entity_config_create() { } #ifndef EMSESP_STANDALONE // always create minimum one config - if (ESP.getMaxAllocHeap() < (6 * 1024) || (!emsesp::EMSESP::system_.PSram() && ESP.getFreeHeap() < (65 * 1024))) { + if (ESP.getMaxAllocHeap() < (6 * 1024) || (!EMSESP::system_.PSram() && ESP.getFreeHeap() < (65 * 1024))) { break; } #endif diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 86b67b178..6836a751a 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1153,7 +1153,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const emsdevices.back()->unique_id(++unique_id_count_); // sort devices based on type - std::sort(emsdevices.begin(), emsdevices.end(), [](const std::unique_ptr & a, const std::unique_ptr & b) { + std::sort(emsdevices.begin(), emsdevices.end(), [](const std::unique_ptr & a, const std::unique_ptr & b) { return a->device_type() < b->device_type(); }); @@ -1394,7 +1394,7 @@ void EMSESP::scheduled_fetch_values() { EMSESP::EMSESP() #ifndef EMSESP_STANDALONE : telnet_([this](Stream & stream, const IPAddress & addr, uint16_t port) -> std::shared_ptr { - return std::make_shared(*this, stream, addr, port); + return std::make_shared(*this, stream, addr, port); }) #endif { @@ -1421,7 +1421,7 @@ void EMSESP::start() { // start the file system #ifndef EMSESP_STANDALONE if (!LittleFS.begin(true)) { - Serial.println("LittleFS Mount Failed. EMS-ESP stopped."); + Serial.println("LittleFS Mount Failed. Using default settings."); return; } #endif diff --git a/src/emsesp.h b/src/emsesp.h index e5d074460..be5ec0e2b 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -1,7 +1,7 @@ /* * EMS-ESP - https://github.com/emsesp/EMS-ESP * Copyright 2020-2023 Paul Derbyshire - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -83,11 +83,11 @@ namespace emsesp { -using DeviceValueUOM = emsesp::DeviceValue::DeviceValueUOM; -using DeviceValueType = emsesp::DeviceValue::DeviceValueType; -using DeviceValueState = emsesp::DeviceValue::DeviceValueState; -using DeviceValueTAG = emsesp::DeviceValue::DeviceValueTAG; -using DeviceValueNumOp = emsesp::DeviceValue::DeviceValueNumOp; +using DeviceValueUOM = DeviceValue::DeviceValueUOM; +using DeviceValueType = DeviceValue::DeviceValueType; +using DeviceValueState = DeviceValue::DeviceValueState; +using DeviceValueTAG = DeviceValue::DeviceValueTAG; +using DeviceValueNumOp = DeviceValue::DeviceValueNumOp; // forward declarations for compiler class EMSESPShell; diff --git a/src/main.cpp b/src/main.cpp index 0906f965a..15acb568d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ /* * EMS-ESP - https://github.com/emsesp/EMS-ESP * Copyright 2020-2023 Paul Derbyshire - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -18,7 +18,9 @@ #include "emsesp.h" -static emsesp::EMSESP application; +using namespace emsesp; + +static EMSESP application; // the main application void setup() { application.start(); diff --git a/src/system.cpp b/src/system.cpp index 552b4ad86..8323c775f 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -1111,7 +1111,7 @@ bool System::check_upgrade(bool factory_settings) { #if defined(EMSESP_DEBUG) if (!missing_version) { - LOG_INFO("Current version from settings is %d.%d.%d-%s", + LOG_INFO("Checking version (settings has %d.%d.%d-%s)...", settings_version.major(), settings_version.minor(), settings_version.patch(), @@ -1119,26 +1119,20 @@ bool System::check_upgrade(bool factory_settings) { } #endif - // always save the new version to the settings - EMSESP::webSettingsService.update( - [&](WebSettings & settings) { - settings.version = EMSESP_APP_VERSION; - return StateUpdateResult::CHANGED; - }, - "local"); - if (factory_settings) { return false; // fresh install, do nothing } version::Semver200_version this_version(EMSESP_APP_VERSION); + bool save_version = true; + // compare versions - bool reboot_required = false; if (this_version > settings_version) { + // need upgrade LOG_NOTICE("Upgrading to version %d.%d.%d-%s", this_version.major(), this_version.minor(), this_version.patch(), this_version.prerelease().c_str()); - // if we're coming from 3.4.4 or 3.5.0b14 then we need to apply new settings + // if we're coming from 3.4.4 or 3.5.0b14 which had no version stored then we need to apply new settings if (missing_version) { LOG_DEBUG("Setting MQTT Entity ID format to v3.4 format"); EMSESP::esp8266React.getMqttSettingsService()->update( @@ -1148,15 +1142,26 @@ bool System::check_upgrade(bool factory_settings) { }, "local"); } - } else if (this_version < settings_version) { + // need downgrade LOG_NOTICE("Downgrading to version %d.%d.%d-%s", this_version.major(), this_version.minor(), this_version.patch(), this_version.prerelease().c_str()); } else { // same version, do nothing - return false; + save_version = false; } - return reboot_required; + // if we did a change, set the new version and reboot + if (save_version) { + EMSESP::webSettingsService.update( + [&](WebSettings & settings) { + settings.version = EMSESP_APP_VERSION; + return StateUpdateResult::CHANGED; + }, + "local"); + return true; // need reboot + } + + return false; } // list commands