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.sensibo.internal;
15 import javax.measure.Unit;
16 import javax.measure.quantity.Temperature;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.core.library.unit.ImperialUnits;
21 import org.openhab.core.library.unit.SIUnits;
24 * The {@link SensiboTemperatureUnitConverter} converts to/from Sensibo temperature symbols to {@code Unit<Temperature>}
26 * @author Arne Seime - Initial contribution
29 public final class SensiboTemperatureUnitConverter {
30 public static Unit<Temperature> parseFromSensiboFormat(@Nullable String symbol) {
36 return SIUnits.CELSIUS;
38 return ImperialUnits.FAHRENHEIT;
40 throw new IllegalArgumentException("Do not understand temperature unit " + symbol);
44 public static String toSensiboFormat(@Nullable Unit<Temperature> unit) {
45 if (SIUnits.CELSIUS.equals(unit)) {
47 } else if (ImperialUnits.FAHRENHEIT.equals(unit)) {
50 throw new IllegalArgumentException("Do not understand temperature unit " + unit);