mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[knx] Fix warnings and remove TODOs (#16394)
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
0f6ae6506e
commit
e96b68d831
@ -131,7 +131,8 @@ public abstract class KNXChannel {
|
||||
} else {
|
||||
for (Class<? extends Type> expectedTypeClass : expectedTypeClasses) {
|
||||
if (command instanceof State state && State.class.isAssignableFrom(expectedTypeClass)) {
|
||||
if (state.as(expectedTypeClass.asSubclass(State.class)) != null) {
|
||||
var subClass = expectedTypeClass.asSubclass(State.class);
|
||||
if (state.as(subClass) != null) {
|
||||
logger.trace(
|
||||
"getCommandSpec command class '{}' is a sub-class of the expectedTypeClass '{}' for key '{}'",
|
||||
command.getClass(), expectedTypeClass, entry.getKey());
|
||||
|
@ -211,7 +211,6 @@ public class ValueDecoder {
|
||||
return handleDpt251(value, subType, preferredType);
|
||||
default:
|
||||
return handleNumericDpt(id, translator, preferredType);
|
||||
// TODO 6.001 is mapped to PercentType, which can only cover 0-100%, not -128..127%
|
||||
}
|
||||
} catch (NumberFormatException | KNXFormatException | KNXIllegalArgumentException | ParseException e) {
|
||||
LOGGER.info("Translator couldn't parse data '{}' for datapoint type '{}' ({}).", data, dptId, e.getClass());
|
||||
@ -271,9 +270,6 @@ public class ValueDecoder {
|
||||
}
|
||||
|
||||
private static Type handleDpt10(String value) throws ParseException {
|
||||
// TODO check handling of DPT10: date is not set to current date, but 1970-01-01 + offset if day is given
|
||||
// maybe we should change the semantics and use current date + offset if day is given
|
||||
|
||||
// Calimero will provide either TIME_DAY_FORMAT or TIME_FORMAT, no-day is not printed
|
||||
Date date = null;
|
||||
try {
|
||||
|
@ -24,6 +24,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.knx.internal.KNXBindingConstants;
|
||||
import org.openhab.binding.knx.internal.client.OutboundSpec;
|
||||
@ -176,7 +177,10 @@ class KNXChannelTest {
|
||||
when(channel.getAcceptedItemType()).thenReturn(ColorItem.class.getName());
|
||||
MyKNXChannel knxChannel = new MyKNXChannel(channel);
|
||||
assertNotNull(knxChannel.getCommandSpec(new HSBType("0,100,100")));
|
||||
assertEquals(knxChannel.getCommandSpec(new HSBType("0,100,100")).getDPT(), "1.001");
|
||||
@Nullable
|
||||
OutboundSpec outboundSpec = knxChannel.getCommandSpec(new HSBType("0,100,100"));
|
||||
assertNotNull(outboundSpec);
|
||||
assertEquals(outboundSpec.getDPT(), "1.001");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -191,8 +195,9 @@ class KNXChannelTest {
|
||||
assertThat(knxChannel, instanceOf(TypeDimmer.class));
|
||||
|
||||
Command command = new PercentType("100");
|
||||
@Nullable
|
||||
OutboundSpec outboundSpec = knxChannel.getCommandSpec(command);
|
||||
assertThat(outboundSpec, is(notNullValue()));
|
||||
assertNotNull(outboundSpec);
|
||||
|
||||
String mappedValue = ValueEncoder.encode(outboundSpec.getValue(), outboundSpec.getDPT());
|
||||
assertThat(mappedValue, is("100"));
|
||||
|
Loading…
Reference in New Issue
Block a user