]> git.basschouten.com Git - openhab-addons.git/blob
6bb35276b2945f3a4cb1c56f461ac0657f855cb1
[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  * <devicelist version="1">
33  * <device identifier="##############" id="##" functionbitmask="2944" fwversion="03.83" manufacturer="AVM" productname=
34  * "FRITZ!DECT 200">
35  * <present>1</present>
36  * <name>FRITZ!DECT 200 #1</name>
37  * <switch>
38  * <state>0</state>
39  * <mode>manuell</mode>
40  * <lock>0</lock>
41  * <devicelock>1</devicelock>
42  * </switch>
43  * <powermeter>
44  * <power>0</power>
45  * <energy>166</energy>
46  * </powermeter>
47  * <temperature>
48  * <celsius>255</celsius>
49  * <offset>0</offset>
50  * </temperature>
51  * </device>
52  * <device identifier="##############" id="xx" functionbitmask="320" fwversion="03.50" manufacturer="AVM" productname=
53  * "Comet DECT">
54  * <present>1</present>
55  * <name>Comet DECT #1</name>
56  * <temperature>
57  * <celsius>220</celsius>
58  * <offset>-10</offset>
59  * </temperature>
60  * <hkr>
61  * <tist>44</tist>
62  * <tsoll>42</tsoll>
63  * <absenk>28</absenk>
64  * <komfort>42</komfort>
65  * <lock>0</lock>
66  * <devicelock>0</devicelock>
67  * <errorcode>0</errorcode>
68  * <batterylow>0</batterylow>
69  * <nextchange>
70  * <endperiod>1484341200</endperiod>
71  * <tchange>28</tchange>
72  * </nextchange>
73  * </hkr>
74  * </device>
75  * </devicelist>
76  *
77  * <pre>
78  *
79  * @author Robert Bausdorf - Initial contribution
80  * @author Christoph Weitkamp - Added support for groups
81  */
82 @XmlAccessorType(XmlAccessType.FIELD)
83 @XmlType
84 @XmlRootElement(name = "devicelist")
85 public class DeviceListModel {
86
87     @XmlAttribute(name = "version")
88     private String apiVersion;
89
90     //@formatter:off
91     @XmlElements({
92         @XmlElement(name = "device", type = DeviceModel.class),
93         @XmlElement(name = "group", type = GroupModel.class)
94     })
95     //@formatter:on
96     private List<AVMFritzBaseModel> devices;
97
98     public List<AVMFritzBaseModel> getDevicelist() {
99         if (devices == null) {
100             devices = Collections.emptyList();
101         }
102         return devices;
103     }
104
105     public void setDevicelist(List<AVMFritzBaseModel> devices) {
106         this.devices = devices;
107     }
108
109     public String getXmlApiVersion() {
110         return apiVersion;
111     }
112
113     @Override
114     public String toString() {
115         return new StringBuilder().append("[devices=").append(devices).append(",version=").append(apiVersion)
116                 .append("]").toString();
117     }
118 }