2 * Copyright (c) 2010-2023 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 = Boolean.TRUE.equals(selection.includeAudio) ? Boolean.TRUE : includeAudio;
197 this.includeDevice = Boolean.TRUE.equals(selection.includeDevice) ? Boolean.TRUE : includeDevice;
198 this.includeElectricity = Boolean.TRUE.equals(selection.includeElectricity) ? Boolean.TRUE : includeElectricity;
199 this.includeEnergy = Boolean.TRUE.equals(selection.includeEnergy) ? Boolean.TRUE : includeEnergy;
200 this.includeExtendedRuntime = Boolean.TRUE.equals(selection.includeExtendedRuntime) ? Boolean.TRUE
201 : includeExtendedRuntime;
202 this.includeHouseDetails = Boolean.TRUE.equals(selection.includeHouseDetails) ? Boolean.TRUE
203 : includeHouseDetails;
204 this.includeLocation = Boolean.TRUE.equals(selection.includeLocation) ? Boolean.TRUE : includeLocation;
205 this.includeManagement = Boolean.TRUE.equals(selection.includeManagement) ? Boolean.TRUE : includeManagement;
206 this.includeNotificationSettings = Boolean.TRUE.equals(selection.includeNotificationSettings) ? Boolean.TRUE
207 : includeNotificationSettings;
208 this.includeOemCfg = Boolean.TRUE.equals(selection.includeOemCfg) ? Boolean.TRUE : includeOemCfg;
209 this.includePrivacy = Boolean.TRUE.equals(selection.includePrivacy) ? Boolean.TRUE : includePrivacy;
210 this.includeReminders = Boolean.TRUE.equals(selection.includeReminders) ? Boolean.TRUE : includeReminders;
211 this.includeSecuritySettings = Boolean.TRUE.equals(selection.includeSecuritySettings) ? Boolean.TRUE
212 : includeSecuritySettings;
213 this.includeSettings = Boolean.TRUE.equals(selection.includeSettings) ? Boolean.TRUE : includeSettings;
214 this.includeTechnician = Boolean.TRUE.equals(selection.includeTechnician) ? Boolean.TRUE : includeTechnician;
215 this.includeUtility = Boolean.TRUE.equals(selection.includeUtility) ? Boolean.TRUE : includeUtility;
216 this.includeVersion = Boolean.TRUE.equals(selection.includeVersion) ? Boolean.TRUE : includeVersion;
217 this.includeWeather = Boolean.TRUE.equals(selection.includeWeather) ? Boolean.TRUE : includeWeather;
222 public String toString() {
223 StringBuilder sb = new StringBuilder();
224 sb.append("selectionType=").append(selectionType).append(",");
225 sb.append("selectionMatch=").append(selectionMatch).append(",");
226 sb.append("includeAlerts=").append(includeAlerts).append(",");
227 sb.append("includeAudio=").append(includeAudio).append(",");
228 sb.append("includeDevice=").append(includeDevice).append(",");
229 sb.append("includeElectricity=").append(includeElectricity).append(",");
230 sb.append("includeEnergy=").append(includeEnergy).append(",");
231 sb.append("includeEquipmentStatus=").append(includeEquipmentStatus).append(",");
232 sb.append("includeExtendedRuntime=").append(includeExtendedRuntime).append(",");
233 sb.append("includeHouseDetails=").append(includeHouseDetails).append(",");
234 sb.append("includeLocation=").append(includeLocation).append(",");
235 sb.append("includeManagement=").append(includeManagement).append(",");
236 sb.append("includeNotificationSettings=").append(includeNotificationSettings).append(",");
237 sb.append("includeOemCfg=").append(includeOemCfg).append(",");
238 sb.append("includePrivacy=").append(includePrivacy).append(",");
239 sb.append("includeProgram=").append(includeProgram).append(",");
240 sb.append("includeReminders=").append(includeReminders).append(",");
241 sb.append("includeRuntime=").append(includeRuntime).append(",");
242 sb.append("includeSecuritySettings=").append(includeSecuritySettings).append(",");
243 sb.append("includeSensors=").append(includeSensors).append(",");
244 sb.append("includeSettings=").append(includeSettings).append(",");
245 sb.append("includeTechnician=").append(includeTechnician).append(",");
246 sb.append("includeUtility=").append(includeUtility).append(",");
247 sb.append("includeVersion=").append(includeVersion).append(",");
248 sb.append("includeWeather=").append(includeWeather);
249 return sb.toString();