]> git.basschouten.com Git - openhab-addons.git/blob
4c3fc1ca12362dbd0644dde9c038d36935d0eb09
[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.avmfritz.internal.dto;
14
15 import java.util.Collections;
16 import java.util.List;
17
18 import javax.xml.bind.annotation.XmlAccessType;
19 import javax.xml.bind.annotation.XmlAccessorType;
20 import javax.xml.bind.annotation.XmlAttribute;
21 import javax.xml.bind.annotation.XmlElement;
22 import javax.xml.bind.annotation.XmlElements;
23 import javax.xml.bind.annotation.XmlRootElement;
24 import javax.xml.bind.annotation.XmlType;
25
26 /**
27  * This JAXB model class maps the XML response to an <b>getdevicelistinfos</b>
28  * command on a FRITZ!Box device. As of today, this class is able to to bind the
29  * devicelist version 1 (currently used by AVM) response:
30  *
31  * <pre>
32  * {@code
33  * <devicelist version="1">
34  * <device identifier="##############" id="##" functionbitmask="2944" fwversion="03.83" manufacturer="AVM" productname=
35  * "FRITZ!DECT 200">
36  * <present>1</present>
37  * <name>FRITZ!DECT 200 #1</name>
38  * <switch>
39  * <state>0</state>
40  * <mode>manuell</mode>
41  * <lock>0</lock>
42  * <devicelock>1</devicelock>
43  * </switch>
44  * <powermeter>
45  * <power>0</power>
46  * <energy>166</energy>
47  * </powermeter>
48  * <temperature>
49  * <celsius>255</celsius>
50  * <offset>0</offset>
51  * </temperature>
52  * </device>
53  * <device identifier="##############" id="xx" functionbitmask="320" fwversion="03.50" manufacturer="AVM" productname=
54  * "Comet DECT">
55  * <present>1</present>
56  * <name>Comet DECT #1</name>
57  * <temperature>
58  * <celsius>220</celsius>
59  * <offset>-10</offset>
60  * </temperature>
61  * <hkr>
62  * <tist>44</tist>
63  * <tsoll>42</tsoll>
64  * <absenk>28</absenk>
65  * <komfort>42</komfort>
66  * <lock>0</lock>
67  * <devicelock>0</devicelock>
68  * <errorcode>0</errorcode>
69  * <batterylow>0</batterylow>
70  * <nextchange>
71  * <endperiod>1484341200</endperiod>
72  * <tchange>28</tchange>
73  * </nextchange>
74  * </hkr>
75  * </device>
76  * </devicelist>
77  * }
78  * </pre>
79  *
80  * @author Robert Bausdorf - Initial contribution
81  * @author Christoph Weitkamp - Added support for groups
82  */
83 @XmlAccessorType(XmlAccessType.FIELD)
84 @XmlType
85 @XmlRootElement(name = "devicelist")
86 public class DeviceListModel {
87
88     @XmlAttribute(name = "version")
89     private String apiVersion;
90
91     //@formatter:off
92     @XmlElements({
93         @XmlElement(name = "device", type = DeviceModel.class),
94         @XmlElement(name = "group", type = GroupModel.class)
95     })
96     //@formatter:on
97     private List<AVMFritzBaseModel> devices;
98
99     public List<AVMFritzBaseModel> getDevicelist() {
100         if (devices == null) {
101             devices = Collections.emptyList();
102         }
103         return devices;
104     }
105
106     public void setDevicelist(List<AVMFritzBaseModel> devices) {
107         this.devices = devices;
108     }
109
110     public String getXmlApiVersion() {
111         return apiVersion;
112     }
113
114     @Override
115     public String toString() {
116         return new StringBuilder().append("[devices=").append(devices).append(",version=").append(apiVersion)
117                 .append("]").toString();
118     }
119 }