]> git.basschouten.com Git - openhab-addons.git/blob
2746523b47a97593b599b3a68e4b0a18e1e70f48
[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.hdpowerview.internal.api.responses;
14
15 import java.util.Base64;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.hdpowerview.internal.api.BatteryKind;
21 import org.openhab.binding.hdpowerview.internal.api.Firmware;
22 import org.openhab.binding.hdpowerview.internal.api.ShadePosition;
23
24 /**
25  * State of all Shades, as returned by an HD PowerView hub
26  *
27  * @author Andy Lintner - Initial contribution
28  */
29 @NonNullByDefault
30 public class Shades {
31
32     public @Nullable List<ShadeData> shadeData;
33     public @Nullable List<Integer> shadeIds;
34
35     /*
36      * the following SuppressWarnings annotation is because the Eclipse compiler
37      * does NOT expect a NonNullByDefault annotation on the inner class, since it is
38      * implicitly inherited from the outer class, whereas the Maven compiler always
39      * requires an explicit NonNullByDefault annotation on all classes
40      */
41     @SuppressWarnings("null")
42     @NonNullByDefault
43     public static class ShadeData {
44         public int id;
45         public @Nullable String name;
46         public int roomId;
47         public int groupId;
48         public int order;
49         public int type;
50         public double batteryStrength;
51         public int batteryStatus;
52         public boolean batteryIsLow;
53         public @Nullable ShadePosition positions;
54         public @Nullable Boolean timedOut;
55         public int signalStrength;
56         public @Nullable Integer capabilities;
57         public @Nullable Firmware firmware;
58         public @Nullable Firmware motor;
59         // note: in old JSON batteryKind was a string but now it's a number; fortunately GSON string accepts either
60         public @Nullable String batteryKind;
61
62         public String getName() {
63             return new String(Base64.getDecoder().decode(name));
64         }
65
66         public BatteryKind getBatteryKind() {
67             return BatteryKind.fromString(batteryKind);
68         }
69     }
70 }