fix negative values - #3297

This commit is contained in:
proddy
2026-10-18 16:11:58 +02:00
parent 9ff4dadedd
commit a52c98e789
+1 -1
View File
@@ -235,7 +235,7 @@ bool WebCustomEntityService::command_setvalue(const char * value, const int8_t i
return false; return false;
} }
int v = (f / entityItem.factor + 0.5); int v = (f / entityItem.factor + (v >= 0 ? 0.5 : -0.5));
if (entityItem.value_type == DeviceValueType::UINT8 || entityItem.value_type == DeviceValueType::INT8) { 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); 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) { } else if (entityItem.value_type == DeviceValueType::UINT16 || entityItem.value_type == DeviceValueType::INT16) {