]> git.basschouten.com Git - openhab-addons.git/blob
219b47d6b5349d3beef59d7e44b5ddb81f60bc4e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.netatmo.internal.api.dto;
14
15 import java.util.Optional;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.netatmo.internal.api.data.ModuleType;
20 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.AlimentationStatus;
21 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.BatteryState;
22 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.FloodLightMode;
23 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.SdCardStatus;
24 import org.openhab.core.library.types.OnOffType;
25 import org.openhab.core.library.types.OpenClosedType;
26 import org.openhab.core.types.State;
27 import org.openhab.core.types.UnDefType;
28
29 /**
30  * The {@link HomeStatusModule} holds module informations returned by getHomeData endpoint
31  *
32  * @author GaĆ«l L'hopital - Initial contribution
33  *
34  */
35
36 @NonNullByDefault
37 public class HomeStatusModule extends NAThing {
38     private @Nullable String firmwareName;
39     private @Nullable String wifiState;
40     private @Nullable String status;
41     private @Nullable OnOffType monitoring;
42     private FloodLightMode floodlight = FloodLightMode.UNKNOWN;
43     private SdCardStatus sdStatus = SdCardStatus.UNKNOWN;
44     private AlimentationStatus alimStatus = AlimentationStatus.UNKNOWN;
45     private @Nullable String sirenStatus;
46     private @Nullable String vpnUrl;
47     private boolean isLocal;
48     private BatteryState batteryState = BatteryState.UNKNOWN;
49     private int batteryLevel;
50
51     private @Nullable OpenClosedType boilerStatus;
52     private boolean boilerValveComfortBoost;
53
54     public State getBoilerStatus() {
55         OpenClosedType status = boilerStatus;
56         return status != null ? status : UnDefType.NULL;
57     }
58
59     public boolean getBoilerValveComfortBoost() {
60         return boilerValveComfortBoost;
61     }
62
63     public Optional<String> getFirmwareName() {
64         return Optional.ofNullable(firmwareName);
65     }
66
67     public Optional<String> getWifiState() {
68         return Optional.ofNullable(wifiState);
69     }
70
71     public Optional<String> getStatus() {
72         return Optional.ofNullable(status);
73     }
74
75     public State getMonitoring() {
76         OnOffType localStatus = monitoring;
77         return localStatus != null ? localStatus // Monitoring is always active on Doorbell
78                 : getType().equals(ModuleType.DOORBELL) ? OnOffType.ON : UnDefType.NULL;
79     }
80
81     public FloodLightMode getFloodlight() {
82         return floodlight;
83     }
84
85     public SdCardStatus getSdStatus() {
86         return sdStatus;
87     }
88
89     public AlimentationStatus getAlimStatus() {
90         return alimStatus;
91     }
92
93     public Optional<String> getSirenStatus() {
94         return Optional.ofNullable(sirenStatus);
95     }
96
97     public @Nullable String getVpnUrl() {
98         return vpnUrl;
99     }
100
101     public boolean isLocal() {
102         return isLocal;
103     }
104
105     public BatteryState getBatteryState() {
106         return batteryState;
107     }
108
109     public int getBatteryLevel() {
110         return batteryLevel;
111     }
112 }