]> git.basschouten.com Git - openhab-addons.git/blob
f0a7f1e82df9cd84c5a0ed2921135e85adfe15c3
[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.netatmo.internal.api.dto;
14
15 import java.time.ZonedDateTime;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.netatmo.internal.api.data.ModuleType;
20 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.SetpointMode;
21 import org.openhab.core.library.types.OnOffType;
22 import org.openhab.core.library.types.OpenClosedType;
23 import org.openhab.core.types.State;
24 import org.openhab.core.types.UnDefType;
25
26 /**
27  * The {@link Room} holds temperature data for a given room.
28  *
29  * @author Bernhard Kreuz - Initial contribution
30  *
31  */
32 @NonNullByDefault
33 public class Room extends NAObject implements NAModule {
34     private @Nullable String type;
35     private @Nullable OnOffType anticipating;
36     private boolean openWindow;
37     private @Nullable ZonedDateTime thermSetpointStartTime;
38     private @Nullable ZonedDateTime thermSetpointEndTime;
39     private SetpointMode thermSetpointMode = SetpointMode.UNKNOWN;
40     private int heatingPowerRequest;
41     private double thermMeasuredTemperature;
42     private double thermSetpointTemperature;
43
44     public State isAnticipating() {
45         OnOffType status = anticipating;
46         return status != null ? status : UnDefType.NULL;
47     }
48
49     public State hasOpenedWindows() {
50         return openWindow ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
51     }
52
53     public int getHeatingPowerRequest() {
54         return heatingPowerRequest;
55     }
56
57     public double getMeasuredTemp() {
58         return thermMeasuredTemperature;
59     }
60
61     public SetpointMode getSetpointMode() {
62         return thermSetpointMode;
63     }
64
65     public double getSetpointTemp() {
66         return thermSetpointTemperature;
67     }
68
69     public @Nullable ZonedDateTime getSetpointBegin() {
70         return thermSetpointStartTime;
71     }
72
73     public @Nullable ZonedDateTime getSetpointEnd() {
74         return thermSetpointEndTime;
75     }
76
77     @Override
78     public ModuleType getType() {
79         // Note: In json api answer type for NARoom is used with words like kitchen, living...
80         return ModuleType.ROOM;
81     }
82
83     public @Nullable String getLocation() {
84         return type;
85     }
86 }