public static final String LISTENING_MODE_CHANNEL = "listeningMode";
public static final String PLAYING_LISTENING_MODE_CHANNEL = "playingListeningMode";
public static final String DISPLAY_INFORMATION_CHANNEL = "displayInformation#displayInformation";
+ public static final String MCACC_MEMORY_CHANNEL = "MCACCMemory#MCACCMemory";
public static final String GROUP_CHANNEL_PATTERN = "zone%s#%s";
public static final Pattern GROUP_CHANNEL_ZONE_PATTERN = Pattern.compile("zone([0-4])#.*");
connection.sendMuteQuery(zone);
connection.sendInputSourceQuery(zone);
connection.sendListeningModeQuery(zone);
+
+ // Channels which are not bound to any specific zone
+ connection.sendMCACCMemoryQuery();
}
/**
updateState(getChannelUID(PioneerAvrBindingConstants.SET_INPUT_SOURCE_CHANNEL, zone), UnDefType.UNDEF);
updateState(getChannelUID(PioneerAvrBindingConstants.LISTENING_MODE_CHANNEL, zone), UnDefType.UNDEF);
updateState(getChannelUID(PioneerAvrBindingConstants.PLAYING_LISTENING_MODE_CHANNEL, zone), UnDefType.UNDEF);
+
+ // Channels which are not bound to any specific zone
+ if (zone == 1) {
+ updateState(PioneerAvrBindingConstants.MCACC_MEMORY_CHANNEL, UnDefType.UNDEF);
+ }
}
/**
} else {
commandSent = connection.sendMuteCommand(command, getZoneFromChannelUID(channelUID.getId()));
}
+ } else if (channelUID.getId().contains(PioneerAvrBindingConstants.MCACC_MEMORY_CHANNEL)) {
+ if (command == RefreshType.REFRESH) {
+ commandSent = connection.sendMCACCMemoryQuery();
+ } else {
+ commandSent = connection.sendMCACCMemoryCommand(command);
+ }
} else {
unknownCommand = true;
}
manageDisplayedInformationUpdate(response);
break;
+ case MCACC_MEMORY:
+ manageMCACCMemoryUpdate(response);
+ break;
+
default:
logger.debug("Unknown response type from AVR @{}. Response discarded: {}", event.getData(),
event.getConnection());
new StringType(DisplayInformationConverter.convertMessageFromIpControl(response.getParameterValue())));
}
+ /**
+ * Notify an AVR MCACC Memory update to openHAB
+ *
+ * @param response
+ */
+ private void manageMCACCMemoryUpdate(AvrResponse response) {
+ updateState(PioneerAvrBindingConstants.MCACC_MEMORY_CHANNEL, new StringType(response.getParameterValue()));
+ }
+
/**
* Build the channelUID from the channel name and the zone number.
*
VOLUME_SET("[0-9]{2,3}", "VL", "ZV", "YV", "HZV"),
INPUT_CHANNEL_SET("[0-9]{2}", "FN", "ZS", "ZT", "ZEA"),
- LISTENING_MODE_SET("[0-9]{4}", "SR");
+ LISTENING_MODE_SET("[0-9]{4}", "SR"),
+ MCACC_MEMORY_SET("[1-6]{1}", "MC");
private String[] zoneCommands;
private String parameterPattern;
this.parameterPattern = parameterPattern;
}
+ @Override
+ public String getCommand() {
+ return zoneCommands[0];
+ }
+
@Override
public String getCommand(int zone) {
return zoneCommands[zone - 1];
private String parameterPattern;
+ protected ParameterizedCommand(ParameterizedCommandType command) {
+ this(command, 0);
+ }
+
protected ParameterizedCommand(ParameterizedCommandType command, int zone) {
super(command, zone);
this.parameterPattern = command.getParameterPattern();
return new IpAvrConnection(host, port);
}
+ /**
+ * Return a SimpleCommand of the type given in parameter.
+ *
+ * @param command
+ * @return
+ */
+ public static SimpleCommand getIpControlCommand(SimpleCommandType command) {
+ SimpleCommand result = new SimpleCommand(command);
+ return result;
+ }
+
/**
* Return a ParameterizedCommand of the type given in parameter and for the given zone.
*
return result;
}
+ /**
+ * Return a ParameterizedCommand of the type given in parameter. The
+ * parameter of the command has to be set before send.
+ *
+ * @param command
+ * @return
+ */
+ public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command) {
+ ParameterizedCommand result = new ParameterizedCommand(command);
+ return result;
+ }
+
/**
* Return a ParameterizedCommand of the type given in parameter. The
* parameter of the command has to be set before send.
/**
* Return a ParameterizedCommand of the type given in parameter. The
- * parameter of the command is set with the given paramter value.
+ * parameter of the command is set with the given parameter value.
+ *
+ * @param command
+ * @param parameter
+ * @param zone
+ * @return
+ */
+ public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, String parameter) {
+ ParameterizedCommand result = getIpControlCommand(command);
+ result.setParameter(parameter);
+ return result;
+ }
+
+ /**
+ * Return a ParameterizedCommand of the type given in parameter. The
+ * parameter of the command is set with the given parameter value.
*
* @param command
* @param parameter
INPUT_SOURCE_CHANNEL("[0-9]{2}", "FN", "Z2F", "Z3F", "ZEA"),
LISTENING_MODE("[0-9]{4}", "SR"),
PLAYING_LISTENING_MODE("[0-9a-f]{4}", "LM"),
- DISPLAY_INFORMATION("[0-9a-fA-F]{30}", "FL");
+ DISPLAY_INFORMATION("[0-9a-fA-F]{30}", "FL"),
+ MCACC_MEMORY("[1-6]{1}", "MC");
private String[] responsePrefixZone;
INPUT_CHANGE_REVERSE("FD"),
LISTENING_MODE_CHANGE_CYCLIC("0010SR"),
LISTENING_MODE_QUERY("?S"),
- INPUT_QUERY("?F", "?ZS", "?ZT", "?ZEA");
+ INPUT_QUERY("?F", "?ZS", "?ZT", "?ZEA"),
+ MCACC_MEMORY_CHANGE_CYCLIC("0MC"),
+ MCACC_MEMORY_QUERY("?MC");
private String zoneCommands[];
this.zoneCommands = command;
}
+ @Override
+ public String getCommand() {
+ return zoneCommands[0];
+ }
+
@Override
public String getCommand(int zone) {
return zoneCommands[zone - 1];
this.zone = zone;
}
+ public SimpleCommand(CommandType commandType) {
+ this(commandType, 0);
+ }
+
@Override
public String getCommand() {
+ if (zone == 0) {
+ return commandType.getCommand() + "\r";
+ }
return commandType.getCommand(zone) + "\r";
}
return sendCommand(RequestResponseFactory.getIpControlCommand(SimpleCommandType.LISTENING_MODE_QUERY, zone));
}
+ @Override
+ public boolean sendMCACCMemoryQuery() {
+ return sendCommand(RequestResponseFactory.getIpControlCommand(SimpleCommandType.MCACC_MEMORY_QUERY));
+ }
+
@Override
public boolean sendPowerCommand(Command command, int zone) throws CommandTypeNotSupportedException {
AvrCommand commandToSend = null;
return sendCommand(commandToSend);
}
+ @Override
+ public boolean sendMCACCMemoryCommand(Command command) throws CommandTypeNotSupportedException {
+ AvrCommand commandToSend = null;
+
+ if (command == IncreaseDecreaseType.INCREASE) {
+ commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.MCACC_MEMORY_CHANGE_CYCLIC);
+ } else if (command instanceof StringType) {
+ String MCACCMemoryValue = ((StringType) command).toString();
+ commandToSend = RequestResponseFactory.getIpControlCommand(ParameterizedCommandType.MCACC_MEMORY_SET)
+ .setParameter(MCACCMemoryValue);
+ } else {
+ throw new CommandTypeNotSupportedException("Command type not supported.");
+ }
+
+ return sendCommand(commandToSend);
+ }
+
/**
* Read incoming data from the AVR and notify listeners for dataReceived and disconnection.
*
* Represent a CommandType of command requests
*/
public interface CommandType {
+ /**
+ * Return the command of this command type.
+ *
+ * @return
+ */
+ public String getCommand();
/**
* Return the command of this command type for the given zone.
*/
public boolean sendListeningModeQuery(int zone);
+ /**
+ * Send an MCACC Memory query to the AVR
+ *
+ * @return
+ */
+ public boolean sendMCACCMemoryQuery();
+
/**
* Send a power command ot the AVR based on the openHAB command
*
*/
public boolean sendMuteCommand(Command command, int zone) throws CommandTypeNotSupportedException;
+ /**
+ * Send an MCACC Memory selection command to the AVR based on the openHAB command
+ *
+ * @param command
+ * @param zone
+ * @return
+ */
+ public boolean sendMCACCMemoryCommand(Command command) throws CommandTypeNotSupportedException;
+
/**
* Return the connection name
*
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="zoneControls" id="zone1">
<label>Zone 1</label>
</channel-group>
<description>Control a 2014 Pioneer AVR (SC-LX87, SC-LX77, SC-LX57, SC-2023, SC-1223, VSX-1123, VSX-923) over IP </description>
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="controls2014" id="zone1">
<label>Zone 1</label>
</channel-group>
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="controls2015" id="zone1">
<label>Zone 1</label>
</channel-group>
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="controls2016" id="zone1">
<label>Zone 1</label>
</channel-group>
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="controls2017" id="zone1">
<label>Zone 1</label>
</channel-group>
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="controls2018" id="zone1">
<label>Zone 1</label>
</channel-group>
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="controls2019" id="zone1">
<label>Zone 1</label>
</channel-group>
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="controls2020" id="zone1">
<label>Zone 1</label>
</channel-group>
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="zoneControls" id="zone1"/>
<channel-group typeId="zoneControls" id="zone2"/>
<channel-group typeId="zoneControls" id="zone3"/>
<channel-groups>
<channel-group typeId="displayInformationGroup" id="displayInformation"/>
+ <channel-group typeId="MCACCMemoryGroup" id="MCACCMemory"/>
<channel-group typeId="zone1Controls" id="zone1"/>
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="zone3Controls" id="zone3"/>
</channels>
</channel-group-type>
+ <channel-group-type id="MCACCMemoryGroup">
+ <label>MCACC Memory</label>
+ <channels>
+ <channel id="MCACCMemory" typeId="setMCACCMemoryChannel"/>
+ </channels>
+ </channel-group-type>
+
<channel-group-type id="zoneControls">
<label>Zone Controls</label>
<channels>
<label>Volume</label>
<description>Set the volume level (dB)</description>
<category>SoundVolume</category>
- <state min="-80" max="12" step="0.5" pattern="%.1f dB"/>
+ <state min="-80" max="12" step="0.5" pattern="%.1f dB"></state>
</channel-type>
<channel-type id="muteChannel">
<state readOnly="true"/>
</channel-type>
+ <channel-type id="setMCACCMemoryChannel">
+ <item-type>String</item-type>
+ <label>MCACC Memory</label>
+ <description>Set the MCACC Memory profile</description>
+ <state>
+ <options>
+ <option value="0000">MCACC MEMORY (cyclic)</option>
+ <option value="0001">MEMORY 1</option>
+ <option value="0002">MEMORY 2</option>
+ <option value="0003">MEMORY 3</option>
+ <option value="0004">MEMORY 4</option>
+ <option value="0005">MEMORY 5</option>
+ <option value="0006">MEMORY 6</option>
+ </options>
+ </state>
+ </channel-type>
+
</thing:thing-descriptions>