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;
15 import org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes;
16 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.constants.JSONApiResponseKeysEnum;
18 import com.google.gson.JsonObject;
21 * The {@link BaseTemperatureControl} is a base implementation for temperature controls status and configurations. For
22 * that it extends the {@link BaseZoneIdentifier}.
24 * @author Michael Ochel - Initial contribution
25 * @author Matthias Siegele - Initial contribution
27 public abstract class BaseTemperatureControl extends BaseZoneIdentifier {
29 protected String controlDSUID;
30 protected Short controlMode;
33 * Creates a new {@link BaseTemperatureControl} through the {@link JsonObject} which will be returned by a zone
35 * Because zone calls do not include a zoneID or zoneName in the json response, the zoneID and zoneName have to
36 * be handed over the constructor.
38 * @param jObject must not be null
39 * @param zoneID must not be null
40 * @param zoneName can be null
42 public BaseTemperatureControl(JsonObject jObject, Integer zoneID, String zoneName) {
43 super(zoneID, zoneName);
48 * Creates a new {@link BaseTemperatureControl} through the {@link JsonObject} which will be returned by an
51 * @param jObject must not be null
53 public BaseTemperatureControl(JsonObject jObject) {
58 private void init(JsonObject jObject) {
59 if (jObject.get(JSONApiResponseKeysEnum.CONTROL_MODE.getKey()) != null) {
60 this.controlMode = jObject.get(JSONApiResponseKeysEnum.CONTROL_MODE.getKey()).getAsShort();
62 if (jObject.get(JSONApiResponseKeysEnum.CONTROL_DSUID.getKey()) != null) {
63 this.controlDSUID = jObject.get(JSONApiResponseKeysEnum.CONTROL_DSUID.getKey()).getAsString();
68 * Returns the dSUID of the control sensor for heating of the zone.
70 * @return the controlDSUID
72 public String getControlDSUID() {
77 * Returns controlMode for heating of the zone.
79 * @return the controlMode
81 public Short getControlMode() {
86 * Returns true, if heating for this zone is not set off (set {@link ControlModes} = {@link ControlModes#OFF}),
89 * @return true, if the set {@link ControlModes} is not {@link ControlModes#OFF}
91 public Boolean isNotSetOff() {
92 return !ControlModes.OFF.getID().equals(controlMode);