]> git.basschouten.com Git - openhab-addons.git/blob
ff7ae4409e1a6ad387860527f50ab21105432b22
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.mielecloud.internal.webservice.api;
14
15 import java.util.Optional;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * Provides easy access to temperature values mapped for cooling devices.
21  *
22  * @author Björn Lange - Initial contribution
23  */
24 @NonNullByDefault
25 public class CoolingDeviceTemperatureState {
26     private final DeviceState deviceState;
27
28     public CoolingDeviceTemperatureState(DeviceState deviceState) {
29         this.deviceState = deviceState;
30     }
31
32     /**
33      * Gets the current temperature of the fridge part of the device.
34      *
35      * @return The current temperature of the fridge part of the device.
36      */
37     public Optional<Integer> getFridgeTemperature() {
38         switch (deviceState.getRawType()) {
39             case FRIDGE:
40                 return deviceState.getTemperature(0);
41
42             case FRIDGE_FREEZER_COMBINATION:
43                 return deviceState.getTemperature(0);
44
45             default:
46                 return Optional.empty();
47         }
48     }
49
50     /**
51      * Gets the target temperature of the fridge part of the device.
52      *
53      * @return The target temperature of the fridge part of the device.
54      */
55     public Optional<Integer> getFridgeTargetTemperature() {
56         switch (deviceState.getRawType()) {
57             case FRIDGE:
58                 return deviceState.getTargetTemperature(0);
59
60             case FRIDGE_FREEZER_COMBINATION:
61                 return deviceState.getTargetTemperature(0);
62
63             default:
64                 return Optional.empty();
65         }
66     }
67
68     /**
69      * Gets the current temperature of the freezer part of the device.
70      *
71      * @return The current temperature of the freezer part of the device.
72      */
73     public Optional<Integer> getFreezerTemperature() {
74         switch (deviceState.getRawType()) {
75             case FREEZER:
76                 return deviceState.getTemperature(0);
77
78             case FRIDGE_FREEZER_COMBINATION:
79                 return deviceState.getTemperature(1);
80
81             default:
82                 return Optional.empty();
83         }
84     }
85
86     /**
87      * Gets the target temperature of the freezer part of the device.
88      *
89      * @return The target temperature of the freezer part of the device.
90      */
91     public Optional<Integer> getFreezerTargetTemperature() {
92         switch (deviceState.getRawType()) {
93             case FREEZER:
94                 return deviceState.getTargetTemperature(0);
95
96             case FRIDGE_FREEZER_COMBINATION:
97                 return deviceState.getTargetTemperature(1);
98
99             default:
100                 return Optional.empty();
101         }
102     }
103 }