Skip to content

Commit a57e100

Browse files
authored
Merge pull request #16 from SmokingDevices/master
Updated for FRITZ-Dect 500 devices
2 parents 520842c + a8b2ad1 commit a57e100

11 files changed

Lines changed: 269 additions & 5 deletions

File tree

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111
}
1212

1313
group 'com.github.kaklakariada'
14-
version = '1.1.0'
14+
version = '1.2.0-SNAPSHOT'
1515
sourceCompatibility = 1.8
1616

1717
tasks.withType(JavaCompile) {
@@ -39,7 +39,7 @@ dependencies {
3939

4040
license {
4141
header = file('gradle/license-header.txt')
42-
exclude('**/deviceListPayload.xml')
42+
exclude('**/deviceList*Payload.xml')
4343
}
4444

4545
task sourceJar(type: Jar) {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* A Java API for managing FritzBox HomeAutomation
3+
* Copyright (C) 2017 Christoph Pirkl <christoph at users.sourceforge.net>
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package com.github.kaklakariada.fritzbox.model.homeautomation;
19+
20+
import org.simpleframework.xml.Attribute;
21+
import org.simpleframework.xml.Element;
22+
import org.simpleframework.xml.Root;
23+
24+
@Root(name = "colorcontrol")
25+
public class ColorControl {
26+
@Element(name = "hue", required = false)
27+
private String hue;
28+
29+
@Element(name = "saturation", required = false)
30+
private String saturation;
31+
32+
@Element(name = "temperature", required = false)
33+
private String temperature;
34+
35+
@Attribute(name = "supported_modes")
36+
private String supportedModes;
37+
38+
@Attribute(name = "current_mode", required = false)
39+
private String current_mode;
40+
41+
public String getHue() {
42+
return hue;
43+
}
44+
45+
public String getSaturation() {
46+
return saturation;
47+
}
48+
49+
public String getTemperature() {
50+
return temperature;
51+
}
52+
53+
public String getSupportedModes() {
54+
return supportedModes;
55+
}
56+
57+
public String getCurrent_mode() {
58+
return current_mode;
59+
}
60+
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public class Device {
6161
private Temperature temperature;
6262
@Element(name = "hkr", required = false)
6363
private Hkr hkr;
64+
@Element(name = "levelcontrol", required = false)
65+
private LevelControl levelControl;
66+
@Element(name = "colorcontrol", required = false)
67+
private ColorControl colorControl;
68+
@Element(name = "etsiunitinfo", required = false)
69+
private EtsiUnitInfo etsiUnitInfo;
6470

6571
public String getIdentifier() {
6672
return identifier;
@@ -126,6 +132,18 @@ public SimpleOnOffState getSimpleOnOff() {
126132
return simpleOnOff;
127133
}
128134

135+
public LevelControl getLevelControl() {
136+
return levelControl;
137+
}
138+
139+
public ColorControl getColorControl() {
140+
return colorControl;
141+
}
142+
143+
public EtsiUnitInfo getEtsiUnitInfo() {
144+
return etsiUnitInfo;
145+
}
146+
129147
@Override
130148
public String toString() {
131149
return "Device [identifier=" + identifier + ", id=" + id + ", functionBitmask=" + functionBitmask
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* A Java API for managing FritzBox HomeAutomation
3+
* Copyright (C) 2017 Christoph Pirkl <christoph at users.sourceforge.net>
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package com.github.kaklakariada.fritzbox.model.homeautomation;
19+
20+
import org.simpleframework.xml.Element;
21+
import org.simpleframework.xml.Root;
22+
23+
@Root(name = "etsiunitinfo")
24+
public class EtsiUnitInfo {
25+
26+
@Element(name = "etsideviceid")
27+
private int etsideviceid;
28+
29+
@Element(name = "unittype")
30+
private int unittype;
31+
32+
@Element(name = "interfaces")
33+
private String interfaces;
34+
35+
public int getEtsideviceid() {
36+
return etsideviceid;
37+
}
38+
39+
public int getUnittype() {
40+
return unittype;
41+
}
42+
43+
public String getInterfaces() {
44+
return interfaces;
45+
}
46+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* A Java API for managing FritzBox HomeAutomation
3+
* Copyright (C) 2017 Christoph Pirkl <christoph at users.sourceforge.net>
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package com.github.kaklakariada.fritzbox.model.homeautomation;
19+
20+
import org.simpleframework.xml.Element;
21+
import org.simpleframework.xml.Root;
22+
23+
@Root(name = "levelcontrol")
24+
public class LevelControl {
25+
26+
@Element(name = "level", required = false)
27+
private int level;
28+
29+
@Element(name = "levelpercentage", required = false)
30+
private int levelpercentage;
31+
32+
public int getLevel() {
33+
return level;
34+
}
35+
36+
public int getLevelpercentage() {
37+
return levelpercentage;
38+
}
39+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
@Root(name = "simpleonoff")
2424
public class SimpleOnOffState {
2525

26-
@Element(name = "state")
26+
@Element(name = "state", required = false)
2727
private int state;
2828

2929
public int getState() {

src/test/java/com/github/kaklakariada/fritzbox/mapping/DeserializerTest.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,29 @@
3030
public class DeserializerTest {
3131

3232
@Test
33-
public void parseDeviceList() throws IOException {
34-
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListPayload.xml")).stream()
33+
public void parseDeviceListFritzDect200() throws IOException {
34+
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListConnectedFritzDect200Payload.xml")).stream()
35+
.collect(joining("\n"));
36+
new Deserializer().parse(fileContent, DeviceList.class);
37+
}
38+
39+
@Test
40+
public void parseDeviceListFritzDect301() throws IOException {
41+
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListConnectedFritzDect200Payload.xml")).stream()
42+
.collect(joining("\n"));
43+
new Deserializer().parse(fileContent, DeviceList.class);
44+
}
45+
46+
@Test
47+
public void parseDeviceListNotConnectedFritzDect500() throws IOException {
48+
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListNotConnectedFritzDect500Payload.xml")).stream()
49+
.collect(joining("\n"));
50+
new Deserializer().parse(fileContent, DeviceList.class);
51+
}
52+
53+
@Test
54+
public void parseDeviceListConnectedFritzDect500() throws IOException {
55+
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListConnectedFritzDect500Payload.xml")).stream()
3556
.collect(joining("\n"));
3657
new Deserializer().parse(fileContent, DeviceList.class);
3758
}

src/test/resources/deviceListPayload.xml renamed to src/test/resources/deviceListConnectedFritzDect200Payload.xml

File renamed without changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<device identifier="09995 0079863" id="20" functionbitmask="320" fwversion="04.94" manufacturer="AVM" productname="FRITZ!DECT 301">
2+
<present>1</present>
3+
<txbusy>0</txbusy>
4+
<name>FRITZ!DECT 301</name>
5+
<battery>100</battery>
6+
<batterylow>0</batterylow>
7+
<temperature>
8+
<celsius>235</celsius>
9+
<offset>0</offset>
10+
</temperature>
11+
<hkr>
12+
<tist>47</tist>
13+
<tsoll>46</tsoll>
14+
<absenk>28</absenk>
15+
<komfort>46</komfort>
16+
<lock>0</lock>
17+
<devicelock>0</devicelock>
18+
<errorcode>0</errorcode>
19+
<windowopenactiv>0</windowopenactiv>
20+
<windowopenactiveendtime>0</windowopenactiveendtime>
21+
<boostactive>0</boostactive>
22+
<boostactiveendtime>0</boostactiveendtime>
23+
<batterylow>0</batterylow>
24+
<battery>100</battery>
25+
<nextchange>
26+
<endperiod>1605643200</endperiod>
27+
<tchange>28</tchange>
28+
</nextchange>
29+
<summeractive>0</summeractive>
30+
<holidayactive>0</holidayactive>
31+
</hkr>
32+
</device>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<devicelist version="1" fwversion="7.21">
2+
<device identifier="00000 0000000-1" id="2000" functionbitmask="237572" fwversion="0.0" manufacturer="AVM" productname="FRITZ!DECT 500">
3+
<present>0</present>
4+
<txbusy>0</txbusy>
5+
<name>FRITZ!DECT 500 power</name>
6+
<simpleonoff>
7+
<state>1</state>
8+
</simpleonoff>
9+
<levelcontrol>
10+
<level>153</level>
11+
<levelpercentage>60</levelpercentage>
12+
</levelcontrol>
13+
<colorcontrol supported_modes="0" current_mode="">
14+
<hue>225</hue>
15+
<saturation>204</saturation>
16+
<temperature>6500</temperature>
17+
</colorcontrol>
18+
<etsiunitinfo>
19+
<etsideviceid>406</etsideviceid>
20+
<unittype>278</unittype>
21+
<interfaces>512,514,513</interfaces>
22+
</etsiunitinfo>
23+
</device>
24+
</devicelist>

0 commit comments

Comments
 (0)