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.epsonprojector.internal.enums;
15 import java.util.Arrays;
16 import java.util.NoSuchElementException;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * Messages for documented error codes.
23 * @author Pauli Anttila - Initial contribution
24 * @author Yannick Schaus - Refactoring
25 * @author Michael Lobstein - Improvements for OH3
28 public enum ErrorMessage {
29 NO_ERROR(0, "00 : No error"),
30 ERROR1(1, "01 : Fan error"),
31 ERROR3(3, "03 : Lamp failure at power on"),
32 ERROR4(4, "04 : High internal temperature error"),
33 ERROR6(6, "06 : Lamp error"),
34 ERROR7(7, "07 : Open Lamp cover door error"),
35 ERROR8(8, "08 : Cinema filter error"),
36 ERROR9(9, "09 : Electric dual-layered capacitor is disconnected"),
37 ERROR10(10, "0A : Auto iris error"),
38 ERROR11(11, "0B : Subsystem error"),
39 ERROR12(12, "0C : Low air flow error"),
40 ERROR13(13, "0D : Air filter air flow sensor error"),
41 ERROR14(14, "0E : Power supply unit error (ballast)"),
42 ERROR15(15, "0F : Shutter error"),
43 ERROR16(16, "10 : Cooling system error (peltier element)"),
44 ERROR17(17, "11 : Cooling system error (pump)"),
45 ERROR18(18, "12 : Static iris error"),
46 ERROR19(19, "13 : Power supply unit error (disagreement of ballast)"),
47 ERROR20(20, "14 : Exhaust shutter error"),
48 ERROR21(21, "15 : Obstacle detection error"),
49 ERROR22(22, "16 : IF board discernment error"),
50 ERROR23(23, "17 : Communication error of \"Stack projection function\""),
51 ERROR24(24, "18 : I2C error");
53 private final int code;
54 private final String message;
56 ErrorMessage(int code, String message) {
58 this.message = message;
61 public String getMessage() {
65 public static String forCode(int code) {
67 return Arrays.stream(values()).filter(e -> e.code == code).findFirst().get().getMessage();
68 } catch (NoSuchElementException e) {
69 // for example, will display 10 as '0A' to match format of error codes in the epson documentation
70 return "Unknown error code (hex): "
71 + String.format("%2s", Integer.toHexString(code)).replace(' ', '0').toUpperCase();