Skip to content

Commit

Permalink
[lcn] Implement PCK messages for LCN-GFPS fingerprint sensors (openha…
Browse files Browse the repository at this point in the history
…b#8273)

Signed-off-by: Andre Jendrysseck <ajendry1@gmail.com>
  • Loading branch information
andrexp authored and CSchlipp committed Sep 12, 2020
1 parent a8bdac9 commit 76e1239
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
16 changes: 14 additions & 2 deletions bundles/org.openhab.binding.lcn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ If a special command is needed, the [Hit Key](#hit-key) action (German: "Sende T
| Send Keys | Sende Tasten | N/A | N/A | N/A | Action: "hitKey": Hits a key of a key table in an LCN module. Can be used to execute commands, not supported by this binding. |
| Dimmer Output Control Multiple | Mehrere Ausgänge steuern | output | 1-4 | Dimmer, Switch | Control multiple outputs simultaneously. See below. |
| Transponder | Transponder | code#transponder | | Trigger | Receive transponder messages |
| Fingerprint | Fingerprint | code#fingerprint | | Trigger | Receive fingerprint code messages |
| Remote Control | Fernbedienung | code#remotecontrolkey | | Trigger | Receive commands from remote control |
| Access Control | Zutrittskontrolle | code#remotecontrolcode | | Trigger | Receive serial numbers from remote control |
| Remote Control Battery Low | Fernbedienung Batterie schwach | code#remotecontrolbatterylow | | Trigger | Triggered when the sending remote control has a low battery |
Expand Down Expand Up @@ -282,9 +283,9 @@ The Rollershutter Channels provide the boolean parameter `invertUpDown`, which c

The Binarysensor Channels provide the boolean parameter `invertState`, which can be set to 'true' if the binary sensor connected uses reverse logic for signaling open/closed.

### Transponder
### Transponder/Fingerprints

LCN transponder readers can be integrated in openHAB e.g. for access control.
LCN transponder readers or fingerprint readers can be integrated in openHAB e.g. for access control.
The transponder function must be enabled in the module's I-port properties within *LCN-PRO*.

Example: When the transponder card with the ID "12ABCD" is seen by the reader connected to LCN module "S000M011", the item "M10_Relay7" is switched on:
Expand All @@ -298,6 +299,17 @@ then
end
```

Example: When fingerprint with ID "AFFE12" is seen by reader connected to LCN module "S000M011", the item "M10_Relay7" is switched on:

```
rule "My Fingerprint"
when
Channel "lcn:module:b827ebfea4bb:S000M011:code#fingerprint" triggered "AFFE12"
then
M10_Relay7.sendCommand(ON)
end
```

### Remote Control

To evaluate commands from LCN remote controls (e.g. LCN-RT or LCN-RT16), the module's I-port behavior must be configured as "IR access control" within *LCN-PRO*:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
public class LcnModuleCodeSubHandler extends AbstractLcnModuleSubHandler {
private static final Pattern TRANSPONDER_PATTERN = Pattern
.compile(LcnBindingConstants.ADDRESS_REGEX + "\\.ZT(?<byte0>\\d{3})(?<byte1>\\d{3})(?<byte2>\\d{3})");
private static final Pattern FINGERPRINT_PATTERN = Pattern.compile(LcnBindingConstants.ADDRESS_REGEX
+ "\\.ZF(?<byte0>[0-9A-Fa-f]{2})(?<byte1>[0-9A-Fa-f]{2})(?<byte2>[0-9A-Fa-f]{2})");
private static final Pattern REMOTE_CONTROL_PATTERN = Pattern.compile(LcnBindingConstants.ADDRESS_REGEX
+ "\\.ZI(?<byte0>\\d{3})(?<byte1>\\d{3})(?<byte2>\\d{3})(?<key>\\d{3})(?<action>\\d{3})");

Expand All @@ -47,11 +49,20 @@ public void handleRefresh(LcnChannelGroup channelGroup, int number) {

@Override
public void handleStatusMessage(Matcher matcher) {
String code = String.format("%02X%02X%02X", Integer.parseInt(matcher.group("byte0")),
Integer.parseInt(matcher.group("byte1")), Integer.parseInt(matcher.group("byte2")));
String code;

if (matcher.pattern() == FINGERPRINT_PATTERN) {
code = String.format("%02X%02X%02X", Integer.parseInt(matcher.group("byte0"), 16),
Integer.parseInt(matcher.group("byte1"), 16), Integer.parseInt(matcher.group("byte2"), 16));
} else {
code = String.format("%02X%02X%02X", Integer.parseInt(matcher.group("byte0")),
Integer.parseInt(matcher.group("byte1")), Integer.parseInt(matcher.group("byte2")));
}

if (matcher.pattern() == TRANSPONDER_PATTERN) {
handler.triggerChannel(LcnChannelGroup.CODE, "transponder", code);
} else if (matcher.pattern() == FINGERPRINT_PATTERN) {
handler.triggerChannel(LcnChannelGroup.CODE, "fingerprint", code);
} else if (matcher.pattern() == REMOTE_CONTROL_PATTERN) {
int keyNumber = Integer.parseInt(matcher.group("key"));
String keyLayer;
Expand Down Expand Up @@ -103,6 +114,6 @@ public void handleStatusMessage(Matcher matcher) {

@Override
public Collection<Pattern> getPckStatusMessagePatterns() {
return Arrays.asList(TRANSPONDER_PATTERN, REMOTE_CONTROL_PATTERN);
return Arrays.asList(TRANSPONDER_PATTERN, FINGERPRINT_PATTERN, REMOTE_CONTROL_PATTERN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ channel-group-type.lcn.keyslocktabled.channel.7.label = D7 Sperre
channel-group-type.lcn.keyslocktabled.channel.8.label = D8 Sperre
channel-group-type.lcn.codes.label = Transponder & Fernbedienungen
channel-group-type.lcn.codes.channel.transponder.label = Transponder-Code
channel-group-type.lcn.codes.channel.fingerprint.label = Fingerprint-Code
channel-group-type.lcn.codes.channel.remotecontrolkey.label = Fernbedienung Tasten
channel-group-type.lcn.codes.channel.remotecontrolcode.label = Fernbedienung Tasten mit Zutrittscode
channel-group-type.lcn.codes.channel.remotecontrolbatterylow.label = Fernbedienung Batterie leer
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@
<label>Transponder &amp; Remote Control</label>
<channels>
<channel typeId="transponders" id="transponder"/>
<channel typeId="fingerprints" id="fingerprint"/>
<channel typeId="remotecontrolkeys" id="remotecontrolkey"/>
<channel typeId="remotecontrolcodes" id="remotecontrolcode"/>
<channel typeId="remotecontrolsbatterylow" id="remotecontrolbatterylow"/>
Expand All @@ -634,6 +635,12 @@
<event/>
</channel-type>

<channel-type id="fingerprints" advanced="true">
<kind>trigger</kind>
<label>Fingerprint Codes</label>
<event/>
</channel-type>

<channel-type id="remotecontrolkeys" advanced="true">
<kind>trigger</kind>
<label>Remote Control Keys</label>
Expand Down

0 comments on commit 76e1239

Please sign in to comment.