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.nano;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.wlanthermo.internal.WlanThermoUtil;
22 * The {@link WlanThermoNanoV1Util} class provides conversion functions for the WlanThermo Nano V1+
24 * @author Christian Schlipp - Initial contribution
27 public class WlanThermoNanoV1Util 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 = "niagara";
33 private WlanThermoNanoV1Util() {
37 private static Map<String, String> createColorMap() {
38 HashMap<String, String> map = new HashMap<>();
39 map.put("niagara", "#5587A2");
40 map.put("rosa", "#FFAEC9");
41 map.put("lapis blue", "#0C4C88");
42 map.put("orange", "#EF562D");
43 map.put("lila", "#A349A4");
44 map.put("red", "#ED1C24");
45 map.put("green", "#22B14C");
46 map.put("gold", "#FFC100");
47 map.put("kale", "#5C7148");
48 map.put("brown", "#804000");
53 * Convert WlanThermo Color Name to Hex
55 * @param colorName the WlanThermo color name
56 * @return The color as Hex String
58 public static String toHex(String colorName) {
59 return COLOR_MAPPINGS.getOrDefault(colorName, DEFAULT_HEX);
62 public static String toColorName(String colorHex) {
63 return toColorName(colorHex, COLOR_MAPPINGS, DEFAULT_COLORNAME);