diff --git a/.classpath b/.classpath deleted file mode 100644 index 7f457fa4138d1da94f59672d2afa430fe5b1a058..0000000000000000000000000000000000000000 --- a/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src/main/java"/> - <classpathentry kind="output" path="target/classes"/> -</classpath> diff --git a/.project b/.project deleted file mode 100644 index 351231a867b5236b017afb2bd1e6b4ab5f3ec129..0000000000000000000000000000000000000000 --- a/.project +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.openhab.binding.openlicht</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ds.core.builder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/ESH-INF/config/config.xml b/ESH-INF/config/config.xml deleted file mode 100644 index 8d0860d539ca4f485fa2afcf290029899584e4a9..0000000000000000000000000000000000000000 --- a/ESH-INF/config/config.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<config-description:config-descriptions - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:config-description="http://eclipse.org/smarthome/schemas/config-description/v1.0.0" - xsi:schemaLocation="http://eclipse.org/smarthome/schemas/config-description/v1.0.0 http://eclipse.org/smarthome/schemas/config-description-1.0.0.xsd"> - - <config-description uri="thing-type:openlicht:mqttdevice"> - <parameter name="brokerName" type="text" required="true"> - <label>Broker Name</label> - <description>Name of the broker as defined in the name of the broker thing. See the MQTT Binding for more information on how to create a MQTT broker thing.</description> - <context>service</context> - <default>embedded-mqtt-broker</default> - </parameter> - <parameter name="base-topic" type="text" required="true"> - <label>Base-Topic</label> - <description>Base topic for publishing updates. Do not include a trailing slash.</description> - <default>sensors</default> - </parameter> - <parameter name="byte-based-messages" type="boolean" required="false"> - <label>Byte-based MQTT Messages</label> - <description>Interpret MQTT messages as raw bytes. If false, interpret the messages as Strings containing numbers.</description> - <default>false</default> - </parameter> - <parameter name="unsupported-category-reset" type="integer" required="false"> - <label>MQTT Unsupported Category Reset Timeout</label> - <description>Timeout in seconds to log again unsupported MQTT categories. Set to zero to disable (default).</description> - <default>0</default> - </parameter> - </config-description> - -</config-description:config-descriptions> diff --git a/ESH-INF/thing/thing-types.xml b/ESH-INF/thing/thing-types.xml deleted file mode 100644 index 9ff3102aaa716b9d3f457003724966faa9361aab..0000000000000000000000000000000000000000 --- a/ESH-INF/thing/thing-types.xml +++ /dev/null @@ -1,223 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<thing:thing-descriptions bindingId="openlicht" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0" - xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd"> - - <!-- Eraser Thing Type --> - <thing-type id="eraser"> - <label>Eraser</label> - <description>Establish communication with a running eraser via MQTT</description> - - <config-description> - <parameter name="brokerName" type="text" required="true"> - <label>Broker Name</label> - <description>Name of the broker as defined in the name of the broker thing. See the MQTT Binding for more information on how to create a MQTT broker thing.</description> - <context>service</context> - <default>embedded-mqtt-broker</default> - </parameter> - <parameter name="byte-based-messages" type="boolean" required="false"> - <label>Byte-based MQTT Messages</label> - <description>Interpret MQTT messages as raw bytes. If false, interpret the messages as Strings containing numbers.</description> - <default>false</default> - </parameter> - <parameter name="base-topic" type="text" required="true"> - <label>Base-Topic</label> - <description>Base topic for publishing updates. Do not include a trailing slash.</description> - <default>oh/in</default> - </parameter> - <parameter name="outTopic" type="text" required="true"> - <label>Outgoing topic</label> - <description>MQTT topic prefix for messages leaving openHAB to eraser.</description> - <default>oh/out/</default> - </parameter> - <parameter name="publish-all" type="boolean" required="true"> - <label>Publish All</label> - <description>If enabled, changes of every item will be published. Otherwise only those of the members of group set in the parameter "Publish Group"</description> - <default>true</default> - </parameter> - <parameter name="publish-group" type="text" required="false"> - <label>Publish group</label> - <description>Group whose members will trigger an update</description> - <context>item</context> - </parameter> - </config-description> - </thing-type> - - <!-- Skywriter HAT Thing Type --> - <thing-type id="skywriter-hat"> - <label>SkyWriterHAT</label> - <description>SkyWriterHAT Gesture Recognition</description> - - <channels> - <channel typeId="flick-type" id="flick" /> - </channels> - - <config-description-ref uri="thing-type:openlicht:mqttdevice" /> - </thing-type> - - <!-- Flick Type --> - <channel-type id="flick-type"> - <item-type>String</item-type> - <label>Last Flick</label> - <description>Last Flick detected (and its direction)</description> - <category>Motion</category> - <state readOnly="true" /> - </channel-type> - - <!-- Polar M600 Thing Type --> - <thing-type id="polar-m600"> - <label>Polar M600</label> - <description>Provides sensor information from a Polar M600 smart watch</description> - - <channels> - <channel typeId="acceleration-type" id="acceleration-x"> - <label>Acceleration X</label> - </channel> - <channel typeId="acceleration-type" id="acceleration-y"> - <label>Acceleration Y</label> - </channel> - <channel typeId="acceleration-type" id="acceleration-z"> - <label>Acceleration Z</label> - </channel> - <channel typeId="rotation-type" id="rotation-x"> - <label>Rotation X</label> - </channel> - <channel typeId="rotation-type" id="rotation-y"> - <label>Rotation Y</label> - </channel> - <channel typeId="rotation-type" id="rotation-z"> - <label>Rotation Z</label> - </channel> - <channel typeId="activity-type" id="activity" /> - <channel typeId="heart-rate-type" id="heart-rate" /> - <channel typeId="steps-type" id="steps" /> - <channel typeId="brightness-type" id="brightness" /> - </channels> - - <config-description-ref uri="thing-type:openlicht:mqttdevice" /> - </thing-type> - - <!-- Polar M600 Thing Type --> - <thing-type id="moto-360"> - <label>Moto 360</label> - <description>Provides sensor information from a Moto 360 smart watch</description> - - <channels> - <channel typeId="acceleration-type" id="acceleration-x"> - <label>Acceleration X</label> - </channel> - <channel typeId="acceleration-type" id="acceleration-y"> - <label>Acceleration Y</label> - </channel> - <channel typeId="acceleration-type" id="acceleration-z"> - <label>Acceleration Z</label> - </channel> - <channel typeId="rotation-type" id="rotation-x"> - <label>Rotation X</label> - </channel> - <channel typeId="rotation-type" id="rotation-y"> - <label>Rotation Y</label> - </channel> - <channel typeId="rotation-type" id="rotation-z"> - <label>Rotation Z</label> - </channel> - <channel typeId="activity-type" id="activity" /> - <channel typeId="heart-rate-type" id="heart-rate" /> - <channel typeId="steps-type" id="steps" /> - <channel typeId="brightness-type" id="brightness" /> - </channels> - - <config-description-ref uri="thing-type:openlicht:mqttdevice" /> - </thing-type> - - <!-- Accelerator Type --> - <channel-type id="acceleration-type"> - <item-type>Number</item-type> - <label>Acceleration</label> - <description>Acceleration in one direction in meters per second.</description> - <category>Motion</category> - <state readOnly="true" /> - </channel-type> - - <!-- Rotation Type --> - <channel-type id="rotation-type"> - <item-type>Number</item-type> - <label>Rotation</label> - <description>Rotation around one axis (unitless).</description> - <category>Motion</category> - <state readOnly="true" /> - </channel-type> - - <!-- Activity Type --> - <channel-type id="activity-type"> - <item-type>String</item-type> - <label>Activity</label> - <description>Current recognized activity.</description> - <state readOnly="true" /> - <event> - <options> - <option value="Runnning">running</option> - <option value="Walking">walking</option> - <option value="Resting">resting</option> - <option value="Unknown">unknown</option> - </options> - </event> - </channel-type> - - <!-- Heart Rate Type --> - <channel-type id="heart-rate-type"> - <item-type>Number</item-type> - <label>Heart Rate</label> - <description>Heart rate in beats per minute.</description> - <state readOnly="true" /> - </channel-type> - - <!-- Steps Type --> - <channel-type id="steps-type"> - <item-type>Number</item-type> - <label>Steps</label> - <description>Steps run today.</description> - <state readOnly="true" ></state> - </channel-type> - - <!-- Samsung S6 Thing Type --> - <thing-type id="samsung-s6"> - <label>Samsung S6</label> - <description>Provides sensor information from a smart phone (a Samsung S6 in our case)</description> - - <channels> - <channel typeId="brightness-type" id="brightness" /> - <channel typeId="acceleration-type" id="acceleration-x"> - <label>Acceleration X</label> - </channel> - <channel typeId="acceleration-type" id="acceleration-y"> - <label>Acceleration Y</label> - </channel> - <channel typeId="acceleration-type" id="acceleration-z"> - <label>Acceleration Z</label> - </channel> - <channel typeId="rotation-type" id="rotation-x"> - <label>Rotation X</label> - </channel> - <channel typeId="rotation-type" id="rotation-y"> - <label>Rotation Y</label> - </channel> - <channel typeId="rotation-type" id="rotation-z"> - <label>Rotation Z</label> - </channel> - </channels> - - <config-description-ref uri="thing-type:openlicht:mqttdevice" /> - </thing-type> - - <!-- General Brightness Type --> - <channel-type id="brightness-type"> - <item-type>Number</item-type> - <label>Brightness</label> - <description>Brightness (Lux).</description> - <category>Light</category> - <state readOnly="true" ></state> - </channel-type> - -</thing:thing-descriptions> diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF deleted file mode 100644 index dcaa926f1199ab630ac5971cfe811d29a8adcd4f..0000000000000000000000000000000000000000 --- a/META-INF/MANIFEST.MF +++ /dev/null @@ -1,32 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ActivationPolicy: lazy -Bundle-ClassPath: . -Bundle-ManifestVersion: 2 -Bundle-Name: OpenLicht Binding -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-SymbolicName: org.openhab.binding.openlicht;singleton:=true -Bundle-Vendor: openHAB -Bundle-Version: 2.3.0.qualifier -Import-Package: - org.eclipse.jdt.annotation;resolution:=optional, - org.eclipse.smarthome.binding.mqtt.handler, - org.eclipse.smarthome.config.core, - org.eclipse.smarthome.core.common.registry, - org.eclipse.smarthome.core.events, - org.eclipse.smarthome.core.items, - org.eclipse.smarthome.core.items.events, - org.eclipse.smarthome.core.library.types, - org.eclipse.smarthome.core.thing, - org.eclipse.smarthome.core.thing.binding, - org.eclipse.smarthome.core.thing.binding.builder, - org.eclipse.smarthome.core.thing.type, - org.eclipse.smarthome.core.types, - org.eclipse.smarthome.io.transport.mqtt, - org.osgi.framework, - org.osgi.service.component, - org.osgi.service.component.annotations;version="[1.3.0,2.0.0)";resolution:=optional, - org.slf4j -Service-Component: OSGI-INF/*.xml -Export-Package: org.openhab.binding.openlicht, - org.openhab.binding.openlicht.handler -Automatic-Module-Name: org.openhab.binding.openlicht 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/OSGI-INF/.gitignore b/OSGI-INF/.gitignore deleted file mode 100644 index 6722cd96e785ac093e976a48df83409bf618b0a1..0000000000000000000000000000000000000000 --- a/OSGI-INF/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.xml diff --git a/pom.xml b/pom.xml index 65813eb2d4a861334681d8423f6f5d78a3e6bdd5..ec585dbee7171a48aee31939a88a3ebbcc5b1993 100644 --- a/pom.xml +++ b/pom.xml @@ -1,17 +1,26 @@ <?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> + </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..2a648aa1fad5b88d5df1d2155d3e14ffb91b7f8d --- /dev/null +++ b/src/main/history/dependencies.xml @@ -0,0 +1,10 @@ +<?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>wrap:mvn:org.lastnpe.eea/eea-all/2.2.1</bundle> + </feature> +</features> 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..018d210e1b5481c9ead83e4b0406523ba12f26de 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/AbstractMqttHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractMqttHandler.java @@ -1,7 +1,7 @@ package org.openhab.binding.openlicht.handler; -import static org.openhab.binding.openlicht.BindingConstants.*; import static org.openhab.binding.openlicht.handler.HandlerPhase.*; +import static org.openhab.binding.openlicht.internal.OpenLichtBindingConstants.*; import java.math.BigDecimal; import java.util.concurrent.ScheduledExecutorService; @@ -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.binding.openlicht.internal.ConfigurationHolder; +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.core.thing.Thing; +import org.openhab.core.thing.ThingRegistry; +import org.openhab.core.thing.ThingRegistryChangeListener; +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.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,4 @@ 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..d9609ccd7d7b9cff1844c5b065d6a76b8fc980be 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java @@ -12,7 +12,7 @@ */ package org.openhab.binding.openlicht.handler; -import static org.openhab.binding.openlicht.BindingConstants.*; +import static org.openhab.binding.openlicht.internal.OpenLichtBindingConstants.*; import java.nio.ByteBuffer; import java.nio.DoubleBuffer; @@ -20,12 +20,12 @@ 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.binding.openlicht.internal.ConfigurationHolder; +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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -128,5 +128,4 @@ public abstract class AbstractSmartWatchHandler extends AbstractMqttHandler { protected boolean subscribeSubTopics() { return true; } - } 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..fca2c430191e7e7bbfbdf43506b2cb2a9c1ae3dc 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java @@ -12,19 +12,19 @@ */ package org.openhab.binding.openlicht.handler; -import static org.openhab.binding.openlicht.BindingConstants.*; +import static org.openhab.binding.openlicht.internal.OpenLichtBindingConstants.*; import java.nio.ByteBuffer; 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.binding.openlicht.internal.ConfigurationHolder; +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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -105,5 +105,4 @@ 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..31f80e753b2e195c206e67b325228009e396c3f0 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java @@ -7,27 +7,27 @@ 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.binding.openlicht.BindingConstants; import org.openhab.binding.openlicht.internal.ConfigurationHolder; import org.openhab.binding.openlicht.internal.DelegateEraserRegistryChangeListener; +import org.openhab.binding.openlicht.internal.OpenLichtBindingConstants; +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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,9 +62,9 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis @Override protected void moreInitializeBefore() { - this.outTopic = getConfigValueAsString(BindingConstants.CONFIG_ERASER_OUT_TOPIC); - this.publishGroupName = getConfigValueAsString(BindingConstants.CONFIG_ERASER_PUBLISH_GROUP); - this.publishAll = getConfigValueAsBoolean(BindingConstants.CONFIG_ERASER_PUBLISH_ALL); + this.outTopic = getConfigValueAsString(OpenLichtBindingConstants.CONFIG_ERASER_OUT_TOPIC); + this.publishGroupName = getConfigValueAsString(OpenLichtBindingConstants.CONFIG_ERASER_PUBLISH_GROUP); + this.publishAll = getConfigValueAsBoolean(OpenLichtBindingConstants.CONFIG_ERASER_PUBLISH_ALL); if (this.outTopic.charAt(this.outTopic.length() - 1) != '/') { this.outTopic += "/"; } @@ -275,5 +275,4 @@ 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..6ad6ba19494a3669fde8f51eb7624ae882dca462 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/Moto360Handler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/Moto360Handler.java @@ -1,7 +1,7 @@ package org.openhab.binding.openlicht.handler; -import org.eclipse.smarthome.core.thing.Thing; import org.openhab.binding.openlicht.internal.ConfigurationHolder; +import org.openhab.core.thing.Thing; public class Moto360Handler extends AbstractSmartWatchHandler { @@ -13,5 +13,4 @@ public class Moto360Handler extends AbstractSmartWatchHandler { protected String getSubTopic() { return "moto360"; } - } 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..5d78787067d61d492e460868b09becc8bd8385eb 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/MqttUtils.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/MqttUtils.java @@ -1,12 +1,12 @@ package org.openhab.binding.openlicht.handler; -import static org.openhab.binding.openlicht.BindingConstants.*; +import static org.openhab.binding.openlicht.internal.OpenLichtBindingConstants.*; 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,4 @@ 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..97a287fd0a02f5841357be5a8b274aab59f64106 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/PolarM600Handler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/PolarM600Handler.java @@ -1,7 +1,7 @@ package org.openhab.binding.openlicht.handler; -import org.eclipse.smarthome.core.thing.Thing; import org.openhab.binding.openlicht.internal.ConfigurationHolder; +import org.openhab.core.thing.Thing; public class PolarM600Handler extends AbstractSmartWatchHandler { @@ -13,5 +13,4 @@ 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..0f3e58c03eb0484bfcf8aac0e8d8aeda8864c5cb 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/SamsungS6Handler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/SamsungS6Handler.java @@ -1,12 +1,11 @@ package org.openhab.binding.openlicht.handler; -import org.eclipse.smarthome.core.thing.Thing; import org.openhab.binding.openlicht.internal.ConfigurationHolder; +import org.openhab.core.thing.Thing; public class SamsungS6Handler extends AbstractSmartphoneHandler { public SamsungS6Handler(Thing thing, ConfigurationHolder configurationHolder) { super(thing, configurationHolder); } - } 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..ca26163d9590d08a4c9b039fa3175b6da19ce66a 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/SkyWriterHATHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/SkyWriterHATHandler.java @@ -8,14 +8,14 @@ */ package org.openhab.binding.openlicht.handler; -import static org.openhab.binding.openlicht.BindingConstants.CHANNEL_FLICK; +import static org.openhab.binding.openlicht.internal.OpenLichtBindingConstants.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.binding.openlicht.internal.ConfigurationHolder; +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.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,4 @@ 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..eb0264b1ac530153ca348661946f84e5d5069863 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.io.transport.mqtt.MqttService; +import org.openhab.core.items.ItemRegistry; +import org.openhab.core.thing.ThingRegistry; import org.osgi.framework.Version; public interface ConfigurationHolder { @@ -27,5 +27,4 @@ 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..c9554d24b93b7ca62246c257d431b064ef324c45 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,12 @@ 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.binding.openlicht.handler.EraserHandler; +import org.openhab.core.items.Item; +import org.openhab.core.items.ItemRegistryChangeListener; -public class DelegateEraserRegistryChangeListener implements RegistryChangeListener<Item> { +public class DelegateEraserRegistryChangeListener implements ItemRegistryChangeListener { private EraserHandler handler; @@ -27,4 +29,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/BindingConstants.java b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtBindingConstants.java similarity index 85% rename from src/main/java/org/openhab/binding/openlicht/BindingConstants.java rename to src/main/java/org/openhab/binding/openlicht/internal/OpenLichtBindingConstants.java index 6e66ee775793dea248cb5ca89a6911b5f93e8da1..a357ab6a56cc6b8c8b200dc2cfe0a14a9c858a47 100644 --- a/src/main/java/org/openhab/binding/openlicht/BindingConstants.java +++ b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtBindingConstants.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 @@ -10,22 +10,28 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.openlicht; +package org.openhab.binding.openlicht.internal; 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 + * The {@link OpenLichtBindingConstants} class defines common constants, which are * used across the whole binding. * * @author René Schöne - Initial contribution */ @NonNullByDefault -public class BindingConstants { +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"; + // Configuration keys public static final String CONFIG_BROKER_NAME = "brokerName"; public static final String CONFIG_BASE_TOPIC = "base-topic"; 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..6bf02f7546c1ce730b346222e3b61e031e7f92a5 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 @@ -16,6 +16,7 @@ package org.openhab.binding.openlicht.internal; * The {@link OpenLichtConfiguration} class contains fields mapping thing configuration parameters. * * @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..78c808b7e507e65bbc95bfa18091e6241602d5e0 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 @@ -12,7 +12,7 @@ */ package org.openhab.binding.openlicht.internal; -import static org.openhab.binding.openlicht.BindingConstants.*; +import static org.openhab.binding.openlicht.internal.OpenLichtBindingConstants.*; import java.util.Collections; import java.util.Set; @@ -23,20 +23,20 @@ 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.binding.openlicht.handler.EraserHandler; import org.openhab.binding.openlicht.handler.Moto360Handler; import org.openhab.binding.openlicht.handler.PolarM600Handler; import org.openhab.binding.openlicht.handler.SamsungS6Handler; import org.openhab.binding.openlicht.handler.SkyWriterHATHandler; +import org.openhab.core.events.EventPublisher; +import org.openhab.core.io.transport.mqtt.MqttService; +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.osgi.framework.FrameworkUtil; import org.osgi.framework.Version; import org.osgi.service.component.ComponentContext; @@ -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) @@ -91,7 +92,7 @@ public class OpenLichtHandlerFactory extends BaseThingHandlerFactory implements if (THING_TYPE_ERASER.equals(thingTypeUID)) { return new EraserHandler(thing, this); } - + System.out.println("null returning"); return null; } diff --git a/ESH-INF/binding/binding.xml b/src/main/resources/OH-INF/binding/binding.xml similarity index 51% rename from ESH-INF/binding/binding.xml rename to src/main/resources/OH-INF/binding/binding.xml index f94ecb6616c1403a19baa52e809ee32ae2ba465b..c261ba9a8bf0a158985bbd4adfc7875c1154e5f8 100644 --- a/ESH-INF/binding/binding.xml +++ b/src/main/resources/OH-INF/binding/binding.xml @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <binding:binding id="openlicht" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:binding="http://eclipse.org/smarthome/schemas/binding/v1.0.0" - xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd"> + 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> - <author>René Schöne</author> </binding:binding> diff --git a/src/main/resources/OH-INF/config/config.xml b/src/main/resources/OH-INF/config/config.xml new file mode 100644 index 0000000000000000000000000000000000000000..8ddda6eeeedb056a034a52ef6326a8f1b685a285 --- /dev/null +++ b/src/main/resources/OH-INF/config/config.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<config-description:config-descriptions + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:config-description="http://eclipse.org/smarthome/schemas/config-description/v1.0.0" + xsi:schemaLocation="http://eclipse.org/smarthome/schemas/config-description/v1.0.0 http://eclipse.org/smarthome/schemas/config-description-1.0.0.xsd"> + + <config-description uri="thing-type:openlicht:mqttdevice"> + <parameter name="brokerName" type="text" required="true"> + <label>Broker Name</label> + <description>Name of the broker as defined in the name of the broker thing. See the MQTT Binding for more information + on how to create a MQTT broker thing.</description> + <context>service</context> + <default>embedded-mqtt-broker</default> + </parameter> + <parameter name="base-topic" type="text" required="true"> + <label>Base-Topic</label> + <description>Base topic for publishing updates. Do not include a trailing slash.</description> + <default>sensors</default> + </parameter> + <parameter name="byte-based-messages" type="boolean" required="false"> + <label>Byte-based MQTT Messages</label> + <description>Interpret MQTT messages as raw bytes. If false, interpret the messages as Strings containing numbers.</description> + <default>false</default> + </parameter> + <parameter name="unsupported-category-reset" type="integer" required="false"> + <label>MQTT Unsupported Category Reset Timeout</label> + <description>Timeout in seconds to log again unsupported MQTT categories. Set to zero to disable (default).</description> + <default>0</default> + </parameter> + </config-description> + +</config-description:config-descriptions> diff --git a/ESH-INF/i18n/openlicht_en_US.properties b/src/main/resources/OH-INF/i18n/openlicht_xx_XX.properties similarity index 100% rename from ESH-INF/i18n/openlicht_en_US.properties rename to src/main/resources/OH-INF/i18n/openlicht_xx_XX.properties 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..b7dbb83eb61399c1cb8814f45adf1f9c6122b045 --- /dev/null +++ b/src/main/resources/OH-INF/thing/thing-types.xml @@ -0,0 +1,225 @@ +<?xml version="1.0" encoding="UTF-8"?> +<thing:thing-descriptions bindingId="openlicht" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0" + xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd"> + + <!-- Eraser Thing Type --> + <thing-type id="eraser"> + <label>Eraser</label> + <description>Establish communication with a running eraser via MQTT</description> + + <config-description> + <parameter name="brokerName" type="text" required="true"> + <label>Broker Name</label> + <description>Name of the broker as defined in the name of the broker thing. See the MQTT Binding for more + information on how to create a MQTT broker thing.</description> + <context>service</context> + <default>embedded-mqtt-broker</default> + </parameter> + <parameter name="byte-based-messages" type="boolean" required="false"> + <label>Byte-based MQTT Messages</label> + <description>Interpret MQTT messages as raw bytes. If false, interpret the messages as Strings containing numbers.</description> + <default>false</default> + </parameter> + <parameter name="base-topic" type="text" required="true"> + <label>Base-Topic</label> + <description>Base topic for publishing updates. Do not include a trailing slash.</description> + <default>oh/in</default> + </parameter> + <parameter name="outTopic" type="text" required="true"> + <label>Outgoing topic</label> + <description>MQTT topic prefix for messages leaving openHAB to eraser.</description> + <default>oh/out/</default> + </parameter> + <parameter name="publish-all" type="boolean" required="true"> + <label>Publish All</label> + <description>If enabled, changes of every item will be published. Otherwise only those of the members of group set + in the parameter "Publish Group"</description> + <default>true</default> + </parameter> + <parameter name="publish-group" type="text" required="false"> + <label>Publish group</label> + <description>Group whose members will trigger an update</description> + <context>item</context> + </parameter> + </config-description> + </thing-type> + + <!-- Skywriter HAT Thing Type --> + <thing-type id="skywriter-hat"> + <label>SkyWriterHAT</label> + <description>SkyWriterHAT Gesture Recognition</description> + + <channels> + <channel typeId="flick-type" id="flick"/> + </channels> + + <config-description-ref uri="thing-type:openlicht:mqttdevice"/> + </thing-type> + + <!-- Flick Type --> + <channel-type id="flick-type"> + <item-type>String</item-type> + <label>Last Flick</label> + <description>Last Flick detected (and its direction)</description> + <category>Motion</category> + <state readOnly="true"/> + </channel-type> + + <!-- Polar M600 Thing Type --> + <thing-type id="polar-m600"> + <label>Polar M600</label> + <description>Provides sensor information from a Polar M600 smart watch</description> + + <channels> + <channel typeId="acceleration-type" id="acceleration-x"> + <label>Acceleration X</label> + </channel> + <channel typeId="acceleration-type" id="acceleration-y"> + <label>Acceleration Y</label> + </channel> + <channel typeId="acceleration-type" id="acceleration-z"> + <label>Acceleration Z</label> + </channel> + <channel typeId="rotation-type" id="rotation-x"> + <label>Rotation X</label> + </channel> + <channel typeId="rotation-type" id="rotation-y"> + <label>Rotation Y</label> + </channel> + <channel typeId="rotation-type" id="rotation-z"> + <label>Rotation Z</label> + </channel> + <channel typeId="activity-type" id="activity"/> + <channel typeId="heart-rate-type" id="heart-rate"/> + <channel typeId="steps-type" id="steps"/> + <channel typeId="brightness-type" id="brightness"/> + </channels> + + <config-description-ref uri="thing-type:openlicht:mqttdevice"/> + </thing-type> + + <!-- Polar M600 Thing Type --> + <thing-type id="moto-360"> + <label>Moto 360</label> + <description>Provides sensor information from a Moto 360 smart watch</description> + + <channels> + <channel typeId="acceleration-type" id="acceleration-x"> + <label>Acceleration X</label> + </channel> + <channel typeId="acceleration-type" id="acceleration-y"> + <label>Acceleration Y</label> + </channel> + <channel typeId="acceleration-type" id="acceleration-z"> + <label>Acceleration Z</label> + </channel> + <channel typeId="rotation-type" id="rotation-x"> + <label>Rotation X</label> + </channel> + <channel typeId="rotation-type" id="rotation-y"> + <label>Rotation Y</label> + </channel> + <channel typeId="rotation-type" id="rotation-z"> + <label>Rotation Z</label> + </channel> + <channel typeId="activity-type" id="activity"/> + <channel typeId="heart-rate-type" id="heart-rate"/> + <channel typeId="steps-type" id="steps"/> + <channel typeId="brightness-type" id="brightness"/> + </channels> + + <config-description-ref uri="thing-type:openlicht:mqttdevice"/> + </thing-type> + + <!-- Accelerator Type --> + <channel-type id="acceleration-type"> + <item-type>Number</item-type> + <label>Acceleration</label> + <description>Acceleration in one direction in meters per second.</description> + <category>Motion</category> + <state readOnly="true"/> + </channel-type> + + <!-- Rotation Type --> + <channel-type id="rotation-type"> + <item-type>Number</item-type> + <label>Rotation</label> + <description>Rotation around one axis (unitless).</description> + <category>Motion</category> + <state readOnly="true"/> + </channel-type> + + <!-- Activity Type --> + <channel-type id="activity-type"> + <item-type>String</item-type> + <label>Activity</label> + <description>Current recognized activity.</description> + <state readOnly="true"/> + <event> + <options> + <option value="Runnning">running</option> + <option value="Walking">walking</option> + <option value="Resting">resting</option> + <option value="Unknown">unknown</option> + </options> + </event> + </channel-type> + + <!-- Heart Rate Type --> + <channel-type id="heart-rate-type"> + <item-type>Number</item-type> + <label>Heart Rate</label> + <description>Heart rate in beats per minute.</description> + <state readOnly="true"/> + </channel-type> + + <!-- Steps Type --> + <channel-type id="steps-type"> + <item-type>Number</item-type> + <label>Steps</label> + <description>Steps run today.</description> + <state readOnly="true"></state> + </channel-type> + + <!-- Samsung S6 Thing Type --> + <thing-type id="samsung-s6"> + <label>Samsung S6</label> + <description>Provides sensor information from a smart phone (a Samsung S6 in our case)</description> + + <channels> + <channel typeId="brightness-type" id="brightness"/> + <channel typeId="acceleration-type" id="acceleration-x"> + <label>Acceleration X</label> + </channel> + <channel typeId="acceleration-type" id="acceleration-y"> + <label>Acceleration Y</label> + </channel> + <channel typeId="acceleration-type" id="acceleration-z"> + <label>Acceleration Z</label> + </channel> + <channel typeId="rotation-type" id="rotation-x"> + <label>Rotation X</label> + </channel> + <channel typeId="rotation-type" id="rotation-y"> + <label>Rotation Y</label> + </channel> + <channel typeId="rotation-type" id="rotation-z"> + <label>Rotation Z</label> + </channel> + </channels> + + <config-description-ref uri="thing-type:openlicht:mqttdevice"/> + </thing-type> + + <!-- General Brightness Type --> + <channel-type id="brightness-type"> + <item-type>Number</item-type> + <label>Brightness</label> + <description>Brightness (Lux).</description> + <category>Light</category> + <state readOnly="true"></state> + </channel-type> + +</thing:thing-descriptions>