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.powermax.internal.state;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * All defined sensor types for all panels except Master panels
20 * @author Laurent Garnier - Initial contribution
23 public enum PowermaxSensorType {
25 MOTION_SENSOR_1((byte) 0x03, "Motion"),
26 MOTION_SENSOR_2((byte) 0x04, "Motion"),
27 MAGNET_SENSOR_1((byte) 0x05, "Magnet"),
28 MAGNET_SENSOR_2((byte) 0x06, "Magnet"),
29 MAGNET_SENSOR_3((byte) 0x07, "Magnet"),
30 SMOKE_SENSOR((byte) 0x0A, "Smoke"),
31 GAS_SENSOR((byte) 0x0B, "Gas"),
32 MOTION_SENSOR_3((byte) 0x0C, "Motion"),
33 WIRED_SENSOR((byte) 0x0F, "Wired");
35 private final byte code;
36 private final String label;
38 private PowermaxSensorType(byte code, String label) {
44 * @return the code identifying the sensor type
46 public byte getCode() {
51 * @return the label associated to the sensor type
53 public String getLabel() {
58 * Get the ENUM value from its identifying code
60 * @param code the identifying code
62 * @return the corresponding ENUM value
64 * @throws IllegalArgumentException if no ENUM value corresponds to this code
66 public static PowermaxSensorType fromCode(byte code) throws IllegalArgumentException {
67 for (PowermaxSensorType sensorType : PowermaxSensorType.values()) {
68 if (sensorType.getCode() == code) {
73 throw new IllegalArgumentException("Invalid code: " + code);