Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
Add Things with initial configuration and empty handler
add Switch State
Receive Current and Power States for SP-2101W
add state format
add disclaimer and javadoc to each class
add scheduler for refreshing the state and values of the thing
add english i18n
adapt infos from code review

Signed-off-by: Falk Harnisch <[email protected]>
  • Loading branch information
Falk authored and fharni committed Jul 3, 2018
1 parent c13f764 commit 20b62a1
Show file tree
Hide file tree
Showing 27 changed files with 1,361 additions and 1 deletion.
7 changes: 7 additions & 0 deletions addons/binding/org.openhab.binding.edimax/.classpath
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.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions addons/binding/org.openhab.binding.edimax/.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.edimax</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="edimax"
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>Edimax SmartPlug Binding</name>
<description>This is the binding for Edimax SmartPlug.</description>
<author>Falk Harnisch</author>

</binding:binding>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# binding
binding.edimax.name = Edimax Binding
binding.edimax.description = Binding for Edimax SmartPlug

# thing types
thing-type.edimax.sp1101w.label = Edimax SP-1101W Binding
thing-type.edimax.sp1101w.description = Binding for Edimax SP-1101W SmartPlug
thing-type.edimax.sp2101w.label = Edimax SP-2101W Binding
thing-type.edimax.sp2101w.description = Binding for Edimax SP-2101W SmartPlug

# channel types
channel-type.edimax.switch.label = Switch
channel-type.edimax.switch.description = On/Off Switch
channel-type.edimax.current.label = Current
channel-type.edimax.current.description = Current in A
channel-type.edimax.power.label = Power
channel-type.edimax.power.description = Power in W
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# binding
binding.edimax.name = Edimax Bindung
binding.edimax.description = Bindung für die Edimax Zwischenstecker

# thing types
thing-type.edimax.sp1101w.label = Edimax SP-1101W Bindung
thing-type.edimax.sp1101w.description = Bindung für den Edimax SP-1101W Zwischenstecker
thing-type.edimax.sp2101w.label = Edimax SP-2101W Bindung
thing-type.edimax.sp2101w.description = Bindung für den Edimax SP-2101W Zwischenstecker

# channel types
channel-type.edimax.switch.label = Schalter
channel-type.edimax.switch.description = An/Aus Schalter
channel-type.edimax.current.label = Strom
channel-type.edimax.current.description = Stromverbrauch in A
channel-type.edimax.power.label = Leistung
channel-type.edimax.power.description = Leistung in W
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="edimax"
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">

<thing-type id="sp2101w">
<label>SP-2101W</label>
<description>Edimax SP-2101W</description>

<channels>
<channel id="switch" typeId="switch" />
<channel id="current" typeId="current" />
<channel id="power" typeId="power" />
</channels>

<config-description>
<parameter name="ipAddress" type="text" required="true">
<label>IP address</label>
<description>The IP address of the Edimax Plug</description>
<context>network-address</context>
</parameter>
<parameter name="username" type="text" required="true">
<label>Username</label>
<description>Username to access the Edimax Plug.</description>
<default>admin</default>
</parameter>
<parameter name="password" type="text" required="true">
<label>Password</label>
<description>Password to access the Edimax Plug.</description>
<default>1234</default>
<context>password</context>
</parameter>
</config-description>
</thing-type>

<thing-type id="sp1101w">
<label>SP-1101W</label>
<description>Edimax SP-1101W</description>

<channels>
<channel typeId="switch" id="switch" />
</channels>

<config-description>
<parameter name="ipAddress" type="text" required="true">
<label>IP address</label>
<description>The IP address of the Edimax Plug</description>
<context>network-address</context>
</parameter>
<parameter name="username" type="text" required="true">
<label>Username</label>
<description>Username to access the Edimax Plug.</description>
<default>admin</default>
</parameter>
<parameter name="password" type="text" required="true">
<label>Password</label>
<description>Password to access the Edimax Plug.</description>
<default>1234</default>
<context>password</context>
</parameter>
</config-description>
</thing-type>

<channel-type id="switch">
<item-type>Switch</item-type>
<label>Switch</label>
<description>On/Off Switch</description>
<category>Switch</category>
</channel-type>

<channel-type id="current">
<item-type>Number</item-type>
<label>Current</label>
<description>Current of the Switch in Ampere</description>
<state readOnly="true" pattern="%.3f A" />
</channel-type>

<channel-type id="power">
<item-type>Number</item-type>
<label>Power</label>
<description>Power of the Switch in Watt</description>
<state readOnly="true" pattern="%.2f W" />
</channel-type>

