Skip to content

Commit

Permalink
Initial contribution of the RME OH2.0 Binding
Browse files Browse the repository at this point in the history
Signed-off-by: Karel Goderis <[email protected]> (github: kgoderis)
  • Loading branch information
kgoderis committed Feb 28, 2016
1 parent bee04e0 commit 20b07a0
Show file tree
Hide file tree
Showing 13 changed files with 740 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/binding/org.openhab.binding.rme/.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.7"/>
<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.rme/.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.rme</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 addons/binding/org.openhab.binding.rme/ESH-INF/binding/binding.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="rme"
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>RME Binding</name>
<description>This is the binding for RME Rain Manager.</description>
<author>Karel Goderis</author>

</binding:binding>
95 changes: 95 additions & 0 deletions addons/binding/org.openhab.binding.rme/ESH-INF/thing/rme.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="rme"
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="manager">
<label>RME Rain Manager</label>
<description>The RME Rain Manager is a controllable water supply unit that can monitor a gauge in a cistern, and switch between rain water and city provided water</description>

<channels>
<channel id="waterlevel" typeId="waterlevel" />
<channel id="mode" typeId="mode" />
<channel id="source" typeId="source" />
<channel id="exitpump" typeId="statusflag">
<label>Exit Pump Active</label>
</channel>
<channel id="entrypump" typeId="statusflag">
<label>Entry Pump Active</label>
</channel>
<channel id="waterexchange" typeId="statusflag">
<label>Water Exchange Active</label>
</channel>
<channel id="cisternsupplyalarm" typeId="statusflag">
<label>Cistern Supply Alarm</label>
</channel>
<channel id="overflowalarm" typeId="statusflag">
<label>Overflow Alarm</label>
</channel>
<channel id="cisternblockedalarm" typeId="statusflag">
<label>Cistern Blocked Alarm</label>
</channel>
<channel id="filtercleaning" typeId="statusflag">
<label>Filter Cleaning Required</label>
</channel>
</channels>

<config-description>
<parameter name="port" type="text">
<label>Serial Port</label>
<description>Serial Port the RME Rain Manager is connected to</description>
<required>true</required>
</parameter>
</config-description>
</thing-type>

<!-- Water Level Channel Type -->
<channel-type id="waterlevel">
<item-type>Number</item-type>
<label>Water Level</label>
<description>Indicates the % the cistern is filled with water</description>
<state readOnly="true" pattern="%.1f %%" />
</channel-type>

<!-- Operation Mode Channel Type -->
<channel-type id="mode">
<item-type>String</item-type>
<label>Operation Mode</label>
<description>Indicates the operation mode of the RME Rain Manager</description>
<state readOnly="true">
<options>
<option value="Automatic">Automatic</option>
<option value="Manual">Manual</option>
</options>
</state>
</channel-type>

<!-- Operation Mode Channel Type -->
<channel-type id="source">
<item-type>String</item-type>
<label>Water Source</label>
<description>Indicates water source used to supply water, e.g cistern or city</description>
<state readOnly="true">
<options>
<option value="Rain">Rain</option>
<option value="City">City</option>
</options>
</state>
</channel-type>

<!-- Status Flag Channel Type -->
<channel-type id="statusflag" advanced="true">
<item-type>Switch</item-type>
<label>Status Flag</label>
<description>Status Flag of an RME operational parameter, e.g ON if set, OFF if unset</description>
<state readOnly="true">
<options>
<option value="ON">ON</option>
<option value="OFF">OFF</option>
</options>
</state>
</channel-type>

