2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lutron.internal.protocol.leap.dto;
15 import java.util.regex.Pattern;
17 import org.openhab.binding.lutron.internal.protocol.leap.AbstractMessageBody;
19 import com.google.gson.annotations.SerializedName;
24 * @author Bob Adair - Initial contribution
26 public class Device extends AbstractMessageBody {
27 public static final Pattern DEVICE_HREF_PATTERN = Pattern.compile("/device/([0-9]+)");
28 private static final Pattern ZONE_HREF_PATTERN = Pattern.compile("/zone/([0-9]+)");
30 @SerializedName("href")
33 @SerializedName("Name")
36 @SerializedName("FullyQualifiedName")
37 public String[] fullyQualifiedName;
39 @SerializedName("Parent")
40 public Href parent = new Href();
42 @SerializedName("SerialNumber")
43 public String serialNumber;
45 @SerializedName("ModelNumber")
46 public String modelNumber;
48 @SerializedName("DeviceType")
49 public String deviceType;
51 @SerializedName("LocalZones")
52 public Href[] localZones;
54 @SerializedName("AssociatedArea")
55 public Href associatedArea = new Href();
57 @SerializedName("OccupancySensors")
58 public Href[] occupancySensors;
60 @SerializedName("LinkNodes")
61 public Href[] linkNodes;
63 @SerializedName("DeviceRules")
64 public Href[] deviceRules;
66 @SerializedName("RepeaterProperties")
67 public RepeaterProperties repeaterProperties;
69 @SerializedName("FirmwareImage")
70 public FirmwareImage firmwareImage;
72 public class FirmwareImage {
73 @SerializedName("Firmware")
74 public Firmware firmware;
75 @SerializedName("Installed")
76 public Installed installed;
79 public class Firmware {
80 @SerializedName("DisplayName")
81 public String displayName;
84 public class Installed {
85 @SerializedName("Year")
87 @SerializedName("Month")
89 @SerializedName("Day")
91 @SerializedName("Hour")
93 @SerializedName("Minute")
95 @SerializedName("Second")
97 @SerializedName("Utc")
101 public class RepeaterProperties {
102 @SerializedName("IsRepeater")
103 public boolean isRepeater;
109 public int getDevice() {
110 return hrefNumber(DEVICE_HREF_PATTERN, href);
114 * Returns the zone number of the first zone listed in LocalZones.
115 * Currently devices should only have one zone listed.
117 public int getZone() {
118 if (localZones != null && localZones.length > 0) {
119 return hrefNumber(ZONE_HREF_PATTERN, localZones[0].href);
125 public String getFullyQualifiedName() {
126 if (fullyQualifiedName != null && fullyQualifiedName.length > 0) {
127 return String.join(" ", fullyQualifiedName);