diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index e172e71b5..e067f33be 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -67,6 +67,7 @@ This release is based on the latest Espressif/Arduino core version 3. It brings - syslog dropped messages at DEBUG because the queue held only 10 lines, less than one bus burst. The queue is now 100. Syslog success and failure counts are included in the MQTT heartbeat, and the Activity page rounds the quality percentage instead of truncating it [#3284](https://github.com/emsesp/EMS-ESP32/issues/3284) - a read or write aimed at EMS-ESP's own bus id was left unanswered, so the sender waited for a timeout. EMS-ESP now sends an empty reply to those reads and acknowledges those writes [#3094](https://github.com/emsesp/EMS-ESP32/issues/3094) - a second boiler monitor `0xE4` carrying `0xFFFF` cleared a valid `pc0Flow`. That empty value is now ignored [#3224](https://github.com/emsesp/EMS-ESP32/issues/3224) +- writing a negative custom entity value was always 1 too high because float-to-int rounding always added +0.5. Negative values now round the same way as positive ones [#3297](https://github.com/emsesp/EMS-ESP32/issues/3297) ## Changed diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index 15c0ab193..5586536dc 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -235,7 +235,7 @@ bool WebCustomEntityService::command_setvalue(const char * value, const int8_t i return false; } - int v = (f / entityItem.factor + (v >= 0 ? 0.5 : -0.5)); + int v = (f / entityItem.factor + (f >= 0 ? 0.5 : -0.5)); if (entityItem.value_type == DeviceValueType::UINT8 || entityItem.value_type == DeviceValueType::INT8) { EMSESP::send_write_request(entityItem.type_id, entityItem.device_id, entityItem.offset, v, entityItem.type_id); } else if (entityItem.value_type == DeviceValueType::UINT16 || entityItem.value_type == DeviceValueType::INT16) {