diff --git a/src/main/java/org/openhab/binding/openlicht/BindingConstants.java b/src/main/java/org/openhab/binding/openlicht/BindingConstants.java index 974b723370fc1e69d6ae78c0190f8a4658e37a31..0327eb53167a893766507d551a0e92327b3b1fa8 100644 --- a/src/main/java/org/openhab/binding/openlicht/BindingConstants.java +++ b/src/main/java/org/openhab/binding/openlicht/BindingConstants.java @@ -32,8 +32,9 @@ public class BindingConstants { // List of all Thing Type UIDs public static final ThingTypeUID THING_TYPE_SKYWRITER_HAT = new ThingTypeUID(BINDING_ID, "skywriter-hat"); - public static final ThingTypeUID THING_TYPE_POLAR = new ThingTypeUID(BINDING_ID, "polar-m600"); - public static final ThingTypeUID THING_TYPE_SMARTPHONE = new ThingTypeUID(BINDING_ID, "samsung-s6"); + public static final ThingTypeUID THING_TYPE_POLAR_M600 = new ThingTypeUID(BINDING_ID, "polar-m600"); + public static final ThingTypeUID THING_TYPE_MOTO_360 = new ThingTypeUID(BINDING_ID, "moto-360"); + public static final ThingTypeUID THING_TYPE_SAMSUNG_S6 = new ThingTypeUID(BINDING_ID, "samsung-s6"); // List of all Channel ids public static final String CHANNEL_FLICK = "flick"; diff --git a/src/main/java/org/openhab/binding/openlicht/handler/PolarHandler.java b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java similarity index 91% rename from src/main/java/org/openhab/binding/openlicht/handler/PolarHandler.java rename to src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java index e7cd7ad4fc56f9cd49d32e0e77c98e10a55026be..69c1724203f7851f9d6dbbb05118120cd95ee41e 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/PolarHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java @@ -27,18 +27,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The {@link PolarHandler} is responsible for handling commands, which are + * The {@link AbstractSmartWatchHandler} is responsible for handling commands, which are * sent to one of the channels. * * @author René Schöne - Initial contribution */ -public class PolarHandler extends AbstractMqttHandler { +public abstract class AbstractSmartWatchHandler extends AbstractMqttHandler { - private final Logger logger = LoggerFactory.getLogger(PolarHandler.class); + private final Logger logger = LoggerFactory.getLogger(AbstractSmartWatchHandler.class); private Set<String> seenUnsupportedCategories; - public PolarHandler(Thing thing, MqttService mqttService) { + public AbstractSmartWatchHandler(Thing thing, MqttService mqttService) { super(thing, mqttService); seenUnsupportedCategories = new HashSet<>(); } diff --git a/src/main/java/org/openhab/binding/openlicht/handler/SmartphoneHandler.java b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java similarity index 87% rename from src/main/java/org/openhab/binding/openlicht/handler/SmartphoneHandler.java rename to src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java index e5b3155a95dca962980bd5328f9d070f2b311257..8f928400226acd405709ff374ecb6c022a0f9151 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/SmartphoneHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java @@ -26,18 +26,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The {@link SmartphoneHandler} is responsible for handling commands, which are + * The {@link AbstractSmartphoneHandler} is responsible for handling commands, which are * sent to one of the channels. * * @author René Schöne - Initial contribution */ -public class SmartphoneHandler extends AbstractMqttHandler { +public abstract class AbstractSmartphoneHandler extends AbstractMqttHandler { - private final Logger logger = LoggerFactory.getLogger(SmartphoneHandler.class); + private final Logger logger = LoggerFactory.getLogger(AbstractSmartphoneHandler.class); private Set<String> seenUnsupportedCategories; - public SmartphoneHandler(Thing thing, MqttService mqttService) { + public AbstractSmartphoneHandler(Thing thing, MqttService mqttService) { super(thing, mqttService); seenUnsupportedCategories = new HashSet<>(); } diff --git a/src/main/java/org/openhab/binding/openlicht/handler/Moto360Handler.java b/src/main/java/org/openhab/binding/openlicht/handler/Moto360Handler.java new file mode 100644 index 0000000000000000000000000000000000000000..4d5a57cbc09af2155dd51567977dfe391fa31472 --- /dev/null +++ b/src/main/java/org/openhab/binding/openlicht/handler/Moto360Handler.java @@ -0,0 +1,12 @@ +package org.openhab.binding.openlicht.handler; + +import org.eclipse.smarthome.core.thing.Thing; +import org.eclipse.smarthome.io.transport.mqtt.MqttService; + +public class Moto360Handler extends AbstractSmartWatchHandler { + + public Moto360Handler(Thing thing, MqttService mqttService) { + super(thing, mqttService); + } + +} diff --git a/src/main/java/org/openhab/binding/openlicht/handler/PolarM600Handler.java b/src/main/java/org/openhab/binding/openlicht/handler/PolarM600Handler.java new file mode 100644 index 0000000000000000000000000000000000000000..934d399ec6791f22a56ce17d96c120e7d91434a4 --- /dev/null +++ b/src/main/java/org/openhab/binding/openlicht/handler/PolarM600Handler.java @@ -0,0 +1,12 @@ +package org.openhab.binding.openlicht.handler; + +import org.eclipse.smarthome.core.thing.Thing; +import org.eclipse.smarthome.io.transport.mqtt.MqttService; + +public class PolarM600Handler extends AbstractSmartWatchHandler { + + public PolarM600Handler(Thing thing, MqttService mqttService) { + super(thing, mqttService); + } + +} diff --git a/src/main/java/org/openhab/binding/openlicht/handler/SamsungS6Handler.java b/src/main/java/org/openhab/binding/openlicht/handler/SamsungS6Handler.java new file mode 100644 index 0000000000000000000000000000000000000000..6a8eb3ac1ed0c0abc7dcb728293862034f8d8cd6 --- /dev/null +++ b/src/main/java/org/openhab/binding/openlicht/handler/SamsungS6Handler.java @@ -0,0 +1,12 @@ +package org.openhab.binding.openlicht.handler; + +import org.eclipse.smarthome.core.thing.Thing; +import org.eclipse.smarthome.io.transport.mqtt.MqttService; + +public class SamsungS6Handler extends AbstractSmartphoneHandler { + + public SamsungS6Handler(Thing thing, MqttService mqttService) { + super(thing, mqttService); + } + +} 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 315b3ec33fac8c867c46f259d829cb113976e201..5ef4ad154eff11db99cac5de51e6b236b218302e 100644 --- a/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtHandlerFactory.java +++ b/src/main/java/org/openhab/binding/openlicht/internal/OpenLichtHandlerFactory.java @@ -27,9 +27,10 @@ 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.PolarHandler; +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.binding.openlicht.handler.SmartphoneHandler; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; @@ -47,7 +48,8 @@ import org.slf4j.LoggerFactory; public class OpenLichtHandlerFactory extends BaseThingHandlerFactory { private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet( - Stream.of(THING_TYPE_SKYWRITER_HAT, THING_TYPE_POLAR, THING_TYPE_SMARTPHONE).collect(Collectors.toSet())); + Stream.of(THING_TYPE_SKYWRITER_HAT, THING_TYPE_POLAR_M600, THING_TYPE_MOTO_360, THING_TYPE_SAMSUNG_S6) + .collect(Collectors.toSet())); private @Nullable MqttService service; @Override @@ -55,11 +57,6 @@ public class OpenLichtHandlerFactory extends BaseThingHandlerFactory { return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); } - // @Override - // protected void activate(ComponentContext componentContext) { - // super.activate(componentContext); - // }; - @Override protected @Nullable ThingHandler createHandler(Thing thing) { ThingTypeUID thingTypeUID = thing.getThingTypeUID(); @@ -67,11 +64,14 @@ public class OpenLichtHandlerFactory extends BaseThingHandlerFactory { if (THING_TYPE_SKYWRITER_HAT.equals(thingTypeUID)) { return new SkyWriterHATHandler(thing, this.service); } - if (THING_TYPE_POLAR.equals(thingTypeUID)) { - return new PolarHandler(thing, this.service); + if (THING_TYPE_POLAR_M600.equals(thingTypeUID)) { + return new PolarM600Handler(thing, this.service); + } + if (THING_TYPE_MOTO_360.equals(thingTypeUID)) { + return new Moto360Handler(thing, this.service); } - if (THING_TYPE_SMARTPHONE.equals(thingTypeUID)) { - return new SmartphoneHandler(thing, this.service); + if (THING_TYPE_SAMSUNG_S6.equals(thingTypeUID)) { + return new SamsungS6Handler(thing, this.service); } return null;