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

Update to Firmware 7.25 #18

Merged
merged 11 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repositories {
}

group 'com.github.kaklakariada'
version = '1.3.0'
version = '1.4.0'

java {
toolchain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public class SessionInfo {
@ElementList(name = "Rights", inline = false, required = false)
private List<UserRight> rights;

@ElementList(name = "Users", inline = false, required = false)
private List<User> users;

public String getSid() {
return sid;
}
Expand All @@ -54,6 +57,10 @@ public List<UserRight> getRights() {
return rights;
}

public List<User> getUsers() {
return users;
}

@Override
public String toString() {
return "SessionInfo [sid=" + sid + ", challenge=" + challenge + ", blockTime=" + blockTime + ", rights="
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/com/github/kaklakariada/fritzbox/model/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* 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;

import org.simpleframework.xml.Attribute;

public class User {
kaklakariada marked this conversation as resolved.
Show resolved Hide resolved

@Attribute(name = "last", required = false)
public boolean last;

public boolean isLast() {
Copy link
Owner

Choose a reason for hiding this comment

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

Sorry for nit-picking. But if this returns an int, we should rename the getter.

Suggested change
public boolean isLast() {
public boolean getLast() {

Copy link
Contributor Author

@SmokingDevices SmokingDevices Feb 28, 2021

Choose a reason for hiding this comment

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

According to the documentation (Page 2: "Bedeutung der Werte:") this should indicate the last user which then (from my point of view) is a boolean.

My poor XML skills didn't bring me to a solution where i could mark the field to be a boolean and the xml annotation would do the translation from 1 to true.

Copy link
Owner

Choose a reason for hiding this comment

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

👍

return last;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ public class ColorControl {
@Attribute(name = "current_mode", required = false)
private String current_mode;

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

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

@Element(name = "unmapped_hue", required = false)
private String unmapped_hue;
kaklakariada marked this conversation as resolved.
Show resolved Hide resolved

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

public String getHue() {
return hue;
}
Expand All @@ -57,4 +69,20 @@ public String getSupportedModes() {
public String getCurrent_mode() {
return current_mode;
}

public String getFullcolorsupport() {
return fullcolorsupport;
}

public String getMapped() {
return mapped;
}

public String getUnmapped_hue() {
return unmapped_hue;
}

public String getUnmapped_saturation() {
return unmapped_saturation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public class Device {
private EtsiUnitInfo etsiUnitInfo;
@ElementList(name = "buttons", required = false, inline = true)
private List<Button> buttons;
@Element(name = "humidity", required = false)
private Humidity humidity;

public String getIdentifier() {
return identifier;
Expand Down Expand Up @@ -149,6 +151,22 @@ public List<Button> getButtons() {
return buttons;
}

public String getPresent() {
return present;
}

public String getTxbusy() {
return txbusy;
}

public Integer getBatterylow() {
return batterylow;
}

public Humidity getHumidity() {
return humidity;
}

@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,32 @@
/**
* 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 = "humidity")
public class Humidity {

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

public int getRelHumidity() {
return relHumidity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.junit.Test;

import com.github.kaklakariada.fritzbox.model.SessionInfo;
import com.github.kaklakariada.fritzbox.model.homeautomation.DeviceList;

public class DeserializerTest {
Expand Down Expand Up @@ -78,4 +79,17 @@ public void parseDeviceListAllTogether() throws IOException {
new Deserializer().parse(fileContent, DeviceList.class);
}

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

@Test
public void parseSessionInfo() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

[Minor] With my from today PR I just introduced assertJ into the project. Maybe you want to have a look at those Assertion classes which allow fluent-API assertions. BR, Peter.

Copy link
Contributor Author

@SmokingDevices SmokingDevices Feb 28, 2021

Choose a reason for hiding this comment

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

Will have a look, but as rebase is not my favourite git command, i would update these tests with my next contribution.

Copy link
Owner

Choose a reason for hiding this comment

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

Rebasing ist not required. I also don't use it ;)

final String fileContent = Files.readAllLines(Paths.get("src/test/resources/sessionInfo.xml")).stream()
.collect(joining("\n"));
new Deserializer().parse(fileContent, SessionInfo.class);
}
}
Loading