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.api.dto.clip2;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.library.types.OnOffType;
18 import org.openhab.core.library.types.QuantityType;
19 import org.openhab.core.library.unit.SIUnits;
20 import org.openhab.core.types.State;
21 import org.openhab.core.types.UnDefType;
23 import com.google.gson.annotations.SerializedName;
26 * DTO for CLIP 2 temperature sensor.
28 * @author Andrew Fiddian-Green - Initial contribution
31 public class Temperature {
32 private float temperature;
33 private @SerializedName("temperature_valid") boolean temperatureValid;
34 private @Nullable @SerializedName("temperature_report") TemperatureReport temperatureReport;
37 * The underlying field is deprecated in the CLIP 2 API.
38 * Moved to temperature_report/temperature.
39 * Should be used only as fallback for older firmwares.
41 * @return temperature in 1.00 degrees Celsius
43 public float getTemperature() {
48 * The underlying field is deprecated in the CLIP 2 API.
49 * Indication whether the value presented in temperature is valid
50 * Should be used only as fallback for older firmwares.
52 public boolean isTemperatureValid() {
53 return temperatureValid;
56 public State getTemperatureState() {
57 return temperatureValid ? new QuantityType<>(temperature, SIUnits.CELSIUS) : UnDefType.UNDEF;
60 public State getTemperatureValidState() {
61 return OnOffType.from(temperatureValid);
64 public @Nullable TemperatureReport getTemperatureReport() {
65 return temperatureReport;