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