From 19cd505b0c9e693831e034fc38f4130d991e2a54 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Sat, 16 Oct 2021 11:33:31 +0200 Subject: [PATCH] [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 --- .../tr064/internal/soap/SOAPValueConverter.java | 15 +++++++++++++++ .../src/main/resources/channels.xml | 8 ++++---- 2 files changed, 19 insertions(+), 4 deletions(-) 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 e175b22273d05..788bf20d785a6 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.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 @@ private State processMacSignalStrength(State state, Tr064ChannelConfig channelCo 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 afccf5454851c..489391c7543d6 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 @@ - + - + - + - +