]> git.basschouten.com Git - openhab-addons.git/blob
137d1969d5d1b114763b0f8f1ce20ebf691999ff
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.lutron.internal.protocol.leap.dto;
14
15 import java.util.regex.Pattern;
16
17 import org.openhab.binding.lutron.internal.protocol.FanSpeedType;
18 import org.openhab.binding.lutron.internal.protocol.leap.AbstractMessageBody;
19
20 import com.google.gson.annotations.SerializedName;
21
22 /**
23  * LEAP ZoneStatus Object
24  *
25  * @author Bob Adair - Initial contribution
26  */
27 public class ZoneStatus extends AbstractMessageBody {
28     public static final Pattern ZONE_HREF_PATTERN = Pattern.compile("/zone/([0-9]+)");
29
30     @SerializedName("href")
31     public String href = "";
32     @SerializedName("Level")
33     public int level; // 0-100
34     @SerializedName("SwitchedLevel")
35     public String switchedLevel = ""; // "On" or "Off"
36     @SerializedName("FanSpeed")
37     public FanSpeedType fanSpeed;
38     @SerializedName("Zone")
39     public Href zone = new Href();;
40     @SerializedName("StatusAccuracy")
41     public String statusAccuracy = ""; // "Good" or ??
42
43     public ZoneStatus() {
44     }
45
46     public int getZone() {
47         if (zone != null) {
48             return hrefNumber(ZONE_HREF_PATTERN, zone.href);
49         } else {
50             return 0;
51         }
52     }
53
54     public boolean statusAccuracyGood() {
55         return "Good".equals(statusAccuracy);
56     }
57
58     public boolean switchedLevelOn() {
59         return "On".equals(switchedLevel);
60     }
61 }