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

[tr064] Fix incorrectly reported decibel values for DSL Noise Margin and Attenuation #11337

Merged
merged 2 commits into from
Oct 16, 2021
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.
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 @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,25 +284,25 @@
<item type="Number:Dimensionless" unit="dB" statePattern="%.1f dB"/>
<service deviceType="urn:dslforum-org:device:WANDevice:1"
serviceId="urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1"/>
<getAction name="GetInfo" argument="NewDownstreamNoiseMargin"/>
<getAction name="GetInfo" argument="NewDownstreamNoiseMargin" postProcessor="processDecaDecibel"/>
</channel>
<channel name="dslUpstreamNoiseMargin" label="DSL Upstream Noise Margin">
<item type="Number:Dimensionless" unit="dB" statePattern="%.1f dB"/>
<service deviceType="urn:dslforum-org:device:WANDevice:1"
serviceId="urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1"/>
<getAction name="GetInfo" argument="NewUpstreamNoiseMargin"/>
<getAction name="GetInfo" argument="NewUpstreamNoiseMargin" postProcessor="processDecaDecibel"/>
</channel>
<channel name="dslDownstreamAttenuation" label="DSL Downstream Attenuation">
<item type="Number:Dimensionless" unit="dB" statePattern="%.1f dB"/>
<service deviceType="urn:dslforum-org:device:WANDevice:1"
serviceId="urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1"/>
<getAction name="GetInfo" argument="NewDownstreamAttenuation"/>
<getAction name="GetInfo" argument="NewDownstreamAttenuation" postProcessor="processDecaDecibel"/>
</channel>
<channel name="dslUpstreamAttenuation" label="DSL Upstream Attenuation">
<item type="Number:Dimensionless" unit="dB" statePattern="%.1f dB"/>
<service deviceType="urn:dslforum-org:device:WANDevice:1"
serviceId="urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1"/>
<getAction name="GetInfo" argument="NewUpstreamAttenuation"/>
<getAction name="GetInfo" argument="NewUpstreamAttenuation" postProcessor="processDecaDecibel"/>
</channel>
<channel name="dslFECErrors" label="DSL FEC Errors">
<item type="Number:Dimensionless"/>
Expand Down