Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onkyo] Add channels for media info #11813

Merged
merged 2 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public class OnkyoBindingConstants {
public static final String CHANNEL_NET_MENU8 = "netmenu#item8";
public static final String CHANNEL_NET_MENU9 = "netmenu#item9";

public final static String CHANNEL_AUDIO_IN_INFO = "info#audioIn";
public final static String CHANNEL_AUDIO_OUT_INFO = "info#audioOut";
public final static String CHANNEL_VIDEO_IN_INFO = "info#videoIn";
public final static String CHANNEL_VIDEO_OUT_INFO = "info#videoOut";

// Used for Discovery service
public static final String MANUFACTURER = "ONKYO";
public static final String UPNP_DEVICE_TYPE = "MediaRenderer";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.onkyo.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.library.types.StringType;
import org.openhab.core.types.State;

/**
* Helper to parse messages.
*
* @author Marcel Verpaalen - Initial contribution
*/
@NonNullByDefault
public final class OnkyoParserHelper {

public static State infoBuilder(String data, int from, int to) {
StringBuilder builder = new StringBuilder();
int end = to;
String[] element = data.split(",");
if (element.length < from) {
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
return StringType.EMPTY;
}
if (element.length < end) {
end = element.length;
}
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
boolean firstElement = true;
for (int i = from; i < end; i++) {
if (!element[i].isEmpty() && !firstElement) {
builder.append(", ");
}
builder.append(element[i]);
firstElement = false;
}
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
return new StringType(builder.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public enum EiscpCommand {

AUDIOINFO("IFA", ""),
AUDIOINFO_QUERY("IFA", "QSTN"),
VIDEOINFO("IFV", ""),
VIDEOINFO_QUERY("IFV", "QSTN"),

SOURCE_UP("SLI", "UP"),
SOURCE_DOWN("SLI", "DOWN"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.openhab.binding.onkyo.internal.OnkyoAlbumArt;
import org.openhab.binding.onkyo.internal.OnkyoConnection;
import org.openhab.binding.onkyo.internal.OnkyoEventListener;
import org.openhab.binding.onkyo.internal.OnkyoParserHelper;
import org.openhab.binding.onkyo.internal.OnkyoStateDescriptionProvider;
import org.openhab.binding.onkyo.internal.ServiceType;
import org.openhab.binding.onkyo.internal.automation.modules.OnkyoThingActions;
Expand Down Expand Up @@ -120,9 +121,7 @@ public void initialize() {
connection.openConnection();
if (connection.isConnected()) {
updateStatus(ThingStatus.ONLINE);

sendCommand(EiscpCommand.INFO_QUERY);
sendCommand(EiscpCommand.AUDIOINFO_QUERY);
checkStatus();
}
});

Expand Down Expand Up @@ -330,6 +329,22 @@ public void handleCommand(ChannelUID channelUID, Command command) {
sendCommand(EiscpCommand.AUDIOINFO_QUERY);
}
break;

/*
* MEDIA INFO
*/
case CHANNEL_AUDIO_IN_INFO:
case CHANNEL_AUDIO_OUT_INFO:
if (command.equals(RefreshType.REFRESH)) {
sendCommand(EiscpCommand.AUDIOINFO_QUERY);
}
break;
case CHANNEL_VIDEO_IN_INFO:
case CHANNEL_VIDEO_OUT_INFO:
if (command.equals(RefreshType.REFRESH)) {
sendCommand(EiscpCommand.VIDEOINFO_QUERY);
}
break;
/*
* MISC
*/
Expand Down Expand Up @@ -485,6 +500,12 @@ public void statusUpdateReceived(String ip, EiscpMessage data) {
case AUDIOINFO:
updateState(CHANNEL_AUDIOINFO, convertDeviceValueToOpenHabState(data.getValue(), StringType.class));
logger.debug("audioinfo message: '{}'", data.getValue());
updateState(CHANNEL_AUDIO_IN_INFO, OnkyoParserHelper.infoBuilder(data.getValue(), 0, 3));
updateState(CHANNEL_AUDIO_OUT_INFO, OnkyoParserHelper.infoBuilder(data.getValue(), 4, 6));
break;
case VIDEOINFO:
updateState(CHANNEL_VIDEO_IN_INFO, OnkyoParserHelper.infoBuilder(data.getValue(), 0, 4));
updateState(CHANNEL_VIDEO_OUT_INFO, OnkyoParserHelper.infoBuilder(data.getValue(), 5, 8));
break;
case INFO:
processInfo(data.getValue());
Expand Down Expand Up @@ -806,6 +827,7 @@ private void checkStatus() {
sendCommand(EiscpCommand.LISTEN_MODE_QUERY);
sendCommand(EiscpCommand.INFO_QUERY);
sendCommand(EiscpCommand.AUDIOINFO_QUERY);
sendCommand(EiscpCommand.VIDEOINFO_QUERY);

if (isChannelAvailable(CHANNEL_POWERZONE2)) {
sendCommand(EiscpCommand.ZONE2_POWER_QUERY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,14 @@
</channels>
</channel-group-type>

<channel-group-type id="information">
<label>Audio &amp; Video Info</label>
<channels>
<channel id="audioIn" typeId="audioIn"/>
<channel id="audioOut" typeId="audioOut"/>
<channel id="videoIn" typeId="videoIn"/>
<channel id="videoOut" typeId="videoOut"/>
</channels>
</channel-group-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,29 @@
<description>Position of the currently selected menu item</description>
<state readOnly="true" pattern="%s"></state>
</channel-type>
<channel-type id="audioIn" advanced="true">
<item-type>String</item-type>
<label>Audio Input Info</label>
<description>Audio Input Stream Information</description>
<state readOnly="true"></state>
</channel-type>
<channel-type id="audioOut" advanced="true">
<item-type>String</item-type>
<label>Audio Output Info</label>
<description>Audio Output Stream Information</description>
<state readOnly="true"></state>
</channel-type>
<channel-type id="videoIn" advanced="true">
<item-type>String</item-type>
<label>Video Input Info</label>
<description>Video Input Stream Information</description>
<state readOnly="true" pattern="%s"></state>
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
</channel-type>
<channel-type id="videoOut" advanced="true">
<item-type>String</item-type>
<label>Video Output Info</label>
<description>Video Output Stream Information</description>
<state readOnly="true" pattern="%s"></state>
</channel-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<channel-group typeId="zone3Controls" id="zone3"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<channel-group typeId="zone1Controls" id="zone1"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<channel-group typeId="zone3Controls" id="zone3"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<channel-group typeId="zone1Controls" id="zone1"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<channel-group typeId="zone3Controls" id="zone3"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<channel-group typeId="zone3Controls" id="zone3"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<channel-group typeId="zone3Controls" id="zone3"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<channel-group typeId="zone3Controls" id="zone3"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<channel-group typeId="zone2Controls" id="zone2"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<channel-group typeId="zone3Controls" id="zone3"/>
<channel-group typeId="playerControls" id="player"/>
<channel-group typeId="netMenuControls" id="netmenu"/>
<channel-group typeId="information" id="info"/>
</channel-groups>

<config-description-ref uri="thing-type:onkyo:config"/>
Expand Down
Loading