Skip to content

Commit

Permalink
First commit of new Wemo Binding for openHAB 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
hmerk committed Jul 25, 2014
1 parent a6169db commit 7fad9ee
Show file tree
Hide file tree
Showing 15 changed files with 728 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bundles/binding/org.openhab.binding.wemo/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions bundles/binding/org.openhab.binding.wemo/.project
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.wemo</name>
<comment>This is the Wemo binding of the open Home Automation Bus (openHAB)</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.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
34 changes: 34 additions & 0 deletions bundles/binding/org.openhab.binding.wemo/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Manifest-Version: 1.0
Private-Package: org.openhab.binding.wemo.internal
Ignore-Package: org.openhab.binding.wemo.internal
Bundle-License: http://www.eclipse.org/legal/epl-v10.html
Bundle-Name: openHAB Wemo Binding
Bundle-SymbolicName: org.openhab.binding.wemo
Bundle-Vendor: openHAB.org
Bundle-Version: 1.6.0.qualifier
Bundle-Activator: org.openhab.binding.wemo.internal.WemoActivator
Bundle-ManifestVersion: 2
Bundle-Description: This is the Wemo binding of the open Home Aut
omation Bus (openHAB)
Import-Package: org.apache.commons.lang,
org.openhab.core.binding,
org.openhab.core.events,
org.openhab.core.items,
org.openhab.core.library.items,
org.openhab.core.library.types,
org.openhab.core.types,
org.openhab.io.net.http,
org.openhab.model.item.binding,
org.osgi.framework,
org.osgi.service.cm,
org.osgi.service.component,
org.osgi.service.event,
org.slf4j
Export-Package: org.openhab.binding.wemo,
org.openhab.binding.wemo.internal
Bundle-DocURL: http://www.openhab.org
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Service-Component: OSGI-INF/binding.xml, OSGI-INF/genericbindingprovider.xml
Bundle-ClassPath: .
Require-Bundle: org.apache.commons.io

30 changes: 30 additions & 0 deletions bundles/binding/org.openhab.binding.wemo/OSGI-INF/binding.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010-2014, openHAB.org 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" activate="activate" deactivate="deactivate" name="org.openhab.binding.wemo.binding">
<implementation class="org.openhab.binding.wemo.internal.WemoBinding" />

<service>
<provide interface="org.osgi.service.event.EventHandler" />
<provide interface="org.osgi.service.cm.ManagedService" />
</service>

<property name="event.topics" type="String" value="openhab/command/*" />
<property name="service.pid" type="String" value="org.openhab.wemo" />

<reference bind="setEventPublisher" cardinality="1..1"
interface="org.openhab.core.events.EventPublisher" name="EventPublisher"
policy="dynamic" unbind="unsetEventPublisher" />
<reference bind="addBindingProvider" cardinality="1..n"
interface="org.openhab.binding.wemo.WemoBindingProvider" name="WemoBindingProvider"
policy="dynamic" unbind="removeBindingProvider" />

</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010-2014, openHAB.org 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" name="org.openhab.binding.wemo.genericbindingprovider">
<implementation class="org.openhab.binding.wemo.internal.WemoGenericBindingProvider"/>

<service>
<provide interface="org.openhab.model.item.binding.BindingConfigReader"/>
<provide interface="org.openhab.binding.wemo.WemoBindingProvider"/>
</service>

</scr:component>
26 changes: 26 additions & 0 deletions bundles/binding/org.openhab.binding.wemo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Documentation of the Wemo binding bundle

## Introduction

The openHAB Wemo binding allows to send commands Belkin Wemo Switches.

For installation of the binding, please see Wiki page [[Bindings]].

####This Binding will be available with openHAB version 1.6 !!!

Wemo Binding needs no configuration in openhab.cfg


## Item Binding Configuration

In order to bind an item to the device, you need to provide configuration settings. The easiest way to do so is to add some binding information in your item file (in the folder configurations/items`). The syntax of the binding configuration strings accepted is the following:

wemo="<friendlyName>"

The friendlyName is given to your device during initial setup with your Android or IOS device.
If not shure about the friendlyNames of your devices, define loglevel "trace" for Wemo Binding and it will show up the found friendlyNames on startup.

Examples, how to configure your items in your items file:

Switch WallFanOffice {wemo="WemoFanOffice"} #Item Name and friendlyName must not be identical!

6 changes: 6 additions & 0 deletions bundles/binding/org.openhab.binding.wemo/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
output.. = target/classes/
source.. = src/main/java/,\
src/main/resources/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
37 changes: 37 additions & 0 deletions bundles/binding/org.openhab.binding.wemo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
<groupId>org.openhab.bundles</groupId>
<artifactId>binding</artifactId>
<version>1.6.0-SNAPSHOT</version>
</parent>

<properties>
<bundle.symbolicName>org.openhab.binding.wemo</bundle.symbolicName>
<bundle.namespace>org.openhab.binding.wemo</bundle.namespace>
<deb.name>openhab-addon-binding-Wemo</deb.name>
<deb.description>openhab addon binding Wemo</deb.description>
</properties>

<modelVersion>4.0.0</modelVersion>
<groupId>org.openhab.binding</groupId>
<artifactId>org.openhab.binding.wemo</artifactId>

<name>openHAB Wemo Binding</name>

<packaging>eclipse-plugin</packaging>

<version>1.6.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.vafer</groupId>
<artifactId>jdeb</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2010-2014, openHAB.org 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.wemo;

import org.openhab.core.binding.BindingProvider;


/**
* @author Hans-Jörg Merk
* @since 1.6.0
*/
public interface WemoBindingProvider extends BindingProvider {

/**
* Get the friendly name for the specified item
*
* @param itemName
* The item whose friendly name is required
* @return The openHAB class type
*/
public String getWemoFriendlyName(String itemName);


}


Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"></u:GetBinaryState>
</s:Body>
</s:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1">
<BinaryState>{{state}}</BinaryState>
</u:SetBinaryState>
</s:Body>
</s:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (c) 2010-2014, openHAB.org 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.wemo.internal;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
* Extension of the default OSGi bundle activator
*
* @author Hans-Jörg Merk
* @since 1.6.0
*/
public final class WemoActivator implements BundleActivator {

private static Logger logger = LoggerFactory.getLogger(WemoActivator.class);

private static BundleContext context;

/**
* Called whenever the OSGi framework starts our bundle
*/
public void start(BundleContext bc) throws Exception {
context = bc;
logger.debug("Wemo binding has been started.");
}

/**
* Called whenever the OSGi framework stops our bundle
*/
public void stop(BundleContext bc) throws Exception {
context = null;
logger.debug("Wemo binding has been stopped.");
}

/**
* Returns the bundle context of this bundle
* @return the bundle context
*/
public static BundleContext getContext() {
return context;
}

}
Loading

0 comments on commit 7fad9ee

Please sign in to comment.