Skip to content

Commit

Permalink
re-add test bundle for demo purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvw committed Jun 28, 2019
1 parent fe19725 commit cc3bf9e
Show file tree
Hide file tree
Showing 52 changed files with 3,386 additions and 0 deletions.
32 changes: 32 additions & 0 deletions bundles/org.openhab.binding.digiplex2/.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.digiplex2/.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.digiplex</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.digiplex2/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/openhab2-addons
110 changes: 110 additions & 0 deletions bundles/org.openhab.binding.digiplex2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Digiplex/EVO Binding

This binding provides integration with Digiplex/EVO alarm systems from [Paradox](http://paradox.com).
It utilizes [PRT3 module](http://www.paradox.com/Products/default.asp?CATID=7&SUBCATID=75&PRD=234) for serial communication.

## Supported Things

### PRT3 Module

Before the binding can be used, a serial adapter must be added manually. Select `PRT3 Module` and enter serial port parameters.
Please refer to PRT3 module manual for instructions how to modify baudrate (default setting is 2400)

## Discovery

Once `PRT3 Module` is added and communication with the alarm system confirmed by its `online` status, please start discovery process to automatically discover (and add as new Things) all zones and areas defined in the alarm system.


## Binding Configuration

There is no binding level configuration required.

## Thing Configuration

### PRT3 Module Configuration

The following section lists the PRT3 Module configuration. If using manual configuration in text files, the parameter names are given in the square brackets.

#### Serial Port [port]

Sets the serial port name for the communication with the alarm system

#### Baud Rate [baudrate]

Baud rate to use for serial port communication

### Area configuration

#### Refresh time of area status (in seconds) [refreshPeriod]

Controls how often area status is refreshed from the alarm system.

## Channels

### PTR3 Module Channels

The table below summarizes all the channels available from the `PTR3 Module` thing.

| Channel | Description |
|--------------------|-------------------------------------------------------------------------|
| messages_sent | Counts the number of messages sent to the module |
| responses_received | Counts the number of responses received from the module |
| events_received | Counts the number of events received from the module |

### Zone Channels

The table below summarizes all the channels available from the `zone` thing.

| Channel | Description |
|------------------|-------------------------------------------------------------------------|
| status | Simple zone status (open/closed) |
| extended_status | Extended zone status as a String (Open/Closed/Tampered/Fire Loop Alarm) |
| alarm | Information whether zone is in alarm (open/closed) |
| fire_alarm | Same as above for fire alarm |
| supervision_lost | Information whether supervision has been lost (open/closed) |
| low_battery | Low battery warning (open/closed) |

### Area Channels

The table below summarizes all the channels available from the `area` thing.

| Channel | Description |
|------------------|-----------------------------------------------------------------------------------|
| status | Area status available as a String |
| armed | Simple (open/closed) information whether zone is armed |
| zone_in_memory | Information whether there are zones in the memory (after alarm has been triggered |
| trouble | Information whether some of the zones are in 'trouble' (malfunctioning) |
| ready | Information whether area is ready (no open zones) |
| in_programming | Checks for programming mode enabled |
| alarm | Information whether area is in alarm |
| strobe | Information whether area is in strobe alarm |
| control | Channel for controlling area |

User is able to send commands through `control` channel to arm/quick arm/disarm the zone.
Every sent message is followed by the channel state change to either `Ok` or `Failed` depending whether command has been accepted by the alarm system.
Note that PRT3 module is capable of handling more kinds of messages, but those are not yet supported by this binding.
Message format is as follows:

| Command | String sent to the `control` channel |
|-------------------|--------------------------------------|
| Regular Arm | AA`<pin>` |
| Force Arm | AF`<pin>` |
| Stay Arm | AS`<pin>` |
| Instant Arm | AI`<pin>` |
| Regular Quick Arm | QA |
| Force Quick Arm | QF |
| Stay Quick Arm | QS |
| Instant Quick Arm | QI |
| Disarm | D`<pin>` |

`<pin>` is your PIN as entered on a keypad.

**Note**: For security reasons please consider not storing your PIN in openhab configuration files.

**Note2**: Please consult your alarm system manual how to enable `Quick Arm` feature. It is not enabled by default.

For example, the following sitemap item can be used to send commands to the area and receive response status as modified color of a label:

```
Switch item=areaControl label="Actions[]" mappings=[QA="Regular Quick Arm",QS="Stay Quick Arm",D1111="Disarm"] labelcolor=[Ok="green",Fail="red"]
```
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.digiplex2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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.0-SNAPSHOT</version>
</parent>

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

<name>openHAB Add-ons :: Bundles :: Digiplex/EVO Binding</name>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* Copyright (c) 2010-2019 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.digiplex;

import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

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

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

private static final String BINDING_ID = "digiplex";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge");
public static final ThingTypeUID THING_TYPE_ZONE = new ThingTypeUID(BINDING_ID, "zone");
public static final ThingTypeUID THING_TYPE_AREA = new ThingTypeUID(BINDING_ID, "area");

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Stream
.of(DigiplexBindingConstants.THING_TYPE_BRIDGE, DigiplexBindingConstants.THING_TYPE_ZONE,
DigiplexBindingConstants.THING_TYPE_AREA)
.collect(Collectors.toSet());

public static final String PROPERTY_ZONE_NO = "ZONE_ID";
public static final String PROPERTY_AREA_NO = "AREA_ID";

// List of all Channel ids
// bridge
public static final String BRIDGE_MESSAGES_SENT = "messages_sent";
public static final String BRIDGE_RESPONSES_RECEIVED = "responses_received";
public static final String BRIDGE_EVENTS_RECEIVED = "events_received";
// Zone
public static final String ZONE_STATUS = "status";
public static final String ZONE_EXTENDED_STATUS = "extended_status";
public static final String ZONE_ALARM = "alarm";
public static final String ZONE_FIRE_ALARM = "fire_alarm";
public static final String ZONE_SUPERVISION_LOST = "supervision_lost";
public static final String ZONE_LOW_BATTERY = "low_battery";
public static final String ZONE_LAST_TRIGGERED = "last_triggered";
// Area
public static final String AREA_STATUS = "status";
public static final String AREA_ARMED = "armed";
public static final String AREA_ZONE_IN_MEMORY = "zone_in_memory";
public static final String AREA_TROUBLE = "trouble";
public static final String AREA_READY = "ready";
public static final String AREA_IN_PROGRAMMING = "in_programming";
public static final String AREA_ALARM = "alarm";
public static final String AREA_STROBE = "strobe";
public static final String AREA_CONTROL = "control";

public static final List<String> ZONE_DEFAULT_NAMES = Arrays.asList("Zone %03d", "Zone %d");
public static final String AREA_DEFAULT_NAME = "Area %d";

public static final StringType COMMAND_OK = new StringType("Ok");
public static final StringType COMMAND_FAIL = new StringType("Fail");

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (c) 2010-2019 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.digiplex.communication;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* Base class for all responses retrieved from PRT3 module.
*
* Handles success/failure.
*
* @author Robert Michalak - Initial contribution
*
*/
@NonNullByDefault
public abstract class AbstractResponse implements DigiplexResponse {

public final boolean success;

public AbstractResponse() {
this.success = true;
}

public AbstractResponse(boolean success) {
this.success = success;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (c) 2010-2019 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.digiplex.communication;

/**
* Response for arm, quick arm and disarm requests
*
* @author Robert Michalak - Initial contribution
*/
public class AreaArmDisarmResponse extends AbstractResponse {

public final int areaNo;
public final ArmDisarmType type;

private AreaArmDisarmResponse(int areaNo, ArmDisarmType type, boolean success) {
super(success);
this.areaNo = areaNo;
this.type = type;
}

/**
* Builds a response for a given areaNo and type. Indicates that request failed.
*/
public static AreaArmDisarmResponse failure(int areaNo, ArmDisarmType type) {
return new AreaArmDisarmResponse(areaNo, type, false);
}

/**
* Builds a response for a given areaNo and type. Indicates that request was successful.
*/
public static AreaArmDisarmResponse success(int areaNo, ArmDisarmType type) {
return new AreaArmDisarmResponse(areaNo, type, true);
}

@Override
public void accept(DigiplexMessageHandler visitor) {
visitor.handleArmDisarmAreaResponse(this);

}

}
Loading

0 comments on commit cc3bf9e

Please sign in to comment.