-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from sebcramer/blinds
Changes due to testing out blinds APIs
- Loading branch information
Showing
3 changed files
with
40 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ient-examples/src/main/java/de/dvdgeisler/iot/dirigera/client/examples/blinds/Blinds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package de.dvdgeisler.iot.dirigera.client.examples.blinds; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
|
||
import de.dvdgeisler.iot.dirigera.client.api.DirigeraApi; | ||
import de.dvdgeisler.iot.dirigera.client.examples.redlightdistrict.RedlightDistrict; | ||
import reactor.core.publisher.Flux; | ||
|
||
@SpringBootApplication | ||
@ComponentScan(basePackageClasses = { DirigeraApi.class }) | ||
public class Blinds { | ||
|
||
private final static Logger log = LoggerFactory.getLogger(RedlightDistrict.class); | ||
|
||
@Bean | ||
CommandLineRunner runBlindsHalfWay(final DirigeraApi api) { | ||
return (String... args) -> { | ||
api.device.blinds.all() | ||
.flatMapMany(Flux::fromIterable) | ||
.doOnNext(d -> log.info( | ||
"Found blinds '{}': id={}, blindsCurrentLevel={}, blindsState={}, blindsTargetLevel={}", | ||
d.id, d.attributes.state.customName, d.attributes.state.blindsCurrentLevel, | ||
d.attributes.state.blindsState, d.attributes.state.blindsTargetLevel)) | ||
.flatMap(device -> api.device.blinds.setTargetLevel(device, 50)) | ||
.blockLast(); | ||
}; | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Blinds.class, args).close(); | ||
} | ||
|
||
} |