Skip to content

Commit

Permalink
[etherrain] EtherRain Binding initial contribution (openhab#5634)
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Inkenbrandt <joe@inkenbrandt.com>
Signed-off-by: CSchlipp <christian@schlipp.de>
  • Loading branch information
dfad1469 authored and CSchlipp committed Jul 26, 2020
1 parent 32a4b4e commit e139b63
Show file tree
Hide file tree
Showing 23 changed files with 1,385 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
/bundles/org.openhab.binding.elerotransmitterstick/ @vbier
/bundles/org.openhab.binding.enocean/ @fruggy83
/bundles/org.openhab.binding.enturno/ @klocsson
/bundles/org.openhab.binding.etherrain/ @dfad1469
/bundles/org.openhab.binding.evohome/ @Nebula83
/bundles/org.openhab.binding.exec/ @kgoderis
/bundles/org.openhab.binding.feed/ @svilenvul
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@
<artifactId>org.openhab.binding.enturno</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.etherrain</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.evohome</artifactId>
Expand Down
32 changes: 32 additions & 0 deletions bundles/org.openhab.binding.etherrain/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions bundles/org.openhab.binding.etherrain/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.etherrain</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
14 changes: 14 additions & 0 deletions bundles/org.openhab.binding.etherrain/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab2-addons

61 changes: 61 additions & 0 deletions bundles/org.openhab.binding.etherrain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Etherrain Binding

The Etherrain binding is used to control a sprinkler controller from Quicksmart:

http://www.quicksmart.com/qs_etherrain.html

The API exposed by the controller is fairly robust, but it is specific.
The binding attempts to map this API to an openHAB thing while perserving the functionality.

## Overview

An Etherrain controller can control 7-8 zones (depending on model) and can also report on the status of a rain sensor.
The controller itself accepts a single command that contains an initial delay, and an on-time for each of the zone.
Once this execute command is sent, the controller will, first, wait the initial delay time, then cycle through each zone and turn it on the amount of time specified.
The binding exposes the rain sensor as a contact as well as the operating status of of the controller.


## Supported Things

The etherrain thing represents a physical Etherrain controller and contains all channels need to control it.

## Discovery

The binding will automatically discover Etherrain controllers when a thing is added.

## Binding Configuration

There are two main categories of configuration.
The first is the configuration of the communication settings (IP address, timeout, etc.).
The second is the initial delay and on-time for each zone when an execute command is issued.

## Thing Configuration

This is optional, it is recommended to let the binding discover and add Etherrain controllers.

To manually configure a Etherrain controller you may specify it's host name or ip ("host").
You can also optionally specify the unit's password ("pw"), port it is communicating on ("port") or refresh rate ("refresh")

```
Bridge etherrain:etherrain:BackyardSprinkler [ host="192.168.1.100"]
```

## Channels

The etherrain controller exposes the rain sensor as well as several status messages.
Finally, there are commands to execute and clear the commands:

items:

```
String SprinkerCommandStatus "Command Status [%s]" (gMain) { channel="etherrain:etherrain:sprinkler0:commandstatus" }
String SprinkerOperatingStatus "Operating Status [%s]" (gMain) { channel="etherrain:etherrain:sprinkler0:operatingstatus" }
String SprinkerOperatingResult "Operating Result [%s]" (gMain) { channel="etherrain:etherrain:sprinkler0:operatingresult" }
String SprinklerActiveZone "Active Zone [%s]" (gMain) { channel="etherrain:etherrain:sprinkler0:relayindex" }
Switch SprinklerRainSensor (gMain) { channel="etherrain:etherrain:sprinkler0:rainsensor" }
Switch SprinklerExecute (gMain) { channel="etherrain:etherrain:sprinkler0:execute" }
Switch SprinklerClear (gMain) { channel="etherrain:etherrain:sprinkler0:clear" }
```

15 changes: 15 additions & 0 deletions bundles/org.openhab.binding.etherrain/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>2.5.4-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.etherrain</artifactId>

<name>openHAB Add-ons :: Bundles :: EtherRain Binding</name>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.etherrain-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>

<feature name="openhab-binding-etherrain" description="Etherrain Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.etherrain/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.etherrain.internal;

import java.util.Collections;
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.thing.ThingTypeUID;

/**
* The {@link EtherRainBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Joe Inkenbrandt - Initial contribution
*/
@NonNullByDefault
public class EtherRainBindingConstants {

private static final String BINDING_ID = "etherrain";

// List of all Thing ids

private static final String ETHERRAIN = "etherrain";

// List of all Thing Type UIDs

public static final ThingTypeUID ETHERRAIN_THING = new ThingTypeUID(BINDING_ID, ETHERRAIN);
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(ETHERRAIN_THING);

// List of internal default values

public static final int DEFAULT_WAIT_BEFORE_INITIAL_REFRESH = 30;
public static final int DEFAULT_REFRESH_RATE = 60;
public static final short DISCOVERY_SUBNET_MASK = 24;
public static final int DISCOVERY_THREAD_POOL_SIZE = 15;
public static final int DISCOVERY_THREAD_POOL_SHUTDOWN_WAIT_TIME_SECONDS = 300;
public static final boolean DISCOVERY_DEFAULT_AUTO_DISCOVER = false;
public static final int DISCOVERY_DEFAULT_TIMEOUT_RATE = 500;
public static final int DISCOVERY_DEFAULT_IP_TIMEOUT_RATE = 750;

// List of all Channel ids

public static final String CHANNEL_ID_COMMAND_STATUS = "commandstatus";
public static final String CHANNEL_ID_OPERATING_STATUS = "operatingstatus";
public static final String CHANNEL_ID_OPERATING_RESULT = "operatingresult";
public static final String CHANNEL_ID_RELAY_INDEX = "relayindex";
public static final String CHANNEL_ID_SENSOR_RAIN = "rainsensor";
public static final String CHANNEL_ID_START_DELAY = "startdelay";
public static final String CHANNEL_ID_EXECUTE = "execute";
public static final String CHANNEL_ID_CLEAR = "clear";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.etherrain.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link EtherRainException} class defines an exception for handling
* EtherRainExceptions
*
* @author Joe Inkenbrandt - Initial contribution
*/

@NonNullByDefault
public class EtherRainException extends Exception {
private static final long serialVersionUID = 1348095602193770716L;

public EtherRainException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.etherrain.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
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;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.eclipse.smarthome.io.net.http.HttpClientFactory;
import org.openhab.binding.etherrain.internal.handler.EtherRainHandler;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link EtherRainHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Joe Inkenbrandt - Initial contribution
*/
@Component(service = ThingHandlerFactory.class, immediate = true, configurationPid = "binding.etherrain")
@NonNullByDefault
public class EtherRainHandlerFactory extends BaseThingHandlerFactory {

private final HttpClient httpClient;

@Activate
public EtherRainHandlerFactory(@Reference HttpClientFactory httpClientFactory) {
httpClient = httpClientFactory.getCommonHttpClient();
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return EtherRainBindingConstants.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (thingTypeUID.equals(EtherRainBindingConstants.ETHERRAIN_THING)) {
return new EtherRainHandler(thing, httpClient);
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.etherrain.internal.api;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link EtherRainCommandResult} is the response packet for Command Result
*
* @author Joe Inkenbrandt - Initial contribution
*/

@NonNullByDefault
public enum EtherRainCommandResult {
OK("OK"),
RN("RN"),
SH("SH"),
NC("NC");

private final String result;

EtherRainCommandResult(String result) {
this.result = result;
}

public String getResult() {
return result;
}

}
Loading

0 comments on commit e139b63

Please sign in to comment.