]> git.basschouten.com Git - openhab-addons.git/blob
25bdb7ff619c56d17e6f00d3764599b643f9de8f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.avmfritz.internal.dto;
14
15 import java.math.BigDecimal;
16
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;
21
22 /**
23  * See {@link DeviceListModel}.
24  *
25  * @author Robert Bausdorf - Initial contribution
26  * @author Christoph Weitkamp - Refactoring of temperature conversion from celsius to FRITZ!Box values
27  */
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");
33
34     private BigDecimal celsius;
35     private BigDecimal offset;
36
37     public BigDecimal getCelsius() {
38         return celsius != null ? TEMP_FACTOR.multiply(celsius) : BigDecimal.ZERO;
39     }
40
41     public void setCelsius(BigDecimal celsius) {
42         this.celsius = celsius;
43     }
44
45     public BigDecimal getOffset() {
46         return offset != null ? TEMP_FACTOR.multiply(offset) : BigDecimal.ZERO;
47     }
48
49     public void setOffset(BigDecimal offset) {
50         this.offset = offset;
51     }
52
53     @Override
54     public String toString() {
55         return new StringBuilder().append("[celsius=").append(getCelsius()).append(",offset=").append(getOffset())
56                 .append("]").toString();
57     }
58 }