From b587c08768a543df28f74d9f562fd534181b2f9a Mon Sep 17 00:00:00 2001 From: Proddy Date: Tue, 3 Jan 2023 14:47:57 +0100 Subject: [PATCH 1/9] tag missing translations --- interface/src/i18n/de/index.ts | 2 +- interface/src/i18n/fr/index.ts | 12 ++++++------ interface/src/i18n/nl/index.ts | 12 ++++++------ interface/src/i18n/no/index.ts | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index 4b15e4ec9..b67789a95 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -70,7 +70,7 @@ const de: Translation = { TEMP_SENSOR: 'Temperatursensor', TEMP_SENSORS: 'Temperatursensoren', WRITE_CMD_SENT: 'Befehl schreiben wurde gesendet', - WRITE_CMD_FAILED: 'Befehl schreiben failed', // TODO + WRITE_CMD_FAILED: 'Befehl schreiben failed', // TODO translate EMS_BUS_WARNING: 'EMS-Bus getrennt. Wenn diese Warnung nach einigen Sekunden immer noch besteht, überprüfen Sie bitte die Einstellungen und das Board-Profil', EMS_BUS_SCANNING: 'Suche nach EMS Geräten...', CONNECTED: 'Verbunden', diff --git a/interface/src/i18n/fr/index.ts b/interface/src/i18n/fr/index.ts index 5f83b2c01..f20e20a69 100644 --- a/interface/src/i18n/fr/index.ts +++ b/interface/src/i18n/fr/index.ts @@ -69,8 +69,8 @@ const fr: Translation = { SENSOR: 'Capteur', TEMP_SENSOR: 'Capteur de température', TEMP_SENSORS: 'Capteurs de température', - WRITE_CMD_SENT: 'Envoyer la commande sent', // TODO - WRITE_CMD_FAILED: 'Envoyer la commande failed', // TODO + WRITE_CMD_SENT: 'Envoyer la commande sent', // TODO translate + WRITE_CMD_FAILED: 'Envoyer la commande failed', // TODO translate EMS_BUS_WARNING: 'Bus EMS déconnecté. Si ce message persiste après quelques secondes, vérifiez les paramètres et la configuration de la carte.', EMS_BUS_SCANNING: 'Scan des appareils EMS...', CONNECTED: 'Connecté', @@ -249,10 +249,10 @@ const fr: Translation = { MQTT_INT_HEARTBEAT: 'Battements', MQTT_QUEUE: 'Queue MQTT', DEFAULT: 'Défaut', - MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO - MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)',// TODO - MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO - MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO + MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO translate + MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)',// TODO translate + MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO translate + MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO translate MQTT_CLEAN_SESSION: 'Flag Clean Session', MQTT_RETAIN_FLAG: 'Toujours activer le Retain Flag', INACTIVE: 'Inactif', diff --git a/interface/src/i18n/nl/index.ts b/interface/src/i18n/nl/index.ts index 0ce16719c..95e58f6f8 100644 --- a/interface/src/i18n/nl/index.ts +++ b/interface/src/i18n/nl/index.ts @@ -69,8 +69,8 @@ const nl: Translation = { SENSOR: 'Sensor', TEMP_SENSOR: 'Temperatuur sensor', TEMP_SENSORS: 'Temperatuur Sensoren', - WRITE_CMD_SENT: 'Schrijf commando sent', // TODO - WRITE_CMD_FAILED: 'Schrijf commando failed', // TODO + WRITE_CMD_SENT: 'Schrijf commando sent', // TODO translate + WRITE_CMD_FAILED: 'Schrijf commando failed', // TODO translate EMS_BUS_WARNING: 'EMS bus niet gevonden. Als deze waarschuwing blijft staan na een paar seconden dan loop de instellingen na en in het bijzonder het apparaat type profiel na.', EMS_BUS_SCANNING: 'Scannen naar EMS apparaten...', CONNECTED: 'Verbonden', @@ -249,10 +249,10 @@ const nl: Translation = { MQTT_INT_HEARTBEAT: 'Heartbeat', MQTT_QUEUE: 'MQTT Queue', DEFAULT: 'Default', - MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO - MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO - MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO - MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO + MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO translate + MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO translate + MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO translate + MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO translate MQTT_CLEAN_SESSION: 'Clean Session aan', MQTT_RETAIN_FLAG: 'Retain flag aan', INACTIVE: 'Inactief', diff --git a/interface/src/i18n/no/index.ts b/interface/src/i18n/no/index.ts index 2f5aedee6..f597002d2 100644 --- a/interface/src/i18n/no/index.ts +++ b/interface/src/i18n/no/index.ts @@ -69,8 +69,8 @@ const no: Translation = { SENSOR: 'Sensor', TEMP_SENSOR: 'Temperatursensor', TEMP_SENSORS: 'Temperaturesensorer', - WRITE_CMD_SENT: 'Skriv kommando sent', // TODO - WRITE_CMD_FAILED: 'Skriv kommando failed', // TODO + WRITE_CMD_SENT: 'Skriv kommando sent', // TODO translate + WRITE_CMD_FAILED: 'Skriv kommando failed', // TODO translate EMS_BUS_WARNING: 'EMS bussen koblet ned. Hvis denne advarselen fortsetter etter noen f¨sekunder sjekk instillinger og prosessorkort', EMS_BUS_SCANNING: 'Søker etter EMS enheter...', CONNECTED: 'Tilkoblet', @@ -249,10 +249,10 @@ const no: Translation = { MQTT_INT_HEARTBEAT: 'Heartbeat', MQTT_QUEUE: 'MQTT Queue', DEFAULT: 'Standard', - MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO - MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO - MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO - MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO + MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO translate + MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO translate + MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO translate + MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO translate MQTT_CLEAN_SESSION: 'Benytt Clean Session', MQTT_RETAIN_FLAG: 'Alltid sett Retain flag', INACTIVE: 'Innaktiv', From c28de99907b72a46c6e547fbd9f5c7c9d5aa944e Mon Sep 17 00:00:00 2001 From: Proddy Date: Tue, 3 Jan 2023 14:48:08 +0100 Subject: [PATCH 2/9] remove comments --- lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp | 2 +- lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp index 5013d2e29..fd434d5c3 100644 --- a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp @@ -37,7 +37,7 @@ class MsgPackDeserializer { NestingLimit nestingLimit) { DeserializationError::Code err; - uint8_t code = 0; // TODO: why do we need to initialize this variable? + uint8_t code = 0; err = readByte(code); if (err) return err; diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp index b6e7ea8c9..e680f5a85 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp @@ -22,7 +22,7 @@ struct Comparer; template struct Comparer::value>::type> : ComparerBase { - T rhs; // TODO: store adapted string? + T rhs; explicit Comparer(T value) : rhs(value) {} From c45ceec33b44c79e4fedee84e22239651d8689d0 Mon Sep 17 00:00:00 2001 From: Proddy Date: Tue, 3 Jan 2023 14:48:20 +0100 Subject: [PATCH 3/9] remove comment --- src/test/test.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/test.cpp b/src/test/test.cpp index ec95a0e79..7339ee22a 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -153,8 +153,6 @@ bool Test::run_test(const char * command, int8_t id) { // HC1 on 0x20 uart_telegram({0xA0, 00, 0xFF, 00, 01, 0xD7, 00, 00, 00, 0x80, 00, 00, 00, 00, 03, 0xC5}); - // TODO - return true; } @@ -639,7 +637,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const // toggle mode for (const auto & emsdevice : EMSESP::emsdevices) { Serial.print("Custom: "); - Serial.print(emsdevice->device_type_name().c_str()); + Serial.print(emsdevice->device_type_name()); Serial.print(" uniqueid="); Serial.println(emsdevice->unique_id()); From 6dc993a2765b22096ec286ba324f9b2229773d43 Mon Sep 17 00:00:00 2001 From: Proddy Date: Tue, 3 Jan 2023 14:48:48 +0100 Subject: [PATCH 4/9] add note to investigate xTaskSuspend and static buffer size --- src/uart/emsuart_esp32.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/uart/emsuart_esp32.cpp b/src/uart/emsuart_esp32.cpp index bdbf34ded..26ee336ae 100644 --- a/src/uart/emsuart_esp32.cpp +++ b/src/uart/emsuart_esp32.cpp @@ -87,6 +87,8 @@ void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t uart_driver_install(EMSUART_NUM, 129, 0, (EMS_MAXBUFFERSIZE + 1) * 2, &uart_queue, 0); // buffer must be > fifo uart_set_rx_full_threshold(EMSUART_NUM, 1); uart_set_rx_timeout(EMSUART_NUM, 0); // disable + + // note setting the static max buffer to 1024 causes OTA to fail xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, configMAX_PRIORITIES - 1, NULL); } tx_mode_ = tx_mode; @@ -99,6 +101,7 @@ void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t void EMSuart::stop() { if (tx_mode_ != 0xFF) { // only call after driver initialisation uart_disable_intr_mask(EMSUART_NUM, UART_BRK_DET_INT_ENA | UART_RXFIFO_FULL_INT_ENA); + // TODO should we xTaskSuspend() the event task here? } }; From 9a09062a842562ca859ffca7593fc5e257ca571f Mon Sep 17 00:00:00 2001 From: Proddy Date: Tue, 3 Jan 2023 14:48:57 +0100 Subject: [PATCH 5/9] bump version --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 68e089c4f..3cb46d0c9 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.5.0-dev.14" +#define EMSESP_APP_VERSION "3.5.0-dev.15" From 5005d06507c4af27511af67a08b60de276d5102c Mon Sep 17 00:00:00 2001 From: Proddy Date: Tue, 3 Jan 2023 14:50:50 +0100 Subject: [PATCH 6/9] Translate Device Name #872 --- interface/src/project/DashboardData.tsx | 8 +-- interface/src/project/DeviceIcon.tsx | 39 +++++++------ .../src/project/SettingsCustomization.tsx | 2 +- interface/src/project/types.ts | 6 +- mock-api/server.js | 18 ++++-- src/emsdevice.cpp | 55 +++++++++++++++---- src/emsdevice.h | 32 +++++------ src/emsesp.cpp | 14 +++-- src/helpers.cpp | 5 +- src/helpers.h | 2 +- src/locale_common.h | 2 +- src/locale_translations.h | 37 ++++++++----- src/system.cpp | 2 +- src/web/WebCustomizationService.cpp | 7 ++- src/web/WebDataService.cpp | 3 +- src/web/WebSettingsService.cpp | 4 +- 16 files changed, 146 insertions(+), 90 deletions(-) diff --git a/interface/src/project/DashboardData.tsx b/interface/src/project/DashboardData.tsx index 0c780e7c2..e4154f18b 100644 --- a/interface/src/project/DashboardData.tsx +++ b/interface/src/project/DashboardData.tsx @@ -142,7 +142,7 @@ const DashboardData: FC = () => { common_theme, { Table: ` - --data-table-library_grid-template-columns: 40px 100px repeat(1, minmax(0, 1fr)) 100px 40px; + --data-table-library_grid-template-columns: 40px 160px repeat(1, minmax(0, 1fr)) 100px 40px; `, BaseRow: ` .td { @@ -704,9 +704,9 @@ const DashboardData: FC = () => { {tableList.map((device: Device, index: number) => ( - + - {device.t} + {device.tn} {device.n} {device.e} @@ -719,7 +719,7 @@ const DashboardData: FC = () => { {(coreData.active_sensors > 0 || coreData.analog_enabled) && ( - + Sensors {LL.ATTACHED_SENSORS()} diff --git a/interface/src/project/DeviceIcon.tsx b/interface/src/project/DeviceIcon.tsx index ec8910487..4d5ac8461 100644 --- a/interface/src/project/DeviceIcon.tsx +++ b/interface/src/project/DeviceIcon.tsx @@ -13,32 +13,35 @@ import { AiOutlineAlert } from 'react-icons/ai'; import { AiOutlineChrome } from 'react-icons/ai'; interface DeviceIconProps { - type: string; + type_id: number; } -const DeviceIcon: FC = ({ type }) => { - switch (type) { - case 'Boiler': - return ; - case 'Sensor': +// matches emsdevice.h DeviceType +const DeviceIcon: FC = ({ type_id }) => { + switch (type_id) { + case 1: + case 2: return ; - case 'Solar': - return ; - case 'Thermostat': + case 3: + return ; + case 4: return ; - case 'Mixer': + case 5: return ; - case 'Heatpump': + case 6: + return ; + case 7: return ; - case 'Switch': - return ; - case 'Connect': - return ; - case 'Gateway': + case 8: return ; - case 'Alert': + case 9: + return ; + case 10: + case 11: + return ; + case 12: return ; - case 'Pump': + case 13: return ; default: return null; diff --git a/interface/src/project/SettingsCustomization.tsx b/interface/src/project/SettingsCustomization.tsx index b32ba7719..06aa98ddc 100644 --- a/interface/src/project/SettingsCustomization.tsx +++ b/interface/src/project/SettingsCustomization.tsx @@ -180,7 +180,7 @@ const SettingsCustomization: FC = () => { return ( <> {de.n && (de.n[0] === '!' ? LL.COMMAND() + ': ' + de.n.slice(1) : de.cn && de.cn !== '' ? de.cn : de.n) + ' '}( - + {de.id} ) diff --git a/interface/src/project/types.ts b/interface/src/project/types.ts index 150abd0ea..02703a1f6 100644 --- a/interface/src/project/types.ts +++ b/interface/src/project/types.ts @@ -59,7 +59,8 @@ export interface Status { } export interface Device { id: string; // id index - t: string; // type + tn: string; // device type translated name + t: number; // device type id b: string; // brand n: string; // name d: number; // deviceid @@ -110,7 +111,8 @@ export interface DeviceShort { d?: number; // deviceid p?: number; // productid s: string; // shortname - t?: string; // device type name + t?: number; // device type id + tn?: string; // device type internal name } export interface Devices { diff --git a/mock-api/server.js b/mock-api/server.js index fc6e7b7ce..d8f33fcf9 100644 --- a/mock-api/server.js +++ b/mock-api/server.js @@ -355,17 +355,20 @@ const emsesp_devices = { { i: 1, s: 'Thermostat (RC20/Moduline 300)', - t: 'thermostat', + t: 4, + tn: 'thermostat', }, { i: 2, s: 'Boiler (Nefit GBx72/Trendline/Cerapur/Greenstar Si/27i)', - t: 'boiler', + t: 3, + tn: 'boiler', }, { i: 4, s: 'Thermostat (RC100/Moduline 1000/1010)', - t: 'thermostat', + t: 4, + tn: 'thermostat', }, ], } @@ -376,7 +379,8 @@ const emsesp_coredata = { devices: [ { id: '2', - t: 'Boiler', + t: 3, + tn: 'Boiler', b: 'Nefit', n: 'GBx72/Trendline/Cerapur/Greenstar Si/27i', d: 8, @@ -386,7 +390,8 @@ const emsesp_coredata = { }, { id: '1', - t: 'Thermostat', + t: 4, + tn: 'Thermostat', b: '', n: 'RC20/Moduline 300', d: 23, @@ -396,7 +401,8 @@ const emsesp_coredata = { }, { id: '4', - t: 'Thermostat', + t: 4, + tn: 'Thermostat', b: 'Buderus', n: 'RC100/Moduline 1000/1010', d: 16, diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 12df734e1..e38bb628c 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -68,7 +68,7 @@ std::string EMSdevice::uom_to_string(uint8_t uom) { } } -std::string EMSdevice::brand_to_string() const { +const std::string EMSdevice::brand_to_string() { switch (brand_) { case EMSdevice::Brand::BOSCH: return "Bosch"; @@ -89,7 +89,7 @@ std::string EMSdevice::brand_to_string() const { } } -// returns the name of the MQTT topic to use for a specific device, without the base +// returns the short name of the device, used in MQTT and console commands, all lowercase const char * EMSdevice::device_type_2_device_name(const uint8_t device_type) { switch (device_type) { case DeviceType::SYSTEM: @@ -125,7 +125,39 @@ const char * EMSdevice::device_type_2_device_name(const uint8_t device_type) { } } -// returns device_type from a string +// returns the translated name of a specific EMS device +// excludes dallassensor, analogsensor and system +const char * EMSdevice::device_type_2_device_name_translated() { + switch (device_type_) { + case DeviceType::BOILER: + return Helpers::translated_word(FL_(boiler_device)); + case DeviceType::THERMOSTAT: + return Helpers::translated_word(FL_(thermostat_device)); + case DeviceType::HEATPUMP: + return Helpers::translated_word(FL_(heatpump_device)); + case DeviceType::SOLAR: + return Helpers::translated_word(FL_(solar_device)); + case DeviceType::CONNECT: + return Helpers::translated_word(FL_(connect_device)); + case DeviceType::MIXER: + return Helpers::translated_word(FL_(mixer_device)); + case DeviceType::CONTROLLER: + return Helpers::translated_word(FL_(controller_device)); + case DeviceType::SWITCH: + return Helpers::translated_word(FL_(switch_device)); + case DeviceType::GATEWAY: + return Helpers::translated_word(FL_(gateway_device)); + case DeviceType::ALERT: + return Helpers::translated_word(FL_(alert_device)); + case DeviceType::PUMP: + return Helpers::translated_word(FL_(pump_device)); + default: + break; + } + return Helpers::translated_word(FL_(unknown)); +} + +// returns device_type from a non-translated EN string uint8_t EMSdevice::device_name_2_device_type(const char * topic) { if (!topic) { return DeviceType::UNKNOWN; @@ -178,11 +210,9 @@ uint8_t EMSdevice::device_name_2_device_type(const char * topic) { return DeviceType::UNKNOWN; } -// return name of the device type, capitalized -std::string EMSdevice::device_type_name() const { - std::string s = device_type_2_device_name(device_type_); - s[0] = toupper(s[0]); - return s; +// return name of the device type, not translated +const char * EMSdevice::device_type_name() { + return device_type_2_device_name(device_type_); } // 0=unknown, 1=bosch, 2=junkers, 3=buderus, 4=nefit, 5=sieger, 11=worcester @@ -208,7 +238,7 @@ uint8_t EMSdevice::decode_brand(uint8_t value) { } // returns string of a human friendly description of the EMS device -std::string EMSdevice::to_string() const { +const std::string EMSdevice::to_string() { // for devices that haven't been lookup yet, don't show all details if (product_id_ == 0) { return std::string(name_) + " (DeviceID:" + Helpers::hextoa(device_id_) + ")"; @@ -223,12 +253,13 @@ std::string EMSdevice::to_string() const { } // returns out brand + device name -std::string EMSdevice::to_string_short() const { +// translated +const std::string EMSdevice::to_string_short() { if (brand_ == Brand::NO_BRAND) { - return device_type_name() + ": " + name_; + return std::string(device_type_2_device_name_translated()) + ": " + name_; } - return device_type_name() + ": " + brand_to_string() + " " + name_; + return std::string(device_type_2_device_name_translated()) + ": " + brand_to_string() + " " + name_; } // for each telegram that has the fetch value set (true) do a read request diff --git a/src/emsdevice.h b/src/emsdevice.h index f5d3937c1..78ae23ef3 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -31,7 +31,7 @@ class EMSdevice { public: virtual ~EMSdevice() = default; // destructor of base class must always be virtual because it's a polymorphic class - static constexpr uint8_t EMS_DEVICES_MAX_TELEGRAMS = 20; + using process_function_p = std::function)>; // device_type defines which derived class to use, e.g. BOILER, THERMOSTAT etc.. EMSdevice(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand) @@ -44,13 +44,16 @@ class EMSdevice { strlcpy(version_, version, sizeof(version_)); } - std::string device_type_name() const; - + // static functions, used outside the class like in console.cpp, command.cpp, emsesp.cpp, mqtt.cpp static const char * device_type_2_device_name(const uint8_t device_type); static uint8_t device_name_2_device_type(const char * topic); static std::string uom_to_string(uint8_t uom); static std::string tag_to_string(uint8_t tag, const bool translate = true); static std::string tag_to_mqtt(uint8_t tag); + static uint8_t decode_brand(uint8_t value); + + const char * device_type_name(); // returns short non-translated device type name + const char * device_type_2_device_name_translated(); // returns translated device type name bool has_tag(const uint8_t tag) const; bool has_cmd(const char * cmd, const int8_t id) const; @@ -113,7 +116,6 @@ class EMSdevice { return name_; } - // unique id of a device inline uint8_t unique_id() const { return unique_id_; } @@ -174,11 +176,9 @@ class EMSdevice { } } - std::string brand_to_string() const; - static uint8_t decode_brand(uint8_t value); - - std::string to_string() const; - std::string to_string_short() const; + const std::string brand_to_string(); + const std::string to_string(); + const std::string to_string_short(); enum Handlers : uint8_t { ALL, RECEIVED, FETCHED, PENDING, IGNORED }; @@ -192,8 +192,6 @@ class EMSdevice { void setCustomEntity(const std::string & entity_id); void getCustomEntities(std::vector & entity_ids); - using process_function_p = std::function)>; - void register_telegram_type(const uint16_t telegram_type_id, const char * telegram_type_name, bool fetch, const process_function_p cb); bool handle_telegram(std::shared_ptr telegram); @@ -201,10 +199,6 @@ class EMSdevice { bool get_value_info(JsonObject & root, const char * cmd, const int8_t id); void get_dv_info(JsonObject & json); -#if defined(EMSESP_STANDALONE_DUMP) - void dump_value_info(); -#endif - enum OUTPUT_TARGET : uint8_t { API_VERBOSE, API_SHORTNAMES, MQTT, CONSOLE }; bool generate_values(JsonObject & output, const uint8_t tag_filter, const bool nested, const uint8_t output_target); void generate_values_web(JsonObject & output); @@ -349,6 +343,8 @@ class EMSdevice { UNKNOWN }; + static constexpr uint8_t EMS_DEVICES_MAX_TELEGRAMS = 20; + // static device IDs static constexpr uint8_t EMS_DEVICE_ID_BOILER = 0x08; // fixed device_id for Master Boiler/UBA static constexpr uint8_t EMS_DEVICE_ID_BOILER_1 = 0x70; // fixed device_id for 1st. Cascade Boiler/UBA @@ -368,7 +364,7 @@ class EMSdevice { static constexpr uint8_t EMS_DEVICE_ID_MODEM = 0x48; static constexpr uint8_t EMS_DEVICE_ID_RFSENSOR = 0x40; // RF sensor only sending, no reply static constexpr uint8_t EMS_DEVICE_ID_RFBASE = 0x50; - static constexpr uint8_t EMS_DEVICE_ID_ROOMTHERMOSTAT = 0x17; //TADO using this with no version reply + static constexpr uint8_t EMS_DEVICE_ID_ROOMTHERMOSTAT = 0x17; // TADO using this with no version reply // generic type IDs static constexpr uint16_t EMS_TYPE_VERSION = 0x02; // type ID for Version information. Generic across all EMS devices. @@ -419,6 +415,10 @@ class EMSdevice { uint8_t count_entities(); bool has_entities() const; +#if defined(EMSESP_STANDALONE_DUMP) + void dump_value_info(); +#endif + private: uint8_t unique_id_; uint8_t device_type_ = DeviceType::SYSTEM; diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 2ecc0301e..07d93608c 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -354,9 +354,10 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) { // do this in the order of factory classes to keep a consistent order when displaying for (const auto & device_class : EMSFactory::device_handlers()) { for (const auto & emsdevice : emsdevices) { - if (emsdevice && (emsdevice->device_type() == device_class.first)) { - // print header - shell.printfln("%s: %s (%d)", emsdevice->device_type_name().c_str(), emsdevice->to_string().c_str(), emsdevice->count_entities()); + auto device_type = emsdevice->device_type(); + if (emsdevice && (device_type == device_class.first)) { + // print header, with device type translated + shell.printfln("%s: %s (%d)", emsdevice->device_type_2_device_name_translated(), emsdevice->to_string().c_str(), emsdevice->count_entities()); DynamicJsonDocument doc(EMSESP_JSON_SIZE_XXLARGE_DYN); // use max size JsonObject json = doc.to(); @@ -822,7 +823,7 @@ void EMSESP::process_version(std::shared_ptr telegram) { // find the device object that matches the deviceID and see if it has a matching telegram type handler // but only process if the telegram is sent to us or it's a broadcast (dest=0x00=all) -// We also check for common telgram types, like the Version(0x02) +// We also check for common telegram types, like the Version(0x02) // returns false if there are none found bool EMSESP::process_telegram(std::shared_ptr telegram) { // if watching or reading... @@ -943,12 +944,13 @@ void EMSESP::show_devices(uuid::console::Shell & shell) { } } - // for all device objects from emsdevice.h (UNKNOWN, SYSTEM, BOILER, THERMOSTAT, MIXER, SOLAR, HEATPUMP, GATEWAY, SWITCH, CONTROLLER, CONNECT) + // for all device objects from emsdevice.h // so we keep a consistent order + // don't translate the device type name for (const auto & device_class : EMSFactory::device_handlers()) { for (const auto & emsdevice : emsdevices) { if (emsdevice && (emsdevice->device_type() == device_class.first)) { - shell.printf("%s: %s", emsdevice->device_type_name().c_str(), emsdevice->to_string().c_str()); + shell.printf("%s: %s", emsdevice->device_type_name(), emsdevice->to_string().c_str()); shell.println(); emsdevice->show_telegram_handlers(shell); diff --git a/src/helpers.cpp b/src/helpers.cpp index a3d029234..f027df312 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -718,7 +718,8 @@ uint8_t Helpers::count_items(const char * const ** list) { } // returns char pointer to translated description or fullname -const char * Helpers::translated_word(const char * const * strings) { +// if force_en is true always take the EN non-translated word +const char * Helpers::translated_word(const char * const * strings, const bool force_en) { uint8_t language_index = EMSESP::system_.language_index(); uint8_t index = 0; @@ -727,7 +728,7 @@ const char * Helpers::translated_word(const char * const * strings) { } // see how many translations we have for this entity. if there is no translation for this, revert to EN - if (Helpers::count_items(strings) >= language_index + 1 && strlen(strings[language_index])) { + if (force_en || (Helpers::count_items(strings) >= language_index + 1 && strlen(strings[language_index]))) { index = language_index; } return strings[index]; diff --git a/src/helpers.h b/src/helpers.h index cc153079b..e4505643c 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -77,7 +77,7 @@ class Helpers { static uint8_t count_items(const char * const ** list); static uint8_t count_items(const char * const * list); - static const char * translated_word(const char * const * strings); + static const char * translated_word(const char * const * strings, const bool force_en = false); #ifdef EMSESP_STANDALONE static char * ultostr(char * ptr, uint32_t value, const uint8_t base); diff --git a/src/locale_common.h b/src/locale_common.h index 65764dc6a..88966551d 100644 --- a/src/locale_common.h +++ b/src/locale_common.h @@ -89,7 +89,7 @@ MAKE_PSTR_WORD(customizations) MAKE_PSTR_WORD(value) MAKE_PSTR_WORD(entities) -// devices +// device types - lowercase, used in MQTT MAKE_PSTR_WORD(boiler) MAKE_PSTR_WORD(thermostat) MAKE_PSTR_WORD(switch) diff --git a/src/locale_translations.h b/src/locale_translations.h index 06f5977e6..5c25b093c 100644 --- a/src/locale_translations.h +++ b/src/locale_translations.h @@ -32,6 +32,20 @@ // translations are in order en, de, nl, sv, pl, no, fr, .... // if there is no translation, it will default to en +// device types, as display in Web and Console +// TODO need completed translations +MAKE_PSTR_LIST(boiler_device, "Boiler", "Kessel", "Boiler") +MAKE_PSTR_LIST(thermostat_device, "Thermostat", "Thermostat", "Thermostaat") +MAKE_PSTR_LIST(heatpump_device, "Heat Pump", "Wärmepumpe", "Warmtepomp") +MAKE_PSTR_LIST(solar_device, "Solar Module", "Solar Module", "Solar Module") +MAKE_PSTR_LIST(connect_device, "Connect Module", "Connect Module", "Connect Module") +MAKE_PSTR_LIST(mixer_device, "Mixer Module", "Mixer Module", "Mixer Module") +MAKE_PSTR_LIST(controller_device, "Controller Module", "Controller Module", "Controller Module") +MAKE_PSTR_LIST(switch_device, "Switch Module","Switch Module","Switch Module") +MAKE_PSTR_LIST(gateway_device, "Gateway Module","Gateway Module","Gateway Module") +MAKE_PSTR_LIST(alert_device, "Alert Module","Alert Module","Alert Module") +MAKE_PSTR_LIST(pump_device, "Pump Module","Pump Module","Pump Module") + // commands MAKE_PSTR_LIST(info_cmd, "lists all values", "Liste aller Werte") MAKE_PSTR_LIST(commands_cmd, "lists all commands", "Liste aller Kommandos") @@ -171,13 +185,13 @@ MAKE_PSTR_LIST(valve, "valve", "Ventil", "Klep", "Ventil", "zawór", "ventil", " MAKE_PSTR_LIST(none, "none", "keine", "geen", "ingen", "brak", "ingen", "aucun") MAKE_PSTR_LIST(hot_water, "hot water", "Warmwasser", "warm water", "varmvatten", "c.w.u.", "varmtvann", "eau chaude") MAKE_PSTR_LIST(pool, "pool", "Pool", "zwembad", "pool", "basen", "basseng", "piscine") -MAKE_PSTR_LIST(outside_temp_alt, "outside temperature alt.", "Außentemp. alternativ", "", "", "temp. zewn. alternat.", "", "température extérieure alternative") -MAKE_PSTR_LIST(outside_temp_par, "outside temperature parallel", "Außentemp. parallel", "", "", "temp. zewn. równoległa", "", "température extérieure parallèle") -MAKE_PSTR_LIST(hp_prefered, "heatpump prefered", "Wärmepumpe bevorzugt", "", "", "preferowana pompa ciepła", "", "pompe à chaleur préférée") -MAKE_PSTR_LIST(boiler_only, "boiler only", "nur Kessel", "", "", "tylko kocioł", "", "chaudière uniquement") -MAKE_PSTR_LIST(reduced_output, "reduced output", "Reduzierte Leistung", "", "", "zmniejszona wydajność", "", "sortie réduite") -MAKE_PSTR_LIST(switchoff, "switch off hp", "WP ausschalten", "", "", "wyłącz pompę ciepła", "", "éteindre la PAC") -MAKE_PSTR_LIST(perm, "perm. reduced", "perm. reduziert", "", "", "stale zmniejszona wydajność", "", "réduction permanente") +MAKE_PSTR_LIST(outside_temp_alt, "outside temperature alt.", "Außentemp. alternativ", "", "", "temp. zewn. alternat.", "", "température extérieure alternative") // TODO translate +MAKE_PSTR_LIST(outside_temp_par, "outside temperature parallel", "Außentemp. parallel", "", "", "temp. zewn. równoległa", "", "température extérieure parallèle") // TODO translate +MAKE_PSTR_LIST(hp_prefered, "heatpump prefered", "Wärmepumpe bevorzugt", "", "", "preferowana pompa ciepła", "", "pompe à chaleur préférée") // TODO translate +MAKE_PSTR_LIST(boiler_only, "boiler only", "nur Kessel", "", "", "tylko kocioł", "", "chaudière uniquement") // TODO translate +MAKE_PSTR_LIST(reduced_output, "reduced output", "Reduzierte Leistung", "", "", "zmniejszona wydajność", "", "sortie réduite") // TODO translate +MAKE_PSTR_LIST(switchoff, "switch off hp", "WP ausschalten", "", "", "wyłącz pompę ciepła", "", "éteindre la PAC") // TODO translate +MAKE_PSTR_LIST(perm, "perm. reduced", "perm. reduziert", "", "", "stale zmniejszona wydajność", "", "réduction permanente") // TODO translate // thermostat MAKE_PSTR_LIST(seltemp, "selTemp", "Solltemperatur", "Doeltemperatuur", "Börtemperatur", "temperatura zadana", "innstilt temperatur", "consigne température") @@ -442,7 +456,6 @@ MAKE_PSTR_LIST(wwSelTempLow, "wwseltemplow", "selected lower temperature", "unte MAKE_PSTR_LIST(wwSelTempOff, "wwseltempoff", "selected temperature for off", "Solltemperatur bei AUS", "Streeftemperatuur bij UIT", "Vald tempereatur för AV", "temperatura gdy grzanie wyłączone", "valgt tempereatur for av", "température sélectionnée pour arrêt") MAKE_PSTR_LIST(wwSelTempSingle, "wwseltempsingle", "single charge temperature", "Solltemperatur Einmalladung", "Streeftemperatuur enkele lading", "Temperatur Engångsladdning", "temperatura dodatkowej ciepłej wody", "temp engangsoppvarming", "température charge unique") MAKE_PSTR_LIST(wwCylMiddleTemp, "wwcylmiddletemp", "cylinder middle temperature (TS3)", "Speichertemperatur Mitte", "Buffer temperatuur midden", "Cylinder Temperatur Mitten (TS3)", "temperatura środka cylindra (TS3)", "vanntank midten temperatur (TS3)", "température moyenne ballon (TS3)") - MAKE_PSTR_LIST(wwSetTemp, "wwsettemp", "set temperature", "Solltemperatur", "Streeftemperatuut", "Börtempertur", "temperatura zadana", "innstilt temperatur", "régler température") MAKE_PSTR_LIST(wwType, "wwtype", "type", "Typ", "type", "Typ", "typ", "type", "type") MAKE_PSTR_LIST(wwComfort, "wwcomfort", "comfort", "Komfort", "Comfort", "Komfort", "komfort", "komfort", "confort") @@ -482,7 +495,6 @@ MAKE_PSTR_LIST(wwOneTimeKey, "wwonetimekey", "one time key function", "Einmallad MAKE_PSTR_LIST(wwSolarTemp, "wwsolartemp", "solar boiler temperature", "Solarboiler Temperatur", "Zonneboiler temperatuur", "Solpanel Temp", "temperatura zasobnika solarnego", "", "température chaudière solaire") // mqtt values / commands - MAKE_PSTR_LIST(switchtime, "switchtime", "program switchtime", "Programm Schaltzeit", "Programma schakeltijd", "Program Bytestid", "program czasowy", "programbyttetid", "heure commutation programme") MAKE_PSTR_LIST(switchtime1, "switchtime1", "own1 program switchtime", "Programm 1 Schaltzeit", "Schakeltijd programma 1", "Program 1 Bytestid", "program przełączania 1", "byttetidprogram 1", "heure de commutation programme 1") MAKE_PSTR_LIST(switchtime2, "switchtime2", "own2 program switchtime", "Programm 2 Schaltzeit", "Schakeltijd programma 2", "Program 2 Bytestid", "program przełączania 2", "byttetid program 2", "heure de changement programme 2") @@ -516,7 +528,6 @@ MAKE_PSTR_LIST(wwSetTempLow, "wwsettemplow", "set low temperature", "untere Soll MAKE_PSTR_LIST(wwWhenModeOff, "wwwhenmodeoff", "when thermostat mode off", "bei Thermostatmodus AUS", "Als Thermostaat op UIT", "när Termostatläge är AV", "gdy wyłączono na termostacie", "når modus er av", "lorsque mode thermostat off") MAKE_PSTR_LIST(wwExtra1, "wwextra1", "circuit 1 extra", "Kreis 1 Extra", "Circuit 1 extra", "Krets 1 Extra", "obieg dodatkowy 1", "ekstra krets 1", "circuit 1 extra") MAKE_PSTR_LIST(wwExtra2, "wwextra2", "circuit 2 extra", "Kreis 2 Extra", "Circuit 2 extra", "Kets 2 Extra", "obieg dodatkowy 2", "ekstra krets 2", "circuit 2 extra") - MAKE_PSTR_LIST(wwCharge, "wwcharge", "charge", "Laden", "Laden", "Ladda", "grzanie", "lade", "charge") MAKE_PSTR_LIST(wwChargeDuration, "wwchargeduration", "charge duration", "Ladedauer", "Laadtijd", "Laddtid", "czas grzania dodatkowej ciepłej wody", "ladetid", "durée charge") MAKE_PSTR_LIST(wwDisinfect, "wwdisinfect", "disinfection", "Desinfektion", "Desinfectie", "Desinfektion", "dezynfekcja termiczna", "desinfeksjon", "désinfection") @@ -540,7 +551,7 @@ MAKE_PSTR_LIST(heattemp, "heattemp", "heat temperature", "Heizen Temperatur", "T MAKE_PSTR_LIST(nighttemp, "nighttemp", "night temperature", "Nachttemperatur", "Nachttemperatuur", "Nattemperatur", "temperatura w nocy", "nattemperatur", "température de nuit") MAKE_PSTR_LIST(nighttemp2, "nighttemp", "night temperature T1", "Nachttemperatur T1", "Nachttemperatuur T1", "Nattemperatur T1", "temperatura w nocy T1", "nattemperatur T1", "température nuit T1") MAKE_PSTR_LIST(ecotemp, "ecotemp", "eco temperature", "eco Temperatur", "Temperatuur eco", "Eko-temperatur", "temperatura w trybie eko", "øko temperatur", "température éco") -MAKE_PSTR_LIST(manualtemp, "manualtemp", "manual temperature", "manuelle Temperatur", "temperatuur handmatig", "Temperatur Manuell", "temperatura ustawiona ręcznie", "manuell temperatur", "température manuelle") +MAKE_PSTR_LIST(manualtemp, "manualtemp", "manual temperature", "manuelle Temperatur", "Temperatuur handmatig", "Temperatur Manuell", "temperatura ustawiona ręcznie", "manuell temperatur", "température manuelle") MAKE_PSTR_LIST(tempautotemp, "tempautotemp", "temporary set temperature automode", "temporäre Solltemperatur", "Streeftemperatuur automodus tijdelijk", "Temporär Aktivering av Auto-läge", "zadana temperatura w pomieszczenia w trybie \"auto\" (tymczasowa)", "temporær valgt temp i automodus", "température temporaire mode automatique") MAKE_PSTR_LIST(remoteseltemp, "remoteseltemp", "temporary set temperature from remote", "temporäre Solltemperatur Remote", "Temperatuur van afstandsbedieding", "Temperatur från fjärruppkoppling", "zadana zdalnie temperatura a pomieszczeniu (tymczasowa)", "temporær valgt temp fra fjernbetjening", "température temporaire depuis télécommande") MAKE_PSTR_LIST(comforttemp, "comforttemp", "comfort temperature", "Komforttemperatur", "Comforttemperatuur", "Komforttemperatur", "temperatura w trybie komfort", "komforttemperatur", "température confort") @@ -570,13 +581,11 @@ MAKE_PSTR_LIST(holidaymode, "holidaymode", "holiday mode", "Urlaubsbetrieb", "Va MAKE_PSTR_LIST(flowtempoffset, "flowtempoffset", "flow temperature offset for mixer", "Vorlauftemperaturanhebung", "Mixer aanvoertemperatuur offset", "Temperaturkorrigering Flödestemp. Blandningsventil", "korekta temperatury przepływu dla miksera", "temperaturkorrigering av blandingsventil", "décalage température de bascule pour mélangeur") MAKE_PSTR_LIST(reducemode, "reducemode", "reduce mode", "Absenkmodus", "Gereduceerde modus", "Reducerat Läge", "tryb zredukowany/obniżony", "", "mode réduction") MAKE_PSTR_LIST(noreducetemp, "noreducetemp", "no reduce below temperature", "Durchheizen unter", "Reduceermodus onderbreken onder", "Inaktivera reducering under", "bez redukcji poniżej temperatury", "inaktiver redusert nedre temp", "pas de réduction en dessous température") - MAKE_PSTR_LIST(reducetemp, "reducetemp", "off/reduce switch temperature", "Absenkmodus unter", "Onderste afschakeltemperatuur", "Avslag/Reducera under", "tryb zredukowany poniżej temperatury", "nedre avstengningstemperatur", "arrêt/réduction température bascule") MAKE_PSTR_LIST(vacreducetemp, "vacreducetemp", "vacations off/reduce switch temperature", "Urlaub Absenkmodus unter", "Vakantiemodus onderste afschakeltemperatuur", "Helg Avslag/Reducering under", "tryb urlopowy poniżej temperatury", "feriemodus nedre utkoblingstemperatur", "vacances – arrêt/réduction température bascule") MAKE_PSTR_LIST(vacreducemode, "vacreducemode", "vacations reduce mode", "Urlaub Absenkmodus", "Vakantie afschakelmodus", "Helg reduceringsläge", "redukcja w trakcie urlopu", "ferieavstengningsmodus", "mode réduction vacances") MAKE_PSTR_LIST(nofrostmode, "nofrostmode", "nofrost mode", "Frostschutz Modus", "Vorstbeveiligingsmodus", "Frostskyddsläge", "temperatura wiodąca dla ochrony przed zamarzaniem", "frostbeskyttelsesmodus", "mode protection gel") MAKE_PSTR_LIST(remotetemp, "remotetemp", "room temperature from remote", "Raumtemperatur Remote", "Ruimtetemperatuur van afstandsbediening", "Rumstemperatur från fjärr", "temperatura w pomieszczeniu (z termostatu)", "romstemperatur fra fjernbetjening", "température pièce depuis télécommande") - MAKE_PSTR_LIST(wwHolidays, "wwholidays", "holiday dates", "Feiertage", "Feestdagen", "Helgdagar", "dni świąteczne", "feriedager varmtvann", "dates vacances") MAKE_PSTR_LIST(wwVacations, "wwvacations", "vacation dates", "Urlaubstage", "Vakantiedagen", "Semesterdatum Varmvatten", "dni urlopowe", "ferie dato varmtvann", "dates vacances") MAKE_PSTR_LIST(holidays, "holidays", "holiday dates", "Feiertage", "Feestdagen", "Helgdatum", "święta", "helligdager", "dates vacances") @@ -622,8 +631,6 @@ MAKE_PSTR_LIST(solarPumpTurnoffDiff, "turnoffdiff", "pump turn off difference", MAKE_PSTR_LIST(pump2MinMod, "pump2minmod", "minimum pump 2 modulation", "minimale Modulation Pumpe 2", "Minimale modulatie pomp 2", "Min Modulering Pump 2", "minimalna modulacja pompy 2", "minimum pumpmodulering 2", "modulation minimale pompe 2") MAKE_PSTR_LIST(solarPump2TurnonDiff, "turnondiff2", "pump 2 turn on difference", "Einschalthysterese Pumpe 2", "Inschakelhysterese pomp 2", "Aktiveringshysteres Pump 2", "histereza załączenia pompy 2", "slå på hysteresepumpe 2", "différence activation pompe 2") MAKE_PSTR_LIST(solarPump2TurnoffDiff, "turnoffdiff2", "pump 2 turn off difference", "Ausschalthysterese Pumpe 2", "Uitschakelhysterese pomp 2", "Avslagshysteres Pump 2", "histereza wyłączenia pompy 2", "slå av hysteresepumpe 2", "différence arrêt pompe 2") - - MAKE_PSTR_LIST(collectorTemp, "collectortemp", "collector temperature (TS1)", "Kollektortemperatur (TS1)", "Collectortemperatuur (TS1)", "Kollektor Temperatur (TS1)", "temperatura kolektora (TS1)", "kollektor temperatur (TS1)", "température collecteur (TS1)") MAKE_PSTR_LIST(collector2Temp, "collector2temp", "collector 2 temperature (TS7)", "Kollector 2 Temperatur (TS7)", "Collector 2 temperatuur (TS7)", "Kollektor 2 Temperatur (TS7)", "temperatura kolektora 2 (TS7)", "kollektor 2 temperatur (TS7)", "température collecteur 2 (TS7)") MAKE_PSTR_LIST(cylBottomTemp, "cylbottomtemp", "cylinder bottom temperature (TS2)", "Speicher Bodentemperatur (TS2)", "Bodemtemperatuur zonneboiler (TS2)", "Cylindertemperatur Botten (TS2)", "temperatura na spodzie zasobnika (TS2)", "beredertemp i bunn (TS2)", "température fond de cylindre (TS2)") diff --git a/src/system.cpp b/src/system.cpp index bb02fc201..f0e30a524 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -1350,7 +1350,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp for (const auto & emsdevice : EMSESP::emsdevices) { if (emsdevice && (emsdevice->device_type() == device_class.first)) { JsonObject obj = devices.createNestedObject(); - obj["type"] = emsdevice->device_type_name(); + obj["type"] = emsdevice->device_type_name(); // non translated name obj["name"] = emsdevice->name(); obj["device id"] = Helpers::hextoa(emsdevice->device_id()); obj["product id"] = emsdevice->product_id(); diff --git a/src/web/WebCustomizationService.cpp b/src/web/WebCustomizationService.cpp index 94faa8ef7..bf1ed8b41 100644 --- a/src/web/WebCustomizationService.cpp +++ b/src/web/WebCustomizationService.cpp @@ -187,9 +187,10 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) { for (const auto & emsdevice : EMSESP::emsdevices) { if (emsdevice->has_entities()) { JsonObject obj = devices.createNestedObject(); - obj["i"] = emsdevice->unique_id(); // its unique id - obj["s"] = emsdevice->device_type_name() + " (" + emsdevice->name() + ")"; // shortname - obj["t"] = Helpers::toLower(emsdevice->device_type_name()); + obj["i"] = emsdevice->unique_id(); // its unique id + obj["s"] = std::string(emsdevice->device_type_2_device_name_translated()) + " (" + emsdevice->name() + ")"; // shortname, is device type translated + obj["tn"] = emsdevice->device_type_name(); // non-translated, lower-case + obj["t"] = emsdevice->device_type(); // internal device type ID } } diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index fc042558f..5331bd09f 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -81,7 +81,8 @@ void WebDataService::core_data(AsyncWebServerRequest * request) { if (emsdevice && (emsdevice->device_type() != EMSdevice::DeviceType::CONTROLLER || emsdevice->count_entities() > 0)) { JsonObject obj = devices.createNestedObject(); obj["id"] = Helpers::smallitoa(buffer, emsdevice->unique_id()); // a unique id as a string - obj["t"] = emsdevice->device_type_name(); // type + obj["tn"] = emsdevice->device_type_2_device_name_translated(); // translated device type name + obj["t"] = emsdevice->device_type(); // device type number obj["b"] = emsdevice->brand_to_string(); // brand obj["n"] = emsdevice->name(); // name obj["d"] = emsdevice->device_id(); // deviceid diff --git a/src/web/WebSettingsService.cpp b/src/web/WebSettingsService.cpp index e9c49d434..c1fa630a5 100644 --- a/src/web/WebSettingsService.cpp +++ b/src/web/WebSettingsService.cpp @@ -240,10 +240,12 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings) String old_local = settings.locale; settings.locale = root["locale"] | EMSESP_DEFAULT_LOCALE; + check_flag(prev, settings.low_clock, ChangeFlags::RESTART); EMSESP::system_.locale(settings.locale); #ifndef EMSESP_STANDALONE if (!old_local.equals(settings.locale)) { - add_flags(ChangeFlags::MQTT); + add_flags(ChangeFlags::RESTART); // force restart + // add_flags(ChangeFlags::MQTT); } #endif From 5c6d6da4f97a684f4738167697bfd51c07a6f0f3 Mon Sep 17 00:00:00 2001 From: Proddy Date: Tue, 3 Jan 2023 14:50:56 +0100 Subject: [PATCH 7/9] update packages --- interface/.typesafe-i18n.json | 2 +- interface/package-lock.json | 41 +++++++++++++++++++---------------- interface/package.json | 4 ++-- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/interface/.typesafe-i18n.json b/interface/.typesafe-i18n.json index ec7e7c401..e7723ecb2 100644 --- a/interface/.typesafe-i18n.json +++ b/interface/.typesafe-i18n.json @@ -1,5 +1,5 @@ { "adapter": "react", "baseLocale": "pl", - "$schema": "https://unpkg.com/typesafe-i18n@5.18.0/schema/typesafe-i18n.json" + "$schema": "https://unpkg.com/typesafe-i18n@5.18.1/schema/typesafe-i18n.json" } \ No newline at end of file diff --git a/interface/package-lock.json b/interface/package-lock.json index 358f79271..2a5582e26 100644 --- a/interface/package-lock.json +++ b/interface/package-lock.json @@ -12,7 +12,7 @@ "@emotion/styled": "^11.10.5", "@msgpack/msgpack": "^2.8.0", "@mui/icons-material": "^5.11.0", - "@mui/material": "^5.11.2", + "@mui/material": "^5.11.3", "@table-library/react-table-library": "4.0.23", "@types/lodash": "^4.14.191", "@types/node": "^18.11.18", @@ -33,7 +33,7 @@ "react-router-dom": "^6.6.1", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.18.0", + "typesafe-i18n": "^5.18.1", "typescript": "^4.9.4" }, "devDependencies": { @@ -2900,9 +2900,9 @@ } }, "node_modules/@mui/core-downloads-tracker": { - "version": "5.11.2", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.2.tgz", - "integrity": "sha512-ztLQELdSSuJFXezng8g5eCzy8mogtzMM8JcfG3HIGgUJ2RlAiBXI2Qe0adKmrJlF4FMat8vTaTeoiRNBZH4t1Q==", + "version": "5.11.3", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.3.tgz", + "integrity": "sha512-Bgb6//KtxY7IC7M5Pa5RKFX1wttc213mqpKqydnz3wn4BGDXfA5c0vf5nTu5zqsJeB4T3ysAJTRJhQ/E1GsZDQ==", "funding": { "type": "opencollective", "url": "https://opencollective.com/mui" @@ -2933,13 +2933,13 @@ } }, "node_modules/@mui/material": { - "version": "5.11.2", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.2.tgz", - "integrity": "sha512-PeraRDsghnDLzejorfe9ps1syxlB8UrGs+UKwg9GGlndv5Tghm+9nwuibrP2TCDC14mlryF+u2WlAOYaPPMwGA==", + "version": "5.11.3", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.3.tgz", + "integrity": "sha512-Oz+rMFiMtxzzDLUxKyyj4mSxF9ShmsBoJ9qvglXCYqklgSrEl1R/Z4hfPZ+2pWd5CriO8U/0CFHr4DksrlTiCw==", "dependencies": { "@babel/runtime": "^7.20.7", "@mui/base": "5.0.0-alpha.112", - "@mui/core-downloads-tracker": "^5.11.2", + "@mui/core-downloads-tracker": "^5.11.3", "@mui/system": "^5.11.2", "@mui/types": "^7.2.3", "@mui/utils": "^5.11.2", @@ -15031,8 +15031,9 @@ } }, "node_modules/typesafe-i18n": { - "version": "5.18.0", - "license": "MIT", + "version": "5.18.1", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.18.1.tgz", + "integrity": "sha512-piqmgTwN1RFHKXgADSRs8otzcGsRh/bZkAfXKs0hvMiJ7QyK8fRsOn0xXgu3MHWre37PJAbcEZt9ps0CN3NokA==", "bin": { "typesafe-i18n": "cli/typesafe-i18n.mjs" }, @@ -17714,9 +17715,9 @@ } }, "@mui/core-downloads-tracker": { - "version": "5.11.2", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.2.tgz", - "integrity": "sha512-ztLQELdSSuJFXezng8g5eCzy8mogtzMM8JcfG3HIGgUJ2RlAiBXI2Qe0adKmrJlF4FMat8vTaTeoiRNBZH4t1Q==" + "version": "5.11.3", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.3.tgz", + "integrity": "sha512-Bgb6//KtxY7IC7M5Pa5RKFX1wttc213mqpKqydnz3wn4BGDXfA5c0vf5nTu5zqsJeB4T3ysAJTRJhQ/E1GsZDQ==" }, "@mui/icons-material": { "version": "5.11.0", @@ -17725,13 +17726,13 @@ } }, "@mui/material": { - "version": "5.11.2", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.2.tgz", - "integrity": "sha512-PeraRDsghnDLzejorfe9ps1syxlB8UrGs+UKwg9GGlndv5Tghm+9nwuibrP2TCDC14mlryF+u2WlAOYaPPMwGA==", + "version": "5.11.3", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.3.tgz", + "integrity": "sha512-Oz+rMFiMtxzzDLUxKyyj4mSxF9ShmsBoJ9qvglXCYqklgSrEl1R/Z4hfPZ+2pWd5CriO8U/0CFHr4DksrlTiCw==", "requires": { "@babel/runtime": "^7.20.7", "@mui/base": "5.0.0-alpha.112", - "@mui/core-downloads-tracker": "^5.11.2", + "@mui/core-downloads-tracker": "^5.11.3", "@mui/system": "^5.11.2", "@mui/types": "^7.2.3", "@mui/utils": "^5.11.2", @@ -24845,7 +24846,9 @@ } }, "typesafe-i18n": { - "version": "5.18.0", + "version": "5.18.1", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.18.1.tgz", + "integrity": "sha512-piqmgTwN1RFHKXgADSRs8otzcGsRh/bZkAfXKs0hvMiJ7QyK8fRsOn0xXgu3MHWre37PJAbcEZt9ps0CN3NokA==", "requires": {} }, "typescript": { diff --git a/interface/package.json b/interface/package.json index 058f14c40..7e8c1fdc2 100644 --- a/interface/package.json +++ b/interface/package.json @@ -8,7 +8,7 @@ "@emotion/styled": "^11.10.5", "@msgpack/msgpack": "^2.8.0", "@mui/icons-material": "^5.11.0", - "@mui/material": "^5.11.2", + "@mui/material": "^5.11.3", "@table-library/react-table-library": "4.0.23", "@types/lodash": "^4.14.191", "@types/node": "^18.11.18", @@ -29,7 +29,7 @@ "react-router-dom": "^6.6.1", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.18.0", + "typesafe-i18n": "^5.18.1", "typescript": "^4.9.4" }, "scripts": { From cfce36c21274cb4ae8eb8af7ef31ff595d4d77be Mon Sep 17 00:00:00 2001 From: Proddy Date: Tue, 3 Jan 2023 15:00:04 +0100 Subject: [PATCH 8/9] small change --- src/emsesp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 07d93608c..feba4230d 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -354,8 +354,7 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) { // do this in the order of factory classes to keep a consistent order when displaying for (const auto & device_class : EMSFactory::device_handlers()) { for (const auto & emsdevice : emsdevices) { - auto device_type = emsdevice->device_type(); - if (emsdevice && (device_type == device_class.first)) { + if (emsdevice && (emsdevice->device_type() == device_class.first)) { // print header, with device type translated shell.printfln("%s: %s (%d)", emsdevice->device_type_2_device_name_translated(), emsdevice->to_string().c_str(), emsdevice->count_entities()); From bab9fd8ec4230f3bfa364ada9d11cdcc42447a05 Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 5 Jan 2023 09:45:33 +0100 Subject: [PATCH 9/9] updates to Translate Device Name #872 --- interface/.typesafe-i18n.json | 2 +- interface/src/project/DeviceIcon.tsx | 47 ++++++++++++++++++++-------- src/web/WebSettingsService.cpp | 1 - 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/interface/.typesafe-i18n.json b/interface/.typesafe-i18n.json index e7723ecb2..ec7e7c401 100644 --- a/interface/.typesafe-i18n.json +++ b/interface/.typesafe-i18n.json @@ -1,5 +1,5 @@ { "adapter": "react", "baseLocale": "pl", - "$schema": "https://unpkg.com/typesafe-i18n@5.18.1/schema/typesafe-i18n.json" + "$schema": "https://unpkg.com/typesafe-i18n@5.18.0/schema/typesafe-i18n.json" } \ No newline at end of file diff --git a/interface/src/project/DeviceIcon.tsx b/interface/src/project/DeviceIcon.tsx index 4d5ac8461..c862559e5 100644 --- a/interface/src/project/DeviceIcon.tsx +++ b/interface/src/project/DeviceIcon.tsx @@ -17,31 +17,52 @@ interface DeviceIconProps { } // matches emsdevice.h DeviceType +const enum DeviceType { + SYSTEM = 0, + DALLASSENSOR, + ANALOGSENSOR, + BOILER, + THERMOSTAT, + MIXER, + SOLAR, + HEATPUMP, + GATEWAY, + SWITCH, + CONTROLLER, + CONNECT, + ALERT, + PUMP, + GENERIC, + HEATSOURCE, + UNKNOWN +} + const DeviceIcon: FC = ({ type_id }) => { switch (type_id) { - case 1: - case 2: + case DeviceType.DALLASSENSOR: + case DeviceType.ANALOGSENSOR: return ; - case 3: + case DeviceType.BOILER: + case DeviceType.HEATSOURCE: return ; - case 4: + case DeviceType.THERMOSTAT: return ; - case 5: + case DeviceType.MIXER: return ; - case 6: + case DeviceType.SOLAR: return ; - case 7: + case DeviceType.HEATPUMP: return ; - case 8: + case DeviceType.GATEWAY: return ; - case 9: + case DeviceType.SWITCH: return ; - case 10: - case 11: + case DeviceType.CONTROLLER: + case DeviceType.CONNECT: return ; - case 12: + case DeviceType.ALERT: return ; - case 13: + case DeviceType.PUMP: return ; default: return null; diff --git a/src/web/WebSettingsService.cpp b/src/web/WebSettingsService.cpp index c1fa630a5..77802b2d5 100644 --- a/src/web/WebSettingsService.cpp +++ b/src/web/WebSettingsService.cpp @@ -245,7 +245,6 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings) #ifndef EMSESP_STANDALONE if (!old_local.equals(settings.locale)) { add_flags(ChangeFlags::RESTART); // force restart - // add_flags(ChangeFlags::MQTT); } #endif