2 * Copyright (c) 2010-2024 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.plugwiseha.internal.api.model.dto;
15 import java.time.ZonedDateTime;
16 import java.util.ArrayList;
17 import java.util.List;
18 import java.util.Optional;
20 import com.thoughtworks.xstream.annotations.XStreamAlias;
21 import com.thoughtworks.xstream.annotations.XStreamImplicit;
24 * The {@link Location} class is an object model class that
25 * mirrors the XML structure provided by the Plugwise Home Automation
26 * controller for a Plugwise zone/location.
27 * It implements the {@link PlugwiseComparableDate} interface and
28 * extends the abstract class {@link PlugwiseBaseModel}.
30 * @author B. van Wetten - Initial contribution
31 * @author Leo Siepel - finish initial contribution
33 @XStreamAlias("location")
34 public class Location extends PlugwiseBaseModel implements PlugwiseComparableDate<Location> {
37 private String description;
39 private String preset;
41 @XStreamImplicit(itemFieldName = "appliance")
42 private List<String> locationAppliances = new ArrayList<String>();
44 @XStreamImplicit(itemFieldName = "point_log", keyFieldName = "type")
45 private Logs pointLogs;
47 @XStreamImplicit(itemFieldName = "actuator_functionality", keyFieldName = "type")
48 private ActuatorFunctionalities actuatorFunctionalities;
50 public String getName() {
54 public String getDescription() {
58 public String getType() {
62 public String getPreset() {
66 public List<String> getLocationAppliances() {
67 return locationAppliances;
70 public Logs getPointLogs() {
71 if (pointLogs == null) {
72 pointLogs = new Logs();
77 public ActuatorFunctionalities getActuatorFunctionalities() {
78 if (actuatorFunctionalities == null) {
79 actuatorFunctionalities = new ActuatorFunctionalities();
81 return actuatorFunctionalities;
84 public Optional<Double> getTemperature() {
85 return this.pointLogs.getTemperature();
88 public Optional<String> getTemperatureUnit() {
89 return this.pointLogs.getTemperatureUnit();
92 public Optional<Double> getSetpointTemperature() {
93 return this.pointLogs.getThermostatTemperature();
96 public Optional<String> getSetpointTemperatureUnit() {
97 return this.pointLogs.getThermostatTemperatureUnit();
100 public Optional<Boolean> getPreHeatState() {
101 return this.actuatorFunctionalities.getPreHeatState();
104 public Optional<Boolean> getCoolingAllowed() {
105 return this.actuatorFunctionalities.getCoolingAllowed();
108 public String getRegulationControl() {
109 if (this.actuatorFunctionalities != null) {
110 return this.actuatorFunctionalities.getRegulationControl();
115 public void setPreset(String preset) {
116 this.preset = preset;
119 public int applianceCount() {
120 if (this.locationAppliances == null) {
123 return this.locationAppliances.size();
128 public int compareDateWith(Location compareTo) {
129 if (compareTo == null) {
132 ZonedDateTime compareToDate = compareTo.getModifiedDate();
133 ZonedDateTime compareFromDate = this.getModifiedDate();
134 if (compareFromDate == null) {
136 } else if (compareToDate == null) {
139 return compareFromDate.compareTo(compareToDate);
144 public boolean isNewerThan(Location hasModifiedDate) {
145 return compareDateWith(hasModifiedDate) > 0;
149 public boolean isOlderThan(Location hasModifiedDate) {
150 return compareDateWith(hasModifiedDate) < 0;