Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[knx] Remove workaround for DPT 14 #14503

Merged
merged 1 commit into from
Feb 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
Expand Down Expand Up @@ -899,28 +897,6 @@ private String quantityTypeToDPTValue(QuantityType<?> qt, int mainNumber, int su
case 8:
return translator3BitControlled.getControlBit() ? UpDownType.DOWN : UpDownType.UP;
}
case 14:
/*
* FIXME: Workaround for a bug in Calimero / Openhab DPTXlator4ByteFloat.makeString(): is using a
* locale when
* translating a Float to String. It could happen the a ',' is used as separator, such as
* 3,14159E20.
* Openhab's DecimalType expects this to be in US format and expects '.': 3.14159E20.
* There is no issue with DPTXlator2ByteFloat since calimero is using a non-localized translation
* there.
*/
DPTXlator4ByteFloat translator4ByteFloat = (DPTXlator4ByteFloat) translator;
Float f = translator4ByteFloat.getValueFloat();
if (Math.abs(f) < 100000) {
value = String.valueOf(f);
} else {
NumberFormat dcf = NumberFormat.getInstance(Locale.US);
if (dcf instanceof DecimalFormat) {
((DecimalFormat) dcf).applyPattern("0.#####E0");
}
value = dcf.format(f);
}
break;
case 18:
DPTXlatorSceneControl translatorSceneControl = (DPTXlatorSceneControl) translator;
int decimalValue = translatorSceneControl.getSceneNumber();
Expand Down