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 @@ ...@@ -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"> 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> <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> <author>René Schöne</author>
</binding:binding> </binding:binding>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<!-- Flick Type --> <!-- Flick Type -->
<channel-type id="flick-type"> <channel-type id="flick-type">
<item-type>Text</item-type> <item-type>String</item-type>
<label>Last Flick</label> <label>Last Flick</label>
<description>Last Flick detected (and its direction)</description> <description>Last Flick detected (and its direction)</description>
<category>Motion</category> <category>Motion</category>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<parent> <parent>
<artifactId>pom</artifactId> <artifactId>pom</artifactId>
<groupId>org.openhab.binding</groupId> <groupId>org.openhab.binding</groupId>
<version>2.4.0-SNAPSHOT</version> <version>2.3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>org.openhab.binding.openlicht</artifactId> <artifactId>org.openhab.binding.openlicht</artifactId>
......
...@@ -6,6 +6,8 @@ import java.math.BigDecimal; ...@@ -6,6 +6,8 @@ import java.math.BigDecimal;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.naming.ConfigurationException;
import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.thing.Thing; import org.eclipse.smarthome.core.thing.Thing;
...@@ -85,10 +87,12 @@ public abstract class AbstractMqttHandler extends BaseThingHandler ...@@ -85,10 +87,12 @@ public abstract class AbstractMqttHandler extends BaseThingHandler
String brokerName = getConfigValueAsString(CONFIG_BROKER_NAME); String brokerName = getConfigValueAsString(CONFIG_BROKER_NAME);
if (broker.getName().equals(brokerName)) { if (broker.getName().equals(brokerName)) {
// this is our broker! // this is our broker!
this.logger.info("Got correct broker, subscribing to topic {}", getTopic());
currentBrokerConnection = broker; currentBrokerConnection = broker;
warnNoBrokerConnection = true; warnNoBrokerConnection = true;
updateTopicLength(); updateTopicLength();
try { try {
currentBrokerConnection.start();
if (subscribeTopic()) { if (subscribeTopic()) {
broker.addConsumer(this); broker.addConsumer(this);
} }
...@@ -98,6 +102,8 @@ public abstract class AbstractMqttHandler extends BaseThingHandler ...@@ -98,6 +102,8 @@ public abstract class AbstractMqttHandler extends BaseThingHandler
this.logger.error("Could not add subscriber to broker {}", brokerName); this.logger.error("Could not add subscriber to broker {}", brokerName);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Could not add subscriber to broker " + brokerName); "Could not add subscriber to broker " + brokerName);
} catch (ConfigurationException e) {
this.logger.error("Error during first connection to mqtt broker", e);
} }
} else { } else {
this.logger.debug("Got another broker, not interessted!"); this.logger.debug("Got another broker, not interessted!");
...@@ -151,7 +157,7 @@ public abstract class AbstractMqttHandler extends BaseThingHandler ...@@ -151,7 +157,7 @@ public abstract class AbstractMqttHandler extends BaseThingHandler
/** /**
* Subclasses may override this to subscribe to a special subtopic. * 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 * @return <code>null</code> by default to not use subtopics
*/ */
......
...@@ -18,7 +18,7 @@ import org.openhab.binding.openlicht.internal.ConfigurationHolder; ...@@ -18,7 +18,7 @@ import org.openhab.binding.openlicht.internal.ConfigurationHolder;
/** /**
* The {@link SkyWriterHATHandler} is responsible for handling commands, which are * 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 * @author René Schöne - Initial contribution
*/ */
...@@ -30,7 +30,7 @@ public class SkyWriterHATHandler extends AbstractMqttHandler { ...@@ -30,7 +30,7 @@ public class SkyWriterHATHandler extends AbstractMqttHandler {
@Override @Override
public void handleCommand(ChannelUID channelUID, Command command) { 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 // TODO: handle command
// Note: if communication with thing fails for some reason, // Note: if communication with thing fails for some reason,
...@@ -41,8 +41,12 @@ public class SkyWriterHATHandler extends AbstractMqttHandler { ...@@ -41,8 +41,12 @@ public class SkyWriterHATHandler extends AbstractMqttHandler {
@Override @Override
public void processMessage(String topic, byte[] payload) { public void processMessage(String topic, byte[] payload) {
try {
String state = new String(payload); String state = new String(payload);
updateState(CHANNEL_FLICK, StringType.valueOf(state)); updateState(CHANNEL_FLICK, StringType.valueOf(state));
} catch (Exception e) {
this.logger.warn("Could not process message", e);
}
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment