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.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl;
15 import java.util.HashMap;
19 import org.openhab.binding.digitalstrom.internal.lib.climate.constants.OperationModes;
20 import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.BaseZoneIdentifier;
21 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.constants.JSONApiResponseKeysEnum;
23 import com.google.gson.JsonObject;
26 * The {@link TemperatureControlValues} acts as container for the digitalSTROM json-method
27 * <i>getTemperatureControlValues</i>. So the {@link TemperatureControlValues} contains all temperature
28 * control values information of a zone.
30 * @author Michael Ochel - Initial contribution
31 * @author Matthias Siegele - Initial contribution
33 public class TemperatureControlValues extends BaseZoneIdentifier {
35 private Map<OperationModes, Float> temperatureControlValues;
36 private String controlDSUID;
37 private Boolean isConfigured;
40 * Creates a new {@link TemperatureControlValues} through the {@link JsonObject} which will be returned by an
43 * @param jObject must not be null
45 public TemperatureControlValues(JsonObject jObject) {
51 * Creates a new {@link TemperatureControlValues} through the {@link JsonObject} which will be returned by a zone
53 * Because of zone calls does not include a zoneID or zoneName in the json response, the zoneID and zoneName have to
54 * be handed over the constructor.
56 * @param jObject must not be null
57 * @param zoneID must not be null
58 * @param zoneName can be null
60 public TemperatureControlValues(JsonObject jObject, Integer zoneID, String zoneName) {
61 super(zoneID, zoneName);
65 private void init(JsonObject jObject) {
66 if (jObject.get(JSONApiResponseKeysEnum.IS_CONFIGURED.getKey()) != null) {
67 this.isConfigured = jObject.get(JSONApiResponseKeysEnum.IS_CONFIGURED.getKey()).getAsBoolean();
70 if (jObject.get(JSONApiResponseKeysEnum.CONTROL_DSUID.getKey()) != null) {
71 this.controlDSUID = jObject.get(JSONApiResponseKeysEnum.CONTROL_DSUID.getKey()).getAsString();
73 temperatureControlValues = new HashMap<>(OperationModes.values().length);
74 for (OperationModes opMode : OperationModes.values()) {
75 if (jObject.get(opMode.getKey()) != null) {
76 temperatureControlValues.put(opMode, jObject.get(opMode.getKey()).getAsFloat());
83 * @see org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.TemperatureControlStatus#getControlDSUID()
84 * @return the controlDSUID
86 public String getControlDSUID() {
91 * @see org.openhab.binding.digitalstrom.internal.lib.serverconnection.constants.JSONApiResponseKeysEnum#IS_CONFIGURED
92 * @return the isConfigured
94 public Boolean getIsConfigured() {
99 * Returns the set temperature of the given operation mode.
101 * @param operationMode must not be null
102 * @return temperature of the operation mode
104 public Float getTemperation(OperationModes operationMode) {
105 return temperatureControlValues.get(operationMode);
109 * Returns the available operation modes as {@link Set}.
111 * @return available operation modes
113 public Set<OperationModes> getOperationModes() {
114 return temperatureControlValues.keySet();
118 * Returns a {@link Map} that maps the available operation modes to the set values.
120 * @return Map with operation modes and their values
122 public Map<OperationModes, Float> getTemperatureControlValues() {
123 return temperatureControlValues;
129 * @see java.lang.Object#toString()
132 public String toString() {
133 return "TemperatureControlValues [temperatureControlValues=" + temperatureControlValues + ", controlDSUID="
134 + controlDSUID + ", isConfigured=" + isConfigured + "]";