Skip to content

Commit

Permalink
Merge pull request #94 from sebcramer/blinds
Browse files Browse the repository at this point in the history
Changes due to testing out blinds APIs
  • Loading branch information
TheMrBooyah committed Aug 1, 2023
2 parents 6fc27df + 4cafd1f commit 3120b2f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ barely tested, and some are known as inoperable.
| Light | <span style="color:green"> **&check;**</span> | <span style="color:green"> **&check;**</span> | <ul><li>STOFTMOLN ceiling/wall lamp WW24</li><li>FLOALT panel WS 60x60</li><li>TRADFRI bulb E27 CWS 806lm</li><li>TRADFRI bulb E27 CWS opal 600lm</li><li>TRADFRI bulb E27 WS opal 980lm</li><li>TRADFRI bulb E27 WS opal 1000lm</li><li>TRADFRI bulb E27 WS globe opal 1055lm</li><li>TRADFRI bulb T120 E27 WS opal 470lm</li><li>TRADFRI bulb E14 WS opal 400lm</li><li>TRADFRI bulb GU10 WS 400lm</li><li>TRADFRI bulb GU10 WS 345lm</li><li>TRADFRI Driver 10W</li><li>TRADFRI Driver 30W</li><li>GUNNARP panel round</li><li>LWA017 (Signify Netherlands B.V.)</li></ul> |
| Outlet | <span style="color:green"> **&check;**</span> | <span style="color:green"> **&check;**</span> | <ul><li>ASKVADER on/off switch</li><li>TRADFRI control outlet</li><li>Aqara Smart Plug (lumi.plug.maeu01)</li></ul> |
| Air Purifier | <span style="color:orange">**?** </span> | <span style="color:red"> **X** </span> | <ul><li>STARKVIND Air purifier</li></ul> |
| Blinds | <span style="color:orange">**?** </span> | <span style="color:orange">**?** </span> | <ul><li>PRAKTLYSING cellular blind</li></ul> |
| Blinds | <span style="color:orange">**&check;** </span> | <span style="color:orange">**?** </span> | <ul><li>PRAKTLYSING cellular blind</li><li>FYRTUR black-out roller blind</li></ul> |
| Light-Controller | <span style="color:green"> **&check;**</span> | <span style="color:red"> **X** </span> | <ul><li>Remote Control N2</li><li>TRADFRI on/off switch</li><li>TRADFRI remote control</li><li>LEPTITER Recessed spot light</li><li>TRADFRI wireless dimmer</li></ul> |
| Blinds-Controller | <span style="color:green"> **&check;**</span> | <span style="color:red"> **X** </span> | <ul><li>TRADFRI open/close remote</li></ul> |
| Sound-Controller | <span style="color:orange">**?** </span> | <span style="color:red"> **X** </span> | <ul><li>SYMFONISK Sound Controller</li></ul> |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@ public Mono<BlindsDevice> setTargetLevel(final BlindsDevice device, final Intege
.flatMap(d -> this.setStateAttribute(d, attributes));
}

public Mono<BlindsDevice> setCurrentLevel(final BlindsDevice device, final Integer currentLevel) {
final BlindsStateAttributes attributes;

if (currentLevel < 0 || currentLevel > 100)
return Mono.error(new IllegalArgumentException("Target level must be between 0 and 100"));

attributes = new BlindsStateAttributes();
attributes.blindsCurrentLevel = currentLevel;

return this.assertCapability(device, "blindsCurrentLevel")
.flatMap(d -> this.setStateAttribute(d, attributes));
}

public Mono<BlindsDevice> setState(final BlindsDevice device, final BlindsState state) {
final BlindsStateAttributes attributes;

Expand Down
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();
}

}

0 comments on commit 3120b2f

Please sign in to comment.