diff --git a/ESH-INF/binding/binding.xml b/ESH-INF/binding/binding.xml index 822a76d07919741584dd5a2863d905d38a416481..cdc1fdcf1d2c5c3def2ed8c99a3359dafa5e6501 100644 --- a/ESH-INF/binding/binding.xml +++ b/ESH-INF/binding/binding.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd"> <name>OpenLicht Binding</name> - <description>This is the binding for OpenLicht (Last Update: 2018-10-01).</description> + <description>This is the binding for OpenLicht (Last Update: 2018-10-01 15:07).</description> <author>René Schöne</author> </binding:binding> diff --git a/ESH-INF/thing/thing-types.xml b/ESH-INF/thing/thing-types.xml index 7d84ec764ae49fb98ab141448188526934c84129..c555472399c34fcb1eb923548cfb9271dcf017cc 100644 --- a/ESH-INF/thing/thing-types.xml +++ b/ESH-INF/thing/thing-types.xml @@ -18,7 +18,7 @@ <!-- Flick Type --> <channel-type id="flick-type"> - <item-type>Text</item-type> + <item-type>String</item-type> <label>Last Flick</label> <description>Last Flick detected (and its direction)</description> <category>Motion</category> diff --git a/pom.xml b/pom.xml index e590521ca4cecdbd3ff32d2a07127d1c127edd74..65813eb2d4a861334681d8423f6f5d78a3e6bdd5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ <parent> <artifactId>pom</artifactId> <groupId>org.openhab.binding</groupId> - <version>2.4.0-SNAPSHOT</version> + <version>2.3.0-SNAPSHOT</version> </parent> <artifactId>org.openhab.binding.openlicht</artifactId> diff --git a/src/main/java/org/openhab/binding/openlicht/handler/AbstractMqttHandler.java b/src/main/java/org/openhab/binding/openlicht/handler/AbstractMqttHandler.java index b94281b2a950b8402a38d9a500d92045381987e0..41c60a8b3da4d61727e99326813a7cfbecd82ca7 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/AbstractMqttHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractMqttHandler.java @@ -6,6 +6,8 @@ import java.math.BigDecimal; import java.nio.ByteBuffer; import java.util.concurrent.ScheduledExecutorService; +import javax.naming.ConfigurationException; + import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.smarthome.core.thing.Thing; @@ -85,10 +87,12 @@ public abstract class AbstractMqttHandler extends BaseThingHandler String brokerName = getConfigValueAsString(CONFIG_BROKER_NAME); if (broker.getName().equals(brokerName)) { // this is our broker! + this.logger.info("Got correct broker, subscribing to topic {}", getTopic()); currentBrokerConnection = broker; warnNoBrokerConnection = true; updateTopicLength(); try { + currentBrokerConnection.start(); if (subscribeTopic()) { broker.addConsumer(this); } @@ -98,6 +102,8 @@ public abstract class AbstractMqttHandler extends BaseThingHandler this.logger.error("Could not add subscriber to broker {}", brokerName); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Could not add subscriber to broker " + brokerName); + } catch (ConfigurationException e) { + this.logger.error("Error during first connection to mqtt broker", e); } } else { this.logger.debug("Got another broker, not interessted!"); @@ -151,7 +157,7 @@ public abstract class AbstractMqttHandler extends BaseThingHandler /** * Subclasses may override this to subscribe to a special subtopic. - * Do not add a leading not a trailing slash! + * Do not add a leading nor a trailing slash! * * @return <code>null</code> by default to not use subtopics */ diff --git a/src/main/java/org/openhab/binding/openlicht/handler/SkyWriterHATHandler.java b/src/main/java/org/openhab/binding/openlicht/handler/SkyWriterHATHandler.java index d5d97b9638ee7c26159722bc25d067b12211052b..a31acaf776ac0fb4a1104c4ee0e95ee7ffb8e167 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/SkyWriterHATHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/SkyWriterHATHandler.java @@ -18,7 +18,7 @@ import org.openhab.binding.openlicht.internal.ConfigurationHolder; /** * The {@link SkyWriterHATHandler} is responsible for handling commands, which are - * sent to one of the channels. + * sent to the channel "$BASE_TOPIC/skywriter". * * @author René Schöne - Initial contribution */ @@ -30,7 +30,7 @@ public class SkyWriterHATHandler extends AbstractMqttHandler { @Override public void handleCommand(ChannelUID channelUID, Command command) { - logger.debug("Got command for read-only thing: {} {}", channelUID.getAsString(), command.toFullString()); + logger.info("Got command for read-only thing: {} {}", channelUID.getAsString(), command.toFullString()); // TODO: handle command // Note: if communication with thing fails for some reason, @@ -41,8 +41,12 @@ public class SkyWriterHATHandler extends AbstractMqttHandler { @Override public void processMessage(String topic, byte[] payload) { - String state = new String(payload); - updateState(CHANNEL_FLICK, StringType.valueOf(state)); + try { + String state = new String(payload); + updateState(CHANNEL_FLICK, StringType.valueOf(state)); + } catch (Exception e) { + this.logger.warn("Could not process message", e); + } } @Override