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 org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.BaseTemperatureControl;
16 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.constants.JSONApiResponseKeysEnum;
18 import com.google.gson.JsonObject;
21 * The {@link TemperatureControlConfig} acts as container for the digitalSTROM json-method
22 * <i>getTemperatureControlConfig</i>. So the {@link TemperatureControlConfig} contains all heating control
23 * configurations of a zone.
25 * @author Michael Ochel - Initial contribution
26 * @author Matthias Siegele - Initial contribution
28 public class TemperatureControlConfig extends BaseTemperatureControl {
30 private Integer referenceZone;
31 private Float ctrlOffset;
32 private Float manualValue;
33 private Float emergencyValue;
38 private Float ctrlImin;
39 private Float ctrlImax;
40 private Float ctrlYmin;
41 private Float ctrlYmax;
42 private Boolean ctrlAntiWindUp;
43 private Boolean ctrlKeepFloorWarm;
46 * Creates a new {@link TemperatureControlConfig} through the {@link JsonObject} which will be returned by an
49 * @param jObject must not be null
51 public TemperatureControlConfig(JsonObject jObject) {
57 * Creates a new {@link TemperatureControlConfig} through the {@link JsonObject} which will be returned by a zone
59 * Because of zone calls does not include a zoneID or zoneName in the json response, the zoneID and zoneName have to
60 * be handed over the constructor.
62 * @param jObject must not be null
63 * @param zoneID must not be null
64 * @param zoneName can be null
66 public TemperatureControlConfig(JsonObject jObject, Integer zoneID, String zoneName) {
67 super(jObject, zoneID, zoneName);
71 private void init(JsonObject jObject) {
73 if (controlMode == 1) {
74 if (jObject.get(JSONApiResponseKeysEnum.EMERGENCY_VALUE.getKey()) != null) {
75 this.emergencyValue = jObject.get(JSONApiResponseKeysEnum.EMERGENCY_VALUE.getKey()).getAsFloat();
77 if (jObject.get(JSONApiResponseKeysEnum.CTRL_KP.getKey()) != null) {
78 this.ctrlKp = jObject.get(JSONApiResponseKeysEnum.CTRL_KP.getKey()).getAsFloat();
80 if (jObject.get(JSONApiResponseKeysEnum.CTRL_TS.getKey()) != null) {
81 this.ctrlTs = jObject.get(JSONApiResponseKeysEnum.CTRL_TS.getKey()).getAsFloat();
83 if (jObject.get(JSONApiResponseKeysEnum.CTRL_TI.getKey()) != null) {
84 this.ctrlTi = jObject.get(JSONApiResponseKeysEnum.CTRL_TI.getKey()).getAsFloat();
86 if (jObject.get(JSONApiResponseKeysEnum.CTRL_KD.getKey()) != null) {
87 this.ctrlKd = jObject.get(JSONApiResponseKeysEnum.CTRL_KD.getKey()).getAsFloat();
89 if (jObject.get(JSONApiResponseKeysEnum.CTRL_MIN.getKey()) != null) {
90 this.ctrlImin = jObject.get(JSONApiResponseKeysEnum.CTRL_MIN.getKey()).getAsFloat();
92 if (jObject.get(JSONApiResponseKeysEnum.CTRL_MAX.getKey()) != null) {
93 this.ctrlImax = jObject.get(JSONApiResponseKeysEnum.CTRL_MAX.getKey()).getAsFloat();
95 if (jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MIN.getKey()) != null) {
96 this.ctrlYmin = jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MIN.getKey()).getAsFloat();
98 if (jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MAX.getKey()) != null) {
99 this.ctrlYmax = jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MAX.getKey()).getAsFloat();
101 if (jObject.get(JSONApiResponseKeysEnum.CTRL_KEEP_FLOOR_WARM.getKey()) != null) {
102 this.ctrlKeepFloorWarm = jObject.get(JSONApiResponseKeysEnum.CTRL_KEEP_FLOOR_WARM.getKey())
105 if (jObject.get(JSONApiResponseKeysEnum.CTRL_ANTI_WIND_UP.getKey()) != null) {
106 this.ctrlAntiWindUp = jObject.get(JSONApiResponseKeysEnum.CTRL_ANTI_WIND_UP.getKey())
110 if (controlMode == 2) {
111 if (jObject.get(JSONApiResponseKeysEnum.REFERENCE_ZONE.getKey()) != null) {
112 this.referenceZone = jObject.get(JSONApiResponseKeysEnum.REFERENCE_ZONE.getKey()).getAsInt();
114 if (jObject.get(JSONApiResponseKeysEnum.CTRL_OFFSET.getKey()) != null) {
115 this.ctrlOffset = jObject.get(JSONApiResponseKeysEnum.CTRL_OFFSET.getKey()).getAsFloat();
122 * Returns the refenceZone, if control-mode is {@link ControlModes#ZONE_FOLLOWER}, otherwise null.
124 * @return the referenceZone
126 public Integer getReferenceZone() {
127 return referenceZone;
131 * Returns the ctrlOffset, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
133 * @return the ctrlOffset
135 public Float getCtrlOffset() {
140 * Returns the manualValue, if control-mode is {@link ControlModes#MANUAL}, otherwise null.
142 * @return the manualValue
144 public Float getManualValue() {
149 * Returns the emergencyValue, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
151 * @return the emergencyValue
153 public Float getEmergencyValue() {
154 return emergencyValue;
158 * Returns the ctrlKp, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
162 public Float getCtrlKp() {
167 * Returns the ctrlTs, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
171 public Float getCtrlTs() {
176 * Returns the ctrlTi, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
180 public Float getCtrlTi() {
185 * Returns the ctrlKd, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
189 public Float getCtrlKd() {
194 * Returns the ctrlImin, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
196 * @return the ctrlImin
198 public Float getCtrlImin() {
203 * Returns the ctrlImax, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
205 * @return the ctrlImax
207 public Float getCtrlImax() {
212 * Returns the ctrlYmin, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
214 * @return the ctrlYmin
216 public Float getCtrlYmin() {
221 * Returns the ctrlYmax, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
223 * @return the ctrlYmax
225 public Float getCtrlYmax() {
230 * Returns the ctrlAntiWindUp, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
232 * @return the ctrlAntiWindUp
234 public Boolean getCtrlAntiWindUp() {
235 return ctrlAntiWindUp;
239 * Returns the ctrlKeepFloorWarm, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
241 * @return the ctrlKeepFloorWarm
243 public Boolean getCtrlKeepFloorWarm() {
244 return ctrlKeepFloorWarm;
250 * @see java.lang.Object#toString()
253 public String toString() {
254 return "TemperatureControlConfig [referenceZone=" + referenceZone + ", ctrlOffset=" + ctrlOffset
255 + ", manualValue=" + manualValue + ", emergencyValue=" + emergencyValue + ", ctrlKp=" + ctrlKp
256 + ", ctrlTs=" + ctrlTs + ", ctrlTi=" + ctrlTi + ", ctrlKd=" + ctrlKd + ", ctrlImin=" + ctrlImin
257 + ", ctrlImax=" + ctrlImax + ", ctrlYmin=" + ctrlYmin + ", ctrlYmax=" + ctrlYmax + ", ctrlAntiWindUp="
258 + ctrlAntiWindUp + ", ctrlKeepFloorWarm=" + ctrlKeepFloorWarm + "]";