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.esp32;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.wlanthermo.internal.WlanThermoUtil;
22 * The {@link WlanThermoEsp32Util} class provides conversion functions for the WlanThermo Nano V3
24 * @author Christian Schlipp - Initial contribution
27 public class WlanThermoEsp32Util extends WlanThermoUtil {
29 private static final Map<String, String> COLOR_MAPPINGS = createColorMap();
30 private static final String DEFAULT_HEX = "#FFFFFF";
31 private static final String DEFAULT_COLORNAME = "undefined";
33 private WlanThermoEsp32Util() {
37 private static Map<String, String> createColorMap() {
38 HashMap<String, String> map = new HashMap<>();
39 map.put("yellow", "#FFFF00");
40 map.put("dark yellow", "#FFC002");
41 map.put("green", "#00FF00");
42 map.put("white", "#FFFFFF");
43 map.put("pink", "#FF1DC4");
44 map.put("orange", "#E46C0A");
45 map.put("olive", "#C3D69B");
46 map.put("light blue", "#0FE6F1");
47 map.put("blue", "#0000FF");
48 map.put("dark green", "#03A923");
49 map.put("brown", "#C84B32");
50 map.put("light brown", "#FF9B69");
51 map.put("dark blue", "#5082BE");
52 map.put("light pink", "#FFB1D0");
53 map.put("light green", "#A6EF03");
54 map.put("dark pink", "#D42A6B");
55 map.put("beige", "#FFDA8F");
56 map.put("azure", "#00B0F0");
57 map.put("dark olive", "#948A54");
62 * Convert WlanThermo Color Name to Hex
64 * @param colorName the WlanThermo color name
65 * @return The color as Hex String
67 public static String toHex(String colorName) {
68 return COLOR_MAPPINGS.getOrDefault(colorName, DEFAULT_HEX);
71 public static String toColorName(String colorHex) {
72 return toColorName(colorHex, COLOR_MAPPINGS, DEFAULT_COLORNAME);