Skip to content

Commit

Permalink
Merge pull request #4 from openhab/2.5.x
Browse files Browse the repository at this point in the history
update fork
  • Loading branch information
mlobstein authored Jun 4, 2020
2 parents 82462cd + c4c35fd commit 5d548cc
Show file tree
Hide file tree
Showing 333 changed files with 17,650 additions and 4,133 deletions.
3 changes: 2 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
/bundles/org.openhab.binding.max/ @marcelrv
/bundles/org.openhab.binding.mcp23017/ @aogorek
/bundles/org.openhab.binding.melcloud/ @lucacalcaterra @paulianttila @thewiep
/bundles/org.openhab.binding.meteoalerte/ @clinique
/bundles/org.openhab.binding.meteoblue/ @9037568
/bundles/org.openhab.binding.meteostick/ @cdjackson
/bundles/org.openhab.binding.miele/ @kgoderis
Expand All @@ -118,6 +119,7 @@
/bundles/org.openhab.binding.milight/ @davidgraeff
/bundles/org.openhab.binding.minecraft/ @ibaton
/bundles/org.openhab.binding.modbus/ @ssalonen
/bundles/org.openhab.binding.modbus.sunspec/ @mrbig
/bundles/org.openhab.binding.mqtt/ @davidgraeff
/bundles/org.openhab.binding.mqtt.generic/ @davidgraeff
/bundles/org.openhab.binding.mqtt.homeassistant/ @davidgraeff
Expand Down Expand Up @@ -190,7 +192,6 @@
/bundles/org.openhab.binding.sonyprojector/ @lolodomo
/bundles/org.openhab.binding.spotify/ @Hilbrand
/bundles/org.openhab.binding.squeezebox/ @digitaldan @mhilbush
/bundles/org.openhab.binding.modbus.sunspec/ @mrbig
/bundles/org.openhab.binding.synopanalyzer/ @clinique
/bundles/org.openhab.binding.systeminfo/ @svilenvul
/bundles/org.openhab.binding.tado/ @dfrommi
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 @@ -541,6 +541,11 @@
<artifactId>org.openhab.binding.melcloud</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.meteoalerte</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.meteoblue</artifactId>
Expand Down
56 changes: 42 additions & 14 deletions bundles/org.openhab.binding.alarmdecoder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The binding supports the following thing types:
* `keypad` - Reports keypad status and optionally sends keypad messages.
* `zone` - Reports status from zone expanders and relay expanders, and also from built-in zones via emulation.
* `rfzone` - Reports status from RF zones.
* `vzone` - Sends commands to virtual zones.
* `lrr` - Reports messages sent from the panel to a Long Range Radio (LRR) or emulated LRR device.

## Discovery
Expand Down Expand Up @@ -86,6 +87,30 @@ Bridge alarmdecoder:serialbridge:ad1 [ serialPort="/dev/ttyS1", bitrate=115200,
}
```

### keypad

The `keypad` thing reports keypad status and optionally sends keypad messages.
For panels that support multiple keypad addresses, it can be configured with an address mask of one or more keypad(s) for which it will receive messages.
When sending messages, it will send from the configured keypad address if only one is configured.
If a mask containing multiple addresses or 0 (all) is configured, it will send messages from the Alarm Decoder's configured address.

Commands sent from the keypad thing are limited to the set of valid keypad command characters supported by the Alarm Decoder (0-9,*,#,<,>).
In addition, the characters A-H will be translated to special keys 1-8.
Command strings containing invalid characters will be ignored.

Parameters:

* `addressMask` (required) Keypad address mask (0 = All addresses)
* `sendCommands` (default = false) Allow keypad commands to be sent to the alarm system from openHAB. Enabling this means the alarm system will be only as secure as your openHAB system.
* `sendStar` (default = false) When disarmed/faulted, automatically send the * character to obtain zone fault information.
* `commandMapping` (optional) Comma separated list of key/value pairs mapping integers to command strings for `intcommand` channel.

Thing config file example:

```
Thing keypad keypad1 [ addressMask=0, sendCommands=true ]
```

### zone

The `zone` thing reports status from zone expanders and relay expanders, and also from built-in zones via emulation.
Expand Down Expand Up @@ -115,28 +140,21 @@ Thing config file example:
Thing rfzone motion1 [ serial=0180010 ]
```

