From cce5c0d09ee6b9e5db7e61600569a0df4fbd5dcb Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 7 Nov 2024 15:41:02 +0100 Subject: [PATCH 01/12] domoticz use "" for no-uom (https://github.com/emsesp/EMS-ESP32/issues/2177#issuecomment-2462320401) --- src/mqtt.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index a52e1d5ae..02ae3a859 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -1140,7 +1140,10 @@ void Mqtt::add_ha_uom(JsonObject doc, const uint8_t type, const uint8_t uom, con } else if (uom == DeviceValueUOM::SECONDS) { doc[uom_ha] = "s"; } else if (uom != DeviceValueUOM::NONE) { - doc[uom_ha] = EMSdevice::uom_to_string(uom); // default + // Domoticz use "" for a no-uom + if (discovery_type() == discoveryType::HOMEASSISTANT) { + doc[uom_ha] = EMSdevice::uom_to_string(uom); // default + } } } From e7334a2492f426442ed740bd6c1491850e881e4b Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 7 Nov 2024 21:28:47 +0100 Subject: [PATCH 02/12] rebuild after wwextra change to bool --- docs/Modbus-Entity-Registers.md | 12 ++++++------ docs/dump_entities.csv | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/Modbus-Entity-Registers.md b/docs/Modbus-Entity-Registers.md index c416151dd..12f04c138 100644 --- a/docs/Modbus-Entity-Registers.md +++ b/docs/Modbus-Entity-Registers.md @@ -4779,7 +4779,7 @@ | circmode | circulation pump mode | enum [off\|on\|auto\|own prog] | | true | DHW | 3 | 1 | 1 | | chargeduration | charge duration | uint8 (>=0<=3810) | minutes | true | DHW | 4 | 1 | 15 | | charge | charge | boolean | | true | DHW | 5 | 1 | 1 | -| extra | extra | uint8 (>=0<=254) | | false | DHW | 6 | 1 | 1 | +| extra | extra | boolean | | false | DHW | 6 | 1 | 1 | | disinfecting | disinfecting | boolean | | true | DHW | 7 | 1 | 1 | | disinfectday | disinfection day | enum [mo\|tu\|we\|th\|fr\|sa\|su\|all] | | true | DHW | 8 | 1 | 1 | | disinfecttime | disinfection time | uint8 (>=0<=1431) | minutes | true | DHW | 9 | 1 | 15 | @@ -4895,7 +4895,7 @@ | circmode | circulation pump mode | enum [off\|on\|auto\|own prog] | | true | DHW | 3 | 1 | 1 | | chargeduration | charge duration | uint8 (>=0<=3810) | minutes | true | DHW | 4 | 1 | 15 | | charge | charge | boolean | | true | DHW | 5 | 1 | 1 | -| extra | extra | uint8 (>=0<=254) | | false | DHW | 6 | 1 | 1 | +| extra | extra | boolean | | false | DHW | 6 | 1 | 1 | | disinfecting | disinfecting | boolean | | true | DHW | 7 | 1 | 1 | | disinfectday | disinfection day | enum [mo\|tu\|we\|th\|fr\|sa\|su\|all] | | true | DHW | 8 | 1 | 1 | | disinfecttime | disinfection time | uint8 (>=0<=1431) | minutes | true | DHW | 9 | 1 | 15 | @@ -5023,7 +5023,7 @@ | circmode | circulation pump mode | enum [off\|on\|auto\|own prog] | | true | DHW | 3 | 1 | 1 | | chargeduration | charge duration | uint8 (>=0<=3810) | minutes | true | DHW | 4 | 1 | 15 | | charge | charge | boolean | | true | DHW | 5 | 1 | 1 | -| extra | extra | uint8 (>=0<=254) | | false | DHW | 6 | 1 | 1 | +| extra | extra | boolean | | false | DHW | 6 | 1 | 1 | | disinfecting | disinfecting | boolean | | true | DHW | 7 | 1 | 1 | | disinfectday | disinfection day | enum [mo\|tu\|we\|th\|fr\|sa\|su\|all] | | true | DHW | 8 | 1 | 1 | | disinfecttime | disinfection time | uint8 (>=0<=1431) | minutes | true | DHW | 9 | 1 | 15 | @@ -5267,7 +5267,7 @@ | circmode | circulation pump mode | enum [off\|on\|auto\|own prog] | | true | DHW | 3 | 1 | 1 | | chargeduration | charge duration | uint8 (>=0<=3810) | minutes | true | DHW | 4 | 1 | 15 | | charge | charge | boolean | | true | DHW | 5 | 1 | 1 | -| extra | extra | uint8 (>=0<=254) | | false | DHW | 6 | 1 | 1 | +| extra | extra | boolean | | false | DHW | 6 | 1 | 1 | | disinfecting | disinfecting | boolean | | true | DHW | 7 | 1 | 1 | | disinfectday | disinfection day | enum [mo\|tu\|we\|th\|fr\|sa\|su\|all] | | true | DHW | 8 | 1 | 1 | | disinfecttime | disinfection time | uint8 (>=0<=1431) | minutes | true | DHW | 9 | 1 | 15 | @@ -5355,7 +5355,7 @@ | circmode | circulation pump mode | enum [off\|on\|auto\|own prog] | | true | DHW | 3 | 1 | 1 | | chargeduration | charge duration | uint8 (>=0<=3810) | minutes | true | DHW | 4 | 1 | 15 | | charge | charge | boolean | | true | DHW | 5 | 1 | 1 | -| extra | extra | uint8 (>=0<=254) | | false | DHW | 6 | 1 | 1 | +| extra | extra | boolean | | false | DHW | 6 | 1 | 1 | | disinfecting | disinfecting | boolean | | true | DHW | 7 | 1 | 1 | | disinfectday | disinfection day | enum [mo\|tu\|we\|th\|fr\|sa\|su\|all] | | true | DHW | 8 | 1 | 1 | | disinfecttime | disinfection time | uint8 (>=0<=1431) | minutes | true | DHW | 9 | 1 | 15 | @@ -5453,7 +5453,7 @@ | circmode | circulation pump mode | enum [off\|on\|auto\|own prog] | | true | DHW | 3 | 1 | 1 | | chargeduration | charge duration | uint8 (>=0<=3810) | minutes | true | DHW | 4 | 1 | 15 | | charge | charge | boolean | | true | DHW | 5 | 1 | 1 | -| extra | extra | uint8 (>=0<=254) | | false | DHW | 6 | 1 | 1 | +| extra | extra | boolean | | false | DHW | 6 | 1 | 1 | | disinfecting | disinfecting | boolean | | true | DHW | 7 | 1 | 1 | | disinfectday | disinfection day | enum [mo\|tu\|we\|th\|fr\|sa\|su\|all] | | true | DHW | 8 | 1 | 1 | | disinfecttime | disinfection time | uint8 (>=0<=1431) | minutes | true | DHW | 9 | 1 | 15 | diff --git a/docs/dump_entities.csv b/docs/dump_entities.csv index 10ec99089..89809c6f0 100644 --- a/docs/dump_entities.csv +++ b/docs/dump_entities.csv @@ -3438,7 +3438,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "UI800, BC400",thermostat,4,circmode,circulation pump mode,enum [off\|on\|auto\|own prog], ,true,select.thermostat_dhw_circulation_pump_mode,select.thermostat_dhw_circmode,6,9,1,3,1 "UI800, BC400",thermostat,4,chargeduration,charge duration,uint8 (>=0<=3810),minutes,true,number.thermostat_dhw_charge_duration,number.thermostat_dhw_chargeduration,6,9,15,4,1 "UI800, BC400",thermostat,4,charge,charge,boolean, ,true,switch.thermostat_dhw_charge,switch.thermostat_dhw_charge,6,9,1,5,1 -"UI800, BC400",thermostat,4,extra,extra,uint8 (>=0<=254), ,false,sensor.thermostat_dhw_extra,sensor.thermostat_dhw_extra,6,9,1,6,1 +"UI800, BC400",thermostat,4,extra,extra,boolean, ,false,binary_sensor.thermostat_dhw_extra,binary_sensor.thermostat_dhw_extra,6,9,1,6,1 "UI800, BC400",thermostat,4,disinfecting,disinfecting,boolean, ,true,switch.thermostat_dhw_disinfecting,switch.thermostat_dhw_disinfecting,6,9,1,7,1 "UI800, BC400",thermostat,4,disinfectday,disinfection day,enum [mo\|tu\|we\|th\|fr\|sa\|su\|all], ,true,select.thermostat_dhw_disinfection_day,select.thermostat_dhw_disinfectday,6,9,1,8,1 "UI800, BC400",thermostat,4,disinfecttime,disinfection time,uint8 (>=0<=1431),minutes,true,number.thermostat_dhw_disinfection_time,number.thermostat_dhw_disinfecttime,6,9,15,9,1 @@ -3807,7 +3807,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "RC200, CW100, CR120, CR50",thermostat,157,circmode,circulation pump mode,enum [off\|on\|auto\|own prog], ,true,select.thermostat_dhw_circulation_pump_mode,select.thermostat_dhw_circmode,6,9,1,3,1 "RC200, CW100, CR120, CR50",thermostat,157,chargeduration,charge duration,uint8 (>=0<=3810),minutes,true,number.thermostat_dhw_charge_duration,number.thermostat_dhw_chargeduration,6,9,15,4,1 "RC200, CW100, CR120, CR50",thermostat,157,charge,charge,boolean, ,true,switch.thermostat_dhw_charge,switch.thermostat_dhw_charge,6,9,1,5,1 -"RC200, CW100, CR120, CR50",thermostat,157,extra,extra,uint8 (>=0<=254), ,false,sensor.thermostat_dhw_extra,sensor.thermostat_dhw_extra,6,9,1,6,1 +"RC200, CW100, CR120, CR50",thermostat,157,extra,extra,boolean, ,false,binary_sensor.thermostat_dhw_extra,binary_sensor.thermostat_dhw_extra,6,9,1,6,1 "RC200, CW100, CR120, CR50",thermostat,157,disinfecting,disinfecting,boolean, ,true,switch.thermostat_dhw_disinfecting,switch.thermostat_dhw_disinfecting,6,9,1,7,1 "RC200, CW100, CR120, CR50",thermostat,157,disinfectday,disinfection day,enum [mo\|tu\|we\|th\|fr\|sa\|su\|all], ,true,select.thermostat_dhw_disinfection_day,select.thermostat_dhw_disinfectday,6,9,1,8,1 "RC200, CW100, CR120, CR50",thermostat,157,disinfecttime,disinfection time,uint8 (>=0<=1431),minutes,true,number.thermostat_dhw_disinfection_time,number.thermostat_dhw_disinfecttime,6,9,15,9,1 @@ -3891,7 +3891,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,circmode,circulation pump mode,enum [off\|on\|auto\|own prog], ,true,select.thermostat_dhw_circulation_pump_mode,select.thermostat_dhw_circmode,6,9,1,3,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,chargeduration,charge duration,uint8 (>=0<=3810),minutes,true,number.thermostat_dhw_charge_duration,number.thermostat_dhw_chargeduration,6,9,15,4,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,charge,charge,boolean, ,true,switch.thermostat_dhw_charge,switch.thermostat_dhw_charge,6,9,1,5,1 -"RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,extra,extra,uint8 (>=0<=254), ,false,sensor.thermostat_dhw_extra,sensor.thermostat_dhw_extra,6,9,1,6,1 +"RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,extra,extra,boolean, ,false,binary_sensor.thermostat_dhw_extra,binary_sensor.thermostat_dhw_extra,6,9,1,6,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,disinfecting,disinfecting,boolean, ,true,switch.thermostat_dhw_disinfecting,switch.thermostat_dhw_disinfecting,6,9,1,7,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,disinfectday,disinfection day,enum [mo\|tu\|we\|th\|fr\|sa\|su\|all], ,true,select.thermostat_dhw_disinfection_day,select.thermostat_dhw_disinfectday,6,9,1,8,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,disinfecttime,disinfection time,uint8 (>=0<=1431),minutes,true,number.thermostat_dhw_disinfection_time,number.thermostat_dhw_disinfecttime,6,9,15,9,1 @@ -3975,7 +3975,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "RC100, CR10, Moduline 1000/1010",thermostat,165,circmode,circulation pump mode,enum [off\|on\|auto\|own prog], ,true,select.thermostat_dhw_circulation_pump_mode,select.thermostat_dhw_circmode,6,9,1,3,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,chargeduration,charge duration,uint8 (>=0<=3810),minutes,true,number.thermostat_dhw_charge_duration,number.thermostat_dhw_chargeduration,6,9,15,4,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,charge,charge,boolean, ,true,switch.thermostat_dhw_charge,switch.thermostat_dhw_charge,6,9,1,5,1 -"RC100, CR10, Moduline 1000/1010",thermostat,165,extra,extra,uint8 (>=0<=254), ,false,sensor.thermostat_dhw_extra,sensor.thermostat_dhw_extra,6,9,1,6,1 +"RC100, CR10, Moduline 1000/1010",thermostat,165,extra,extra,boolean, ,false,binary_sensor.thermostat_dhw_extra,binary_sensor.thermostat_dhw_extra,6,9,1,6,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,disinfecting,disinfecting,boolean, ,true,switch.thermostat_dhw_disinfecting,switch.thermostat_dhw_disinfecting,6,9,1,7,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,disinfectday,disinfection day,enum [mo\|tu\|we\|th\|fr\|sa\|su\|all], ,true,select.thermostat_dhw_disinfection_day,select.thermostat_dhw_disinfectday,6,9,1,8,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,disinfecttime,disinfection time,uint8 (>=0<=1431),minutes,true,number.thermostat_dhw_disinfection_time,number.thermostat_dhw_disinfecttime,6,9,15,9,1 @@ -4060,7 +4060,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "Rego 2000/3000",thermostat,172,circmode,circulation pump mode,enum [off\|on\|auto\|own prog], ,true,select.thermostat_dhw_circulation_pump_mode,select.thermostat_dhw_circmode,6,9,1,3,1 "Rego 2000/3000",thermostat,172,chargeduration,charge duration,uint8 (>=0<=3810),minutes,true,number.thermostat_dhw_charge_duration,number.thermostat_dhw_chargeduration,6,9,15,4,1 "Rego 2000/3000",thermostat,172,charge,charge,boolean, ,true,switch.thermostat_dhw_charge,switch.thermostat_dhw_charge,6,9,1,5,1 -"Rego 2000/3000",thermostat,172,extra,extra,uint8 (>=0<=254), ,false,sensor.thermostat_dhw_extra,sensor.thermostat_dhw_extra,6,9,1,6,1 +"Rego 2000/3000",thermostat,172,extra,extra,boolean, ,false,binary_sensor.thermostat_dhw_extra,binary_sensor.thermostat_dhw_extra,6,9,1,6,1 "Rego 2000/3000",thermostat,172,disinfecting,disinfecting,boolean, ,true,switch.thermostat_dhw_disinfecting,switch.thermostat_dhw_disinfecting,6,9,1,7,1 "Rego 2000/3000",thermostat,172,disinfectday,disinfection day,enum [mo\|tu\|we\|th\|fr\|sa\|su\|all], ,true,select.thermostat_dhw_disinfection_day,select.thermostat_dhw_disinfectday,6,9,1,8,1 "Rego 2000/3000",thermostat,172,disinfecttime,disinfection time,uint8 (>=0<=1431),minutes,true,number.thermostat_dhw_disinfection_time,number.thermostat_dhw_disinfecttime,6,9,15,9,1 @@ -4171,7 +4171,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "Rego 3000, UI800, Logamatic BC400",thermostat,253,circmode,circulation pump mode,enum [off\|on\|auto\|own prog], ,true,select.thermostat_dhw_circulation_pump_mode,select.thermostat_dhw_circmode,6,9,1,3,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,chargeduration,charge duration,uint8 (>=0<=3810),minutes,true,number.thermostat_dhw_charge_duration,number.thermostat_dhw_chargeduration,6,9,15,4,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,charge,charge,boolean, ,true,switch.thermostat_dhw_charge,switch.thermostat_dhw_charge,6,9,1,5,1 -"Rego 3000, UI800, Logamatic BC400",thermostat,253,extra,extra,uint8 (>=0<=254), ,false,sensor.thermostat_dhw_extra,sensor.thermostat_dhw_extra,6,9,1,6,1 +"Rego 3000, UI800, Logamatic BC400",thermostat,253,extra,extra,boolean, ,false,binary_sensor.thermostat_dhw_extra,binary_sensor.thermostat_dhw_extra,6,9,1,6,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,disinfecting,disinfecting,boolean, ,true,switch.thermostat_dhw_disinfecting,switch.thermostat_dhw_disinfecting,6,9,1,7,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,disinfectday,disinfection day,enum [mo\|tu\|we\|th\|fr\|sa\|su\|all], ,true,select.thermostat_dhw_disinfection_day,select.thermostat_dhw_disinfectday,6,9,1,8,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,disinfecttime,disinfection time,uint8 (>=0<=1431),minutes,true,number.thermostat_dhw_disinfection_time,number.thermostat_dhw_disinfecttime,6,9,15,9,1 From fdf7ab1aa782e2084925fd9a5a78910c6f93599f Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 7 Nov 2024 21:29:14 +0100 Subject: [PATCH 03/12] rename dump functions --- src/emsdevice.cpp | 6 ++---- src/emsdevice.h | 9 ++++----- src/emsesp.cpp | 4 ++-- src/test/test.cpp | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index a1efd137e..f28fc9bb1 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -1271,7 +1271,7 @@ void EMSdevice::getCustomizationEntities(std::vector & entity_ids) // pipe symbols (|) are escaped so they can be converted to Markdown in the Wiki // format is: device name,device type,product id,shortname,fullname,type [options...] \\| (min/max),uom,writeable,discovery entityid v3.4, discovery entityid #if defined(EMSESP_STANDALONE) -void EMSdevice::dump_value_info() { +void EMSdevice::dump_devicevalue_info() { for (auto & dv : devicevalues_) { if (dv.fullname != nullptr) { Serial.print('\"'); @@ -1287,7 +1287,7 @@ void EMSdevice::dump_value_info() { Serial.print(dv.short_name); Serial.print(','); - Serial.print(dv.fullname[0]); + Serial.print(dv.fullname[0]); // TODO why german? Serial.print(','); // per type @@ -1438,8 +1438,6 @@ void EMSdevice::dump_value_info() { Serial.print(","); // modbus specific infos - - Serial.print(device_type()); Serial.print(','); diff --git a/src/emsdevice.h b/src/emsdevice.h index 62540d5c2..4f02fd76e 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -483,7 +483,7 @@ class EMSdevice { } }; void dump_telegram_info(std::vector & telegram_functions_dump); - void dump_value_info(); + void dump_devicevalue_info(); #endif private: @@ -518,14 +518,13 @@ class EMSdevice { } }; - std::vector telegram_functions_; // each EMS device has its own set of registered telegram types - std::vector handlers_ignored_; #if defined(EMSESP_STANDALONE) || defined(EMSESP_TEST) - public: // so we can call it from WebCustomizationService::test() + public: // so we can call it from WebCustomizationService::test() and EMSESP::dump_all_entities() #endif - std::vector devicevalues_; // all the device values + std::vector telegram_functions_; // each EMS device has its own set of registered telegram types + std::vector devicevalues_; // all the device values }; } // namespace emsesp diff --git a/src/emsesp.cpp b/src/emsesp.cpp index b2c826353..bae7a1b67 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -332,7 +332,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) { // Dump all entities to Serial out // this is intended to run within the OS with lots of available memory! #if defined(EMSESP_STANDALONE) -void EMSESP::dump_all_values(uuid::console::Shell & shell) { +void EMSESP::dump_all_entities(uuid::console::Shell & shell) { Serial.println("---- CSV START ----"); // marker use by py script // add header for CSV Serial.println("device name,device type,product id,shortname,fullname,type [options...] \\| (min/max),uom,writeable,discovery entityid v3.4,discovery " @@ -361,7 +361,7 @@ void EMSESP::dump_all_values(uuid::console::Shell & shell) { // for testing the mixer use ... if (device.product_id == 69) { emsdevices.push_back( EMSFactory::add(device.device_type, device_id, device.product_id, "1.0", device.default_name, device.flags, EMSdevice::Brand::NO_BRAND)); - emsdevices.back()->dump_value_info(); + emsdevices.back()->dump_devicevalue_info(); } } } diff --git a/src/test/test.cpp b/src/test/test.cpp index 03854c796..9aa17ae3e 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -442,7 +442,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const if (command == "entity_dump") { System::test_set_all_active(true); - EMSESP::dump_all_values(shell); + EMSESP::dump_all_entities(shell); ok = true; } From c2e90e271035c2b73c8a4b0b272409cc51f98e5e Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 7 Nov 2024 21:29:28 +0100 Subject: [PATCH 04/12] fix standalone language order --- src/common.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/common.h b/src/common.h index 608527620..aa49be717 100644 --- a/src/common.h +++ b/src/common.h @@ -52,18 +52,19 @@ using string_vector = std::vector; #define F_(string_name) (__pstr__##string_name) #define FL_(list_name) (__pstr__L_##list_name) +// The language settings below must match system.cpp #if defined(EMSESP_TEST) // in Test mode use two languages (en & de) to save flash memory needed for the tests -#define MAKE_WORD_TRANSLATION(list_name, en, de, ...) static const char * const __pstr__L_##list_name[] = {de, nullptr}; -#define MAKE_TRANSLATION(list_name, shortname, en, de, ...) static const char * const __pstr__L_##list_name[] = {shortname, de, nullptr}; +#define MAKE_WORD_TRANSLATION(list_name, en, de, ...) static const char * const __pstr__L_##list_name[] = {en, de, nullptr}; +#define MAKE_TRANSLATION(list_name, shortname, en, de, ...) static const char * const __pstr__L_##list_name[] = {shortname, en, de, nullptr}; #elif defined(EMSESP_EN_ONLY) // EN only #define MAKE_WORD_TRANSLATION(list_name, en, ...) static const char * const __pstr__L_##list_name[] = {en, nullptr}; #define MAKE_TRANSLATION(list_name, shortname, en, ...) static const char * const __pstr__L_##list_name[] = {shortname, en, nullptr}; #elif defined(EMSESP_DE_ONLY) // EN + DE -#define MAKE_WORD_TRANSLATION(list_name, en, de, ...) static const char * const __pstr__L_##list_name[] = {de, nullptr}; -#define MAKE_TRANSLATION(list_name, shortname, en, de, ...) static const char * const __pstr__L_##list_name[] = {shortname, de, nullptr}; +#define MAKE_WORD_TRANSLATION(list_name, en, de, ...) static const char * const __pstr__L_##list_name[] = {en, de, nullptr}; +#define MAKE_TRANSLATION(list_name, shortname, en, de, ...) static const char * const __pstr__L_##list_name[] = {shortname, en, de, nullptr}; #else #define MAKE_WORD_TRANSLATION(list_name, ...) static const char * const __pstr__L_##list_name[] = {__VA_ARGS__, nullptr}; #define MAKE_TRANSLATION(list_name, ...) static const char * const __pstr__L_##list_name[] = {__VA_ARGS__, nullptr}; From 7f5ab93644d5ddd74781775c5eeb0397c07fad20 Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 7 Nov 2024 21:29:35 +0100 Subject: [PATCH 05/12] formatting --- src/emsesp.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/emsesp.h b/src/emsesp.h index 018dae180..df418a9f5 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -124,25 +124,23 @@ class EMSESP { static void send_write_request(const uint16_t type_id, const uint8_t dest, const uint8_t offset, const uint8_t value); static void send_write_request(const uint16_t type_id, const uint8_t dest, const uint8_t offset, const uint8_t value, const uint16_t validate_typeid); - static bool device_exists(const uint8_t device_id); - static void device_active(const uint8_t device_id, const bool active); - static bool cmd_is_readonly(const uint8_t device_type, const uint8_t device_id, const char * cmd, const int8_t id); - + static bool device_exists(const uint8_t device_id); + static void device_active(const uint8_t device_id, const bool active); + static bool cmd_is_readonly(const uint8_t device_type, const uint8_t device_id, const char * cmd, const int8_t id); static uint8_t device_id_from_cmd(const uint8_t device_type, const char * cmd, const int8_t id); static uint8_t count_devices(const uint8_t device_type); static uint8_t count_devices(); static uint8_t device_index(const uint8_t device_type, const uint8_t unique_id); - - static bool get_device_value_info(JsonObject root, const char * cmd, const int8_t id, const uint8_t devicetype); + static bool get_device_value_info(JsonObject root, const char * cmd, const int8_t id, const uint8_t devicetype); static void show_device_values(uuid::console::Shell & shell); static void show_sensor_values(uuid::console::Shell & shell); - static void dump_all_values(uuid::console::Shell & shell); - static void dump_all_telegrams(uuid::console::Shell & shell); - static void show_devices(uuid::console::Shell & shell); static void show_ems(uuid::console::Shell & shell); + static void dump_all_entities(uuid::console::Shell & shell); + static void dump_all_telegrams(uuid::console::Shell & shell); + static void uart_init(); static void incoming_telegram(uint8_t * data, const uint8_t length); From 06fa5419319ef7bc03c89d96c39c1550e2690c2d Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 7 Nov 2024 21:29:57 +0100 Subject: [PATCH 06/12] add Michaels solution to uom on Domoticz --- src/mqtt.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 02ae3a859..e2c588fac 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -1140,10 +1140,10 @@ void Mqtt::add_ha_uom(JsonObject doc, const uint8_t type, const uint8_t uom, con } else if (uom == DeviceValueUOM::SECONDS) { doc[uom_ha] = "s"; } else if (uom != DeviceValueUOM::NONE) { - // Domoticz use "" for a no-uom - if (discovery_type() == discoveryType::HOMEASSISTANT) { - doc[uom_ha] = EMSdevice::uom_to_string(uom); // default - } + doc[uom_ha] = EMSdevice::uom_to_string(uom); // default + } else if (discovery_type() != discoveryType::HOMEASSISTANT) { + // Domoticz use " " for a no-uom + doc[uom_ha] = " "; } } From 7b4cd5c4d1ddc449fa9f9e8e76553bdc395f48b6 Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 7 Nov 2024 21:30:24 +0100 Subject: [PATCH 07/12] remove comment --- src/emsdevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index f28fc9bb1..70ae30a15 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -1287,7 +1287,7 @@ void EMSdevice::dump_devicevalue_info() { Serial.print(dv.short_name); Serial.print(','); - Serial.print(dv.fullname[0]); // TODO why german? + Serial.print(dv.fullname[0]); Serial.print(','); // per type From 367260b14338496a028563bcfe79c34a82869e31 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 9 Nov 2024 15:08:04 +0100 Subject: [PATCH 08/12] package update --- interface/package.json | 2 +- interface/yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/package.json b/interface/package.json index 1fa3a5d6b..a75874e78 100644 --- a/interface/package.json +++ b/interface/package.json @@ -61,7 +61,7 @@ "typescript-eslint": "8.13.0", "vite": "^5.4.10", "vite-plugin-imagemin": "^0.6.1", - "vite-tsconfig-paths": "^5.1.0" + "vite-tsconfig-paths": "^5.1.1" }, "packageManager": "yarn@4.5.1" } diff --git a/interface/yarn.lock b/interface/yarn.lock index 7bdb8f559..9c955c8b0 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -1697,7 +1697,7 @@ __metadata: typescript-eslint: "npm:8.13.0" vite: "npm:^5.4.10" vite-plugin-imagemin: "npm:^0.6.1" - vite-tsconfig-paths: "npm:^5.1.0" + vite-tsconfig-paths: "npm:^5.1.1" languageName: unknown linkType: soft @@ -6954,9 +6954,9 @@ __metadata: languageName: node linkType: hard -"vite-tsconfig-paths@npm:^5.1.0": - version: 5.1.0 - resolution: "vite-tsconfig-paths@npm:5.1.0" +"vite-tsconfig-paths@npm:^5.1.1": + version: 5.1.1 + resolution: "vite-tsconfig-paths@npm:5.1.1" dependencies: debug: "npm:^4.1.1" globrex: "npm:^0.1.2" @@ -6966,7 +6966,7 @@ __metadata: peerDependenciesMeta: vite: optional: true - checksum: 10c0/fff3fc7ada55aa4cfd6cad5c6006a8eaf74df0cc1ed5e9282c0c479012c57095d391379cb1742c394711cbb3ee591c66e27838779d8388297bdf033aa6e57719 + checksum: 10c0/7d18e2f6daa057e21885bffd3dc751f2a8fe1f249a70e4ca35b944c505d1b59d6e7c3f2278afef5139aa4cabdcb307567d3d26f2009dcccff4281c485c89a231 languageName: node linkType: hard From b00f5dd8c06d5b52974dd9bd27313d61211cea53 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 9 Nov 2024 15:08:36 +0100 Subject: [PATCH 09/12] improved version check - #2190 --- interface/src/api/endpoints.ts | 2 +- interface/src/app/settings/Version.tsx | 33 ++++++++------------- interface/vite.config.ts | 3 +- mock-api/rest_server.ts | 41 +++++++++++++++++++------- src/test/test.cpp | 26 ++++++++-------- src/web/WebStatusService.cpp | 27 +++++++++++------ 6 files changed, 76 insertions(+), 56 deletions(-) diff --git a/interface/src/api/endpoints.ts b/interface/src/api/endpoints.ts index 08f5dea0f..c0d2842e6 100644 --- a/interface/src/api/endpoints.ts +++ b/interface/src/api/endpoints.ts @@ -57,7 +57,7 @@ export const alovaInstance = createAlova({ }); export const alovaInstanceGH = createAlova({ - baseURL: 'https://api.github.com/repos/emsesp/EMS-ESP32/releases', + baseURL: process.env.NODE_ENV === 'development' ? '/gh' : 'https://api.github.com/repos/emsesp/EMS-ESP32/releases', statesHook: ReactHook, requestAdapter: xhrRequestAdapter() }); diff --git a/interface/src/app/settings/Version.tsx b/interface/src/app/settings/Version.tsx index 2855c8684..4c9b904ef 100644 --- a/interface/src/app/settings/Version.tsx +++ b/interface/src/app/settings/Version.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { toast } from 'react-toastify'; import CancelIcon from '@mui/icons-material/Cancel'; @@ -36,7 +36,7 @@ const Version = () => { const [upgradeAvailable, setUpgradeAvailable] = useState(false); const { send: sendCheckUpgrade } = useRequest( - (version: string) => callAction({ action: 'checkUpgrade', param: version }), + (versions: string) => callAction({ action: 'checkUpgrade', param: versions }), { immediate: false } @@ -54,27 +54,18 @@ const Version = () => { } ); - // called immediately to get the latest version, on page load - const { data: latestVersion } = useRequest(getStableVersion, { - // uncomment next 2 lines for testing, uses https://github.com/emsesp/EMS-ESP32/releases/download/v3.6.5/EMS-ESP-3_6_5-ESP32-16MB+.bin - // immediate: false, - // initialData: '3.6.5' - }).onSuccess((event) => { - if (!useDev) { - void sendCheckUpgrade(event.data); - } - }); + // called immediately to get the latest versions on page load + const { data: latestVersion } = useRequest(getStableVersion); + const { data: latestDevVersion } = useRequest(getDevVersion); - // called immediately to get the latest version, on page load, then check for upgrade (works for both dev and stable) - const { data: latestDevVersion } = useRequest(getDevVersion, { - // uncomment next 2 lines for testing, uses https://github.com/emsesp/EMS-ESP32/releases/download/latest/EMS-ESP-3_7_0-dev_31-ESP32-16MB+.bin - // immediate: false, - // initialData: '3.7.0-dev.32' - }).onSuccess((event) => { - if (useDev) { - void sendCheckUpgrade(event.data); + useEffect(() => { + if (latestVersion && latestDevVersion) { + console.log("Latest versions, stable: " + latestVersion + " dev: " + latestDevVersion); + sendCheckUpgrade(latestDevVersion + "," + latestVersion).catch((error: Error) => { + console.error("Failed to check upgrade:", error); + }); } - }); + }, [latestVersion, latestDevVersion]); const STABLE_URL = 'https://github.com/emsesp/EMS-ESP32/releases/download/'; const STABLE_RELNOTES_URL = diff --git a/interface/vite.config.ts b/interface/vite.config.ts index faf902d63..5198143d4 100644 --- a/interface/vite.config.ts +++ b/interface/vite.config.ts @@ -20,7 +20,8 @@ export default defineConfig(({ command, mode }) => { changeOrigin: true, secure: false }, - '/rest': 'http://localhost:3080' + '/rest': 'http://localhost:3080', + '/gh': 'http://localhost:3080' // mock for GitHub API } } }; diff --git a/mock-api/rest_server.ts b/mock-api/rest_server.ts index 9b209bba6..c27ffb40e 100644 --- a/mock-api/rest_server.ts +++ b/mock-api/rest_server.ts @@ -21,6 +21,7 @@ const router = AutoRouter({ const REST_ENDPOINT_ROOT = '/rest/'; const API_ENDPOINT_ROOT = '/api/'; +const GH_ENDPOINT_ROOT = '/gh/'; // for mock GitHub API for version checking // HTTP HEADERS for msgpack const headers = { @@ -28,6 +29,13 @@ const headers = { 'Content-type': 'application/msgpack' }; +// Versions - all without the 'v' +const THIS_VERSION = '3.7.0'; +// const THIS_VERSION = '3.6.4'; // for testing +const LATEST_STABLE_VERSION = '3.7.0'; +const LATEST_DEV_VERSION = '3.7.1-dev.4'; +const VERSION_IS_UPGRADEABLE = true; + // GLOBAL VARIABLES let countWifiScanPoll = 0; // wifi network scan let countHardwarePoll = 0; // for during an upload @@ -199,16 +207,18 @@ function custom_support() { function check_upgrade(version: string) { let data = {}; if (version) { - console.log('check upgrade from version', version); + const dev_version = version.split(',')[0]; + const stable_version = version.split(',')[1]; + console.log("latest dev version: " + dev_version + ", latest stable version: " + stable_version); + console.log('Version upgrade check from version ' + THIS_VERSION + ', upgradable: ' + VERSION_IS_UPGRADEABLE); data = { - emsesp_version: VERSION, - // upgradeable: true - upgradeable: false + emsesp_version: THIS_VERSION, + upgradeable: VERSION_IS_UPGRADEABLE }; } else { - console.log('requesting ems-esp version'); + console.log('requesting ems-esp version ('+THIS_VERSION+')'); data = { - emsesp_version: VERSION + emsesp_version: THIS_VERSION }; } return data; @@ -468,11 +478,8 @@ const VERIFY_AUTHORIZATION_ENDPOINT = REST_ENDPOINT_ROOT + 'verifyAuthorization' const SIGN_IN_ENDPOINT = REST_ENDPOINT_ROOT + 'signIn'; const GENERATE_TOKEN_ENDPOINT = REST_ENDPOINT_ROOT + 'generateToken'; -const VERSION = '3.7.0'; -// const VERSION = '3.6.4'; - let system_status = { - emsesp_version: VERSION, + emsesp_version: THIS_VERSION, bus_status: 0, // status: 2, uptime: 77186, @@ -573,7 +580,7 @@ const EMSESP_SYSTEM_INFO_ENDPOINT = API_ENDPOINT_ROOT + 'system/info'; const emsesp_info = { System: { - version: VERSION, + version: THIS_VERSION, uptime: '001+06:40:34.018', 'uptime (seconds)': 110434, freemem: 131, @@ -4878,6 +4885,18 @@ router return status(404); // not found }); +// Mock GitHub API + +router + .get(GH_ENDPOINT_ROOT + '/tags/latest', () => { + console.log('returning latest development version: ' + LATEST_DEV_VERSION); + return { name: 'v'+LATEST_DEV_VERSION }; + }) + .get(GH_ENDPOINT_ROOT + '/latest', () => { + console.log('returning latest stable version: ' + LATEST_STABLE_VERSION); + return { name: 'v'+LATEST_STABLE_VERSION }; + }); + export default router; // use this with cloudflare workers instead diff --git a/src/test/test.cpp b/src/test/test.cpp index 9aa17ae3e..05a3f791b 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -1014,22 +1014,22 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const // request.url("/api"); // EMSESP::webAPIService.webAPIService(&request, doc.as()); - char data2[] = "{\"action\":\"customSupport\", \"param\":\"hello\"}"; - deserializeJson(doc, data2); - request.url("/rest/action"); - EMSESP::webStatusService.action(&request, doc.as()); + // char data2[] = "{\"action\":\"customSupport\", \"param\":\"hello\"}"; + // deserializeJson(doc, data2); + // request.url("/rest/action"); + // EMSESP::webStatusService.action(&request, doc.as()); - char data3[] = "{\"action\":\"export\", \"param\":\"schedule\"}"; - deserializeJson(doc, data3); - request.url("/rest/action"); - EMSESP::webStatusService.action(&request, doc.as()); + // char data3[] = "{\"action\":\"export\", \"param\":\"schedule\"}"; + // deserializeJson(doc, data3); + // request.url("/rest/action"); + // EMSESP::webStatusService.action(&request, doc.as()); - char data4[] = "{\"action\":\"export\", \"param\":\"allvalues\"}"; - deserializeJson(doc, data4); - request.url("/rest/action"); - EMSESP::webStatusService.action(&request, doc.as()); + // char data4[] = "{\"action\":\"export\", \"param\":\"allvalues\"}"; + // deserializeJson(doc, data4); + // request.url("/rest/action"); + // EMSESP::webStatusService.action(&request, doc.as()); - char data5[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.0-dev.99\"}"; + char data5[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.99,3.7.0\"}"; deserializeJson(doc, data5); request.url("/rest/action"); EMSESP::webStatusService.action(&request, doc.as()); diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index 4c15f0227..85999d688 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -203,18 +203,27 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json) } // action = checkUpgrade -bool WebStatusService::checkUpgrade(JsonObject root, std::string & latest_version) { - root["emsesp_version"] = EMSESP_APP_VERSION; +bool WebStatusService::checkUpgrade(JsonObject root, std::string & versions) { + root["emsesp_version"] = EMSESP_APP_VERSION; // always send back current version + + // versions holds the latest development version and stable version in one string, comma separated + std::string latest_dev_version = versions.substr(0, versions.find(',')); + std::string latest_stable_version = versions.substr(versions.find(',') + 1); + + if (!versions.empty()) { + version::Semver200_version this_version(EMSESP_APP_VERSION); // current version + bool using_dev_version = !this_version.prerelease().empty(); + version::Semver200_version latest_version(using_dev_version ? latest_dev_version : latest_stable_version); // latest version + + root["upgradeable"] = (latest_version > this_version); - if (!latest_version.empty()) { #if defined(EMSESP_DEBUG) - emsesp::EMSESP::logger().debug("Checking for upgrade: %s < %s", EMSESP_APP_VERSION, latest_version.c_str()); + emsesp::EMSESP::logger().debug("Checking for version upgrade. This version=%s, latest dev=%s, latest stable=%s. Upgradeable=%s", + EMSESP_APP_VERSION, + latest_dev_version.c_str(), + latest_stable_version.c_str(), + root["upgradeable"].as() ? "true" : "false"); #endif - - version::Semver200_version settings_version(EMSESP_APP_VERSION); - version::Semver200_version this_version(latest_version); - - root["upgradeable"] = (this_version > settings_version); } return true; // always ok From 0927a2b44b0c486f3d82a15763ff70a0c38c85e4 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 9 Nov 2024 15:55:26 +0100 Subject: [PATCH 10/12] update tests --- src/test/test.cpp | 7 +++++++ src/test/test.h | 2 +- src/web/WebStatusService.cpp | 30 ++++++++++++++++++++---------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/test/test.cpp b/src/test/test.cpp index 05a3f791b..a79d9bee8 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -1029,11 +1029,18 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const // request.url("/rest/action"); // EMSESP::webStatusService.action(&request, doc.as()); + // should show dev version and be updatable char data5[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.99,3.7.0\"}"; deserializeJson(doc, data5); request.url("/rest/action"); EMSESP::webStatusService.action(&request, doc.as()); + // should show dev version and not be updatable + char data6[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.4,3.7.0\"}"; + deserializeJson(doc, data6); + request.url("/rest/action"); + EMSESP::webStatusService.action(&request, doc.as()); + // char data6[] = "{\"device\":\"system\", \"cmd\":\"read\",\"value\":\"8 2 27 1\"}"; // deserializeJson(doc, data6); // json = doc.as(); diff --git a/src/test/test.h b/src/test/test.h index e2c6fd94e..e979985b7 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -41,7 +41,7 @@ namespace emsesp { // #define EMSESP_DEBUG_DEFAULT "310" // #define EMSESP_DEBUG_DEFAULT "render" // #define EMSESP_DEBUG_DEFAULT "api" -// #define EMSESP_DEBUG_DEFAULT "api3" +#define EMSESP_DEBUG_DEFAULT "api3" // #define EMSESP_DEBUG_DEFAULT "crash" // #define EMSESP_DEBUG_DEFAULT "dv" // #define EMSESP_DEBUG_DEFAULT "lastcode" diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index 85999d688..5309a423c 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -204,29 +204,39 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json) // action = checkUpgrade bool WebStatusService::checkUpgrade(JsonObject root, std::string & versions) { - root["emsesp_version"] = EMSESP_APP_VERSION; // always send back current version - - // versions holds the latest development version and stable version in one string, comma separated - std::string latest_dev_version = versions.substr(0, versions.find(',')); - std::string latest_stable_version = versions.substr(versions.find(',') + 1); + std::string current_version; +#ifndef EMSESP_STANDALONE + current_version = EMSESP_APP_VERSION; // always send back current version +#else + // for testing only + // current_version = "3.6.5"; + current_version = "3.7.0-dev-7"; +#endif if (!versions.empty()) { - version::Semver200_version this_version(EMSESP_APP_VERSION); // current version - bool using_dev_version = !this_version.prerelease().empty(); + // versions holds the latest development version and stable version in one string, comma separated + std::string latest_dev_version = versions.substr(0, versions.find(',')); + std::string latest_stable_version = versions.substr(versions.find(',') + 1); + + version::Semver200_version this_version(current_version); + bool using_dev_version = !this_version.prerelease().find("dev"); version::Semver200_version latest_version(using_dev_version ? latest_dev_version : latest_stable_version); // latest version root["upgradeable"] = (latest_version > this_version); #if defined(EMSESP_DEBUG) - emsesp::EMSESP::logger().debug("Checking for version upgrade. This version=%s, latest dev=%s, latest stable=%s. Upgradeable=%s", - EMSESP_APP_VERSION, + emsesp::EMSESP::logger().debug("Checking for version upgrade. This version=%s, latest dev=%s, latest stable=%s. Using %s releases. Upgradeable=%s", + current_version.c_str(), latest_dev_version.c_str(), latest_stable_version.c_str(), + using_dev_version ? "dev" : "stable", root["upgradeable"].as() ? "true" : "false"); #endif } - return true; // always ok + root["emsesp_version"] = current_version; + + return true; } // action = allvalues From 00beb2a03971577c17c7ac35968137e5f8aec928 Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 10 Nov 2024 00:37:14 +0100 Subject: [PATCH 11/12] updates to firmware check UI --- interface/src/app/settings/Settings.tsx | 4 +- interface/src/app/settings/Version.tsx | 55 +++++++++++++++++-------- interface/src/i18n/cz/index.ts | 1 - interface/src/i18n/de/index.ts | 1 - interface/src/i18n/en/index.ts | 1 - interface/src/i18n/fr/index.ts | 1 - interface/src/i18n/it/index.ts | 1 - interface/src/i18n/nl/index.ts | 1 - interface/src/i18n/no/index.ts | 1 - interface/src/i18n/pl/index.ts | 1 - interface/src/i18n/sk/index.ts | 1 - interface/src/i18n/sv/index.ts | 1 - interface/src/i18n/tr/index.ts | 1 - mock-api/rest_server.ts | 13 +++--- 14 files changed, 47 insertions(+), 36 deletions(-) diff --git a/interface/src/app/settings/Settings.tsx b/interface/src/app/settings/Settings.tsx index 57c902489..acf630053 100644 --- a/interface/src/app/settings/Settings.tsx +++ b/interface/src/app/settings/Settings.tsx @@ -86,8 +86,8 @@ const Settings = () => { diff --git a/interface/src/app/settings/Version.tsx b/interface/src/app/settings/Version.tsx index 4c9b904ef..d86ba43c5 100644 --- a/interface/src/app/settings/Version.tsx +++ b/interface/src/app/settings/Version.tsx @@ -60,10 +60,12 @@ const Version = () => { useEffect(() => { if (latestVersion && latestDevVersion) { - console.log("Latest versions, stable: " + latestVersion + " dev: " + latestDevVersion); - sendCheckUpgrade(latestDevVersion + "," + latestVersion).catch((error: Error) => { - console.error("Failed to check upgrade:", error); - }); + // console.log("Latest versions, stable: " + latestVersion + " dev: " + latestDevVersion); + sendCheckUpgrade(latestDevVersion + ',' + latestVersion).catch( + (error: Error) => { + toast.error('Failed to check upgrade: ' + error.message); + } + ); } }, [latestVersion, latestDevVersion]); @@ -104,7 +106,7 @@ const Version = () => { setRestarting(true); }; - useLayoutTitle(LL.EMS_ESP_VER()); + useLayoutTitle('EMS-ESP Firmware'); const internet_live = latestDevVersion !== undefined && latestVersion !== undefined; @@ -191,8 +193,18 @@ const Version = () => { Platform - Release + Release Type + {internet_live && ( + <> + + Latest Stable Release + + + Latest Development Release + + + )} @@ -213,24 +225,31 @@ const Version = () => { > (changelog) + {!isDev && internet_live && ( + + )} + {internet_live && ( + <> + {latestVersion} + + {latestDevVersion} + + + )} - {!isDev && ( - - )} -    diff --git a/interface/src/i18n/cz/index.ts b/interface/src/i18n/cz/index.ts index 6b9d0a32c..8d93d0187 100644 --- a/interface/src/i18n/cz/index.ts +++ b/interface/src/i18n/cz/index.ts @@ -177,7 +177,6 @@ const cz: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Opravdu chcete resetovat zařízení EMS-ESP do továrního nastavení?', STABLE: 'Stabilní', DEVELOPMENT: 'Vývojová verze', - EMS_ESP_VER: 'Verze firmwaru', UPTIME: 'Doba provozu systému', FREE_MEMORY: 'Volná paměť', PSRAM: 'PSRAM (Velikost / Volná)', diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index e53e92cdc..476ebf097 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -177,7 +177,6 @@ const de: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Sind Sie sicher, alle Einstellungen auf Werkseinstellung zu setzen?', STABLE: 'Stabil', DEVELOPMENT: 'Entwicklung', - EMS_ESP_VER: 'Firmware-Version', UPTIME: 'Systembetriebszeit', FREE_MEMORY: 'Freier RAM Speicher', PSRAM: 'PSRAM (Größe / Frei)', diff --git a/interface/src/i18n/en/index.ts b/interface/src/i18n/en/index.ts index 0ad95342f..40c14a2e4 100644 --- a/interface/src/i18n/en/index.ts +++ b/interface/src/i18n/en/index.ts @@ -177,7 +177,6 @@ const en: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Are you sure you want to reset EMS-ESP to its factory defaults?', STABLE: 'Stable', DEVELOPMENT: 'Development', - EMS_ESP_VER: 'Firmware Version', UPTIME: 'System Uptime', FREE_MEMORY: 'Free Memory', PSRAM: 'PSRAM (Size / Free)', diff --git a/interface/src/i18n/fr/index.ts b/interface/src/i18n/fr/index.ts index 759bd9ef4..4672a094c 100644 --- a/interface/src/i18n/fr/index.ts +++ b/interface/src/i18n/fr/index.ts @@ -177,7 +177,6 @@ const fr: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: "Êtes-vous sûr de vouloir réinitialiser l'appareil à ses paramètres d'usine ?", STABLE: 'Stable', // TODO translate DEVELOPMENT: 'Développement', - EMS_ESP_VER: 'Firmware Version', // TODO translate UPTIME: 'Durée de fonctionnement du système', FREE_MEMORY: 'Libre Memory', PSRAM: 'PSRAM (Taille / Libre)', diff --git a/interface/src/i18n/it/index.ts b/interface/src/i18n/it/index.ts index e27340b09..8813d9dd3 100644 --- a/interface/src/i18n/it/index.ts +++ b/interface/src/i18n/it/index.ts @@ -177,7 +177,6 @@ const it: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Sei sicuro di voler ripristinare il dispositivo alle impostazioni di fabbrica??', STABLE: 'Stable', // TODO translate DEVELOPMENT: 'Sviluppo', - EMS_ESP_VER: 'Versione Firmware', UPTIME: 'Tempo di attività del sistema', FREE_MEMORY: 'Free Memory', PSRAM: 'PSRAM (Size / Free)', diff --git a/interface/src/i18n/nl/index.ts b/interface/src/i18n/nl/index.ts index 9b5851139..8f9de0884 100644 --- a/interface/src/i18n/nl/index.ts +++ b/interface/src/i18n/nl/index.ts @@ -177,7 +177,6 @@ const nl: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Weet je zeker dat je een reset naar fabrieksinstellingen uit wilt voeren?', STABLE: 'Stable', DEVELOPMENT: 'Development', - EMS_ESP_VER: 'Firmware Versie', UPTIME: 'Systeem Uptime', FREE_MEMORY: 'Free Memory', PSRAM: 'PSRAM (Size / Free)', diff --git a/interface/src/i18n/no/index.ts b/interface/src/i18n/no/index.ts index 048cb75f3..2b573c7e6 100644 --- a/interface/src/i18n/no/index.ts +++ b/interface/src/i18n/no/index.ts @@ -177,7 +177,6 @@ const no: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Er du sikker på at du vil resette enheten til fabrikkinstillinger?', STABLE: 'Stable', // TODO translate DEVELOPMENT: 'Development', - EMS_ESP_VER: 'Firmware Version', // TODO translate UPTIME: 'System Oppetid', FREE_MEMORY: 'Ledig Memory', PSRAM: 'PSRAM (Størrelse / Ledig)', diff --git a/interface/src/i18n/pl/index.ts b/interface/src/i18n/pl/index.ts index 216dc58ea..99eaf709d 100644 --- a/interface/src/i18n/pl/index.ts +++ b/interface/src/i18n/pl/index.ts @@ -177,7 +177,6 @@ const pl: BaseTranslation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Na pewno chcesz przywrócić ustawienia fabryczne interfejsu EMS-ESP?', STABLE: 'Stable', // TODO translate DEVELOPMENT: 'Testowe', - EMS_ESP_VER: 'Wersja Firmware', UPTIME: 'Czas działania systemu', FREE_MEMORY: 'Wolne Memory', PSRAM: 'PSRAM (rozmiar / wolne)', diff --git a/interface/src/i18n/sk/index.ts b/interface/src/i18n/sk/index.ts index 07e88a183..77093b5e4 100644 --- a/interface/src/i18n/sk/index.ts +++ b/interface/src/i18n/sk/index.ts @@ -177,7 +177,6 @@ const sk: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Naozaj chcete resetovať EMS-ESP na predvolené výrobné nastavenia?', STABLE: 'Stabilná', DEVELOPMENT: 'Vývojárska', - EMS_ESP_VER: 'Firmware verzia', UPTIME: 'Beh systému', FREE_MEMORY: 'Voľné Memory', PSRAM: 'PSRAM (Veľkosť / Voľné)', diff --git a/interface/src/i18n/sv/index.ts b/interface/src/i18n/sv/index.ts index 2dccd1c21..ad593e1a9 100644 --- a/interface/src/i18n/sv/index.ts +++ b/interface/src/i18n/sv/index.ts @@ -177,7 +177,6 @@ const sv: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Är du säker att du vill fabriksåterställa enheten?', STABLE: 'Stable', // TODO translate DEVELOPMENT: 'Utveckling', - EMS_ESP_VER: 'Firmware Version', // TODO translate UPTIME: 'Systemets Upptid', FREE_MEMORY: 'Ledigt Memory', PSRAM: 'PSRAM (Storlek / Ledigt)', diff --git a/interface/src/i18n/tr/index.ts b/interface/src/i18n/tr/index.ts index 7f84a6fa4..a21f735fd 100644 --- a/interface/src/i18n/tr/index.ts +++ b/interface/src/i18n/tr/index.ts @@ -177,7 +177,6 @@ const tr: Translation = { SYSTEM_FACTORY_TEXT_DIALOG: 'Cihazı fabrika ayarlarına döndürmek istediğinize emin misiniz?', STABLE: 'Stable', // TODO translate DEVELOPMENT: 'Geliştirme', - EMS_ESP_VER: 'Firmware Sürümü', UPTIME: 'Sistem Çalışma Süresi', FREE_MEMORY: 'Yığın Memory', PSRAM: 'PSRAM (Boyut / Boş)', diff --git a/mock-api/rest_server.ts b/mock-api/rest_server.ts index c27ffb40e..bfa115189 100644 --- a/mock-api/rest_server.ts +++ b/mock-api/rest_server.ts @@ -30,11 +30,14 @@ const headers = { }; // Versions - all without the 'v' -const THIS_VERSION = '3.7.0'; -// const THIS_VERSION = '3.6.4'; // for testing -const LATEST_STABLE_VERSION = '3.7.0'; -const LATEST_DEV_VERSION = '3.7.1-dev.4'; -const VERSION_IS_UPGRADEABLE = true; +let THIS_VERSION = '3.7.0'; +let LATEST_STABLE_VERSION = '3.7.0'; +let LATEST_DEV_VERSION = '3.7.1-dev.4'; +let VERSION_IS_UPGRADEABLE = false; + +// for testing +// THIS_VERSION = '3.6.5'; +// VERSION_IS_UPGRADEABLE = true; // GLOBAL VARIABLES let countWifiScanPoll = 0; // wifi network scan From 6b3cb00917f3299d6aa88e0c917bf88247d5ec56 Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 10 Nov 2024 16:52:39 +0100 Subject: [PATCH 12/12] #2190 --- interface/src/api/endpoints.ts | 5 +- interface/src/app/settings/Settings.tsx | 2 +- interface/src/app/settings/Version.tsx | 213 ++++++++++-------- .../src/app/settings/security/ManageUsers.tsx | 2 +- interface/src/i18n/cz/index.ts | 2 +- interface/src/i18n/de/index.ts | 2 +- interface/src/i18n/en/index.ts | 2 +- interface/src/i18n/fr/index.ts | 2 +- interface/src/i18n/it/index.ts | 2 +- interface/src/i18n/nl/index.ts | 2 +- interface/src/i18n/no/index.ts | 2 +- interface/src/i18n/pl/index.ts | 2 +- interface/src/i18n/sk/index.ts | 2 +- interface/src/i18n/sv/index.ts | 2 +- interface/src/i18n/tr/index.ts | 2 +- mock-api/rest_server.ts | 6 +- src/test/test.cpp | 20 +- src/version.h | 2 +- src/web/WebStatusService.cpp | 46 ++-- 19 files changed, 182 insertions(+), 136 deletions(-) diff --git a/interface/src/api/endpoints.ts b/interface/src/api/endpoints.ts index c0d2842e6..cbc0a4bca 100644 --- a/interface/src/api/endpoints.ts +++ b/interface/src/api/endpoints.ts @@ -57,7 +57,10 @@ export const alovaInstance = createAlova({ }); export const alovaInstanceGH = createAlova({ - baseURL: process.env.NODE_ENV === 'development' ? '/gh' : 'https://api.github.com/repos/emsesp/EMS-ESP32/releases', + baseURL: + process.env.NODE_ENV === 'development' + ? '/gh' + : 'https://api.github.com/repos/emsesp/EMS-ESP32/releases', statesHook: ReactHook, requestAdapter: xhrRequestAdapter() }); diff --git a/interface/src/app/settings/Settings.tsx b/interface/src/app/settings/Settings.tsx index acf630053..7aba45df7 100644 --- a/interface/src/app/settings/Settings.tsx +++ b/interface/src/app/settings/Settings.tsx @@ -87,7 +87,7 @@ const Settings = () => { icon={BuildIcon} bgcolor="#72caf9" label="EMS-ESP Firmware" - text={'v'+data.emsesp_version} + text={'v' + data.emsesp_version} to="version" /> diff --git a/interface/src/app/settings/Version.tsx b/interface/src/app/settings/Version.tsx index d86ba43c5..94332f96a 100644 --- a/interface/src/app/settings/Version.tsx +++ b/interface/src/app/settings/Version.tsx @@ -2,6 +2,8 @@ import { useEffect, useState } from 'react'; import { toast } from 'react-toastify'; import CancelIcon from '@mui/icons-material/Cancel'; +import CheckIcon from '@mui/icons-material/Done'; +import DownloadIcon from '@mui/icons-material/GetApp'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import WarningIcon from '@mui/icons-material/Warning'; import { @@ -11,7 +13,6 @@ import { DialogActions, DialogContent, DialogTitle, - Divider, Link, Typography } from '@mui/material'; @@ -108,9 +109,13 @@ const Version = () => { useLayoutTitle('EMS-ESP Firmware'); + // see if we have internet access const internet_live = latestDevVersion !== undefined && latestVersion !== undefined; + // check for older boards where auto-upgrade is not supported + const download_only = data && !data.psram; + const renderUploadDialog = () => { if (!internet_live) { return null; @@ -123,26 +128,15 @@ const Version = () => { onClose={() => setOpenDialog(false)} > - {LL.INSTALL('') + - ' ' + - (useDev ? LL.DEVELOPMENT() : LL.STABLE()) + - ' Firmware'} + {(download_only ? LL.DOWNLOAD(0) : LL.INSTALL('')) + ' ' + ' Firmware'} - {LL.INSTALL_VERSION(useDev ? latestDevVersion : latestVersion)} + {LL.INSTALL_VERSION( + download_only ? LL.DOWNLOAD(1) : LL.INSTALL(''), + useDev ? latestDevVersion : latestVersion + )} - - changelog - -  |  - - {LL.DOWNLOAD(1)} - + {!download_only && ( + + )} ); }; - // useDevVersion = true to force using the dev version const showFirmwareDialog = (useDevVersion: boolean) => { if (useDevVersion || data.emsesp_version.includes('dev')) { setUseDev(true); @@ -184,29 +189,23 @@ const Version = () => { return ( <> - + + Firmware Version + + + - + {LL.VERSION()} - + Platform - + Release Type - {internet_live && ( - <> - - Latest Stable Release - - - Latest Development Release - - - )} - + {data.emsesp_version} {data.build_flags && ( @@ -216,69 +215,101 @@ const Version = () => { )} {getPlatform()} - - {isDev ? LL.DEVELOPMENT() : LL.STABLE()}  - - (changelog) - + + {isDev ? LL.DEVELOPMENT() : LL.STABLE()} {!isDev && internet_live && ( - + + + )} - {internet_live && ( - <> - {latestVersion} - - {latestDevVersion} - - - )} - - - - -    - {upgradeAvailable ? LL.UPGRADE_AVAILABLE() : LL.LATEST_VERSION()} - {upgradeAvailable && - internet_live && - (data.psram ? ( - - ) : ( - <> -    - - {LL.DOWNLOAD(1)} v - {isDev ? latestDevVersion : latestVersion} - - - ))} + + Latest Available Versions + {internet_live ? ( + <> + + + + Stable Release + + + Development Release + + + + + {latestVersion}   + + (changelog) + + {!isDev && upgradeAvailable && ( + + )} + + + {latestDevVersion}   + + (changelog) + + {isDev && upgradeAvailable && ( + + )} + + + + {upgradeAvailable ? ( + + + {LL.UPGRADE_AVAILABLE()} + + ) : ( + + + {LL.LATEST_VERSION()} + + )} + + ) : ( + + not online + + )} + {renderUploadDialog()} diff --git a/interface/src/app/settings/security/ManageUsers.tsx b/interface/src/app/settings/security/ManageUsers.tsx index affcf6496..758882869 100644 --- a/interface/src/app/settings/security/ManageUsers.tsx +++ b/interface/src/app/settings/security/ManageUsers.tsx @@ -2,9 +2,9 @@ import { useContext, useState } from 'react'; import { useBlocker } from 'react-router-dom'; import CancelIcon from '@mui/icons-material/Cancel'; -import CheckIcon from '@mui/icons-material/Check'; import CloseIcon from '@mui/icons-material/Close'; import DeleteIcon from '@mui/icons-material/Delete'; +import CheckIcon from '@mui/icons-material/Done'; import EditIcon from '@mui/icons-material/Edit'; import PersonAddIcon from '@mui/icons-material/PersonAdd'; import VpnKeyIcon from '@mui/icons-material/VpnKey'; diff --git a/interface/src/i18n/cz/index.ts b/interface/src/i18n/cz/index.ts index 8d93d0187..e8935fa62 100644 --- a/interface/src/i18n/cz/index.ts +++ b/interface/src/i18n/cz/index.ts @@ -331,7 +331,7 @@ const cz: Translation = { ALLVALUES: 'Všechny hodnoty', SPECIAL_FUNCTIONS: 'Speciální funkce', WAIT_FIRMWARE: 'Firmware se nahrává a instaluje', - INSTALL_VERSION: 'Tímto se nainstaluje verze {0}. Jste si jistí?', + INSTALL_VERSION: 'Tímto se {0} verze {1}. Jste si jistí?', SWITCH_DEV: 'přepnout na vývojovou verzi', UPGRADE_AVAILABLE: 'Je k dispozici aktualizace firmwaru!', LATEST_VERSION: 'Používáte nejnovější verzi firmwaru.', diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index 476ebf097..a1a384452 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -331,7 +331,7 @@ const de: Translation = { ALLVALUES: 'Alle Werte', SPECIAL_FUNCTIONS: 'Sonderfunktionen', WAIT_FIRMWARE: 'Die Firmware wird hochgeladen und installiert.', - INSTALL_VERSION: 'Dadurch wird die Version installiert {0}. Sind Sie sicher?', + INSTALL_VERSION: 'Dadurch wird die Version {0} {1}. Sind Sie sicher?', SWITCH_DEV: 'Wechseln Sie zur Entwicklungsversion!', UPGRADE_AVAILABLE: 'Es ist ein Firmware-Upgrade verfügbar.', LATEST_VERSION: 'Sie verwenden die neueste Firmware-Version.', diff --git a/interface/src/i18n/en/index.ts b/interface/src/i18n/en/index.ts index 40c14a2e4..e52b31977 100644 --- a/interface/src/i18n/en/index.ts +++ b/interface/src/i18n/en/index.ts @@ -331,7 +331,7 @@ const en: Translation = { ALLVALUES: 'All Values', SPECIAL_FUNCTIONS: 'Special Functions', WAIT_FIRMWARE: 'Firmware is uploading and installing', - INSTALL_VERSION: 'This will install version {0}. Are you sure?', + INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', SWITCH_DEV: 'switch to the development version', UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', LATEST_VERSION: 'You are using the latest firmware version.', diff --git a/interface/src/i18n/fr/index.ts b/interface/src/i18n/fr/index.ts index 4672a094c..f29674778 100644 --- a/interface/src/i18n/fr/index.ts +++ b/interface/src/i18n/fr/index.ts @@ -331,7 +331,7 @@ const fr: Translation = { ALLVALUES: 'All Values', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate - INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate + INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate SWITCH_DEV: 'switch to the development version', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate diff --git a/interface/src/i18n/it/index.ts b/interface/src/i18n/it/index.ts index 8813d9dd3..582490226 100644 --- a/interface/src/i18n/it/index.ts +++ b/interface/src/i18n/it/index.ts @@ -331,7 +331,7 @@ const it: Translation = { ALLVALUES: 'All Values', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate - INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate + INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate SWITCH_DEV: 'switch to the development version', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate diff --git a/interface/src/i18n/nl/index.ts b/interface/src/i18n/nl/index.ts index 8f9de0884..2e5314a00 100644 --- a/interface/src/i18n/nl/index.ts +++ b/interface/src/i18n/nl/index.ts @@ -331,7 +331,7 @@ const nl: Translation = { ALLVALUES: 'All Values', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate - INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate + INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate SWITCH_DEV: 'switch to the development version', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate diff --git a/interface/src/i18n/no/index.ts b/interface/src/i18n/no/index.ts index 2b573c7e6..2ea128bb8 100644 --- a/interface/src/i18n/no/index.ts +++ b/interface/src/i18n/no/index.ts @@ -331,7 +331,7 @@ const no: Translation = { ALLVALUES: 'All Values', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate - INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate + INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate SWITCH_DEV: 'switch to the development version', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate diff --git a/interface/src/i18n/pl/index.ts b/interface/src/i18n/pl/index.ts index 99eaf709d..3910815af 100644 --- a/interface/src/i18n/pl/index.ts +++ b/interface/src/i18n/pl/index.ts @@ -331,7 +331,7 @@ const pl: BaseTranslation = { ALLVALUES: 'All Values', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate - INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate + INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate SWITCH_DEV: 'switch to the development version', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate diff --git a/interface/src/i18n/sk/index.ts b/interface/src/i18n/sk/index.ts index 77093b5e4..13e2bfcdc 100644 --- a/interface/src/i18n/sk/index.ts +++ b/interface/src/i18n/sk/index.ts @@ -331,7 +331,7 @@ const sk: Translation = { ALLVALUES: 'Všetky hodnoty', SPECIAL_FUNCTIONS: 'Špeciálne funkcie', WAIT_FIRMWARE: 'Firmvér sa nahráva a inštaluje', - INSTALL_VERSION: 'Týmto sa nainštaluje verzia {0}. Si si istý?', + INSTALL_VERSION: 'Týmto sa {0} verzia {1}. Si si istý?', SWITCH_DEV: 'prejsť na vývojovú verziu', UPGRADE_AVAILABLE: 'K dispozícii je aktualizácia firmvéru!', LATEST_VERSION: 'Používate poslednú verziu firmvéru.', diff --git a/interface/src/i18n/sv/index.ts b/interface/src/i18n/sv/index.ts index ad593e1a9..ce9b6a3b1 100644 --- a/interface/src/i18n/sv/index.ts +++ b/interface/src/i18n/sv/index.ts @@ -331,7 +331,7 @@ const sv: Translation = { ALLVALUES: 'All Values', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate - INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate + INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate SWITCH_DEV: 'switch to the development version', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate diff --git a/interface/src/i18n/tr/index.ts b/interface/src/i18n/tr/index.ts index a21f735fd..0ac801948 100644 --- a/interface/src/i18n/tr/index.ts +++ b/interface/src/i18n/tr/index.ts @@ -331,7 +331,7 @@ const tr: Translation = { ALLVALUES: 'All Values', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate - INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate + INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate SWITCH_DEV: 'switch to the development version', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate diff --git a/mock-api/rest_server.ts b/mock-api/rest_server.ts index bfa115189..d6b00e235 100644 --- a/mock-api/rest_server.ts +++ b/mock-api/rest_server.ts @@ -35,7 +35,11 @@ let LATEST_STABLE_VERSION = '3.7.0'; let LATEST_DEV_VERSION = '3.7.1-dev.4'; let VERSION_IS_UPGRADEABLE = false; -// for testing +// for testing - scenario 1 +// THIS_VERSION = '3.7.1-dev.1'; +// VERSION_IS_UPGRADEABLE = true; + +// for testing - scenario 2 // THIS_VERSION = '3.6.5'; // VERSION_IS_UPGRADEABLE = true; diff --git a/src/test/test.cpp b/src/test/test.cpp index a79d9bee8..3c9bf294e 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -1029,17 +1029,21 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const // request.url("/rest/action"); // EMSESP::webStatusService.action(&request, doc.as()); - // should show dev version and be updatable - char data5[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.99,3.7.0\"}"; - deserializeJson(doc, data5); + // test version checks + // test with "current_version_s = "3.7.1-dev.8" in WebStatusService::checkUpgrade() request.url("/rest/action"); + deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.9,3.7.0\"}"); // is upgradable + EMSESP::webStatusService.action(&request, doc.as()); + deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.7,3.7.0\"}"); // is not upgradable EMSESP::webStatusService.action(&request, doc.as()); - // should show dev version and not be updatable - char data6[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.4,3.7.0\"}"; - deserializeJson(doc, data6); - request.url("/rest/action"); - EMSESP::webStatusService.action(&request, doc.as()); + // test with "current_version_s = "3.6.5" in WebStatusService::checkUpgrade() + // request.url("/rest/action"); + // deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.9,3.6.5\"}"); // is noy upgradable + // EMSESP::webStatusService.action(&request, doc.as()); + // deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.7,3.7.0\"}"); // is upgradable + // EMSESP::webStatusService.action(&request, doc.as()); + // char data6[] = "{\"device\":\"system\", \"cmd\":\"read\",\"value\":\"8 2 27 1\"}"; // deserializeJson(doc, data6); diff --git a/src/version.h b/src/version.h index bc1eb86f2..4386509df 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.7.1-dev.4" \ No newline at end of file +#define EMSESP_APP_VERSION "3.7.1-dev.5" \ No newline at end of file diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index 5309a423c..e9e4a3b4c 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -203,38 +203,42 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json) } // action = checkUpgrade +// versions holds the latest development version and stable version in one string, comma separated bool WebStatusService::checkUpgrade(JsonObject root, std::string & versions) { - std::string current_version; + std::string current_version_s; #ifndef EMSESP_STANDALONE - current_version = EMSESP_APP_VERSION; // always send back current version + current_version_s = EMSESP_APP_VERSION; #else - // for testing only - // current_version = "3.6.5"; - current_version = "3.7.0-dev-7"; + // for testing only - see api3 test in test.cpp + // current_version_s = "3.6.5"; + current_version_s = "3.7.1-dev.8"; #endif if (!versions.empty()) { - // versions holds the latest development version and stable version in one string, comma separated - std::string latest_dev_version = versions.substr(0, versions.find(',')); - std::string latest_stable_version = versions.substr(versions.find(',') + 1); - - version::Semver200_version this_version(current_version); - bool using_dev_version = !this_version.prerelease().find("dev"); - version::Semver200_version latest_version(using_dev_version ? latest_dev_version : latest_stable_version); // latest version - - root["upgradeable"] = (latest_version > this_version); + version::Semver200_version current_version(current_version_s); + bool using_dev_version = !current_version.prerelease().find("dev"); // look for dev in the name to determine if we're using dev version + version::Semver200_version latest_version(using_dev_version ? versions.substr(0, versions.find(',')) : versions.substr(versions.find(',') + 1)); + bool upgradeable = (latest_version > current_version); #if defined(EMSESP_DEBUG) - emsesp::EMSESP::logger().debug("Checking for version upgrade. This version=%s, latest dev=%s, latest stable=%s. Using %s releases. Upgradeable=%s", - current_version.c_str(), - latest_dev_version.c_str(), - latest_stable_version.c_str(), - using_dev_version ? "dev" : "stable", - root["upgradeable"].as() ? "true" : "false"); + emsesp::EMSESP::logger() + .debug("Checking Version upgrade. Using %s release branch. current version=%d.%d.%d-%s, latest version=%d.%d.%d-%s (%s upgradeable)", + (using_dev_version ? "dev" : "stable"), + current_version.major(), + current_version.minor(), + current_version.patch(), + current_version.prerelease().c_str(), + latest_version.major(), + latest_version.minor(), + latest_version.patch(), + latest_version.prerelease().c_str(), + upgradeable ? "IS" : "NOT"); #endif + + root["upgradeable"] = upgradeable; } - root["emsesp_version"] = current_version; + root["emsesp_version"] = current_version_s; // always send back current version return true; }