]> git.basschouten.com Git - openhab-addons.git/blob
f154c81845413ee454d09112ea0243df83d7ec2e
[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.sinope.internal.core.appdata;
14
15 import java.nio.ByteBuffer;
16 import java.nio.ByteOrder;
17
18 /**
19  * The Class SinopeOutTempData.
20  *
21  * @author Pascal Larin - Initial contribution
22  */
23 public class SinopeOutTempData extends SinopeAppData {
24
25     /**
26      * Instantiates a new sinope out temp data.
27      */
28     public SinopeOutTempData() {
29         super(new byte[] { 0x00, 0x00, 0x02, 0x04 }, new byte[] { 0, 0 });
30     }
31
32     /**
33      * Gets the out temp.
34      *
35      * @return the out temp
36      */
37     public int getOutTemp() {
38         if (getData() != null) {
39             ByteBuffer bb = ByteBuffer.wrap(getData());
40             bb.order(ByteOrder.LITTLE_ENDIAN);
41             return bb.getShort();
42         }
43         return -273;
44     }
45
46     /**
47      * @see org.openhab.binding.sinope.internal.core.appdata.SinopeAppData#toString()
48      */
49     @Override
50     public String toString() {
51         StringBuilder sb = new StringBuilder();
52         sb.append(super.toString());
53         if (getData() != null) {
54             sb.append(String.format("\n\tOutside temperature is %2.2f C", this.getOutTemp() / 100.0));
55         }
56         return sb.toString();
57     }
58 }