]> git.basschouten.com Git - openhab-addons.git/blob
c27755a9e93aa5af70f0d5c90d1c9dd9add38d92
[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.meater.internal.dto;
14
15 import java.time.Instant;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 import com.google.gson.annotations.SerializedName;
22
23 /**
24  * The {@link MeaterProbeDTO} class defines the DTO for the Meater probe.
25  *
26  * @author Jan Gustafsson - Initial contribution
27  */
28 @NonNullByDefault
29 public class MeaterProbeDTO {
30
31     public String status = "";
32     public long statusCode;
33     public Data data = new Data();
34     public Meta meta = new Meta();
35
36     public Data getData() {
37         return data;
38     }
39
40     public class Data {
41
42         @Nullable
43         public List<Device> devices;
44
45         public @Nullable List<Device> getDevices() {
46             return devices;
47         }
48
49         public @Nullable Device getDevice(String id) {
50             List<Device> localDevices = devices;
51             if (localDevices != null) {
52                 for (Device meaterProbe : localDevices) {
53                     if (id.equals(meaterProbe.id)) {
54                         return meaterProbe;
55                     }
56                 }
57             }
58             return null;
59         }
60     }
61
62     public class Meta {
63     }
64
65     public class Device {
66         public String id = "";
67         public Temperature temperature = new Temperature();
68         public @Nullable Cook cook = new Cook();
69         @SerializedName("updated_at")
70         private long lastConnection;
71
72         public @Nullable Instant getLastConnection() {
73             if (lastConnection > 0) {
74                 return Instant.ofEpochSecond(lastConnection);
75             }
76             return null;
77         }
78     }
79
80     public class Cook {
81         public String id = "";
82         public String name = "";
83         public String state = "";
84         public TemperatureCook temperature = new TemperatureCook();
85         public Time time = new Time();
86     }
87
88     public class TemperatureCook {
89         public double target;
90         public double peak;
91     }
92
93     public class Temperature {
94         public double internal;
95         public double ambient;
96     }
97
98     public class Time {
99         public long elapsed;
100         public long remaining;
101     }
102 }