### keypad
### vzone

The `keypad` thing reports keypad status and optionally sends keypad messages.
For panels that support multiple keypad addresses, it can be configured with an address mask of one or more keypad(s) for which it will receive messages.
When sending messages, it will send from the configured keypad address if only one is configured.
If a mask containing multiple addresses or 0 (all) is configured, it will send messages from the Alarm Decoder's configured address.

Commands sent from the keypad thing are limited to the set of valid keypad command characters supported by the Alarm Decoder (0-9,*,#,<,>).
In addition, the characters A-H will be translated to special keys 1-8.
Command strings containing invalid characters will be ignored.
The `vzone` thing sends open/close commands a virtual zone.
After enabling zone expander emulation on both the alarm panel and the Alarm Decoder device, it can be used to control the state of a virtual zone.
The `command` channel is write-only, and accepts either the string "OPEN" or the string "CLOSED".
The `state` channel is a switch type channel that reflects the current state of the virtual zone (ON=closed/OFF=open).

Parameters:

* `addressMask` (required) Keypad address mask (0 = All addresses)
* `sendCommands` (default = false) Allow keypad commands to be sent to the alarm system from openHAB. Enabling this means the alarm system will be only as secure as your openHAB system.
* `sendStar` (default = false) When disarmed/faulted, automatically send the * character to obtain zone fault information.
* `commandMapping` (optional) Comma separated list of key/value pairs mapping integers to command strings for `intcommand` channel.
* `address` (required) Virtual zone number (0-99)

Thing config file example:

```
Thing keypad keypad1 [ addressMask=0, sendCommands=true ]
Thing vzone watersensor [ address=41 ]
```

### lrr
Expand Down Expand Up @@ -175,6 +193,13 @@ The alarmdecoder things expose the following channels:
| loop3 | Contact | RO |Loop 3 state |
| loop4 | Contact | RO |Loop 4 state |

**vzone**

| channel | type |RO/RW| description |
|--------------|---------|-----|------------------------------|
| command | String | WO |"OPEN" or "CLOSED" command |
| state | Switch | RW |Zone state (ON = closed) |

**keypad**

| channel | type |RO/RW| description |
Expand Down Expand Up @@ -222,6 +247,7 @@ Bridge alarmdecoder:ipbridge:ad1 [ hostname="cerberus.home", tcpPort=10000, disc
Thing zone frontdoor [ address=10, channel=1 ]
Thing zone backdoor [ address=11, channel=1 ]
Thing rfzone motion1 [ serial=0180010 ]
Thing vzone watersensor [ address=41 ]
Thing keypad keypad1 [ addressMask=0, sendCommands=true ]
Thing lrr lrr [ partition=0 ]
}
Expand All @@ -247,6 +273,8 @@ Contact Motion1Loop2 "Loop 2" {channel="alarmdecoder:rfzone:ad1:motion1:loop2"}
Contact Motion1Loop3 "Loop 3" {channel="alarmdecoder:rfzone:ad1:motion1:loop3"}
Contact Motion1Loop4 "Loop 4" {channel="alarmdecoder:rfzone:ad1:motion1:loop4"}
String WaterSensorCmd "Virtual Zone Command" {channel="alarmdecoder:vzone:ad1:watersensor:command"}
Number LrrPartition "Partition Number [%d]" {channel="alarmdecoder:lrr:ad1:lrr:partition"}
Number LrrEventData "CID Event Data [%d]" {channel="alarmdecoder:lrr:ad1:lrr:eventdata"}
String LrrMessage "CID Message" {channel="alarmdecoder:lrr:ad1:lrr:cidmessage"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class AlarmDecoderBindingConstants {
public static final ThingTypeUID THING_TYPE_SERIALBRIDGE = new ThingTypeUID(BINDING_ID, "serialbridge");
public static final ThingTypeUID THING_TYPE_ZONE = new ThingTypeUID(BINDING_ID, "zone");
public static final ThingTypeUID THING_TYPE_RFZONE = new ThingTypeUID(BINDING_ID, "rfzone");
public static final ThingTypeUID THING_TYPE_VZONE = new ThingTypeUID(BINDING_ID, "vzone");
public static final ThingTypeUID THING_TYPE_KEYPAD = new ThingTypeUID(BINDING_ID, "keypad");
public static final ThingTypeUID THING_TYPE_LRR = new ThingTypeUID(BINDING_ID, "lrr");

Expand All @@ -54,6 +55,10 @@ public class AlarmDecoderBindingConstants {
public static final String PROPERTY_ID = "id";

public static final String CHANNEL_CONTACT = "contact";
public static final String CHANNEL_STATE = "state";

// Channel IDs for VZoneHandler
public static final String CHANNEL_COMMAND = "command";

// Channel IDs for RFZoneHandler
public static final String PROPERTY_SERIAL = "serial";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.openhab.binding.alarmdecoder.internal.handler.LRRHandler;
import org.openhab.binding.alarmdecoder.internal.handler.RFZoneHandler;
import org.openhab.binding.alarmdecoder.internal.handler.SerialBridgeHandler;
import org.openhab.binding.alarmdecoder.internal.handler.VZoneHandler;
import org.openhab.binding.alarmdecoder.internal.handler.ZoneHandler;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Activate;
Expand All @@ -58,7 +59,7 @@ public class AlarmDecoderHandlerFactory extends BaseThingHandlerFactory {

private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
.unmodifiableSet(Stream.of(THING_TYPE_IPBRIDGE, THING_TYPE_SERIALBRIDGE, THING_TYPE_ZONE, THING_TYPE_RFZONE,
THING_TYPE_KEYPAD, THING_TYPE_LRR).collect(Collectors.toSet()));
THING_TYPE_VZONE, THING_TYPE_KEYPAD, THING_TYPE_LRR).collect(Collectors.toSet()));

private final Logger logger = LoggerFactory.getLogger(AlarmDecoderHandlerFactory.class);

Expand Down Expand Up @@ -94,6 +95,8 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return new ZoneHandler(thing);
} else if (THING_TYPE_RFZONE.equals(thingTypeUID)) {
return new RFZoneHandler(thing);
} else if (THING_TYPE_VZONE.equals(thingTypeUID)) {
return new VZoneHandler(thing);
} else if (THING_TYPE_KEYPAD.equals(thingTypeUID)) {
return new KeypadHandler(thing);
} else if (THING_TYPE_LRR.equals(thingTypeUID)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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.alarmdecoder.internal.config;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link VZoneConfig} class contains fields mapping thing configuration parameters for VZoneHandler.
*
* @author Bob Adair - Initial contribution
*/
@NonNullByDefault
public class VZoneConfig {
public int address = -1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private void notifyChildHandlers(ADMessage msg) {
* contact channels are initialized into the UNDEF state. This method is called when there is reason to assume that
* there are no faulted zones, because the alarm panel is in state READY. Zone handlers that have not yet received
* updates can then set their contact states to CLOSED. Only executes the first time panel is ready after bridge
* connect/reconnect. Currently only notifies ZoneHandler and RFZoneHandler things.
* connect/reconnect.
*/
private void notifyChildHandlersPanelReady() {
if (!panelReadyReceived) {
Expand All @@ -355,7 +355,7 @@ private void notifyChildHandlersPanelReady() {
// Notify child zone handlers by calling notifyPanelReady() for each
for (Thing thing : getThing().getThings()) {
ADThingHandler handler = (ADThingHandler) thing.getHandler();
if (handler != null && (handler instanceof ZoneHandler || handler instanceof RFZoneHandler)) {
if (handler != null) {
handler.notifyPanelReady();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* 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.alarmdecoder.internal.handler;

import static org.openhab.binding.alarmdecoder.internal.AlarmDecoderBindingConstants.*;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingStatus;
import org.eclipse.smarthome.core.thing.ThingStatusDetail;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.types.UnDefType;
import org.openhab.binding.alarmdecoder.internal.config.VZoneConfig;
import org.openhab.binding.alarmdecoder.internal.protocol.ADCommand;
import org.openhab.binding.alarmdecoder.internal.protocol.ADMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* The {@link VZoneHandler} is responsible for sending state commands to virtual zones.
*
* @author Bob Adair - Initial contribution
*/
@NonNullByDefault
public class VZoneHandler extends ADThingHandler {

public static final String CMD_OPEN = "OPEN";
public static final String CMD_CLOSED = "CLOSED";

private final Logger logger = LoggerFactory.getLogger(VZoneHandler.class);

private VZoneConfig config = new VZoneConfig();

public VZoneHandler(Thing thing) {
super(thing);
}

@Override
public void initialize() {
config = getConfigAs(VZoneConfig.class);

if (config.address < 0 || config.address > 99) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Invalid address setting");
return;
}
logger.debug("Virtual zone handler initializing for address {}", config.address);
initDeviceState();
}

@Override
public void initChannelState() {
UnDefType state = UnDefType.UNDEF;
updateState(CHANNEL_STATE, state);
firstUpdateReceived.set(false);
}

@Override
public void notifyPanelReady() {
logger.trace("Virtual zone handler for {} received panel ready notification.", config.address);
if (firstUpdateReceived.compareAndSet(false, true)) {
updateState(CHANNEL_STATE, OnOffType.ON);
}
}

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (channelUID.getId().equals(CHANNEL_COMMAND)) {
if (command instanceof StringType) {
String cmd = ((StringType) command).toString();
if (CMD_OPEN.equalsIgnoreCase(cmd)) {
sendCommand(ADCommand.setZone(config.address, ADCommand.ZONE_OPEN));
setChannelState(OnOffType.OFF);
} else if (CMD_CLOSED.equalsIgnoreCase(cmd)) {
sendCommand(ADCommand.setZone(config.address, ADCommand.ZONE_CLOSED));
setChannelState(OnOffType.ON);
} else {
logger.debug("Virtual zone handler {} received invalid command: {}", config.address, cmd);
}
}
} else if (channelUID.getId().equals(CHANNEL_STATE)) {
if (command instanceof OnOffType) {
if (command == OnOffType.OFF) {
sendCommand(ADCommand.setZone(config.address, ADCommand.ZONE_OPEN));
setChannelState(OnOffType.OFF);
} else if (command == OnOffType.ON) {
sendCommand(ADCommand.setZone(config.address, ADCommand.ZONE_CLOSED));
setChannelState(OnOffType.ON);
}
}
}
}

private void setChannelState(OnOffType state) {
updateState(CHANNEL_STATE, state);
firstUpdateReceived.set(true);
}

@Override
public void handleUpdate(ADMessage msg) {
// There can be no update requests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public final class ADCommand {
public static final String SPECIAL_KEY_7 = "\u0007\u0007\u0007";
public static final String SPECIAL_KEY_8 = "\u0008\u0008\u0008";

public static final int ZONE_OPEN = 1;
public static final int ZONE_CLOSED = 0;

// public static final String KEYPAD_COMMAND_CHARACTERS = "0123456789*#<>";
public static final String KEYPAD_COMMAND_REGEX = "^[0-9A-H*#<>]+$";

Expand Down
Loading

0 comments on commit 5d548cc

Please sign in to comment.