</thing:thing-descriptions>
21 changes: 21 additions & 0 deletions addons/binding/org.openhab.binding.rme/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: RME Binding
Bundle-SymbolicName: org.openhab.binding.rme;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: .
Import-Package: com.google.common.collect,
org.apache.commons.io,
org.apache.commons.lang,
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.slf4j
Service-Component: OSGI-INF/*.xml
Export-Package: org.openhab.binding.rme,
org.openhab.binding.rme.handler
Require-Bundle: org.openhab.io.transport.serial
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.openhab.binding.rme.internal.RMEHandlerFactory">

<implementation class="org.openhab.binding.rme.internal.RMEHandlerFactory"/>

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

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

This binding integrates the RME RainManager rain water pump and management system

## Supported Things

Manager

## Thing Configuration

The Thing configuration requires the name of the serial port that is used to connect the ESH host with the RME unit

## Channels

All devices support some of the following channels:

| Channel Type ID | Item Type | Description |
|-----------------|------------------------|--------------|----------------- |------------- |
| waterlevel | Number | Indicates the % the cistern is filled with water |
| mode | String | Indicates the operation mode of the RME Rain Manager, Automatic or Manual |
| source | String | Indicates water source used to supply water, e.g cistern or city |
| exitpump | Switch | Indicates whether the exit pump is switched on |
| entrypump | Switch | Indicates whether the entry pump is switched on |

## Full Example

.things

```
Thing rme:manager:m1 [ port="/dev/tty.usbserial-FTGVQA6D" ]
```

.items
```
Number RMECisternLevel "Water level [%.1f %%]"(rme) {channel="rme:manager:m1:waterlevel"}
String RMEMode (rme) {channel="rme:manager:m1:mode"}
String RMESource (rme) {channel="rme:manager:m1:source"}
Switch RMEExitPump (rme) {channel="rme:manager:m1:exitpump"}
Switch RMEEntryPump (rme) {channel="rme:manager:m1:entrypump"}
Switch RMEWaterExchange (rme) {channel="rme:manager:m1:waterexchange"}
Switch RMECisternSupply (rme) {channel="rme:manager:m1:cisternsupplyalarm"}
Switch RMEOverflowAlarm (rme) {channel="rme:manager:m1:overflowalarm"}
Switch RMECisternBlockedAlarm (rme) {channel="rme:manager:m1:cisternblockedalarm"}
Switch RMEFilterCleaning(rme) {channel="rme:manager:m1:filtercleaning"}
```
6 changes: 6 additions & 0 deletions addons/binding/org.openhab.binding.rme/build.properties
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/
24 changes: 24 additions & 0 deletions addons/binding/org.openhab.binding.rme/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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>

<properties>
<bundle.symbolicName>org.openhab.binding.rme</bundle.symbolicName>
<bundle.namespace>org.openhab.binding.rme</bundle.namespace>
</properties>

<groupId>org.openhab.binding</groupId>
<artifactId>org.openhab.binding.rme</artifactId>
<version>2.0.0-SNAPSHOT</version>

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

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* 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.rme;

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

/**
* The {@link RMEBinding} class defines common constants, which are used across
* the whole binding.
*
* @author Karel Goderis - Initial contribution
*/
public class RMEBindingConstants {

public static final String BINDING_ID = "rme";

// List of all Thing Type UIDs
public final static ThingTypeUID THING_TYPE_MANAGER = new ThingTypeUID(BINDING_ID, "manager");

// List of all Channel ids
public enum DataField {

LEVEL("waterlevel", 1),
MODE("mode", 2),
SOURCE("source", 3),
EXITPUMP("exitpump", 4),
ENTRYPUMP("entrypump", 5),
WATEREXCHANGE("waterexchange", 6),
CISTERNSUPPLYALARM("cisternsupplyalarm", 7),
OVERFLOWALARM("overflowalarm", 8),
CISTERNBLOCKEDALARM("cisternblockedalarm", 9),
FILTERCLEANING("filtercleaning", 10);

private final String id;
private final int number;

private DataField(final String id, final int number) {
this.number = number;
this.id = id;
}

@Override
public String toString() {
return String.valueOf(number);
}

public int toNumber() {
return number;
}

public static DataField get(int valueSelectorNumber) throws IllegalArgumentException {

for (DataField c : DataField.values()) {
if (c.number == valueSelectorNumber) {
return c;
}
}

throw new IllegalArgumentException("Not a valid value selector");
}

public static DataField get(String valueSelectorText) throws IllegalArgumentException {

for (DataField c : DataField.values()) {
if (c.id.equals(valueSelectorText)) {
return c;
}
}

throw new IllegalArgumentException("Not a valid value selector");
}

public String channelID() {
return this.id;
}

}

}
Loading

0 comments on commit 20b07a0

Please sign in to comment.