diff --git a/src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java b/src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java index b9478a6ccbfad64f2827b56e80517db04fbb8a1a..084293069f02ca77475967fe689212796cbc209a 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java @@ -149,10 +149,11 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis @Override public void processMessage(String topic, byte[] payload) { // check topic, and forward payload to respective item - logger.debug("Got message, in topc: '" + topic + "'"); + final String stringPayload = new String(payload); + logger.debug("{} got message, in topc: '{}' with payload '{}'", this, topic, stringPayload); int indexOfLastSlash = topic.lastIndexOf('/'); String itemName = topic.substring(indexOfLastSlash + 1); - logger.debug("Using item name: '" + itemName + "'"); + logger.debug("{} using item name: '{}'", this, itemName); ItemRegistry registry = this.itemRegistry; if (registry != null) { Item item; @@ -165,13 +166,22 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis // assume this is a GenericItem GenericItem genericItem = (GenericItem) item; // State newState = parseState(genericItem, new String(payload)); - Command command = TypeParser.parseCommand(genericItem.getAcceptedCommandTypes(), new String(payload)); + Command command = TypeParser.parseCommand(genericItem.getAcceptedCommandTypes(), stringPayload); EventPublisher localEventPublisher = this.eventPublisher; if (command != null && localEventPublisher != null) { localEventPublisher.post(ItemEventFactory.createCommandEvent(itemName, command)); } else { - logger.debug("Could not create command for event-publisher {}, item {} and payload {}", - localEventPublisher, itemName, new String(payload)); + logger.debug( + "Could not create command for event-publisher {}, item {} with accecpted command types {} and payload {}", + localEventPublisher, itemName, genericItem.getAcceptedCommandTypes(), stringPayload); + logger.debug("Trying to set state instead"); + State state = TypeParser.parseState(genericItem.getAcceptedDataTypes(), stringPayload); + if (state != null) { + genericItem.setState(state); + } else { + logger.debug("Could not create new state for item {} with accepted date types {} and payload {}", + itemName, genericItem.getAcceptedDataTypes(), stringPayload); + } } // if (newState != null) { // logger.debug("Setting state {} of type {} for {}", newState, newState.getClass().getSimpleName(),