Skip to content

Commit

Permalink
[gce] GCE Binding initial contribution (openhab#5457)
Browse files Browse the repository at this point in the history
Signed-off-by:  Gaël L'hopital <gael@lhopital.org>
  • Loading branch information
clinique authored and andrewfg committed Oct 8, 2020
1 parent ff40520 commit 3b9bdbf
Show file tree
Hide file tree
Showing 28 changed files with 1,871 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 @@ -71,6 +71,7 @@
/bundles/org.openhab.binding.fsinternetradio/ @paphko
/bundles/org.openhab.binding.ftpupload/ @paulianttila
/bundles/org.openhab.binding.gardena/ @gerrieg
/bundles/org.openhab.binding.gce/ @clinique
/bundles/org.openhab.binding.globalcache/ @mhilbush
/bundles/org.openhab.binding.gpstracker/ @gbicskei
/bundles/org.openhab.binding.gree/ @markus7017
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 @@ -351,6 +351,11 @@
<artifactId>org.openhab.binding.gardena</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.gce</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.goecharger</artifactId>
Expand Down
32 changes: 32 additions & 0 deletions bundles/org.openhab.binding.gce/.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.gce/.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.gce</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>
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.gce/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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/openhab-addons
192 changes: 192 additions & 0 deletions bundles/org.openhab.binding.gce/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# GCE Binding

This binding aims to handle various GCE Electronics equipments.
IPX800 is a 8 relay webserver from gce-electronics with a lot of possibilities:

* 8 Digital Input
* 8 Relay (250V / 10A / channel)
* 4 Analog Input
* 8 Counters
* Ability to cascade up to 3 extensions for a total of 32 inputs / 32 relay

Each IPX800 connected to openHAB must be configured with the setting 'Send data on status changed' on the website in M2M > TCP client.

To make it simple, IPX800 is a simple device that drives output and retrieves input.
On input we generally connect push buttons (for instance house switchs), on ouputs we can connect light bulbs for instance.

Features of the binding:

* Multi ipx support
* Direct TCP connection
* Auto reconnect
* Simple clic/Long press
* Pulse mode support

## Binding Configuration

There is no configuration at binding level.


## Thing Configuration

The IPX800v3 (ID : 'ipx800v3') accepts the following configuration parameters :

| Property | Default | Required | Description |
|---------------------|---------|----------|-----------------------------|
| hostname | | Yes | IP address or hostname. |
| portNumber | 9870 | No | TCP client connection port. |
| pullInterval* | 5000 | No | Refresh interval (in ms) |

The binding will query periodically the 'globalstatus.xml' page of the IPX to get fresh informations.
This is especially usefull for Analog inputs and Counter as modification of these values on PLC side does not trigger any M2M message.

The thing provides four groups of channels.

### Digital Inputs

This represents the inputs of the PLC. Each can be open or closed.
They are usually commuted by physical devices like pushbuttons, magnets...

#### Digital Input Channels (contacts)

Each input will have these associated channels:

| Group | Channel Name | Item Type | R/W | Description |
|----------|------------------------|-------------|-----|-----------------------------------------------------------------------------|
| contact | `portnumber` | Contact | R | Status of the actual port (OPEN, CLOSED) |
| contact | `portnumber`-duration | Number:Time | R | Updated when the port status changes to the duration of the previous state. |

Associated events:

| Channel Type ID | Options | Description | Conf Dependency |
|--------------------|-------------------|--------------------------------------------------|-----------------|
| `portnumber`-event | | Triggered on or after a port status change | |
| | PRESSED | Triggered when state changes from OPEN to CLOSED | |
| | RELEASED | Triggered when state changes from CLOSED to OPEN | |
| | LONG_PRESS | Triggered when RELEASED after a long period | longPressTime |
| | SHORT_PRESS | Triggered when RELEASED before a long period | longPressTime |
| | PULSE | Triggered during CLOSED state | pulsePeriod |

#### Configuration

| Property | Default | Unit | Description |
|-----------------|---------|------|---------------------------------------------------------------------------------|
| debouncePeriod | 0(*) | ms | Debounce time (ignores flappling within this time). No debounce is done if '0'. |
| longPressTime | 0(*) | ms | Delay before triggering long press event. Ignored if '0'. |
| pulsePeriod | 0(*) | ms | Period of pulse event triggering while the entry is closed. Ignored if '0'. |
| pulseTimeout | 0(*) | ms | Period of time after pulsing will be stopped. None if '0'. |

* Values below 100ms should be avoided as the JVM could skip them and proceed in the same time slice.


### Digital Outputs Channels (relays)

Each output will have these associated channels:

| Group | Channel Name | Item Type | R/W | Description |
|----------|------------------------|-------------|-----|-----------------------------------------------------------------------------|
| relay | `portnumber` | Switch | R/W | Status of the actual port (ON, OFF) |
| relay | `portnumber`-duration | Number:Time | R | Updated when the port status changes to the duration of the previous state. |

#### Configuration

| Property | Default | Description |
|-----------------|---------|--------------------------------------------------------------------------|
| pulse | false | If set, the output will be in pulse mode, releasing it after the contact |

### Counters Channels

Each counter will have these associated channels:

| Group | Channel Name | Item Type | R/W | Description |
|----------|--------------------------|-------------|-----|--------------------------------------------------------------------------------|
| counter | `counternumber` | Number | R | Actual value of the counter |
| counter | `counternumber`-duration | Number:Time | R | Updated when the counter status changes to the duration of the previous state. |

#### Configuration

This channel has no configuration setting.

### Analog Inputs Channels

Each analog port will have these associated channels:

| Group | Channel Name | Item Type | R/W | Description |
|--------|-----------------------|--------------------------|-----|-----------------------------------------------------------------------------|
| analog | `portnumber` | Number | R | Value of the port. |
| analog | `portnumber`-duration | Number:Time | R | Updated when the port status changes to the duration of the previous state. |
| analog | `portnumber`-voltage | Number:ElectricPotential | R | Electrical equivalency of the analogic value |

#### Configuration

| Property | Default | Description |
|------------|---------|-------------------------------------------------------------------------------------|
| hysteresis | 0 | If set, the channel will ignore status if change (+ or -) is less than hysteresis/2 |


## Rule Actions

Multiple actions are supported by this binding. In classic rules these are accessible as shown in the example below:

Getting ipxActions variable in scripts

```
val ipxActions = getActions("gce","gce:ipx800v3:43cc8d07")
if(null === ipxActions) {
logInfo("actions", "ipxActions not found, check thing ID")
return
} else {
// do something with sunActions
}
```

### resetCounter(counterId)

Resets the value of the given counter to 0.

* `counterId` (Integer) - id of the counter.


### reset(placeholder)

Restarts the PLC.

* `placeholder` (Integer) - This parameter is not used (can be null).

## Example

### Things

ipx800.things

```java

Thing gce:ipx800v3:ipx "IPX800" @ "diningroom" [hostname="192.168.0.144", portNumber=9870] {
Channels:
Type contact : contact#1 [ // Aimant Détection porte de garage ouverte
debouncePeriod=2500,
pulsePeriod=1000,
pulseTimeout=60000
]
Type contact : contact#2 [ // Aimant Détection porte de garage fermée
debouncePeriod=2500
]
Type relay : relay#8 [ // Actionneur porte de garage
pulse=true
]
}
```

ipx800.items

```java

Group gIPXInputs "Inputs" <input>
Contact input1 "Porte garage ouverte [%s]" <contact> (gIPXInputs) {channel="gce:ipx800v3:ipx:contact#1"}
Contact input2 "Porte garage fermée [%s]" <contact> (gIPXInputs) {channel="gce:ipx800v3:ipx:contact#2"}

Group gIPXOutputs "Outputs" <output>
Switch output3 "Chaudière" <furnace> (gIPXOutputs) {channel="gce:ipx800v3:ipx:relay#3"}
Switch output4 "Lumière Porche" <light> (gIPXOutputs) {channel="gce:ipx800v3:ipx:relay#4"}

```
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.gce/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>2.5.9-SNAPSHOT</version>
</parent>

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

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

</project>
9 changes: 9 additions & 0 deletions bundles/org.openhab.binding.gce/src/main/feature/feature.xml
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.gce-${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-gce" description="GCE Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.gce/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.gce.internal;

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

/**
* The {@link GCEBindingConstants} class defines common constants, which are used
* across the whole binding.
*
* @author Gaël L'hopital - Initial Contribution
*/
@NonNullByDefault
public class GCEBindingConstants {

public static final String BINDING_ID = "gce";

// Bridge Type UID
public static final ThingTypeUID IPXV3_THING_TYPE = new ThingTypeUID(BINDING_ID, "ipx800v3");

public static final String CHANNEL_LAST_STATE_DURATION = "duration";
public static final String CHANNEL_VOLTAGE = "voltage";
public static final String TRIGGER_CONTACT = "contact-trigger";

public static final String EVENT_PRESSED = "PRESSED";
public static final String EVENT_RELEASED = "RELEASED";
public static final String EVENT_SHORT_PRESS = "SHORT_PRESS";
public static final String EVENT_LONG_PRESS = "LONG_PRESS";
public static final String EVENT_PULSE = "PULSE";

// Adressable thing
}
Loading

0 comments on commit 3b9bdbf

Please sign in to comment.