Merge with v24.11.7

This commit is contained in:
Benoit Leforestier 2024-12-14 11:56:48 +01:00
parent df1d12d33a
commit 5452a82781
6 changed files with 56 additions and 35 deletions

View File

@ -82,6 +82,10 @@ private:
String _i18n_current_power_w; String _i18n_current_power_w;
String _i18n_yield_total_mwh; String _i18n_yield_total_mwh;
String _i18n_yield_total_kwh; String _i18n_yield_total_kwh;
String _i18n_powermeter_power_w;
String _i18n_powermeter_power_kw;
String _i18n_pm_positive_today_kwh;
String _i18n_pm_negative_today_kwh;
}; };
extern DisplayGraphicClass Display; extern DisplayGraphicClass Display;

View File

@ -23,7 +23,9 @@ public:
String& offline, String& offline,
String& power_w, String& power_kw, String& power_w, String& power_kw,
String& yield_today_wh, String& yield_today_kwh, String& yield_today_wh, String& yield_today_kwh,
String& yield_total_kwh, String& yield_total_mwh); String& yield_total_kwh, String& yield_total_mwh,
String& yield_powermeter_power_w, String& yield_powermeter_power_kw,
String& yield_pm_positive_today_kwh, String& yield_pm_negative_today_kwh);
private: private:
void readLangPacks(); void readLangPacks();

View File

@ -4,8 +4,8 @@
*/ */
#include "Display_Graphic.h" #include "Display_Graphic.h"
#include "Datastore.h" #include "Datastore.h"
#include "JsyMk.h"
#include "I18n.h" #include "I18n.h"
#include "JsyMk.h"
#include <NetworkSettings.h> #include <NetworkSettings.h>
#include <map> #include <map>
#include <time.h> #include <time.h>
@ -185,6 +185,10 @@ void DisplayGraphicClass::setLocale(const String& locale)
_i18n_yield_today_kwh = i18n_yield_today_kwh[idx]; _i18n_yield_today_kwh = i18n_yield_today_kwh[idx];
_i18n_yield_total_kwh = i18n_yield_total_kwh[idx]; _i18n_yield_total_kwh = i18n_yield_total_kwh[idx];
_i18n_yield_total_mwh = i18n_yield_total_mwh[idx]; _i18n_yield_total_mwh = i18n_yield_total_mwh[idx];
_i18n_powermeter_power_w = i18n_powermeter_power_w[idx];
_i18n_powermeter_power_kw = i18n_powermeter_power_kw[idx];
_i18n_pm_positive_today_kwh = i18n_pm_positive_today_kwh[idx];
_i18n_pm_negative_today_kwh = i18n_pm_negative_today_kwh[idx];
I18n.readDisplayStrings(locale, I18n.readDisplayStrings(locale,
_i18n_date_format, _i18n_date_format,
@ -194,7 +198,11 @@ void DisplayGraphicClass::setLocale(const String& locale)
_i18n_yield_today_wh, _i18n_yield_today_wh,
_i18n_yield_today_kwh, _i18n_yield_today_kwh,
_i18n_yield_total_kwh, _i18n_yield_total_kwh,
_i18n_yield_total_mwh); _i18n_yield_total_mwh,
_i18n_powermeter_power_w,
_i18n_powermeter_power_kw,
_i18n_pm_positive_today_kwh,
_i18n_pm_negative_today_kwh);
} }
void DisplayGraphicClass::setDiagramMode(DiagramMode_t mode) void DisplayGraphicClass::setDiagramMode(DiagramMode_t mode)
@ -235,9 +243,11 @@ void DisplayGraphicClass::loop()
const char direction = (JsyMk.getFieldValue(0, JsyMkClass::Field_t::NEGATIVE) > 0) ? 'O' : 'I'; const char direction = (JsyMk.getFieldValue(0, JsyMkClass::Field_t::NEGATIVE) > 0) ? 'O' : 'I';
if (watts > 999) { if (watts > 999) {
snprintf(_fmtText, sizeof(_fmtText), i18n_powermeter_power_kw[_display_language], direction, watts / 1000); // snprintf(_fmtText, sizeof(_fmtText), i18n_powermeter_power_kw[_display_language], direction, watts / 1000);
snprintf(_fmtText, sizeof(_fmtText), _i18n_powermeter_power_kw.c_str(), direction, watts / 1000);
} else { } else {
snprintf(_fmtText, sizeof(_fmtText), i18n_powermeter_power_w[_display_language], direction, watts); // snprintf(_fmtText, sizeof(_fmtText), i18n_powermeter_power_w[_display_language], direction, watts);
snprintf(_fmtText, sizeof(_fmtText), _i18n_powermeter_power_w.c_str(), direction, watts);
} }
printText(_fmtText, 0); printText(_fmtText, 0);
} }
@ -288,28 +298,28 @@ void DisplayGraphicClass::loop()
if (displayPowerMeter) { if (displayPowerMeter) {
// Daily Input // Daily Input
float wattsInput = JsyMk.getFieldValue(0, JsyMkClass::Field_t::TODAY_POSITIVE_ENERGY); float wattsInput = JsyMk.getFieldValue(0, JsyMkClass::Field_t::TODAY_POSITIVE_ENERGY);
snprintf(_fmtText, sizeof(_fmtText), i18n_pm_positive_today_kwh[_display_language], wattsInput); snprintf(_fmtText, sizeof(_fmtText), _i18n_pm_positive_today_kwh.c_str(), wattsInput);
printText(_fmtText, 1); printText(_fmtText, 1);
// Daily Output // Daily Output
float wattsOutput = JsyMk.getFieldValue(0, JsyMkClass::Field_t::TODAY_NEGATIVE_ENERGY); float wattsOutput = JsyMk.getFieldValue(0, JsyMkClass::Field_t::TODAY_NEGATIVE_ENERGY);
snprintf(_fmtText, sizeof(_fmtText), i18n_pm_negative_today_kwh[_display_language], wattsOutput); snprintf(_fmtText, sizeof(_fmtText), _i18n_pm_negative_today_kwh.c_str(), wattsOutput);
printText(_fmtText, 2); printText(_fmtText, 2);
} else { } else {
// Daily production // Daily production
float wattsToday = Datastore.getTotalAcYieldDayEnabled(); float wattsToday = Datastore.getTotalAcYieldDayEnabled();
if (wattsToday >= 10000) { if (wattsToday >= 10000) {
snprintf(_fmtText, sizeof(_fmtText), _i18n_yield_today_kwh.c_str(), wattsToday / 1000); snprintf(_fmtText, sizeof(_fmtText), _i18n_yield_today_kwh.c_str(), wattsToday / 1000);
} else { } else {
snprintf(_fmtText, sizeof(_fmtText), _i18n_yield_today_wh.c_str(), wattsToday); snprintf(_fmtText, sizeof(_fmtText), _i18n_yield_today_wh.c_str(), wattsToday);
} }
printText(_fmtText, 1); printText(_fmtText, 1);
// Total production // Total production
const float wattsTotal = Datastore.getTotalAcYieldTotalEnabled(); const float wattsTotal = Datastore.getTotalAcYieldTotalEnabled();
auto const format = (wattsTotal >= 1000) ? _i18n_yield_total_mwh : _i18n_yield_total_kwh; auto const format = (wattsTotal >= 1000) ? _i18n_yield_total_mwh : _i18n_yield_total_kwh;
snprintf(_fmtText, sizeof(_fmtText), format.c_str(), wattsTotal); snprintf(_fmtText, sizeof(_fmtText), format.c_str(), wattsTotal);
printText(_fmtText, 2); printText(_fmtText, 2);
} }
//=====> IP or Date-Time ======== //=====> IP or Date-Time ========

