Skip to content
Snippets Groups Projects
Commit 7a88e94b authored by René Schöne's avatar René Schöne
Browse files

Work on skywriter.

parent 4ea6e59b
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......@@ -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>
......
......@@ -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>
......
......@@ -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
*/
......
......@@ -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) {
try {
String state = new String(payload);
updateState(CHANNEL_FLICK, StringType.valueOf(state));
} catch (Exception e) {
this.logger.warn("Could not process message", e);
}
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment