diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000000000000000000000000000000000000..38d625e349232ff5ffcc71bd75e4692cdac12768 --- /dev/null +++ b/NOTICE @@ -0,0 +1,13 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-addons diff --git a/pom.xml b/pom.xml index 65813eb2d4a861334681d8423f6f5d78a3e6bdd5..2cc0e6e7ecce188a56cd56f82c458c41eb379131 100644 --- a/pom.xml +++ b/pom.xml @@ -1,17 +1,32 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <dependencies> + <dependency> + <groupId>org.openhab.addons.bundles</groupId> + <artifactId>org.openhab.binding.mqtt</artifactId> + <version>3.0.0-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.openhab.core.bundles</groupId> + <artifactId>org.openhab.core.automation</artifactId> + <version>3.0.0-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + </dependencies> <parent> - <artifactId>pom</artifactId> - <groupId>org.openhab.binding</groupId> - <version>2.3.0-SNAPSHOT</version> + <groupId>org.openhab.addons.bundles</groupId> + <artifactId>org.openhab.addons.reactor.bundles</artifactId> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>org.openhab.binding.openlicht</artifactId> - <packaging>eclipse-plugin</packaging> - <name>OpenLicht Binding</name> + <name>openHAB Add-ons :: Bundles :: OpenLicht Binding</name> </project> diff --git a/src/main/feature/feature.xml b/src/main/feature/feature.xml new file mode 100644 index 0000000000000000000000000000000000000000..e086eca1f76e6aa5926f59ef2e82d82e44b952fd --- /dev/null +++ b/src/main/feature/feature.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2010-2020 Contributors to the openHAB project + + See the NOTICE file(s) distributed with this work for additional + information. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License 2.0 which is available at + http://www.eclipse.org/legal/epl-2.0 + + SPDX-License-Identifier: EPL-2.0 + +--> +<features name="org.openhab.binding.openlicht-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"> + <repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository> + + <feature name="openhab-binding-openlicht" description="OpenLicht Binding" version="${project.version}"> + <feature>openhab-runtime-base</feature> + <bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.openlicht/${project.version}</bundle> + </feature> +</features> diff --git a/src/main/history/dependencies.xml b/src/main/history/dependencies.xml new file mode 100644 index 0000000000000000000000000000000000000000..2e16a5a518925cba34917b4d51bff826a29f676b --- /dev/null +++ b/src/main/history/dependencies.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<features xmlns="http://karaf.apache.org/xmlns/features/v1.6.0" name="org.openhab.binding.openlicht-3.0.0-SNAPSHOT"> + <feature version="0.0.0"> + <feature>openhab-runtime-base</feature> + <feature>wrap</feature> + <bundle>mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt/3.0.0-SNAPSHOT</bundle> + <bundle>mvn:org.openhab.addons.bundles/org.openhab.binding.openlicht/3.0.0-SNAPSHOT</bundle> + <bundle>mvn:org.openhab.core.bundles/org.openhab.core.automation/3.0.0-SNAPSHOT</bundle> + <bundle>mvn:org.openhab.core.bundles/org.openhab.core.config.core/3.0.0-SNAPSHOT</bundle> + <bundle>mvn:org.openhab.core.bundles/org.openhab.core.ephemeris/3.0.0-SNAPSHOT</bundle> + <bundle>mvn:org.openhab.core.bundles/org.openhab.core.thing/3.0.0-SNAPSHOT</bundle> + <bundle>wrap:mvn:org.lastnpe.eea/eea-all/2.2.1</bundle> + </feature> +</features> diff --git a/src/main/java/org/openhab/binding/openlicht/BindingConstants.java b/src/main/java/org/openhab/binding/openlicht/BindingConstants.java index 6e66ee775793dea248cb5ca89a6911b5f93e8da1..ecec9873e156da45718261c4b436f79d30b629b3 100644 --- a/src/main/java/org/openhab/binding/openlicht/BindingConstants.java +++ b/src/main/java/org/openhab/binding/openlicht/BindingConstants.java @@ -13,7 +13,7 @@ package org.openhab.binding.openlicht; import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.smarthome.core.thing.ThingTypeUID; +import org.openhab.core.thing.ThingTypeUID; /** * The {@link BindingConstants} class defines common constants, which are 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 7fcd087f6d970831ab5550de4ab3f8b2693c2dea..0d43245d9563d52d6ebe3cf78ca98ce2c68b9067 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/AbstractMqttHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractMqttHandler.java @@ -10,24 +10,24 @@ import java.util.concurrent.locks.ReentrantLock; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler; -import org.eclipse.smarthome.core.common.registry.RegistryChangeListener; -import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.thing.ThingRegistry; -import org.eclipse.smarthome.core.thing.ThingStatus; -import org.eclipse.smarthome.core.thing.ThingStatusDetail; -import org.eclipse.smarthome.core.thing.binding.BaseThingHandler; -import org.eclipse.smarthome.core.thing.binding.ThingHandler; -import org.eclipse.smarthome.io.transport.mqtt.MqttBrokerConnection; -import org.eclipse.smarthome.io.transport.mqtt.MqttMessageSubscriber; -import org.eclipse.smarthome.io.transport.mqtt.MqttServiceObserver; +import org.openhab.binding.mqtt.handler.AbstractBrokerHandler; +import org.openhab.core.thing.ThingRegistryChangeListener; +import org.openhab.core.thing.Thing; +import org.openhab.core.thing.ThingRegistry; +import org.openhab.core.thing.ThingStatus; +import org.openhab.core.thing.ThingStatusDetail; +import org.openhab.core.thing.binding.BaseThingHandler; +import org.openhab.core.thing.binding.ThingHandler; +import org.openhab.core.io.transport.mqtt.MqttBrokerConnection; +import org.openhab.core.io.transport.mqtt.MqttMessageSubscriber; +import org.openhab.core.io.transport.mqtt.MqttServiceObserver; import org.openhab.binding.openlicht.internal.ConfigurationHolder; import org.osgi.framework.Version; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class AbstractMqttHandler extends BaseThingHandler - implements MqttMessageSubscriber, MqttServiceObserver, RegistryChangeListener<Thing> { + implements MqttMessageSubscriber, MqttServiceObserver, ThingRegistryChangeListener { private final @NonNull Logger logger = LoggerFactory.getLogger(AbstractMqttHandler.class); private @Nullable ThingRegistry thingRegistry; @@ -240,7 +240,9 @@ public abstract class AbstractMqttHandler extends BaseThingHandler // String topic = subscribeSubTopics() ? (getTopic().substring(0, usedTopicLength) + "out") // : (getTopic() + "/out"); byte[] payload = message.getBytes(); - currentBrokerConnection.publish(topic, payload); + + // Last two parameters of the following line are experimental + currentBrokerConnection.publish(topic, payload, 1, true); } public final String getTopic() { @@ -259,8 +261,8 @@ public abstract class AbstractMqttHandler extends BaseThingHandler /** * Updates the state of the managed thing. Subclasses may override this to add special handling. * - * @param phase Phase of the thing configuration - * @param success Whether the phase was successful + * @param phase Phase of the thing configuration + * @param success Whether the phase was successful * @param description Detailed description of the status */ protected void statusUpdate(HandlerPhase phase, boolean success, String description) { @@ -342,5 +344,5 @@ public abstract class AbstractMqttHandler extends BaseThingHandler // output[i] = input.getFloat(); // } // } - + } diff --git a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java index 5e7c953b029315a1a0b049bd210ed5ecb70a0db9..dabf3297d482b03edd12bc455c7f6c180189819e 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java @@ -20,11 +20,11 @@ import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.eclipse.smarthome.core.library.types.DecimalType; -import org.eclipse.smarthome.core.thing.ChannelUID; -import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.types.Command; -import org.eclipse.smarthome.core.types.RefreshType; +import org.openhab.core.library.types.DecimalType; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.types.Command; +import org.openhab.core.types.RefreshType; import org.openhab.binding.openlicht.internal.ConfigurationHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java index 6ba499cc529d2c10552ecedb9ef7625c5345b254..fee1fa35717c1bc1efd1f1f7f55770c5e686a53b 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java @@ -19,11 +19,11 @@ import java.nio.DoubleBuffer; import java.util.HashSet; import java.util.Set; -import org.eclipse.smarthome.core.library.types.DecimalType; -import org.eclipse.smarthome.core.thing.ChannelUID; -import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.types.Command; -import org.eclipse.smarthome.core.types.RefreshType; +import org.openhab.core.library.types.DecimalType; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.types.Command; +import org.openhab.core.types.RefreshType; import org.openhab.binding.openlicht.internal.ConfigurationHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -105,5 +105,5 @@ public abstract class AbstractSmartphoneHandler extends AbstractMqttHandler { protected String getSubTopic() { return "phone"; } - + } 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 084293069f02ca77475967fe689212796cbc209a..100d356d0f3d48269cab95573fb702c23e749465 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java @@ -7,24 +7,24 @@ import java.util.Set; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.smarthome.core.events.EventPublisher; -import org.eclipse.smarthome.core.items.GenericItem; -import org.eclipse.smarthome.core.items.GroupItem; -import org.eclipse.smarthome.core.items.Item; -import org.eclipse.smarthome.core.items.ItemNotFoundException; -import org.eclipse.smarthome.core.items.ItemRegistry; -import org.eclipse.smarthome.core.items.StateChangeListener; -import org.eclipse.smarthome.core.items.events.ItemEventFactory; -import org.eclipse.smarthome.core.library.types.DateTimeType; -import org.eclipse.smarthome.core.library.types.DecimalType; -import org.eclipse.smarthome.core.library.types.HSBType; -import org.eclipse.smarthome.core.library.types.OnOffType; -import org.eclipse.smarthome.core.library.types.StringType; -import org.eclipse.smarthome.core.thing.ChannelUID; -import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.types.Command; -import org.eclipse.smarthome.core.types.State; -import org.eclipse.smarthome.core.types.TypeParser; +import org.openhab.core.events.EventPublisher; +import org.openhab.core.items.GenericItem; +import org.openhab.core.items.GroupItem; +import org.openhab.core.items.Item; +import org.openhab.core.items.ItemNotFoundException; +import org.openhab.core.items.ItemRegistry; +import org.openhab.core.items.StateChangeListener; +import org.openhab.core.items.events.ItemEventFactory; +import org.openhab.core.library.types.DateTimeType; +import org.openhab.core.library.types.DecimalType; +import org.openhab.core.library.types.HSBType; +import org.openhab.core.library.types.OnOffType; +import org.openhab.core.library.types.StringType; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.types.Command; +import org.openhab.core.types.State; +import org.openhab.core.types.TypeParser; import org.openhab.binding.openlicht.BindingConstants; import org.openhab.binding.openlicht.internal.ConfigurationHolder; import org.openhab.binding.openlicht.internal.DelegateEraserRegistryChangeListener; @@ -275,5 +275,5 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis public void stateUpdated(Item item, State state) { // ignored, as no change } - + } diff --git a/src/main/java/org/openhab/binding/openlicht/handler/Moto360Handler.java b/src/main/java/org/openhab/binding/openlicht/handler/Moto360Handler.java index bf201fa5562a9e41dec5210fd31d00c05f746dd6..8f404818da10b6e1dbe55d2496e1e6e967ef024b 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/Moto360Handler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/Moto360Handler.java @@ -1,6 +1,6 @@ package org.openhab.binding.openlicht.handler; -import org.eclipse.smarthome.core.thing.Thing; +import org.openhab.core.thing.Thing; import org.openhab.binding.openlicht.internal.ConfigurationHolder; public class Moto360Handler extends AbstractSmartWatchHandler { diff --git a/src/main/java/org/openhab/binding/openlicht/handler/MqttUtils.java b/src/main/java/org/openhab/binding/openlicht/handler/MqttUtils.java index dc0dbfa942a975f6cfcd0666106fb2803920ed17..52075c35a5fc9744cbb3f1c8e93ae565eca9ace1 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/MqttUtils.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/MqttUtils.java @@ -6,7 +6,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import org.eclipse.smarthome.core.library.types.DecimalType; +import org.openhab.core.library.types.DecimalType; public class MqttUtils { @@ -68,5 +68,5 @@ public class MqttUtils { updateState.accept(channelId, entry.getValue()); } } - + } diff --git a/src/main/java/org/openhab/binding/openlicht/handler/PolarM600Handler.java b/src/main/java/org/openhab/binding/openlicht/handler/PolarM600Handler.java index 6e30e8dd3b16663862b725501b24c7c4d70ab340..3e686107a27612d0fdae8c7e4720c8801b2f7cfa 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/PolarM600Handler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/PolarM600Handler.java @@ -1,6 +1,6 @@ package org.openhab.binding.openlicht.handler; -import org.eclipse.smarthome.core.thing.Thing; +import org.openhab.core.thing.Thing; import org.openhab.binding.openlicht.internal.ConfigurationHolder; public class PolarM600Handler extends AbstractSmartWatchHandler { @@ -13,5 +13,5 @@ public class PolarM600Handler extends AbstractSmartWatchHandler { protected String getSubTopic() { return "polar"; } - + } diff --git a/src/main/java/org/openhab/binding/openlicht/handler/SamsungS6Handler.java b/src/main/java/org/openhab/binding/openlicht/handler/SamsungS6Handler.java index 2a65819c0f2ff5fd864042b953d70d873cd9c2f7..dfb6de598a4984437893e6fa9a8ca380427b5e30 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/SamsungS6Handler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/SamsungS6Handler.java @@ -1,6 +1,6 @@ package org.openhab.binding.openlicht.handler; -import org.eclipse.smarthome.core.thing.Thing; +import org.openhab.core.thing.Thing; import org.openhab.binding.openlicht.internal.ConfigurationHolder; public class SamsungS6Handler extends AbstractSmartphoneHandler { 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 d9367131b02c2f67aa4f71156beebb2452cc3f40..41c3cdf1b7c4e4d929aee9615ab0b7a75a567cea 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/SkyWriterHATHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/SkyWriterHATHandler.java @@ -11,10 +11,10 @@ package org.openhab.binding.openlicht.handler; import static org.openhab.binding.openlicht.BindingConstants.CHANNEL_FLICK; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.smarthome.core.library.types.StringType; -import org.eclipse.smarthome.core.thing.ChannelUID; -import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.types.Command; +import org.openhab.core.library.types.StringType; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.types.Command; import org.openhab.binding.openlicht.internal.ConfigurationHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; * sent to the channel "$BASE_TOPIC/skywriter". * * @author René Schöne - Initial contribution + * @author Manuel Krombholz - Upgrade OH Version */ public class SkyWriterHATHandler extends AbstractMqttHandler { @@ -52,5 +53,5 @@ public class SkyWriterHATHandler extends AbstractMqttHandler { protected String getSubTopic() { return "skywriter"; } - + } diff --git a/src/main/java/org/openhab/binding/openlicht/handler/UpdateState.java b/src/main/java/org/openhab/binding/openlicht/handler/UpdateState.java index c03e3ccb5ea9ae12f71239e12a878dcb3b839d1b..3c1728be1d13bc62327d5c77f5f5b67028dba8b7 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/UpdateState.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/UpdateState.java @@ -2,7 +2,7 @@ package org.openhab.binding.openlicht.handler; import java.util.function.BiConsumer; -import org.eclipse.smarthome.core.types.State; +import org.openhab.core.types.State; @FunctionalInterface public interface UpdateState extends BiConsumer<String, State> { diff --git a/src/main/java/org/openhab/binding/openlicht/internal/ConfigurationHolder.java b/src/main/java/org/openhab/binding/openlicht/internal/ConfigurationHolder.java index 0ae8f02e4e6a5919ee0aaafe2ff8d992006b4498..3ba6de1bb1bf03c7d0811ab0a412a3d0bcd74263 100644 --- a/src/main/java/org/openhab/binding/openlicht/internal/ConfigurationHolder.java +++ b/src/main/java/org/openhab/binding/openlicht/internal/ConfigurationHolder.java @@ -3,10 +3,10 @@ package org.openhab.binding.openlicht.internal; import java.util.concurrent.ScheduledExecutorService; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.smarthome.core.events.EventPublisher; -import org.eclipse.smarthome.core.items.ItemRegistry; -import org.eclipse.smarthome.core.thing.ThingRegistry; -import org.eclipse.smarthome.io.transport.mqtt.MqttService; +import org.openhab.core.events.EventPublisher; +import org.openhab.core.items.ItemRegistry; +import org.openhab.core.thing.ThingRegistry; +import org.openhab.core.io.transport.mqtt.MqttService; import org.osgi.framework.Version; public interface ConfigurationHolder { @@ -27,5 +27,5 @@ public interface ConfigurationHolder { EventPublisher getEventPublisher(); Version getVersion(); - + } diff --git a/src/main/java/org/openhab/binding/openlicht/internal/DelegateEraserRegistryChangeListener.java b/src/main/java/org/openhab/binding/openlicht/internal/DelegateEraserRegistryChangeListener.java index 9d0ea7833f7411c5f6b124c42ed4ba486a1acc73..a1ecfad97e58212e9270c503846873b0b9c1f245 100644 --- a/src/main/java/org/openhab/binding/openlicht/internal/DelegateEraserRegistryChangeListener.java +++ b/src/main/java/org/openhab/binding/openlicht/internal/DelegateEraserRegistryChangeListener.java @@ -1,10 +1,11 @@ package org.openhab.binding.openlicht.internal; -import org.eclipse.smarthome.core.common.registry.RegistryChangeListener; -import org.eclipse.smarthome.core.items.Item; +import java.util.Collection; +import org.openhab.core.items.ItemRegistryChangeListener; +import org.openhab.core.items.Item; import org.openhab.binding.openlicht.handler.EraserHandler; -public class DelegateEraserRegistryChangeListener implements RegistryChangeListener<Item> { +public class DelegateEraserRegistryChangeListener implements ItemRegistryChangeListener { private EraserHandler handler; @@ -27,4 +28,8 @@ public class DelegateEraserRegistryChangeListener implements RegistryChangeListe handler.updated(oldElement, element); } + @Override + public void allItemsChanged(Collection<String> oldItemNames) { + // TODO: Implement! + } } diff --git a/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtBindingConstants.java b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtBindingConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..f81653530024220faa63032964315cd5c19c5c0b --- /dev/null +++ b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtBindingConstants.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.openlicht.internal; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.thing.ThingTypeUID; + +/** + * The {@link OpenLichtBindingConstants} class defines common constants, which are + * used across the whole binding. + * + * @author Manuel Krombholz - Initial contribution + */ +@NonNullByDefault +public class OpenLichtBindingConstants { + + private static final String BINDING_ID = "openlicht"; + + // List of all Thing Type UIDs + public static final ThingTypeUID THING_TYPE_SAMPLE = new ThingTypeUID(BINDING_ID, "sample"); + + // List of all Channel ids + public static final String CHANNEL_1 = "channel1"; +} diff --git a/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtConfiguration.java b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtConfiguration.java index ab149a85a5f0b5c3e6474a732e7bafab310972a0..b60c72ac21414c23beee002eb744847a3d36fce3 100644 --- a/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtConfiguration.java +++ b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtConfiguration.java @@ -1,8 +1,8 @@ /** - * Copyright (c) 2014,2018 by the respective copyright holders. + * Copyright (c) 2010-2020 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. + * information. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -15,7 +15,8 @@ package org.openhab.binding.openlicht.internal; /** * The {@link OpenLichtConfiguration} class contains fields mapping thing configuration parameters. * - * @author René Schöne - Initial contribution + * @author René Schöne - Initial contribution + * @author Manuel Krombholz - Upgrade OH Version */ public class OpenLichtConfiguration { diff --git a/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtHandler.java b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..2a33fe94e215b22933104b8f8141719549e09d57 --- /dev/null +++ b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtHandler.java @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2010-2020 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.openlicht.internal; + +import static org.openhab.binding.openlicht.internal.OpenLichtBindingConstants.*; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.thing.ThingStatus; +import org.openhab.core.thing.binding.BaseThingHandler; +import org.openhab.core.types.Command; +import org.openhab.core.types.RefreshType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The {@link OpenLichtHandler} is responsible for handling commands, which are + * sent to one of the channels. + * + * @author Manuel Krombholz - Initial contribution + */ +@NonNullByDefault +public class OpenLichtHandler extends BaseThingHandler { + + private final Logger logger = LoggerFactory.getLogger(OpenLichtHandler.class); + + private @Nullable OpenLichtConfiguration config; + + public OpenLichtHandler(Thing thing) { + super(thing); + } + + @Override + public void handleCommand(ChannelUID channelUID, Command command) { + if (CHANNEL_1.equals(channelUID.getId())) { + if (command instanceof RefreshType) { + // TODO: handle data refresh + } + + // TODO: handle command + + // Note: if communication with thing fails for some reason, + // indicate that by setting the status with detail information: + // updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, + // "Could not control device at IP address x.x.x.x"); + } + } + + @Override + public void initialize() { + config = getConfigAs(OpenLichtConfiguration.class); + + // TODO: Initialize the handler. + // The framework requires you to return from this method quickly. Also, before leaving this method a thing + // status from one of ONLINE, OFFLINE or UNKNOWN must be set. This might already be the real thing status in + // case you can decide it directly. + // In case you can not decide the thing status directly (e.g. for long running connection handshake using WAN + // access or similar) you should set status UNKNOWN here and then decide the real status asynchronously in the + // background. + + // set the thing status to UNKNOWN temporarily and let the background task decide for the real status. + // the framework is then able to reuse the resources from the thing handler initialization. + // we set this upfront to reliably check status updates in unit tests. + updateStatus(ThingStatus.UNKNOWN); + + // Example for background initialization: + scheduler.execute(() -> { + boolean thingReachable = true; // <background task with long running initialization here> + // when done do: + if (thingReachable) { + updateStatus(ThingStatus.ONLINE); + } else { + updateStatus(ThingStatus.OFFLINE); + } + }); + + // These logging types should be primarily used by bindings + // logger.trace("Example trace message"); + // logger.debug("Example debug message"); + // logger.warn("Example warn message"); + + // Note: When initialization can NOT be done set the status with more details for further + // analysis. See also class ThingStatusDetail for all available status details. + // Add a description to give user information to understand why thing does not work as expected. E.g. + // updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, + // "Can not access device as username and/or password are invalid"); + } +} diff --git a/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtHandlerFactory.java b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtHandlerFactory.java index ced6638330e615f9bbf7f52dbfa87a4d5be8b243..6f80894d36d347df219af65eb20ca9bec7406ff5 100644 --- a/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtHandlerFactory.java +++ b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtHandlerFactory.java @@ -1,8 +1,8 @@ /** - * Copyright (c) 2014,2018 by the respective copyright holders. + * Copyright (c) 2010-2020 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. + * information. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -23,15 +23,15 @@ import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.smarthome.core.events.EventPublisher; -import org.eclipse.smarthome.core.items.ItemRegistry; -import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.thing.ThingRegistry; -import org.eclipse.smarthome.core.thing.ThingTypeUID; -import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory; -import org.eclipse.smarthome.core.thing.binding.ThingHandler; -import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory; -import org.eclipse.smarthome.io.transport.mqtt.MqttService; +import org.openhab.core.events.EventPublisher; +import org.openhab.core.items.ItemRegistry; +import org.openhab.core.thing.Thing; +import org.openhab.core.thing.ThingRegistry; +import org.openhab.core.thing.ThingTypeUID; +import org.openhab.core.thing.binding.BaseThingHandlerFactory; +import org.openhab.core.thing.binding.ThingHandler; +import org.openhab.core.thing.binding.ThingHandlerFactory; +import org.openhab.core.io.transport.mqtt.MqttService; import org.openhab.binding.openlicht.handler.EraserHandler; import org.openhab.binding.openlicht.handler.Moto360Handler; import org.openhab.binding.openlicht.handler.PolarM600Handler; @@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory; * handlers. * * @author René Schöne - Initial contribution + * @author Manuel Krombholz - Upgrade OH Version */ @NonNullByDefault @Component(configurationPid = "binding.openlicht", service = ThingHandlerFactory.class) diff --git a/src/main/resources/OH-INF/binding/binding.xml b/src/main/resources/OH-INF/binding/binding.xml new file mode 100644 index 0000000000000000000000000000000000000000..c261ba9a8bf0a158985bbd4adfc7875c1154e5f8 --- /dev/null +++ b/src/main/resources/OH-INF/binding/binding.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<binding:binding id="openlicht" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:binding="https://openhab.org/schemas/binding/v1.0.0" + xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd"> + + <name>OpenLicht Binding</name> + <description>This is the binding for OpenLicht.</description> + +</binding:binding> diff --git a/src/main/resources/OH-INF/i18n/openlicht_xx_XX.properties b/src/main/resources/OH-INF/i18n/openlicht_xx_XX.properties new file mode 100644 index 0000000000000000000000000000000000000000..fbd6a84d0422096192f6119d92881a77d63f1416 --- /dev/null +++ b/src/main/resources/OH-INF/i18n/openlicht_xx_XX.properties @@ -0,0 +1,17 @@ +# FIXME: please substitute the xx_XX with a proper locale, ie. de_DE +# FIXME: please do not add the file to the repo if you add or change no content +# binding +binding.openlicht.name = <Your localized Binding name> +binding.openlicht.description = <Your localized Binding description> + +# thing types +thing-type.openlicht.sample.label = <Your localized Thing label> +thing-type.openlicht.sample.description = <Your localized Thing description> + +# thing type config description +thing-type.config.openlicht.sample.config1.label = <Your localized config parameter label> +thing-type.config.openlicht.sample.config1.description = <Your localized config parameter description> + +# channel types +channel-type.openlicht.sample-channel.label = <Your localized Channel label> +channel-type.openlicht.sample-channel.description = <Your localized Channel description> diff --git a/src/main/resources/OH-INF/thing/thing-types.xml b/src/main/resources/OH-INF/thing/thing-types.xml new file mode 100644 index 0000000000000000000000000000000000000000..c193a13e32fffb0769b56a8feaa0f4f1f78d6527 --- /dev/null +++ b/src/main/resources/OH-INF/thing/thing-types.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<thing:thing-descriptions bindingId="openlicht" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" + xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> + + <!-- Sample Thing Type --> + <thing-type id="sample"> + <label>OpenLicht Binding Thing</label> + <description>Sample thing for OpenLicht Binding</description> + + <channels> + <channel id="channel1" typeId="sample-channel"/> + </channels> + + <config-description> + <parameter name="config1" type="text" required="true"> + <label>Sample Parameter</label> + <description>This is a sample text configuration parameter</description> + </parameter> + </config-description> + + </thing-type> + + <!-- Sample Channel Type --> + <channel-type id="sample-channel"> + <item-type>openlichtItem</item-type> + <label>OpenLicht Binding Channel</label> + <description>Sample channel for OpenLicht Binding</description> + </channel-type> + +</thing:thing-descriptions>