зеркало из https://github.com/mozilla/smarthome.git
a few improvements to the binding archetype
Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Родитель
fef7f6f43e
Коммит
2cf7963b75
|
@ -3,5 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -8,9 +8,11 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
|||
Bundle-ClassPath: .
|
||||
Import-Package: com.google.common.collect,
|
||||
org.eclipse.smarthome.config.core,
|
||||
org.eclipse.smarthome.core.library.types,
|
||||
org.eclipse.smarthome.core.thing,
|
||||
org.eclipse.smarthome.core.thing.binding,
|
||||
org.eclipse.smarthome.core.types
|
||||
org.eclipse.smarthome.core.types,
|
||||
org.slf4j
|
||||
Service-Component: OSGI-INF/*
|
||||
Export-Package: ${package},
|
||||
${package}.handler
|
||||
|
|
|
@ -19,7 +19,10 @@ public class ${bindingIdCamelCase}BindingConstants {
|
|||
|
||||
public static final String BINDING_ID = "${bindingId}";
|
||||
|
||||
// List all Thing Type UIDs, related to the ${bindingIdCamelCase} Binding
|
||||
public final static ThingTypeUID SAMPLE_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "sample");
|
||||
// List of all Thing Type UIDs
|
||||
public final static ThingTypeUID THING_TYPE_SAMPLE = new ThingTypeUID(BINDING_ID, "sample");
|
||||
|
||||
// List of all Channel ids
|
||||
public final static String CHANNEL_1 = "channel1");
|
||||
|
||||
}
|
||||
|
|
|
@ -7,10 +7,14 @@
|
|||
*/
|
||||
package ${package}.handler;
|
||||
|
||||
import static ${package}.${bindingIdCamelCase}BindingConstants.*;
|
||||
|
||||
import org.eclipse.smarthome.core.thing.ChannelUID;
|
||||
import org.eclipse.smarthome.core.thing.Thing;
|
||||
import org.eclipse.smarthome.core.thing.binding.BaseThingHandler;
|
||||
import org.eclipse.smarthome.core.types.Command;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The {@link ${bindingIdCamelCase}Handler} is responsible for handling commands, which are
|
||||
|
@ -20,13 +24,15 @@ import org.eclipse.smarthome.core.types.Command;
|
|||
*/
|
||||
public class ${bindingIdCamelCase}Handler extends BaseThingHandler {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(${bindingIdCamelCase}Handler.class);
|
||||
|
||||
public ${bindingIdCamelCase}Handler(Thing thing) {
|
||||
super(thing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||
if(channelUID.getId().equals("channel1")) {
|
||||
if(channelUID.getId().equals(CHANNEL_1)) {
|
||||
// TODO: handle command
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче