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

Separate different smartwatches.

parent 7a544205
No related branches found
No related tags found
No related merge requests found
......@@ -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";
......
......@@ -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<>();
}
......
......@@ -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<>();
}
......
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);
}
}
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);
}
}
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);
}
}
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment