Merge pull request #2679 from MichaelDvP/dev

bosch texts to utf8, add entities #2669
This commit is contained in:
Proddy
2025-10-24 21:06:29 +02:00
committed by GitHub
10 changed files with 132 additions and 18 deletions

View File

@@ -28,6 +28,7 @@ For more details go to [docs.emsesp.org](https://docs.emsesp.org/).
- SRC plus thermostats [#2636](https://github.com/emsesp/EMS-ESP32/issues/2636)
- Greenstar 2000 [#2645](https://github.com/emsesp/EMS-ESP32/issues/2645)
- RC3xx `dhw modetype` [#2659](https://github.com/emsesp/EMS-ESP32/discussions/2659)
- new boiler entities VR0,VR1, compressor speed [#2669](https://github.com/emsesp/EMS-ESP32/issues/2669)
## Fixed

View File

@@ -857,7 +857,7 @@ void EMSdevice::publish_value(void * value_p) const {
break;
case DeviceValueType::STRING:
if (Helpers::hasValue((char *)(value_p))) {
strlcpy(payload, (char *)(value_p), sizeof(payload));
Helpers::render_string(payload, (char *)(value_p), sizeof(payload));
}
break;
default:
@@ -967,7 +967,8 @@ void EMSdevice::generate_values_web(JsonObject output, const bool is_dashboard)
// handle TEXT strings
else if (dv.type == DeviceValueType::STRING) {
obj["v"] = (char *)(dv.value_p);
char s[55];
obj["v"] = Helpers::render_string(s, (char *)(dv.value_p), sizeof(s));
}
// handle ENUMs
@@ -1079,7 +1080,8 @@ void EMSdevice::generate_values_web_customization(JsonArray output) {
// handle TEXT strings
else if (dv.type == DeviceValueType::STRING) {
obj["v"] = (char *)(dv.value_p);
char s[55];
obj["v"] = Helpers::render_string(s, (char *)(dv.value_p), sizeof(s));
}
// handle ENUMs
@@ -1648,7 +1650,8 @@ void EMSdevice::get_value_json(JsonObject json, DeviceValue & dv) {
case DeviceValueType::STRING:
if (Helpers::hasValue((char *)(dv.value_p))) {
json[value] = (char *)(dv.value_p);
char s[55];
json[value] = Helpers::render_string(s, (char *)(dv.value_p), sizeof(s));
}
json[type] = ("string");
break;
@@ -1782,7 +1785,8 @@ bool EMSdevice::generate_values(JsonObject output, const int8_t tag_filter, cons
// handle TEXT strings
else if (dv.type == DeviceValueType::STRING) {
json[name] = (char *)(dv.value_p);
char s[55];
json[name] = Helpers::render_string(s, (char *)(dv.value_p), sizeof(s));
}
// handle ENUMs

View File

@@ -381,6 +381,95 @@ char * Helpers::render_value(char * result, const uint32_t value, const int8_t f
return result;
}
// convert special Latin1 characters to UTF8
char * Helpers::render_string(char * result, const char * c, const uint8_t len) {
char * p = result;
while (*c != '\0' && (p - result < len)) {
switch ((uint8_t)*c) {
case 0xC4: // Ä
*p = 0xC3;
*(++p) = 0x84;
break;
case 0xD6: // Ö
*p = 0xC3;
*(++p) = 0x96;
break;
case 0xDC: // Ü
*p = 0xC3;
*(++p) = 0x9C;
break;
case 0xDF: // ß
*p = 0xC3;
*(++p) = 0x9F;
break;
case 0xE4: // ä
*p = 0xC3;
*(++p) = 0xA4;
break;
case 0xF6: // ö
*p = 0xC3;
*(++p) = 0xB6;
break;
case 0xFC: // ü
*p = 0xC3;
*(++p) = 0xBC;
break;
case 0xF0: // greek capital Xi, used for boiler servicecode dhw+heat
*p = 0xCE;
*(++p) = 0x9E;
break;
default:
*p = (*c & 0x80) ? '?' : *c;
break;
}
c++;
p++;
}
*p = '\0'; // terminat result
return result;
}
char * Helpers::utf8tolatin1(char * result, const char * c, const uint8_t len) {
char * p = result;
while (*c != '\0' && (p - result < len)) {
if ((uint8_t)*c == 0xC3) {
c++;
switch ((uint8_t)*c) {
case 0x84: // Ä
*p = 0xC4;
break;
case 0x96: // Ö
*p = 0xD6;
break;
case 0x9C: // Ü
*p = 0xDC;
break;
case 0x9F: // ß
*p = 0xDF;
break;
case 0xA4: // ä
*p = 0xE4;
break;
case 0xB6: // ö
*p = 0xF6;
break;
case 0xBC: // ü
*p = 0xFC;
break;
default:
break;
}
} else if ((uint8_t)*c > 127) {
*p = '?';
} else {
*p = *c;
}
c++;
p++;
}
*p = '\0'; // terminat result
return result;
}
// creates string of hex values from an array of bytes
std::string Helpers::data_to_hex(const uint8_t * data, const uint8_t length) {
if (length == 0) {

View File

@@ -34,6 +34,8 @@ class Helpers {
static char * render_value(char * result, const int16_t value, const int8_t format, const uint8_t fahrenheit = 0);
static char * render_value(char * result, const int32_t value, const int8_t format, const uint8_t fahrenheit = 0);
static char * render_boolean(char * result, const bool value, const bool dashboard = false);
static char * render_string(char * result, const char * s, const uint8_t len);
static char * utf8tolatin1(char * result, const char * s, const uint8_t len);
static char * hextoa(char * result, const uint8_t value);
static char * hextoa(char * result, const uint16_t value);

View File

@@ -459,6 +459,9 @@ MAKE_TRANSLATION(hpBrineIn, "hpbrinein", "brine in/evaporator", "Sole in/Verdamp
MAKE_TRANSLATION(hpBrineOut, "hpbrineout", "brine out/condenser", "Sole aus/Kondensator", "pekel uit/condensor", "Brine ut (kondensor)", "temperatura glikolu na wyjściu kolektora (TB1)", "Brine ut/kondensor", "sortie saumure/condenseur", "anahtar valfi", "salamoia nell uscita evaporatore", "výstup soľanky/kondenzátor", "solanka out/kondenzátor")
MAKE_TRANSLATION(hpSwitchValve, "hpswitchvalve", "switch valve", "Schaltventil", "schakelklep", "Växelventil", "zawór przełączający", "skifteventil", "valve de commutation", "ısı pompası aktivitesi", "valvola commutazione pompa di calore", "prepínací ventil", "přepínací ventil")
MAKE_TRANSLATION(hpActivity, "hpactivity", "compressor activity", "Kompressoraktivität", "Compressoractiviteit", "Kompressoraktivitet", "pompa ciepła, aktywność sprężarki", "kompressoraktivitet", "hp ısı pompası", "attività compressore", "činnosť kompresora", "činnost kompresoru")
MAKE_TRANSLATION(hpTargetSpd, "hptargetspd", "compressor target speed", "Kompressorsolldrehzahl") // TODO translate
MAKE_TRANSLATION(receiverValveVr0, "recvalve", "receiver valve VR0", "Eingangsventil VR0") // TODO translate
MAKE_TRANSLATION(expansionValveVr1, "expvalve", "expansion valve VR1", "Ausdehnungsventil VR1") // TODO translate
MAKE_TRANSLATION(hpMaxPower, "hpmaxpower", "compressor max power", "max. Kompressorleistung", "", "Max. Kompressoreffekt", "maksymalna wydajność sprężarki", "", "", "", "", "max výkon kompresora", "maximální výkon kompresoru") // TODO translate
MAKE_TRANSLATION(pvMaxComp, "pvmaxcomp", "pv compressor max power", "PV max. Kompressorleistung", "", "PV Max. Kompressoreffekt", "maksymalna wydajność sprężarki", "", "", "", "", "pv max výkon kompresora", "maximální výkon PV kompresoru") // TODO translate

View File

@@ -1828,7 +1828,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
obj["brand"] = emsdevice->brand_to_char();
obj["version"] = emsdevice->version();
obj["entities"] = emsdevice->count_entities();
char result[500];
char result[1000];
(void)emsdevice->show_telegram_handlers(result, sizeof(result), EMSdevice::Handlers::RECEIVED);
if (result[0] != '\0') {
obj["handlersReceived"] = result; // don't show handlers if there aren't any

View File

@@ -589,7 +589,10 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &hpBrinePumpSpd_, DeviceValueType::UINT8, FL_(hpBrinePumpSpd), DeviceValueUOM::PERCENT);
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &hpSwitchValve_, DeviceValueType::BOOL, FL_(hpSwitchValve), DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &hpCompSpd_, DeviceValueType::UINT8, FL_(hpCompSpd), DeviceValueUOM::PERCENT);
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &hpTargetSpd_, DeviceValueType::UINT8, FL_(hpTargetSpd), DeviceValueUOM::PERCENT);
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &hpCircSpd_, DeviceValueType::UINT8, FL_(hpCircSpd), DeviceValueUOM::PERCENT);
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &receiverValveVr0_, DeviceValueType::UINT8, FL_(receiverValveVr0), DeviceValueUOM::PERCENT);
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &expansionValveVr1_, DeviceValueType::UINT8, FL_(expansionValveVr1), DeviceValueUOM::PERCENT);
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
&hpBrineIn_,
DeviceValueType::INT16,
@@ -1305,7 +1308,8 @@ void Boiler::process_UBAMonitorFast(std::shared_ptr<const Telegram> telegram) {
if ((telegram->message_length > 18) && (telegram->offset == 0)) {
char serviceCode[4];
telegram->read_value(serviceCode[0], 18);
serviceCode[0] = (serviceCode[0] == (char)0xF0) ? '~' : serviceCode[0];
// 0xF0 for 3 stacked horizontal lines like greek capital Xi
// serviceCode[0] = (serviceCode[0] == (char)0xF0) ? '~' : serviceCode[0];
telegram->read_value(serviceCode[1], 19);
serviceCode[2] = '\0'; // null terminate string
has_update(serviceCode_, serviceCode, sizeof(serviceCode_));
@@ -1471,9 +1475,9 @@ void Boiler::process_UBAMonitorFastPlus(std::shared_ptr<const Telegram> telegram
if ((telegram->message_length > 3) && (telegram->offset == 0)) {
char serviceCode[4] = {0};
telegram->read_value(serviceCode[0], 1);
serviceCode[0] = (serviceCode[0] == (char)0xF0) ? '~' : serviceCode[0];
// serviceCode[0] = (serviceCode[0] == (char)0xF0) ? '~' : serviceCode[0];
telegram->read_value(serviceCode[1], 2);
serviceCode[1] = (serviceCode[1] == (char)0xF0) ? '~' : serviceCode[1];
// serviceCode[1] = (serviceCode[1] == (char)0xF0) ? '~' : serviceCode[1];
telegram->read_value(serviceCode[2], 3);
serviceCode[3] = '\0';
has_update(serviceCode_, serviceCode, sizeof(serviceCode_));
@@ -1725,6 +1729,11 @@ void Boiler::process_HpPower(std::shared_ptr<const Telegram> telegram) {
has_bitupdate(telegram, hpInput[2].state, 1, 6);
has_bitupdate(telegram, hpInput[3].state, 1, 7);
// from https://github.com/emsesp/EMS-ESP32/issues/2669
has_update(telegram, hpTargetSpd_, 22);
has_update(telegram, receiverValveVr0_, 15);
has_update(telegram, expansionValveVr1_, 16);
// has_update(hpHeatingOn_, hpActivity_ == 1 ? 0xFF : 0);
// has_update(hpCoolingOn_, hpActivity_ == 2 ? 0xFF : 0);
// has_update(hpWwOn_, hpActivity_ == 3 ? 0xFF : 0);

View File

@@ -246,6 +246,9 @@ class Boiler : public EMSdevice {
uint8_t hpSetDiffPress_;
uint8_t fan_;
uint8_t hpshutdown_;
uint8_t receiverValveVr0_;
uint8_t expansionValveVr1_;
uint8_t hpTargetSpd_;
// Pool unit
int8_t poolSetTemp_;

View File

@@ -49,6 +49,12 @@ Connect::Connect(uint8_t device_type, uint8_t device_id, uint8_t product_id, con
// 0x2040, broadcast 36 bytes:
// data: 0E 60 00 DF 0D AF 0A 46 0A 46 02 9A 1C 53 1C 53 12 AD 12 AD 00 00 13 C2
// data: 1F 37 1F 37 00 00 00 00 18 97 11 27 (offset 24)
#if defined(EMSESP_STANDALONE)
// if we're just dumping out values, create a single dummy SRC
auto new_room = std::make_shared<Connect::RoomCircuit>(0);
room_circuits_.push_back(new_room);
register_device_values_room(new_room);
#endif
}
/*
* OutdoorTemp - type 0xD1 - external temperature
@@ -145,8 +151,7 @@ void Connect::process_roomThermostatName(std::shared_ptr<const Telegram> telegra
has_update(telegram, rc->icon_, 0);
for (uint8_t i = telegram->offset; i < telegram->message_length + telegram->offset && i < 100; i++) {
if ((i > 1) && (i % 2) == 0) {
// replace ISOLatin1 characters with questionmark
rc->name_[(i - 2) / 2] = telegram->message_data[i - telegram->offset] & 0x80 ? '?' : telegram->message_data[i - telegram->offset];
rc->name_[(i - 2) / 2] = telegram->message_data[i - telegram->offset];
}
}
rc->name_[50] = '\0'; // make sure name is terminated
@@ -229,14 +234,12 @@ bool Connect::set_name(const char * value, const int8_t id) {
if (rc == nullptr || value == nullptr || strlen(value) > 50) {
return false;
}
uint8_t len = strlen(value) * 2 + 2;
Helpers::utf8tolatin1(rc->name_, value, sizeof(rc->name_));
uint8_t len = strlen(rc->name_) * 2 + 2;
uint8_t data[len];
for (uint8_t i = 0; i < strlen(value) + 1; i++) { // include terminating '\0'
for (uint8_t i = 0; i < strlen(rc->name_) + 1; i++) { // include terminating '\0'
data[2 * i] = 0;
data[2 * i + 1] = value[i];
if (value[i] & 0x80) { // accept only ascii names
return false;
}
data[2 * i + 1] = rc->name_[i];
}
uint8_t ofs = 0;
while (len > 0) {

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.7.3-dev.21"
#define EMSESP_APP_VERSION "3.7.3-dev.22"