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 @SerializedName("IsThisDevice")
73 public boolean isThisDevice;
75 public class FirmwareImage {
76 @SerializedName("Firmware")
77 public Firmware firmware;
78 @SerializedName("Installed")
79 public ProjectTimestamp installed;
82 public class Firmware {
83 @SerializedName("DisplayName")
84 public String displayName;
87 public class RepeaterProperties {
88 @SerializedName("IsRepeater")
89 public boolean isRepeater;
95 public int getDevice() {
96 return hrefNumber(DEVICE_HREF_PATTERN, href);
100 * Returns the zone number of the first zone listed in LocalZones.
101 * Currently devices should only have one zone listed.
103 public int getZone() {
104 if (localZones != null && localZones.length > 0) {
105 return hrefNumber(ZONE_HREF_PATTERN, localZones[0].href);
111 public String getFullyQualifiedName() {
112 if (fullyQualifiedName != null && fullyQualifiedName.length > 0) {
113 return String.join(" ", fullyQualifiedName);