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