</thing:thing-descriptions>
22 changes: 22 additions & 0 deletions addons/binding/org.openhab.binding.edimax/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Manifest-Version: 1.0
Bundle-ClassPath: .
Bundle-ManifestVersion: 2
Bundle-Name: Edimax Binding
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.openhab.binding.edimax;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.4.0.qualifier
Export-Package: org.openhab.binding.edimax
Import-Package:
org.apache.commons.lang.builder,
org.eclipse.jdt.annotation;resolution:=optional,
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.openhab.binding.edimax,
org.slf4j
Service-Component: OSGI-INF/*.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010-2018 by the respective copyright holders.
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.edimax">

<implementation class="org.openhab.binding.edimax.internal.handler.EdimaxHandlerFactory"/>

<service>
<provide interface="org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory"/>
</service>

</scr:component>
61 changes: 61 additions & 0 deletions addons/binding/org.openhab.binding.edimax/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Edimax Binding

This binding can handle Edimax Smart Plug switches.

## Supported Things

This binding supports the following thing types:

| Thing | Thing Type | Description |
|--------------|------------|--------------------------------------------------------|
| sp1101w | Thing | A smart plug, that can be remote switched. |
| sp2101w | Thing | Same as sp1101w, but with metering feature. |

## Binding Configuration

There are no overall binding configuration settings that need to be set.
All settings are through thing configuration parameters.

## Thing Configuration

All things has the same configuration properties.

| Parameter Label | Parameter ID | Description | Required |
|------------------------------|--------------------------|----------------------------------------------------|----------|
| IP Address | ipAddress | The IP address of the Edimax Plug. | true |
| Username | username | Username to access the Edimax Plug. | true |
| Password | password | Password to access the Edimax Plug. | true |

## Channels

SP-1101W support the following channels:

| Channel Type ID | Item Type | Description |
|-----------------|--------------|-------------------------------------------|
| switch | Switch | On/Off Switch |

SP-2101W support the following channels:

| Channel Type ID | Item Type | Description |
|-----------------|--------------|-------------------------------------------|
| switch | Switch | On/Off Switch |
| Current | Number | Current of the Switch in ampere |
| Power | Number | Power of the Switch in watt |

## Full Example

**demo.things**

```
edimax:sp1101w:switch1 "Switch SP-1101W" [ ipAddress="192.168.188.26", username="admin", password="1234" ]
edimax:sp2101w:switch2 "Switch SP-2101W" [ ipAddress="192.168.188.26", username="admin", password="1234" ]
```

**demo.items**

```
Switch Light { channel="edimax:sp1101w:switch1:switch"}
Switch Washer { channel="edimax:sp2101w:switch2:switch"}
Number Current { channel="edimax:sp2101w:switch2:current"}
Number Power { channel="edimax:sp2101w:switch2:power"}
```
28 changes: 28 additions & 0 deletions addons/binding/org.openhab.binding.edimax/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>

<p>June 5, 2006</p>
<h3>License</h3>

<p>The openHAB community makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>

<p>If you did not receive this Content directly from the openHAB community, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.openhab.org/">openhab.org</a>.</p>

</body>
</html>
7 changes: 7 additions & 0 deletions addons/binding/org.openhab.binding.edimax/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source.. = src/main/java/
output.. = target/classes
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
ESH-INF/,\
about.html
18 changes: 18 additions & 0 deletions addons/binding/org.openhab.binding.edimax/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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.4.0-SNAPSHOT</version>
</parent>

<groupId>org.openhab.binding</groupId>
<artifactId>org.openhab.binding.edimax</artifactId>

<name>Edimax Binding</name>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* 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.edimax;

import org.eclipse.smarthome.core.thing.ThingTypeUID;

/**
* The {@link EdimaxBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Falk Harnisch - Initial contribution
*/
public class EdimaxBindingConstants {

public static final String BINDING_ID = "edimax";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_SP1101W = new ThingTypeUID(BINDING_ID, "sp1101w");
public static final ThingTypeUID THING_TYPE_SP2101W = new ThingTypeUID(BINDING_ID, "sp2101w");

// List of all Channel ids
public static final String SWITCH = "switch";
public static final String CURRENT = "current";
public static final String POWER = "power";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* 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.edimax.internal;

/**
* This Exception will be thrown, if the return type is unknown.
*
* @author Falk Harnisch - Initial Contribution
*
*/
public class UnknownTypeException extends RuntimeException {

private static final long serialVersionUID = 4826720539738874681L;

public UnknownTypeException(String message) {
super(message);
}
}
Loading

0 comments on commit 20b62a1

Please sign in to comment.