]> git.basschouten.com Git - openhab-addons.git/blob
3e4a4426fd0ce0c597e12f374b02f3521efdcb1d
[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.millheat.internal.model;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.openhab.binding.millheat.internal.dto.RoomDTO;
19
20 /**
21  * The {@link Room} represents a room in a home as designed by the end user in the Millheat app.
22  *
23  * @author Arne Seime - Initial contribution
24  */
25 public class Room {
26     private final Home home;
27     private final long id;
28     private final String name;
29     private final int currentTemp;
30     private final int comfortTemp;
31     private final int sleepTemp;
32     private final int awayTemp;
33     private final boolean heatingActive;
34     private final ModeType mode;
35     private final String roomProgramName;
36     private final List<Heater> heaters = new ArrayList<>();
37
38     public Room(final RoomDTO dto, final Home home) {
39         this.home = home;
40         id = dto.roomId;
41         name = dto.name;
42         currentTemp = (int) dto.currentTemp;
43         comfortTemp = dto.comfortTemp;
44         sleepTemp = dto.sleepTemp;
45         awayTemp = dto.awayTemp;
46         heatingActive = dto.heatStatus;
47         mode = ModeType.valueOf(dto.currentMode);
48         roomProgramName = dto.roomProgram;
49     }
50
51     public void addHeater(final Heater h) {
52         heaters.add(h);
53     }
54
55     public List<Heater> getHeaters() {
56         return heaters;
57     }
58
59     public Integer getTargetTemperature() {
60         switch (mode) {
61             case VACATION:
62                 return home.getHolidayTemp();
63             case SLEEP:
64                 return sleepTemp;
65             case COMFORT:
66                 return comfortTemp;
67             case AWAY:
68                 return awayTemp;
69             case OFF:
70             case ALWAYSHOME:
71             default:
72                 return null;
73         }
74     }
75
76     @Override
77     public String toString() {
78         return "Room [home=" + home.getId() + ", id=" + id + ", name=" + name + ", currentTemp=" + currentTemp
79                 + ", comfortTemp=" + comfortTemp + ", sleepTemp=" + sleepTemp + ", awayTemp=" + awayTemp
80                 + ", heatingActive=" + heatingActive + ", mode=" + mode + ", roomProgramName=" + roomProgramName
81                 + ", heaters=" + heaters + "]";
82     }
83
84     public Home getHome() {
85         return home;
86     }
87
88     public Long getId() {
89         return id;
90     }
91
92     public String getName() {
93         return name;
94     }
95
96     public int getCurrentTemp() {
97         return currentTemp;
98     }
99
100     public int getComfortTemp() {
101         return comfortTemp;
102     }
103
104     public int getSleepTemp() {
105         return sleepTemp;
106     }
107
108     public int getAwayTemp() {
109         return awayTemp;
110     }
111
112     public boolean isHeatingActive() {
113         return heatingActive;
114     }
115
116     public ModeType getMode() {
117         return mode;
118     }
119
120     public String getRoomProgramName() {
121         return roomProgramName;
122     }
123 }