]> git.basschouten.com Git - openhab-addons.git/blob
a2a2306c23857c106e687b03ca27e296b9ae76ef
[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.radiothermostat.internal.dto;
14
15 import com.google.gson.annotations.SerializedName;
16
17 /**
18  * The {@link RadioThermostatTimeDTO} is responsible for storing
19  * the "time" node from the thermostat JSON response
20  *
21  * @author Michael Lobstein - Initial contribution
22  */
23 public class RadioThermostatTimeDTO {
24     @SerializedName("day")
25     private Integer dayOfWeek;
26
27     @SerializedName("hour")
28     private Integer hour;
29
30     @SerializedName("minute")
31     private Integer minute;
32
33     public RadioThermostatTimeDTO() {
34     }
35
36     public Integer getDayOfWeek() {
37         return dayOfWeek;
38     }
39
40     public Integer getHour() {
41         return hour;
42     }
43
44     public Integer getMinute() {
45         return minute;
46     }
47
48     /**
49      * Convenience method to return the total number of runtime minutes
50      * 
51      * @return {runtime hours + minutes as minutes Integer}
52      */
53     public Integer getRuntime() {
54         return (hour * 60) + minute;
55     }
56
57     /**
58      * Get formatted thermostat date stamp
59      *
60      * @return {Day of week/Time string}
61      */
62     public String getThemostatDateTime() {
63         String day;
64
65         switch (dayOfWeek.toString()) {
66             case "0":
67                 day = "Monday ";
68                 break;
69             case "1":
70                 day = "Tuesday ";
71                 break;
72             case "2":
73                 day = "Wednesday ";
74                 break;
75             case "3":
76                 day = "Thursday ";
77                 break;
78             case "4":
79                 day = "Friday ";
80                 break;
81             case "5":
82                 day = "Saturday ";
83                 break;
84             case "6":
85                 day = "Sunday ";
86                 break;
87             default:
88                 day = "";
89         }
90         return day + hour + ":" + String.format("%02d", minute);
91     }
92 }