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.hue.internal.dto.clip2;
15 import java.util.Objects;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.library.types.QuantityType;
19 import org.openhab.core.library.unit.Units;
21 import com.google.gson.annotations.SerializedName;
24 * DTO for CLIP 2 mirek schema.
26 * @author Andrew Fiddian-Green - Initial contribution
29 public class MirekSchema {
30 private static final int MIN = 153;
31 private static final int MAX = 500;
33 public static final MirekSchema DEFAULT_SCHEMA = new MirekSchema();
35 private @SerializedName("mirek_minimum") int mirekMinimum = MIN;
36 private @SerializedName("mirek_maximum") int mirekMaximum = MAX;
38 public int getMirekMaximum() {
42 public int getMirekMinimum() {
46 private String toKelvin(int mirek) {
47 QuantityType<?> kelvin = QuantityType.valueOf(mirek, Units.MIRED).toInvertibleUnit(Units.KELVIN);
48 return Objects.nonNull(kelvin) ? String.format("%.0f K", kelvin.doubleValue()) : "";
51 public String toPropertyValue() {
52 return String.format("%s .. %s", toKelvin(mirekMinimum), toKelvin(mirekMaximum));