]> git.basschouten.com Git - openhab-addons.git/blob
009bd46c4fcf4c5784199b6849a74f99e2e3fa30
[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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * The {@link RevisionDTO} contains information indicating what data
20  * has changed on the thermostat(s).
21  *
22  * @author Mark Hilbush - Initial contribution
23  */
24 @NonNullByDefault
25 public class RevisionDTO {
26
27     /*
28      * The thermostat identifier.
29      */
30     public String identifier;
31
32     /*
33      * The thermostat name, otherwise an empty field if one is not set.
34      */
35     public @Nullable String name;
36
37     /*
38      * Whether the thermostat is currently connected to the ecobee servers.
39      */
40     public @Nullable Boolean connected;
41
42     /*
43      * Current thermostat revision. This revision is incremented whenever
44      * the thermostat program, hvac mode, settings or configuration change.
45      * Changes to the following objects will update the thermostat revision:
46      * Settings, Program, Event, Device.
47      */
48     public String thermostatRevision;
49
50     /*
51      * Current revision of the thermostat alerts. This revision is incremented
52      * whenever a new Alert is issued or an Alert is modified (acknowledged or deferred).
53      */
54     public String alertsRevision;
55
56     /*
57      * The current revision of the thermostat runtime settings. This revision is
58      * incremented whenever the thermostat transmits a new status message, or
59      * updates the equipment state or Remote Sensor readings. The shortest interval
60      * this revision may change is 3 minutes.
61      */
62     public String runtimeRevision;
63
64     /*
65      * The current revision of the thermostat interval runtime settings. This
66      * revision is incremented whenever the thermostat transmits a new status message
67      * in the form of a Runtime object. The thermostat updates this on a 15 minute interval.
68      */
69     public String intervalRevision;
70
71     public RevisionDTO() {
72         identifier = "";
73         thermostatRevision = "";
74         alertsRevision = "";
75         runtimeRevision = "";
76         intervalRevision = "";
77     }
78
79     public String getId() {
80         return identifier;
81     }
82
83     public RevisionDTO getThis() {
84         return this;
85     }
86
87     public boolean hasChanged(@Nullable RevisionDTO previous) {
88         if (previous == null) {
89             return true;
90         }
91         return !(thermostatRevision.equals(previous.thermostatRevision)
92                 && alertsRevision.equals(previous.alertsRevision) && runtimeRevision.equals(previous.runtimeRevision)
93                 && intervalRevision.equals(previous.intervalRevision));
94     }
95
96     @Override
97     public String toString() {
98         StringBuilder sb = new StringBuilder();
99         sb.append("id:").append(identifier);
100         sb.append(" tstat:").append(thermostatRevision);
101         sb.append(" alert:").append(alertsRevision);
102         sb.append(" rntim:").append(runtimeRevision);
103         sb.append(" intrv:").append(intervalRevision);
104         return sb.toString();
105     }
106 }