[nuvo] Add favorites selection channel and fix a few bugs (#8631)

* Fix issue with All Mute and extra source options
* Add channel to select preset favorite

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
mlobstein 2020-10-01 22:41:58 -05:00 committed by GitHub
parent 003c3af985
commit 4c6d63df38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 26 deletions

View File

@ -70,6 +70,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#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 |
@ -113,6 +114,7 @@ Switch nuvo_z1_power "Power" { channel="nuvo:amplifier:myamp:zone1#power" }
Number nuvo_z1_source "Source Input [%s]" { channel="nuvo:amplifier:myamp:zone1#source" }
Dimmer nuvo_z1_volume "Volume [%d %%]" { channel="nuvo:amplifier:myamp:zone1#volume" }
Switch nuvo_z1_mute "Mute" { channel="nuvo:amplifier:myamp:zone1#mute" }
Number nuvo_z1_favorite "Favorite" { channel="nuvo:amplifier:myamp:zone1#favorite" }
Player nuvo_z1_control "Control" { channel="nuvo:amplifier:myamp:zone1#control" }
Number nuvo_z1_treble "Treble Adjustment [%s]" { channel="nuvo:amplifier:myamp:zone1#treble" }
Number nuvo_z1_bass "Bass Adjustment [%s]" { channel="nuvo:amplifier:myamp:zone1#bass" }
@ -197,6 +199,8 @@ sitemap nuvo label="Audio Control" {
//Volume can be a Setpoint also
Slider item=nuvo_z1_volume minValue=0 maxValue=100 step=1 visibility=[nuvo_z1_power==ON] icon="soundvolume"
Switch item=nuvo_z1_mute visibility=[nuvo_z1_power==ON] icon="soundvolume_mute"
// mappings is optional to override the default dropdown item labels
Selection item=nuvo_z1_favorite visibility=[nuvo_z1_power==ON] icon="player" //mappings=[1="WNYC", 2="BBC One", 2="My Playlist"]
Default item=nuvo_z1_control visibility=[nuvo_z1_power==ON]
Text item=nuvo_s1_display_line1 visibility=[nuvo_z1_source=="1"] icon="zoom"
@ -253,13 +257,15 @@ sitemap nuvo label="Audio Control" {
Text item=nuvo_s6_track_position visibility=[nuvo_z1_source=="6"]
Text item=nuvo_s6_button_press visibility=[nuvo_z1_source=="6"] icon="none"
Setpoint item=nuvo_z1_treble label="Treble Adjustment [%d]" minValue=-18 maxValue=18 step=2 visibility=[nuvo_z1_power==ON]
Setpoint item=nuvo_z1_bass label="Bass Adjustment [%d]" minValue=-18 maxValue=18 step=2 visibility=[nuvo_z1_power==ON]
Setpoint item=nuvo_z1_balance label="Balance Adjustment [%d]" minValue=-18 maxValue=18 step=2 visibility=[nuvo_z1_power==ON]
Switch item=nuvo_z1_loudness visibility=[nuvo_z1_power==ON]
Switch item=nuvo_z1_dnd visibility=[nuvo_z1_power==ON]
Text item=nuvo_z1_lock label="Zone Locked: [%s]" icon="lock"
Switch item=nuvo_z1_party visibility=[nuvo_z1_power==ON]
Text label="Advanced" icon="settings" visibility=[nuvo_z1_power==ON] {
Setpoint item=nuvo_z1_treble label="Treble Adjustment [%d]" minValue=-18 maxValue=18 step=2
Setpoint item=nuvo_z1_bass label="Bass Adjustment [%d]" minValue=-18 maxValue=18 step=2
Setpoint item=nuvo_z1_balance label="Balance Adjustment [%d]" minValue=-18 maxValue=18 step=2
Switch item=nuvo_z1_loudness
Switch item=nuvo_z1_dnd
Switch item=nuvo_z1_party
}
Text item=nuvo_z1_lock label="Zone Locked: [%s]" icon="lock" visibility=[nuvo_z1_lock=="1"]
}
//repeat for zones 2-20 (substitute z1)
@ -294,9 +300,6 @@ then
// Send a message to Zone 11
//actions.sendNuvoCommand("Z11MSG\"Hello World\",0,0")
// Select a Favorite (1-12) for Zone 2
//actions.sendNuvoCommand("Z2FAV1")
end
// In the below examples, a method for maintaing Metadata information

View File

@ -39,6 +39,7 @@ public class NuvoBindingConstants {
// zone
public static final String CHANNEL_TYPE_POWER = "power";
public static final String CHANNEL_TYPE_SOURCE = "source";
public static final String CHANNEL_TYPE_FAVORITE = "favorite";
public static final String CHANNEL_TYPE_VOLUME = "volume";
public static final String CHANNEL_TYPE_MUTE = "mute";
public static final String CHANNEL_TYPE_CONTROL = "control";

View File

@ -40,6 +40,7 @@ public enum NuvoCommand {
ON("ON"),
OFF("OFF"),
SOURCE("SRC"),
FAVORITE("FAV"),
VOLUME("VOL"),
MUTE_ON("MUTEON"),
MUTE_OFF("MUTEOFF"),

View File

@ -23,6 +23,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
@ -98,6 +99,7 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
private static final int MAX_ZONES = 20;
private static final int MAX_SRC = 6;
private static final int MAX_FAV = 12;
private static final int MIN_VOLUME = 0;
private static final int MAX_VOLUME = 79;
private static final int MIN_EQ = -18;
@ -129,8 +131,8 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
Set<Integer> activeZones = new HashSet<>(1);
// A state option list for the source labels
List<StateOption> sourceLabels = new ArrayList<>();
// A tree map that maps the source ids to source labels
TreeMap<String, String> sourceLabels = new TreeMap<String, String>();
/**
* Constructor
@ -274,6 +276,15 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
}
}
break;
case CHANNEL_TYPE_FAVORITE:
if (command instanceof DecimalType) {
int value = ((DecimalType) command).intValue();
if (value >= 1 && value <= MAX_FAV) {
logger.debug("Got favorite command {} zone {}", value, target);
connector.sendCommand(target, NuvoCommand.FAVORITE, String.valueOf(value));
}
}
break;
case CHANNEL_TYPE_VOLUME:
if (command instanceof PercentType) {
int value = (MAX_VOLUME
@ -373,14 +384,13 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
break;
case CHANNEL_TYPE_ALLMUTE:
if (command instanceof OnOffType) {
connector.sendCommand(target,
connector.sendCommand(
command == OnOffType.ON ? NuvoCommand.ALLMUTE_ON : NuvoCommand.ALLMUTE_OFF);
}
break;
case CHANNEL_TYPE_PAGE:
if (command instanceof OnOffType) {
connector.sendCommand(target,
command == OnOffType.ON ? NuvoCommand.PAGE_ON : NuvoCommand.PAGE_OFF);
connector.sendCommand(command == OnOffType.ON ? NuvoCommand.PAGE_ON : NuvoCommand.PAGE_OFF);
}
break;
}
@ -484,10 +494,10 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
} else {
logger.debug("no match on message: {}", updateData);
}
} else if (updateData.contains(NAME_QUOTE) && sourceLabels.size() <= MAX_SRC) {
} else if (updateData.contains(NAME_QUOTE)) {
// example: NAME"Ipod"
String name = updateData.split("\"")[1];
sourceLabels.add(new StateOption(key, name));
sourceLabels.put(key, name);
}
break;
case TYPE_ZONE_UPDATE:
@ -594,11 +604,16 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
if (prevUpdateTime == lastEventReceived) {
error = "Controller not responding to status requests";
} else {
List<StateOption> sourceStateOptions = new ArrayList<>();
sourceLabels.keySet().forEach(key -> {
sourceStateOptions.add(new StateOption(key, sourceLabels.get(key)));
});
// Put the source labels on all active zones
activeZones.forEach(zoneNum -> {
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(),
ZONE.toLowerCase() + zoneNum + CHANNEL_DELIMIT + CHANNEL_TYPE_SOURCE),
sourceLabels);
sourceStateOptions);
});
}
} catch (NuvoException e) {

View File

@ -6,7 +6,7 @@
<!-- Nuvo Whole House Amplifier Thing -->
<thing-type id="amplifier">
<label>Whole House Amplifier</label>
<label>Nuvo Whole House Amplifier</label>
<description>
A Multi-zone Whole House Amplifier System
</description>
@ -96,27 +96,27 @@
<label>Zone 20</label>
<description>The Controls for Zone 20</description>
</channel-group>
<channel-group id="source1" typeId="source">
<channel-group id="source1" typeId="source_info">
<label>Source 1</label>
<description>The Display Information for Source 1</description>
</channel-group>
<channel-group id="source2" typeId="source">
<channel-group id="source2" typeId="source_info">
<label>Source 2</label>
<description>The Display Information for Source 2</description>
</channel-group>
<channel-group id="source3" typeId="source">
<channel-group id="source3" typeId="source_info">
<label>Source 3</label>
<description>The Display Information for Source 3</description>
</channel-group>
<channel-group id="source4" typeId="source">
<channel-group id="source4" typeId="source_info">
<label>Source 4</label>
<description>The Display Information for Source 4</description>
</channel-group>
<channel-group id="source5" typeId="source">
<channel-group id="source5" typeId="source_info">
<label>Source 5</label>
<description>The Display Information for Source 5</description>
</channel-group>
<channel-group id="source6" typeId="source">
<channel-group id="source6" typeId="source_info">
<label>Source 6</label>
<description>The Display Information for Source 6</description>
</channel-group>
@ -169,6 +169,7 @@
<channels>
<channel id="power" typeId="system.power"/>
<channel id="source" typeId="source"/>
<channel id="favorite" typeId="favorite"/>
<channel id="volume" typeId="system.volume"/>
<channel id="mute" typeId="system.mute"/>
<channel id="control" typeId="control"/>
@ -182,7 +183,7 @@
</channels>
</channel-group-type>
<channel-group-type id="source">
<channel-group-type id="source_info">
<label>Source Info</label>
<description>The Display Information for the Source</description>
<channels>
@ -215,6 +216,28 @@
<description>Select the Source Input for the Zone</description>
</channel-type>
<channel-type id="favorite">
<item-type>Number</item-type>
<label>Favorite</label>
<description>Select a Preset Favorite for the Zone</description>
<state>
<options>
<option value="1">Favorite 1</option>
<option value="2">Favorite 2</option>
<option value="3">Favorite 3</option>
<option value="4">Favorite 4</option>
<option value="5">Favorite 5</option>
<option value="6">Favorite 6</option>
<option value="7">Favorite 7</option>
<option value="8">Favorite 8</option>
<option value="9">Favorite 9</option>
<option value="10">Favorite 10</option>
<option value="11">Favorite 11</option>
<option value="12">Favorite 12</option>
</options>
</state>
</channel-type>
<channel-type id="control">
<item-type>Player</item-type>
<label>Control</label>