2 * Copyright (c) 2010-2021 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.powermax.internal.state;
16 * All defined sensor types for Master panels
18 * @author Laurent Garnier - Initial contribution
20 public enum PowermasterSensorType {
22 SENSOR_TYPE_1((byte) 0x01, "Motion"),
23 SENSOR_TYPE_2((byte) 0x04, "Camera"),
24 SENSOR_TYPE_3((byte) 0x16, "Smoke"),
25 SENSOR_TYPE_4((byte) 0x1A, "Temperature"),
26 SENSOR_TYPE_5((byte) 0x2A, "Magnet"),
27 SENSOR_TYPE_6((byte) 0xFE, "Wired");
32 private PowermasterSensorType(byte code, String label) {
38 * @return the code identifying the sensor type
40 public byte getCode() {
45 * @return the label associated to the sensor type
47 public String getLabel() {
52 * Get the ENUM value from its identifying code
54 * @param code the identifying code
56 * @return the corresponding ENUM value
58 * @throws IllegalArgumentException if no ENUM value corresponds to this code
60 public static PowermasterSensorType fromCode(byte code) throws IllegalArgumentException {
61 for (PowermasterSensorType sensorType : PowermasterSensorType.values()) {
62 if (sensorType.getCode() == code) {
67 throw new IllegalArgumentException("Invalid code: " + code);