]> git.basschouten.com Git - openhab-addons.git/blob
5583bc4aef831635f81d09dfed7c8ba50294f3b9
[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.List;
16 import java.util.Optional;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.netatmo.internal.api.ApiResponse;
21 import org.openhab.binding.netatmo.internal.deserialization.NAObjectMap;
22
23 /**
24  * The {@link NAHomeStatus} holds data for a given home.
25  *
26  * @author GaĆ«l L'hopital - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class NAHomeStatus {
31     public class NAHomeStatusResponse extends ApiResponse<NAHomeStatus> {
32     }
33
34     public class HomeStatus extends NAThing {
35         private @Nullable NAObjectMap<HomeStatusModule> modules;
36
37         public NAObjectMap<HomeStatusModule> getModules() {
38             NAObjectMap<HomeStatusModule> local = modules;
39             return local != null ? local : new NAObjectMap<>();
40         }
41     }
42
43     public class Energy extends HomeStatus {
44         private @Nullable NAObjectMap<Room> rooms;
45
46         public NAObjectMap<Room> getRooms() {
47             NAObjectMap<Room> local = rooms;
48             return local != null ? local : new NAObjectMap<>();
49         }
50     }
51
52     public class Security extends HomeStatus {
53         private @Nullable NAObjectMap<HomeStatusPerson> persons;
54
55         public NAObjectMap<HomeStatusPerson> getPersons() {
56             NAObjectMap<HomeStatusPerson> local = persons;
57             return local != null ? local : new NAObjectMap<>();
58         }
59     }
60
61     private @Nullable HomeStatus home;
62     private List<NAError> errors = List.of();
63
64     public Optional<HomeStatus> getHomeStatus() {
65         return Optional.ofNullable(home);
66     }
67
68     public List<NAError> getErrors() {
69         return errors;
70     }
71 }