2 * Copyright (c) 2010-2022 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;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * All defined sensor types for Master panels
20 * @author Laurent Garnier - Initial contribution
23 public enum PowermasterSensorType {
25 SENSOR_TYPE_1((byte) 0x01, "Motion"),
26 SENSOR_TYPE_2((byte) 0x04, "Camera"),
27 SENSOR_TYPE_3((byte) 0x16, "Smoke"),
28 SENSOR_TYPE_4((byte) 0x1A, "Temperature"),
29 SENSOR_TYPE_5((byte) 0x2A, "Magnet"),
30 SENSOR_TYPE_6((byte) 0xFE, "Wired");
32 private final byte code;
33 private final String label;
35 private PowermasterSensorType(byte code, String label) {
41 * @return the code identifying the sensor type
43 public byte getCode() {
48 * @return the label associated to the sensor type
50 public String getLabel() {
55 * Get the ENUM value from its identifying code
57 * @param code the identifying code
59 * @return the corresponding ENUM value
61 * @throws IllegalArgumentException if no ENUM value corresponds to this code
63 public static PowermasterSensorType fromCode(byte code) throws IllegalArgumentException {
64 for (PowermasterSensorType sensorType : PowermasterSensorType.values()) {
65 if (sensorType.getCode() == code) {
70 throw new IllegalArgumentException("Invalid code: " + code);