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.avmfritz.internal.dto;
15 import java.math.BigDecimal;
17 import javax.xml.bind.annotation.XmlAccessType;
18 import javax.xml.bind.annotation.XmlAccessorType;
19 import javax.xml.bind.annotation.XmlRootElement;
20 import javax.xml.bind.annotation.XmlType;
23 * See {@link DeviceListModel}.
25 * @author Robert Bausdorf - Initial contribution
26 * @author Christoph Weitkamp - Refactoring of temperature conversion from celsius to FRITZ!Box values
28 @XmlAccessorType(XmlAccessType.FIELD)
29 @XmlType(propOrder = { "celsius", "offset" })
30 @XmlRootElement(name = "temperature")
31 public class TemperatureModel {
32 public static final BigDecimal TEMP_FACTOR = new BigDecimal("0.1");
34 private BigDecimal celsius;
35 private BigDecimal offset;
37 public BigDecimal getCelsius() {
38 return celsius != null ? TEMP_FACTOR.multiply(celsius) : BigDecimal.ZERO;
41 public void setCelsius(BigDecimal celsius) {
42 this.celsius = celsius;
45 public BigDecimal getOffset() {
46 return offset != null ? TEMP_FACTOR.multiply(offset) : BigDecimal.ZERO;
49 public void setOffset(BigDecimal offset) {
54 public String toString() {
55 return new StringBuilder().append("[celsius=").append(getCelsius()).append(",offset=").append(getOffset())
56 .append("]").toString();