]> git.basschouten.com Git - openhab-addons.git/blob
59861c4dd5b4b470e7feb0e2f9fed0c73a628ef4
[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> localModules = modules;
39             return localModules != null ? localModules : new NAObjectMap<>();
40         }
41     }
42
43     public class Energy extends HomeStatus {
44         private NAObjectMap<Room> rooms = new NAObjectMap<>();
45
46         public NAObjectMap<Room> getRooms() {
47             return rooms;
48         }
49     }
50
51     public class Security extends HomeStatus {
52         private NAObjectMap<HomeStatusPerson> persons = new NAObjectMap<>();
53
54         public NAObjectMap<HomeStatusPerson> getPersons() {
55             return persons;
56         }
57     }
58
59     private @Nullable HomeStatus home;
60     private List<NAError> errors = List.of();
61
62     public Optional<HomeStatus> getHomeStatus() {
63         return Optional.ofNullable(home);
64     }
65
66     public List<NAError> getErrors() {
67         return errors;
68     }
69 }