-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?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.7"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.openhab.binding.mysensors</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> |
11 changes: 11 additions & 0 deletions
11
addons/binding/org.openhab.binding.mysensors/ESH-INF/binding/binding.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<binding:binding id="mysensors" | ||
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"> | ||
|
||
<name>MySensors Binding</name> | ||
<description>This is the binding for MySensors.</description> | ||
<author>Tim Oberfoell</author> | ||
|
||
</binding:binding> |
11 changes: 11 additions & 0 deletions
11
addons/binding/org.openhab.binding.mysensors/ESH-INF/i18n/mysensors_xx_XX.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# binding | ||
binding.mysensors.name = <Your localized Binding name> | ||
binding.mysensors.description = <Your localized Binding description> | ||
|
||
# thing types | ||
thing-type.mysensors.sample.label = <Your localized Thing label> | ||
thing-type.mysensors.sample.description = <Your localized Thing description> | ||
|
||
# channel types | ||
channel-type.mysensors.sample-channel.label = <Your localized Channel label> | ||
channel-type.mysensors.sample-channel.description = <Your localized Channel description> |
24 changes: 24 additions & 0 deletions
24
addons/binding/org.openhab.binding.mysensors/ESH-INF/thing/thing-types.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<thing:thing-descriptions bindingId="mysensors" | ||
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"> | ||
|
||
<!-- Sample Thing Type --> | ||
<thing-type id="sample"> | ||
<label>MySensors Binding Thing</label> | ||
<description>Sample thing for MySensors Binding</description> | ||
|
||
<channels> | ||
<channel id="channel1" typeId="sample-channel"/> | ||
</channels> | ||
</thing-type> | ||
|
||
<!-- Sample Channel Type --> | ||
<channel-type id="sample-channel"> | ||
<item-type>mysensorsItem</item-type> | ||
<label>MySensors Binding Channel</label> | ||
<description>Sample channel for MySensors Binding</description> | ||
</channel-type> | ||
|
||
</thing:thing-descriptions> |
22 changes: 22 additions & 0 deletions
22
addons/binding/org.openhab.binding.mysensors/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: MySensors Binding | ||
Bundle-SymbolicName: org.openhab.binding.mysensors;singleton:=true | ||
Bundle-Vendor: openHAB | ||
Bundle-Version: 2.0.0.qualifier | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 | ||
Bundle-ClassPath: . | ||
Import-Package: | ||
org.openhab.binding.mysensors, | ||
org.openhab.binding.mysensors.handler, | ||
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.thing.binding.builder, | ||
org.eclipse.smarthome.core.thing.type, | ||
org.eclipse.smarthome.core.types, | ||
org.slf4j | ||
Service-Component: OSGI-INF/*.xml | ||
Export-Package: org.openhab.binding.mysensors, | ||
org.openhab.binding.mysensors.handler |
19 changes: 19 additions & 0 deletions
19
addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsHandlerFactory.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
--> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="binding.mysensors"> | ||
|
||
<implementation class="org.openhab.binding.mysensors.internal.MySensorsHandlerFactory"/> | ||
|
||
<service> | ||
<provide interface="org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory"/> | ||
</service> | ||
|
||
</scr:component> |
6 changes: 6 additions & 0 deletions
6
addons/binding/org.openhab.binding.mysensors/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source.. = src/main/java/ | ||
output.. = target/classes | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
OSGI-INF/,\ | ||
ESH-INF/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?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"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.openhab.binding</groupId> | ||
<artifactId>pom</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<groupId>org.openhab.binding</groupId> | ||
<artifactId>org.openhab.binding.mysensors</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
|
||
<name>MySensors Binding</name> | ||
<packaging>eclipse-plugin</packaging> | ||
|
||
</project> |
28 changes: 28 additions & 0 deletions
28
...ding.mysensors/src/main/java/org/openhab/binding/mysensors/MySensorsBindingConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.binding.mysensors; | ||
|
||
import org.eclipse.smarthome.core.thing.ThingTypeUID; | ||
|
||
/** | ||
* The {@link MySensorsBinding} class defines common constants, which are | ||
* used across the whole binding. | ||
* | ||
* @author Tim Oberfoell - Initial contribution | ||
*/ | ||
public class MySensorsBindingConstants { | ||
|
||
public static final String BINDING_ID = "mysensors"; | ||
|
||
// 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"; | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
...nding.mysensors/src/main/java/org/openhab/binding/mysensors/handler/MySensorsHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.binding.mysensors.handler; | ||
|
||
import static org.openhab.binding.mysensors.MySensorsBindingConstants.*; | ||
|
||
import org.eclipse.smarthome.core.thing.ChannelUID; | ||
import org.eclipse.smarthome.core.thing.Thing; | ||
import org.eclipse.smarthome.core.thing.ThingStatus; | ||
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 MySensorsHandler} is responsible for handling commands, which are | ||
* sent to one of the channels. | ||
* | ||
* @author Tim Oberfoell - Initial contribution | ||
*/ | ||
public class MySensorsHandler extends BaseThingHandler { | ||
|
||
private Logger logger = LoggerFactory.getLogger(MySensorsHandler.class); | ||
|
||
public MySensorsHandler(Thing thing) { | ||
super(thing); | ||
} | ||
|
||
@Override | ||
public void handleCommand(ChannelUID channelUID, Command command) { | ||
if(channelUID.getId().equals(CHANNEL_1)) { | ||
// 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() { | ||
// TODO: Initialize the thing. If done set status to ONLINE to indicate proper working. | ||
// Long running initialization should be done asynchronously in background. | ||
updateStatus(ThingStatus.ONLINE); | ||
|
||
// 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"); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...sensors/src/main/java/org/openhab/binding/mysensors/internal/MySensorsHandlerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) 2014 openHAB UG (haftungsbeschraenkt) and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.binding.mysensors.internal; | ||
|
||
import static org.openhab.binding.mysensors.MySensorsBindingConstants.*; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
import org.openhab.binding.mysensors.handler.MySensorsHandler; | ||
import org.eclipse.smarthome.core.thing.Thing; | ||
import org.eclipse.smarthome.core.thing.ThingTypeUID; | ||
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory; | ||
import org.eclipse.smarthome.core.thing.binding.ThingHandler; | ||
|
||
/** | ||
* The {@link MySensorsHandlerFactory} is responsible for creating things and thing | ||
* handlers. | ||
* | ||
* @author Tim Oberfoell - Initial contribution | ||
*/ | ||
public class MySensorsHandlerFactory extends BaseThingHandlerFactory { | ||
|
||
private final static Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_SAMPLE); | ||
|
||
@Override | ||
public boolean supportsThingType(ThingTypeUID thingTypeUID) { | ||
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); | ||
} | ||
|
||
@Override | ||
protected ThingHandler createHandler(Thing thing) { | ||
|
||
ThingTypeUID thingTypeUID = thing.getThingTypeUID(); | ||
|
||
if (thingTypeUID.equals(THING_TYPE_SAMPLE)) { | ||
return new MySensorsHandler(thing); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
|