]> git.basschouten.com Git - openhab-addons.git/blob
1df83053acf9400613e3ff4d3aa38c78e74c04d4
[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.ecobee.internal.dto.thermostat.summary;
14
15 import java.util.HashSet;
16 import java.util.Set;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * The {@link RunningDTO} contains information indicating what equipment
23  * is running.
24  *
25  * @author John Cocula - Initial contribution
26  * @author Mark Hilbush - Adapt for OH2/3
27  */
28 @NonNullByDefault
29 public class RunningDTO {
30
31     /*
32      * The thermostat identifier.
33      */
34     public String identifier;
35
36     /*
37      * If no equipment is currently running no data is returned. Possible values
38      * are: heatPump, heatPump2, heatPump3, compCool1, compCool2, auxHeat1,
39      * auxHeat2, auxHeat3, fan, humidifier, dehumidifier, ventilator, economizer,
40      * compHotWater, auxHotWater.
41      */
42     public final Set<String> runningEquipment;
43
44     public RunningDTO() {
45         identifier = "";
46         runningEquipment = new HashSet<>();
47     }
48
49     public String getId() {
50         return identifier;
51     }
52
53     public RunningDTO getThis() {
54         return this;
55     }
56
57     public boolean hasChanged(@Nullable RunningDTO previous) {
58         if (previous == null) {
59             return true;
60         }
61         return !runningEquipment.equals(previous.runningEquipment);
62     }
63
64     public boolean isIdle() {
65         return runningEquipment.isEmpty();
66     }
67
68     public boolean isHeating() {
69         return runningEquipment.contains("heatPump") || runningEquipment.contains("heatPump2")
70                 || runningEquipment.contains("heatPump3") || runningEquipment.contains("auxHeat1")
71                 || runningEquipment.contains("auxHeat2") || runningEquipment.contains("auxHeat3");
72     }
73
74     public boolean isCooling() {
75         return runningEquipment.contains("compCool1") || runningEquipment.contains("compCool2");
76     }
77
78     public boolean isRunning(final String equipment) {
79         return runningEquipment.contains(equipment);
80     }
81 }