From: Stefan Giehl Date: Sat, 16 Oct 2021 09:33:31 +0000 (+0200) Subject: [tr064] fix incorrectly reported decibel values for DSL Noise Margin and Attenuation... X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=19cd505b0c9e693831e034fc38f4130d991e2a54;p=openhab-addons.git [tr064] fix incorrectly reported decibel values for DSL Noise Margin and Attenuation (#11337) * [tr064] fix incorrectly reported decibel values for DSL Noise Margin and Attenuation Signed-off-by: Stefan Giehl * apply review feedback Signed-off-by: Stefan Giehl --- diff --git a/bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/soap/SOAPValueConverter.java b/bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/soap/SOAPValueConverter.java index e175b22273..788bf20d78 100644 --- a/bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/soap/SOAPValueConverter.java +++ b/bundles/org.openhab.binding.tr064/src/main/java/org/openhab/binding/tr064/internal/soap/SOAPValueConverter.java @@ -38,6 +38,7 @@ import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; +import org.openhab.core.library.unit.Units; import org.openhab.core.types.Command; import org.openhab.core.types.State; import org.openhab.core.types.UnDefType; @@ -200,6 +201,20 @@ public class SOAPValueConverter { return mappedSignalStrength; } + /** + * post processor for decibel values (which are served as deca decibel) + * + * @param state the channel value in deca decibel + * @param channelConfig channel config of the channel + * @return the state converted to decibel + */ + @SuppressWarnings("unused") + private State processDecaDecibel(State state, Tr064ChannelConfig channelConfig) { + Float value = state.as(DecimalType.class).floatValue() / 10; + + return new QuantityType(value, Units.DECIBEL); + } + /** * post processor for answering machine new messages channel * diff --git a/bundles/org.openhab.binding.tr064/src/main/resources/channels.xml b/bundles/org.openhab.binding.tr064/src/main/resources/channels.xml index afccf54548..489391c754 100644 --- a/bundles/org.openhab.binding.tr064/src/main/resources/channels.xml +++ b/bundles/org.openhab.binding.tr064/src/main/resources/channels.xml @@ -284,25 +284,25 @@ - + - + - + - +