]> git.basschouten.com Git - openhab-addons.git/blob
0bf14b52bffe0d46f89a60c759acb1671b0598a0
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.paradoxalarm.internal.model;
14
15 import java.util.Arrays;
16 import java.util.HashMap;
17 import java.util.Map;
18
19 import org.openhab.core.util.HexUtils;
20
21 /**
22  * The {@link ParadoxInformation} Class that provides the basic panel
23  * information (serial number, panel type, application, hardware and bootloader
24  * versions. It's the object representation of 37 bytes 0x72 serial response.
25  *
26  * @author Konstantin Polihronov - Initial contribution
27  */
28 public class ParadoxInformationConstants {
29     public static Map<String, PanelType> panelTypes = new HashMap<>();
30     static {
31         panelTypes.put("0xA122", PanelType.EVO48);
32         panelTypes.put("0xA133", PanelType.EVO48);
33         panelTypes.put("0xA159", PanelType.EVO48);
34         panelTypes.put("0xA123", PanelType.EVO192);
35         panelTypes.put("0xA15A", PanelType.EVO192);
36         panelTypes.put("0xA16D", PanelType.EVOHD);
37         panelTypes.put("0xA41E", PanelType.SP5500);
38         panelTypes.put("0xA450", PanelType.SP5500);
39         panelTypes.put("0xA41F", PanelType.SP6000);
40         panelTypes.put("0xA451", PanelType.SP6000);
41         panelTypes.put("0xA420", PanelType.SP7000);
42         panelTypes.put("0xA452", PanelType.SP7000);
43         panelTypes.put("0xA524", PanelType.MG5000);
44         panelTypes.put("0xA526", PanelType.MG5050);
45         panelTypes.put("0xAE53", PanelType.SP4000);
46         panelTypes.put("0xAE54", PanelType.SP65);
47     }
48
49     public static PanelType parsePanelType(byte[] infoPacket) {
50         if (infoPacket == null || infoPacket.length != 37) {
51             return PanelType.UNKNOWN;
52         }
53         byte[] panelTypeBytes = Arrays.copyOfRange(infoPacket, 6, 8);
54         String key = "0x" + HexUtils.bytesToHex(panelTypeBytes);
55
56         return ParadoxInformationConstants.panelTypes.getOrDefault(key, PanelType.UNKNOWN);
57     }
58 }