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.wlanthermo.internal.api.mini;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.wlanthermo.internal.WlanThermoUtil;
22 * The {@link WlanThermoMiniUtil} class provides conversion functions for the WlanThermo Mini
24 * @author Christian Schlipp - Initial contribution
27 public class WlanThermoMiniUtil extends WlanThermoUtil {
28 private static final Map<String, String> COLOR_MAPPINGS = createColorMap();
29 private static final String DEFAULT_HEX = "#ffffff";
31 private WlanThermoMiniUtil() {
35 private static Map<String, String> createColorMap() {
36 HashMap<String, String> map = new HashMap<>();
37 map.put("green", "#008000");
38 map.put("red", "#FF0000");
39 map.put("blue", "#0000FF");
40 map.put("olive", "#808000");
41 map.put("magenta", "#FF00FF");
42 map.put("yellow", "#FFFF00");
43 map.put("violet", "#EE82EE");
44 map.put("orange", "#FFA500");
45 map.put("mediumpurple3", "#9370DB");
46 map.put("aquamarine", "#7FFFD4");
47 map.put("brown", "#A52A2A");
48 map.put("plum", "#DDA0DD");
49 map.put("skyblue", "#87CEEB");
50 map.put("orange-red", "#FF4500");
51 map.put("salmon", "#FA8072");
52 map.put("black", "#000000");
53 map.put("dark-grey", "#A9A9A9");
54 map.put("purple", "800080");
55 map.put("turquoise", "#40E0D0");
56 map.put("khaki", "#F0E68C");
57 map.put("dark-violet", "#9400D3");
58 map.put("seagreen", "#2E8B57");
59 map.put("web-blue", "#0080ff");
60 map.put("steelblue", "#4682B4");
61 map.put("gold", "#FFD700");
62 map.put("dark-green", "#006400");
63 map.put("midnight-blue", "#191970");
64 map.put("dark-khaki", "#BDB76B");
65 map.put("dark-olivegreen", "#556B2F");
66 map.put("pink", "#FFC0CB");
67 map.put("chartreuse", "#7FFF00");
68 map.put("gray", "#808080");
69 map.put("slategrey", "#708090");
74 * Convert WlanThermo Color Name to Hex
76 * @param colorName the WlanThermo color name
77 * @return The color as Hex String
79 public static String toHex(String colorName) {
80 return COLOR_MAPPINGS.getOrDefault(colorName, DEFAULT_HEX);