Skip to content

Commit 746190d

Browse files
committed
Add element simpleonoff
1 parent 80fe711 commit 746190d

4 files changed

Lines changed: 69 additions & 1 deletion

File tree

src/main/java/com/github/kaklakariada/fritzbox/model/homeautomation/Device.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public class Device {
5353
private Integer battery;
5454
@Element(name = "switch", required = false)
5555
private SwitchState switchState;
56+
@Element(name = "simpleonoff", required = false)
57+
private SimpleOnOffState simpleOnOff;
5658
@Element(name = "powermeter", required = false)
5759
private PowerMeter powerMeter;
5860
@Element(name = "temperature", required = false)
@@ -120,11 +122,16 @@ public Hkr getHkr() {
120122
return hkr;
121123
}
122124

125+
public SimpleOnOffState getSimpleOnOff() {
126+
return simpleOnOff;
127+
}
128+
123129
@Override
124130
public String toString() {
125131
return "Device [identifier=" + identifier + ", id=" + id + ", functionBitmask=" + functionBitmask
126132
+ ", firmwareVersion=" + firmwareVersion + ", manufacturer=" + manufacturer + ", productName="
127-
+ productName + ", present=" + present + ", name=" + name + ", switchState=" + switchState
133+
+ productName + ", present=" + present + ", txbusy=" + txbusy + ", name=" + name + ", batterylow="
134+
+ batterylow + ", battery=" + battery + ", switchState=" + switchState + ", simpleOnOff=" + simpleOnOff
128135
+ ", powerMeter=" + powerMeter + ", temperature=" + temperature + ", hkr=" + hkr + "]";
129136
}
130137
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.github.kaklakariada.fritzbox.model.homeautomation;
2+
3+
import org.simpleframework.xml.Element;
4+
import org.simpleframework.xml.Root;
5+
6+
@Root(name = "simpleonoff")
7+
public class SimpleOnOffState {
8+
9+
@Element(name = "state")
10+
private int state;
11+
12+
public int getState() {
13+
return state;
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.github.kaklakariada.fritzbox.mapping;
2+
3+
import static java.util.stream.Collectors.joining;
4+
5+
import java.io.IOException;
6+
import java.nio.file.Files;
7+
import java.nio.file.Paths;
8+
9+
import org.junit.Test;
10+
11+
import com.github.kaklakariada.fritzbox.model.homeautomation.DeviceList;
12+
13+
public class DeserializerTest {
14+
15+
@Test
16+
public void parseDeviceList() throws IOException {
17+
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListPayload.xml")).stream()
18+
.collect(joining("\n"));
19+
new Deserializer().parse(fileContent, DeviceList.class);
20+
}
21+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<devicelist version="1" fwversion="7.21">
2+
<device identifier="00000 00000" id="16" functionbitmask="35712" fwversion="04.16" manufacturer="AVM" productname="FRITZ!DECT 200">
3+
<present>1</present>
4+
<txbusy>0</txbusy>
5+
<name>FRITZ!DECT 200 #1</name>
6+
<switch>
7+
<state>0</state>
8+
<mode>manuell</mode>
9+
<lock>0</lock>
10+
<devicelock>0</devicelock>
11+
</switch>
12+
<simpleonoff>
13+
<state>0</state>
14+
</simpleonoff>
15+
<powermeter>
16+
<voltage>233810</voltage>
17+
<power>0</power>
18+
<energy>14535</energy>
19+
</powermeter>
20+
<temperature>
21+
<celsius>270</celsius>
22+
<offset>0</offset>
23+
</temperature>
24+
</device>
25+
</devicelist>

0 commit comments

Comments
 (0)