Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for FRITZ-Dect 500 devices #16

Merged
merged 2 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}

group 'com.github.kaklakariada'
version = '1.1.0'
version = '1.2.0-SNAPSHOT'
sourceCompatibility = 1.8

tasks.withType(JavaCompile) {
Expand Down Expand Up @@ -39,7 +39,7 @@ dependencies {

license {
header = file('gradle/license-header.txt')
exclude('**/deviceListPayload.xml')
exclude('**/deviceList*Payload.xml')
}

task sourceJar(type: Jar) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* A Java API for managing FritzBox HomeAutomation
* Copyright (C) 2017 Christoph Pirkl <christoph at users.sourceforge.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.kaklakariada.fritzbox.model.homeautomation;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

@Root(name = "colorcontrol")
public class ColorControl {
@Element(name = "hue", required = false)
private String hue;

@Element(name = "saturation", required = false)
private String saturation;

@Element(name = "temperature", required = false)
private String temperature;

@Attribute(name = "supported_modes")
private String supportedModes;

@Attribute(name = "current_mode", required = false)
private String current_mode;

public String getHue() {
return hue;
}

public String getSaturation() {
return saturation;
}

public String getTemperature() {
return temperature;
}

public String getSupportedModes() {
return supportedModes;
}

public String getCurrent_mode() {
return current_mode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public class Device {
private Temperature temperature;
@Element(name = "hkr", required = false)
private Hkr hkr;
@Element(name = "levelcontrol", required = false)
private LevelControl levelControl;
@Element(name = "colorcontrol", required = false)
private ColorControl colorControl;
@Element(name = "etsiunitinfo", required = false)
private EtsiUnitInfo etsiUnitInfo;

public String getIdentifier() {
return identifier;
Expand Down Expand Up @@ -126,6 +132,18 @@ public SimpleOnOffState getSimpleOnOff() {
return simpleOnOff;
}

public LevelControl getLevelControl() {
return levelControl;
}

public ColorControl getColorControl() {
return colorControl;
}

public EtsiUnitInfo getEtsiUnitInfo() {
return etsiUnitInfo;
}

@Override
public String toString() {
return "Device [identifier=" + identifier + ", id=" + id + ", functionBitmask=" + functionBitmask
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* A Java API for managing FritzBox HomeAutomation
* Copyright (C) 2017 Christoph Pirkl <christoph at users.sourceforge.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.kaklakariada.fritzbox.model.homeautomation;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

@Root(name = "etsiunitinfo")
public class EtsiUnitInfo {

@Element(name = "etsideviceid")
private int etsideviceid;

@Element(name = "unittype")
private int unittype;

@Element(name = "interfaces")
private String interfaces;

public int getEtsideviceid() {
return etsideviceid;
}

public int getUnittype() {
return unittype;
}

public String getInterfaces() {
return interfaces;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* A Java API for managing FritzBox HomeAutomation
* Copyright (C) 2017 Christoph Pirkl <christoph at users.sourceforge.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.kaklakariada.fritzbox.model.homeautomation;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

@Root(name = "levelcontrol")
public class LevelControl {

@Element(name = "level", required = false)
private int level;

@Element(name = "levelpercentage", required = false)
private int levelpercentage;

public int getLevel() {
return level;
}

public int getLevelpercentage() {
return levelpercentage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@Root(name = "simpleonoff")
public class SimpleOnOffState {

@Element(name = "state")
@Element(name = "state", required = false)
private int state;

public int getState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,29 @@
public class DeserializerTest {

@Test
public void parseDeviceList() throws IOException {
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListPayload.xml")).stream()
public void parseDeviceListFritzDect200() throws IOException {
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListConnectedFritzDect200Payload.xml")).stream()
.collect(joining("\n"));
new Deserializer().parse(fileContent, DeviceList.class);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding tests 👍

}

@Test
public void parseDeviceListFritzDect301() throws IOException {
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListConnectedFritzDect200Payload.xml")).stream()
.collect(joining("\n"));
new Deserializer().parse(fileContent, DeviceList.class);
}

@Test
public void parseDeviceListNotConnectedFritzDect500() throws IOException {
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListNotConnectedFritzDect500Payload.xml")).stream()
.collect(joining("\n"));
new Deserializer().parse(fileContent, DeviceList.class);
}

@Test
public void parseDeviceListConnectedFritzDect500() throws IOException {
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceListConnectedFritzDect500Payload.xml")).stream()
.collect(joining("\n"));
new Deserializer().parse(fileContent, DeviceList.class);
}
Expand Down
32 changes: 32 additions & 0 deletions src/test/resources/deviceListConnectedFritzDect301Payload.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<device identifier="09995 0079863" id="20" functionbitmask="320" fwversion="04.94" manufacturer="AVM" productname="FRITZ!DECT 301">
<present>1</present>
<txbusy>0</txbusy>
<name>FRITZ!DECT 301</name>
<battery>100</battery>
<batterylow>0</batterylow>
<temperature>
<celsius>235</celsius>
<offset>0</offset>
</temperature>
<hkr>
<tist>47</tist>
<tsoll>46</tsoll>
<absenk>28</absenk>
<komfort>46</komfort>
<lock>0</lock>
<devicelock>0</devicelock>
<errorcode>0</errorcode>
<windowopenactiv>0</windowopenactiv>
<windowopenactiveendtime>0</windowopenactiveendtime>
<boostactive>0</boostactive>
<boostactiveendtime>0</boostactiveendtime>
<batterylow>0</batterylow>
<battery>100</battery>
<nextchange>
<endperiod>1605643200</endperiod>
<tchange>28</tchange>
</nextchange>
<summeractive>0</summeractive>
<holidayactive>0</holidayactive>
</hkr>
</device>
24 changes: 24 additions & 0 deletions src/test/resources/deviceListConnectedFritzDect500Payload.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<devicelist version="1" fwversion="7.21">
<device identifier="00000 0000000-1" id="2000" functionbitmask="237572" fwversion="0.0" manufacturer="AVM" productname="FRITZ!DECT 500">
<present>0</present>
<txbusy>0</txbusy>
<name>FRITZ!DECT 500 power</name>
<simpleonoff>
<state>1</state>
</simpleonoff>
<levelcontrol>
<level>153</level>
<levelpercentage>60</levelpercentage>
</levelcontrol>
<colorcontrol supported_modes="0" current_mode="">
<hue>225</hue>
<saturation>204</saturation>
<temperature>6500</temperature>
</colorcontrol>
<etsiunitinfo>
<etsideviceid>406</etsideviceid>
<unittype>278</unittype>
<interfaces>512,514,513</interfaces>
</etsiunitinfo>
</device>
</devicelist>
24 changes: 24 additions & 0 deletions src/test/resources/deviceListNotConnectedFritzDect500Payload.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<devicelist version="1" fwversion="7.21">
<device identifier="00000 0000000-1" id="2000" functionbitmask="237572" fwversion="0.0" manufacturer="AVM" productname="FRITZ!DECT 500">
<present>0</present>
<txbusy>0</txbusy>
<name>FRITZ!DECT 500 without power</name>
<simpleonoff>
<state/>
</simpleonoff>
<levelcontrol>
<level/>
<levelpercentage/>
</levelcontrol>
<colorcontrol supported_modes="0" current_mode="">
<hue/>
<saturation/>
<temperature/>
</colorcontrol>
<etsiunitinfo>
<etsideviceid>406</etsideviceid>
<unittype>278</unittype>
<interfaces>512,514,513</interfaces>
</etsiunitinfo>
</device>
</devicelist>