2 * Copyright (c) 2010-2021 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.ecobee.internal.dto;
18 * The {@link SelectionDTO} defines the resources and information to return
19 * as part of a response. The selection is required in all requests however
20 * meaning of some selection fields is only meaningful to certain types of requests.
22 * The selectionType parameter defines the type of selection to perform. The selectionMatch
23 * specifies the matching criteria for the type specified.
25 * @author Mark Hilbush - Initial contribution
27 public class SelectionDTO {
30 * The type of match data supplied: Values: thermostats, registered, managementSet.
32 public SelectionType selectionType;
35 * The match data based on selectionType (e.g. a comma-separated list of thermostat
36 * idendifiers in the case of a selectionType of thermostats)
38 public String selectionMatch;
41 * Include the thermostat's unacknowledged alert objects. If not specified, defaults to false.
43 public Boolean includeAlerts;
46 * Include the audio configuration for the selected Thermostat(s). If not specified, defaults to false.
48 public Boolean includeAudio;
51 * Include the thermostat device configuration objects. If not specified, defaults to false.
53 public Boolean includeDevice;
56 * Include the electricity readings object. If not specified, defaults to false.
58 public Boolean includeElectricity;
61 * Include the energy configuration for the selected Thermostat(s). If not specified, defaults to false.
63 public Boolean includeEnergy;
66 * Include the current thermostat equipment status information. If not specified, defaults to false.
68 public Boolean includeEquipmentStatus;
71 * Include the thermostat calendar events objects. If not specified, defaults to false.
73 public Boolean includeEvents;
76 * Include the extended thermostat runtime object. If not specified, defaults to false.
78 public Boolean includeExtendedRuntime;
81 * Include the current thermostat house details object. If not specified, defaults to false.
83 public Boolean includeHouseDetails;
86 * Include the thermostat location object. If not specified, defaults to false.
88 public Boolean includeLocation;
91 * Include the thermostat management company object. If not specified, defaults to false.
93 public Boolean includeManagement;
96 * Include the current thermostat alert and reminders settings. If not specified, defaults to false.
98 public Boolean includeNotificationSettings;
101 * Include the current thermostat OemCfg object. If not specified, defaults to false.
103 public Boolean includeOemCfg;
106 * Include the current thermostat privacy settings. Note: access to this object is restricted
107 * to callers with implict authentication, setting this value to true without proper
108 * credentials will result in an authentication exception.
110 public Boolean includePrivacy;
113 * Include the thermostat program object. If not specified, defaults to false.
115 public Boolean includeProgram;
118 * Include the thermostat reminder object. If not specified, defaults to false.
120 public Boolean includeReminders;
123 * Include the thermostat runtime object. If not specified, defaults to false.
125 public Boolean includeRuntime;
128 * Include the current securitySettings object for the selected Thermostat(s). If not specified, defaults to false.
130 public Boolean includeSecuritySettings;
133 * Include the list of current thermostatRemoteSensor objects for the selected Thermostat(s).
134 * If not specified, defaults to false.
136 public Boolean includeSensors;
139 * Include the thermostat settings object. If not specified, defaults to false.
141 public Boolean includeSettings;
144 * Include the thermostat technician object. If not specified, defaults to false.
146 public Boolean includeTechnician;
149 * Include the thermostat utility company object. If not specified, defaults to false.
151 public Boolean includeUtility;
154 * Include the current firmware version the Thermostat is running. If not specified, defaults to false.
156 public Boolean includeVersion;
159 * Include the current thermostat weather forecast object. If not specified, defaults to false.
161 public Boolean includeWeather;
163 public SelectionDTO() {
164 selectionType = SelectionType.REGISTERED;
167 public void setThermostats(Set<String> thermostatIds) {
168 if (thermostatIds == null || thermostatIds.isEmpty()) {
169 selectionType = SelectionType.REGISTERED;
172 selectionType = SelectionType.THERMOSTATS;
173 selectionMatch = String.join(",", thermostatIds);
177 public void setSelectionType(SelectionType selectionType) {
178 this.selectionType = selectionType;
182 * Merge this selection object with the one passed in as a parameter.
185 * @return A SelectionDTO object representing the merged selection objects
187 public SelectionDTO mergeSelection(SelectionDTO selection) {
188 // Always get alerts, equipmentStatus, events, program, runtime, and sensors
189 this.includeAlerts = Boolean.TRUE;
190 this.includeEquipmentStatus = Boolean.TRUE;
191 this.includeEvents = Boolean.TRUE;
192 this.includeProgram = Boolean.TRUE;
193 this.includeRuntime = Boolean.TRUE;
194 this.includeSensors = Boolean.TRUE;
196 this.includeAudio = selection.includeAudio == Boolean.TRUE ? Boolean.TRUE : includeAudio;
197 this.includeDevice = selection.includeDevice == Boolean.TRUE ? Boolean.TRUE : includeDevice;
198 this.includeElectricity = selection.includeElectricity == Boolean.TRUE ? Boolean.TRUE : includeElectricity;
199 this.includeEnergy = selection.includeEnergy == Boolean.TRUE ? Boolean.TRUE : includeEnergy;
200 this.includeExtendedRuntime = selection.includeExtendedRuntime == Boolean.TRUE ? Boolean.TRUE
201 : includeExtendedRuntime;
202 this.includeHouseDetails = selection.includeHouseDetails == Boolean.TRUE ? Boolean.TRUE : includeHouseDetails;
203 this.includeLocation = selection.includeLocation == Boolean.TRUE ? Boolean.TRUE : includeLocation;
204 this.includeManagement = selection.includeManagement == Boolean.TRUE ? Boolean.TRUE : includeManagement;
205 this.includeNotificationSettings = selection.includeNotificationSettings == Boolean.TRUE ? Boolean.TRUE
206 : includeNotificationSettings;
207 this.includeOemCfg = selection.includeOemCfg == Boolean.TRUE ? Boolean.TRUE : includeOemCfg;
208 this.includePrivacy = selection.includePrivacy == Boolean.TRUE ? Boolean.TRUE : includePrivacy;
209 this.includeReminders = selection.includeReminders == Boolean.TRUE ? Boolean.TRUE : includeReminders;
210 this.includeSecuritySettings = selection.includeSecuritySettings == Boolean.TRUE ? Boolean.TRUE
211 : includeSecuritySettings;
212 this.includeSettings = selection.includeSettings == Boolean.TRUE ? Boolean.TRUE : includeSettings;
213 this.includeTechnician = selection.includeTechnician == Boolean.TRUE ? Boolean.TRUE : includeTechnician;
214 this.includeUtility = selection.includeUtility == Boolean.TRUE ? Boolean.TRUE : includeUtility;
215 this.includeVersion = selection.includeVersion == Boolean.TRUE ? Boolean.TRUE : includeVersion;
216 this.includeWeather = selection.includeWeather == Boolean.TRUE ? Boolean.TRUE : includeWeather;
221 public String toString() {
222 StringBuilder sb = new StringBuilder();
223 sb.append("selectionType=").append(selectionType).append(",");
224 sb.append("selectionMatch=").append(selectionMatch).append(",");
225 sb.append("includeAlerts=").append(includeAlerts).append(",");
226 sb.append("includeAudio=").append(includeAudio).append(",");
227 sb.append("includeDevice=").append(includeDevice).append(",");
228 sb.append("includeElectricity=").append(includeElectricity).append(",");
229 sb.append("includeEnergy=").append(includeEnergy).append(",");
230 sb.append("includeEquipmentStatus=").append(includeEquipmentStatus).append(",");
231 sb.append("includeExtendedRuntime=").append(includeExtendedRuntime).append(",");
232 sb.append("includeHouseDetails=").append(includeHouseDetails).append(",");
233 sb.append("includeLocation=").append(includeLocation).append(",");
234 sb.append("includeManagement=").append(includeManagement).append(",");
235 sb.append("includeNotificationSettings=").append(includeNotificationSettings).append(",");
236 sb.append("includeOemCfg=").append(includeOemCfg).append(",");
237 sb.append("includePrivacy=").append(includePrivacy).append(",");
238 sb.append("includeProgram=").append(includeProgram).append(",");
239 sb.append("includeReminders=").append(includeReminders).append(",");
240 sb.append("includeRuntime=").append(includeRuntime).append(",");
241 sb.append("includeSecuritySettings=").append(includeSecuritySettings).append(",");
242 sb.append("includeSensors=").append(includeSensors).append(",");
243 sb.append("includeSettings=").append(includeSettings).append(",");
244 sb.append("includeTechnician=").append(includeTechnician).append(",");
245 sb.append("includeUtility=").append(includeUtility).append(",");
246 sb.append("includeVersion=").append(includeVersion).append(",");
247 sb.append("includeWeather=").append(includeWeather);
248 return sb.toString();