View File

@ -44,7 +44,9 @@ void I18nClass::readDisplayStrings(
String& offline, String& offline,
String& power_w, String& power_kw, String& power_w, String& power_kw,
String& yield_today_wh, String& yield_today_kwh, String& yield_today_wh, String& yield_today_kwh,
String& yield_total_kwh, String& yield_total_mwh) String& yield_total_kwh, String& yield_total_mwh,
String& yield_powermeter_power_w, String& yield_powermeter_power_kw,
String& yield_pm_positive_today_kwh, String& yield_pm_negative_today_kwh)
{ {
auto filename = getFilenameByLocale(locale); auto filename = getFilenameByLocale(locale);
if (filename == "") { if (filename == "") {
@ -104,6 +106,22 @@ void I18nClass::readDisplayStrings(
yield_total_mwh = displayData["yield_total_mwh"].as<String>(); yield_total_mwh = displayData["yield_total_mwh"].as<String>();
} }
if (displayData["yield_powermeter_power_w"].as<String>() != "null") {
yield_powermeter_power_w = displayData["yield_powermeter_power_w"].as<String>();
}
if (displayData["yield_powermeter_power_kw"].as<String>() != "null") {
yield_powermeter_power_kw = displayData["yield_powermeter_power_kw"].as<String>();
}
if (displayData["yield_pm_positive_today_kwh"].as<String>() != "null") {
yield_pm_positive_today_kwh = displayData["yield_pm_positive_today_kwh"].as<String>();
}
if (displayData["yield_pm_negative_today_kwh"].as<String>() != "null") {
yield_pm_negative_today_kwh = displayData["yield_pm_negative_today_kwh"].as<String>();
}
f.close(); f.close();
} }

View File

@ -304,7 +304,7 @@ void MqttHandleHassClass::publishPowerMeterField(size_t channel, JsyMkClass::Fie
serializeJson(root, buffer); serializeJson(root, buffer);
publish(configTopic, buffer); publish(configTopic, buffer);
} else { } else {
publish(configTopic, {}); publish(configTopic, String {});
} }
} }

View File

@ -157,19 +157,6 @@ void setup()
JsyMk.init(scheduler); JsyMk.init(scheduler);
MessageOutput.println("done"); MessageOutput.println("done");
// Check for default DTU serial
MessageOutput.print("Check for default DTU serial... ");
if (config.Dtu.Serial == DTU_SERIAL) {
MessageOutput.print("generate serial based on ESP chip id: ");
const uint64_t dtuId = Utils::generateDtuSerial();
MessageOutput.printf("%0x%08x... ",
((uint32_t)((dtuId >> 32) & 0xFFFFFFFF)),
((uint32_t)(dtuId & 0xFFFFFFFF)));
config.Dtu.Serial = dtuId;
Configuration.write();
}
MessageOutput.println("done");
InverterSettings.init(scheduler); InverterSettings.init(scheduler);
Datastore.init(scheduler); Datastore.init(scheduler);