2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.alarmdecoder.internal.protocol;
15 import java.util.List;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
20 * The {@link LRRMessage} class represents a parsed LRR message.
21 * Based partly on code from the OH1 alarmdecoder binding by Bernd Pfrommer and Lucky Mallari.
23 * @author Bob Adair - Initial contribution
26 public class LRRMessage extends ADMessage {
28 // Example: !LRR:012,1,CID_1441,ff
29 // or: !LRR:000,1,ARM_AWAY
31 /** Event data contains user number or zone number for the event */
32 public final String eventData;
34 /** Partition event applies to. 0 means all partitions. */
35 public final int partition;
37 /** CID message for event as defined in SIA DC-05-1999.09 standard */
38 public final String cidMessage;
41 public final String reportCode;
43 public LRRMessage(String message) throws IllegalArgumentException {
46 String topLevel[] = message.split(":");
47 if (topLevel.length != 2) {
48 throw new IllegalArgumentException("multiple colons in LRR message");
51 List<String> parts = splitMsg(topLevel[1]);
53 // Apparently the 4th part of the LRR message may not be included depending on version
54 if (parts.size() < 3 || parts.size() > 4) {
55 throw new IllegalArgumentException("Invalid number of parts in LRR message");
58 eventData = parts.get(0);
59 cidMessage = parts.get(2);
60 reportCode = parts.size() == 4 ? parts.get(3) : "";
63 partition = Integer.parseInt(parts.get(1));
64 } catch (NumberFormatException e) {
65 throw new IllegalArgumentException("LRR msg contains invalid number: " + e.getMessage(), e);