Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gce] GCE Binding initial contribution #5457

Merged
merged 17 commits into from
Sep 15, 2020
Merged
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,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 @@ -339,6 +339,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
160 changes: 160 additions & 0 deletions bundles/org.openhab.binding.gce/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# 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).


```
clinique marked this conversation as resolved.
Show resolved Hide resolved
```


Hilbrand marked this conversation as resolved.
Show resolved Hide resolved
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>
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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* 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 static org.openhab.binding.gce.internal.GCEBindingConstants.IPXV3_THING_TYPE;

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

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
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.openhab.binding.gce.internal.handler.Ipx800v3Handler;
import org.osgi.service.component.annotations.Component;

/**
* The {@link GCEHandlerFactory} is responsible for creating things and
* thing handlers.
*
* @author Gaël L'hopital - Initial contribution
*/
@NonNullByDefault
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.gce")
public class GCEHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(IPXV3_THING_TYPE);

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

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
return IPXV3_THING_TYPE.equals(thingTypeUID) ? new Ipx800v3Handler(thing) : null;
}
}
Loading