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

[sensebox] Fixed handling of micro sign and greek letter mu #7204

Merged
merged 1 commit into from Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -96,12 +96,6 @@ public SenseBoxData reallyFetchDataFromServer(String senseBoxId) {
}

for (SenseBoxSensor sensor : parsedData.getSensors()) {
// the uom library uses the 'MICRO SIGN', so if we encounter the GREEK SMALL LETTER MU,
// replace it with the proper representation.
if (sensor.getUnit() != null) {
sensor.getUnit().replaceAll("\u03bc", "\00b5");
}

if ("VEML6070".equals(sensor.getSensorType())) {
// "unit" is not nicely comparable, so use sensor type for now
parsedData.setUvIntensity(sensor);
Expand Down
Expand Up @@ -12,7 +12,6 @@
*/
package org.openhab.binding.sensebox.internal.handler;

import static org.eclipse.smarthome.core.library.unit.MetricPrefix.HECTO;
import static org.openhab.binding.sensebox.internal.SenseBoxBindingConstants.*;

import java.math.BigDecimal;
Expand All @@ -27,6 +26,7 @@
import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.library.types.PointType;
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.unit.MetricPrefix;
import org.eclipse.smarthome.core.library.unit.SIUnits;
import org.eclipse.smarthome.core.library.unit.SmartHomeUnits;
import org.eclipse.smarthome.core.thing.ChannelUID;
Expand Down Expand Up @@ -287,7 +287,7 @@ private State decimalFromSensor(@Nullable SenseBoxSensor sensorData) {
// Some stations report measurements in Pascal, but send 'hPa' as units...
bd = bd.divide(ONEHUNDRED);
}
result = new QuantityType<>(bd, HECTO(SIUnits.PASCAL));
result = new QuantityType<>(bd, MetricPrefix.HECTO(SIUnits.PASCAL));
break;
case "lx":
result = new QuantityType<>(bd, SmartHomeUnits.LUX);
Expand Down
Expand Up @@ -57,7 +57,9 @@ public void setTitle(String title) {
}

public String getUnit() {
return unit;
// the uom library uses the 'MICRO SIGN', so if we encounter the GREEK SMALL LETTER MU,
// replace it with the proper representation.
return unit != null ? unit.replaceAll("\u03bc", "\u00b5") : "";
}

public void setUnit(String unit) {
Expand Down