Skip to content

Commit

Permalink
[nuvo] Include NuvoNet source favorites in zone favorite channel (#…
Browse files Browse the repository at this point in the history
…15292)

* Include NuvoNet source favorites in zone `favorite` channel
* Use existing constants
* VALID_SOURCES to enum list

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
  • Loading branch information
mlobstein authored Jul 24, 2023
1 parent 4c9f207 commit 51f3bf6
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 208 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.nuvo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The following channels are available:
| zoneN#source (where N= 1-20) | Number | Select the source input for a zone (1-6) |
| zoneN#volume (where N= 1-20) | Dimmer | Control the volume for a zone (0-100%) [translates to 0-79] |
| zoneN#mute (where N= 1-20) | Switch | Mute or unmute a zone |
| zoneN#favorite (where N= 1-20) | Number | Select a preset Favorite for a zone (1-12) |
| zoneN#favorite (where N= 1-20) | Number | Select a preset Favorite for a zone (1-12). Also will display and can select any favorite specified in openHAB NuvoNet sources |
| zoneN#control (where N= 1-20) | Player | Simulate pressing the transport control buttons on the keypad e.g. play/pause/next/previous |
| zoneN#treble (where N= 1-20) | Number | Adjust the treble control for a zone (-18 to 18 [in increments of 2]) -18=none, 0=flat, 18=full |
| zoneN#bass (where N= 1-20) | Number | Adjust the bass control for a zone (-18 to 18 [in increments of 2]) -18=none, 0=flat, 18=full |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ public class NuvoBindingConstants {
public static final String TYPE_RESTART = "RESTART";
public static final String DISABLE = "disable";
public static final String ALBUM_ART_ID = "albumartid";
public static final String SRC_KEY = "S";
public static final String ZONE_KEY = "Z";
public static final String ALBUM_ART_AVAILABLE = "ALBUMARTAVAILABLE";
public static final String ALBUM_ART_FRAG = "ALBUMARTFRAG";
public static final String HTTP = "http://";
public static final String HTTPS = "https://";
public static final String PLAY_MUSIC_PRESET = "PLAY_MUSIC_PRESET:";
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.eclipse.jdt.annotation.NonNullByDefault;

Expand All @@ -25,44 +24,46 @@
*/
@NonNullByDefault
public enum NuvoEnum {
SYSTEM("SYSTEM", "SYSTEM"),
ZONE1("Z1", "ZCFG1"),
ZONE2("Z2", "ZCFG2"),
ZONE3("Z3", "ZCFG3"),
ZONE4("Z4", "ZCFG4"),
ZONE5("Z5", "ZCFG5"),
ZONE6("Z6", "ZCFG6"),
ZONE7("Z7", "ZCFG7"),
ZONE8("Z8", "ZCFG8"),
ZONE9("Z9", "ZCFG9"),
ZONE10("Z10", "ZCFG10"),
ZONE11("Z11", "ZCFG11"),
ZONE12("Z12", "ZCFG12"),
ZONE13("Z13", "ZCFG13"),
ZONE14("Z14", "ZCFG14"),
ZONE15("Z15", "ZCFG15"),
ZONE16("Z16", "ZCFG16"),
ZONE17("Z17", "ZCFG17"),
ZONE18("Z18", "ZCFG18"),
ZONE19("Z19", "ZCFG19"),
ZONE20("Z20", "ZCFG20"),
SOURCE1("S1", "SCFG1"),
SOURCE2("S2", "SCFG2"),
SOURCE3("S3", "SCFG3"),
SOURCE4("S4", "SCFG4"),
SOURCE5("S5", "SCFG5"),
SOURCE6("S6", "SCFG6");
SYSTEM("SYSTEM", "SYSTEM", 0),
ZONE1("Z1", "ZCFG1", 1),
ZONE2("Z2", "ZCFG2", 2),
ZONE3("Z3", "ZCFG3", 3),
ZONE4("Z4", "ZCFG4", 4),
ZONE5("Z5", "ZCFG5", 5),
ZONE6("Z6", "ZCFG6", 6),
ZONE7("Z7", "ZCFG7", 7),
ZONE8("Z8", "ZCFG8", 8),
ZONE9("Z9", "ZCFG9", 9),
ZONE10("Z10", "ZCFG10", 10),
ZONE11("Z11", "ZCFG11", 11),
ZONE12("Z12", "ZCFG12", 12),
ZONE13("Z13", "ZCFG13", 13),
ZONE14("Z14", "ZCFG14", 14),
ZONE15("Z15", "ZCFG15", 15),
ZONE16("Z16", "ZCFG16", 16),
ZONE17("Z17", "ZCFG17", 17),
ZONE18("Z18", "ZCFG18", 18),
ZONE19("Z19", "ZCFG19", 19),
ZONE20("Z20", "ZCFG20", 20),
SOURCE1("S1", "SCFG1", 1),
SOURCE2("S2", "SCFG2", 2),
SOURCE3("S3", "SCFG3", 3),
SOURCE4("S4", "SCFG4", 4),
SOURCE5("S5", "SCFG5", 5),
SOURCE6("S6", "SCFG6", 6);

private final String id;
private final String cfgId;
private final int num;

// make a list of all valid source ids
public static final List<String> VALID_SOURCES = Arrays.stream(values()).map(NuvoEnum::name)
.filter(s -> s.contains("SOURCE")).collect(Collectors.toList());
// make a list of all valid source enums
public static final List<NuvoEnum> VALID_SOURCES = Arrays.stream(values()).filter(s -> s.name().contains("SOURCE"))
.toList();

NuvoEnum(String id, String cfgId) {
NuvoEnum(String id, String cfgId, int num) {
this.id = id;
this.cfgId = cfgId;
this.num = num;
}

/**
Expand All @@ -82,4 +83,13 @@ public String getId() {
public String getConfigId() {
return cfgId;
}

/**
* Get the num
*
* @return the num
*/
public int getNum() {
return num;
}
}
Loading

0 comments on commit 51f3bf6

Please sign in to comment.