Skip to content

Commit

Permalink
Use MusicPlaybackState instead SpeakerPlaybackState
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdgeisler committed Nov 28, 2022
1 parent fcd7105 commit 3baf1e3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import de.dvdgeisler.iot.dirigera.client.api.http.ClientApi;
import de.dvdgeisler.iot.dirigera.client.api.model.device.Device;
import de.dvdgeisler.iot.dirigera.client.api.model.device.speaker.*;
import de.dvdgeisler.iot.dirigera.client.api.model.music.MusicPlaybackState;
import reactor.core.publisher.Mono;

import java.util.Optional;

import static de.dvdgeisler.iot.dirigera.client.api.model.device.speaker.SpeakerPlaybackState.*;
import static de.dvdgeisler.iot.dirigera.client.api.model.music.MusicPlaybackState.*;

@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
public class SpeakerDeviceApi extends DefaultDeviceApi<
Expand Down Expand Up @@ -44,7 +45,7 @@ public Mono<SpeakerDevice> setVolume(final SpeakerDevice device, final Integer v
.flatMap(d -> this.setStateAttribute(d, createStateAttribute(Optional.empty(), Optional.of(volume), Optional.empty())));
}

public Mono<SpeakerDevice> setPlayback(final SpeakerDevice device, final SpeakerPlaybackState playbackState) {
public Mono<SpeakerDevice> setPlayback(final SpeakerDevice device, final MusicPlaybackState playbackState) {
return this.assertCapability(device, "playback")
.flatMap(d -> this.setStateAttribute(d, createStateAttribute(Optional.empty(), Optional.empty(), Optional.of(playbackState))));
}
Expand All @@ -65,7 +66,7 @@ public Mono<SpeakerDevice> previous(final SpeakerDevice device) {
return this.setPlayback(device, PREVIOUS);
}

private SpeakerStateAttributes createStateAttribute(final Optional<Boolean> isMuted, final Optional<Integer> volume, final Optional<SpeakerPlaybackState> playback) {
private SpeakerStateAttributes createStateAttribute(final Optional<Boolean> isMuted, final Optional<Integer> volume, final Optional<MusicPlaybackState> playback) {
final SpeakerStateAttributes attributes = new SpeakerStateAttributes();

isMuted.ifPresent(b -> attributes.isMuted = b);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import de.dvdgeisler.iot.dirigera.client.api.model.device.DeviceStateAttributes;
import de.dvdgeisler.iot.dirigera.client.api.model.music.MusicPlaybackState;

import java.time.LocalDateTime;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class SpeakerStateAttributes extends DeviceStateAttributes {
public SpeakerPlaybackState playback;
public MusicPlaybackState playback;
public LocalDateTime playbackLastChangedTimestamp;
public SpeakerAudioAttributes playbackAudio;
public SpeakerPlaybackPosition playbackPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import com.fasterxml.jackson.annotation.JsonProperty;

public enum MusicPlaybackState {
@JsonProperty("idle")
@JsonProperty("playbackIdle")
IDLE,
@JsonProperty("playing")
@JsonProperty("playbackPlaying")
PLAYING,
@JsonProperty("paused")
@JsonProperty("playbackPaused")
PAUSED,
@JsonProperty("next")
@JsonProperty("playbackNext")
NEXT,
@JsonProperty("previous")
@JsonProperty("playbackPrevious")
PREVIOUS,
@JsonProperty("buffering")
@JsonProperty("playbackBuffering")
BUFFERING
}

0 comments on commit 3baf1e3

Please sign in to comment.