Difference between revisions of "Fritzbox-java-api"
Jump to navigation
Jump to search
Line 12: | Line 12: | ||
When the application properties are set more tests are run. E.g. one test should show "Logged in with session id ..." | When the application properties are set more tests are run. E.g. one test should show "Logged in with session id ..." | ||
+ | = Code Example = | ||
+ | see https://github.com/WolfgangFahl/fritzbox-java-api/blob/master/src/main/java/com/github/kaklakariada/fritzbox/TestDriver.java | ||
+ | <source lang='java'> | ||
+ | final Config config = ConfigService.readConfig(); | ||
+ | |||
+ | LOG.info("Logging in to '{}' with username '{}'", config.baseUrl, | ||
+ | config.username); | ||
+ | final HomeAutomation homeAutomation = HomeAutomation.connect(config); | ||
+ | |||
+ | final DeviceList devices = homeAutomation.getDeviceListInfos(); | ||
+ | LOG.info("Found {} devices", devices.getDevices().size()); | ||
+ | for (final Device device : devices.getDevices()) { | ||
+ | LOG.info("\t{}", device); | ||
+ | } | ||
+ | |||
+ | final List<String> ids = homeAutomation.getSwitchList(); | ||
+ | LOG.info("Found {} device ids: {}", ids.size(), ids); | ||
+ | |||
+ | if (devices.getDevices().isEmpty()) { | ||
+ | homeAutomation.logout(); | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | for (final String ain : ids) { | ||
+ | testHomeAutomation(homeAutomation, ain); | ||
+ | // testEnergyStats(homeAutomation.getSession(), ain); | ||
+ | } | ||
+ | </source> | ||
= Configuration File = | = Configuration File = | ||
You might want to set your application properties in $HOME/.fritzbox/application.properties | You might want to set your application properties in $HOME/.fritzbox/application.properties |
Revision as of 10:28, 26 October 2017
- https://github.com/WolfgangFahl/fritzbox-java-api is a fork of
- https://github.com/kaklakariada/fritzbox-java-api
Unit tests
The unit tests can be run with:
mvn test
If you did not setup your configuration file yet there will be a warning: You might want to set your application properties in $HOME.fritzbox/application.properties When the application properties are set more tests are run. E.g. one test should show "Logged in with session id ..."
Code Example
final Config config = ConfigService.readConfig();
LOG.info("Logging in to '{}' with username '{}'", config.baseUrl,
config.username);
final HomeAutomation homeAutomation = HomeAutomation.connect(config);
final DeviceList devices = homeAutomation.getDeviceListInfos();
LOG.info("Found {} devices", devices.getDevices().size());
for (final Device device : devices.getDevices()) {
LOG.info("\t{}", device);
}
final List<String> ids = homeAutomation.getSwitchList();
LOG.info("Found {} device ids: {}", ids.size(), ids);
if (devices.getDevices().isEmpty()) {
homeAutomation.logout();
return;
}
for (final String ain : ids) {
testHomeAutomation(homeAutomation, ain);
// testEnergyStats(homeAutomation.getSession(), ain);
}
Configuration File
You might want to set your application properties in $HOME/.fritzbox/application.properties
fritzbox.url=http://fritz.box:443
fritzbox.username=user
fritzbox.password=secret