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 all commits
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
15 changes: 15 additions & 0 deletions bundles/org.openhab.binding.onkyo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ The Onkyo AVR supports the following channels (some channels are model specific)
| netmenu#item7 | String | The text of USB/Net Menu entry 7 |
| netmenu#item8 | String | The text of USB/Net Menu entry 8 |
| netmenu#item9 | String | The text of USB/Net Menu entry 9 |
| information#audioIn | String | Details of the input audio format |
| information#audioOut | String | Details of the output audio format |
| information#videoIn | String | Details of the input video format |
| information#videoOut | String | Details of the output video format |

## Rule Actions

Expand Down Expand Up @@ -255,6 +259,11 @@ String avrLrNet_Item6 "Item6 [%s]" <text> { channel="onkyo:onkyoAVR:av
String avrLrNet_Item7 "Item7 [%s]" <text> { channel="onkyo:onkyoAVR:avr-livingroom:netmenu#item7" }
String avrLrNet_Item8 "Item8 [%s]" <text> { channel="onkyo:onkyoAVR:avr-livingroom:netmenu#item8" }
String avrLrNet_Item9 "Item9 [%s]" <text> { channel="onkyo:onkyoAVR:avr-livingroom:netmenu#item9" }

String audioIn "Audio In [%s]" <settings> ["Point"] { channel="onkyo:onkyoAVR:avr-livingroom:information#audioIn" }
String audioOut "Audio Out [%s]" <settings> ["Point"] { channel="onkyo:onkyoAVR:avr-livingroom:information#audioOut" }
String videoIn "Video In [%s]" <settings> ["Point"] { channel="onkyo:onkyoAVR:avr-livingroom:information#videoIn" }
String videoOut "Video Out [%s]" <settings> ["Point"] { channel="onkyo:onkyoAVR:avr-livingroom:information#videoOut" }
```

## Sitemap Configuration
Expand Down Expand Up @@ -301,6 +310,12 @@ sitemap demo label="Onkyo AVR"
Text item=avrLrNet_Item8
Text item=avrLrNet_Item9
}
Frame label="Audio & Video Information" {
Text item=audioIn
Text item=audioOut
Text item=videoIn
Text item=videoOut
}
}
```

Expand Down
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 java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;

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

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

/**
* Slices the string, removing empty values
*
* @param data comma separated string
* @param startIndex initial index of the range to be copied
* @param endIndex final index of the range to be copied (inclusive)
* @return formatted StringType
*/
public static StringType infoBuilder(String data, int startIndex, int endIndex) {
String[] params = data.split(",");
int toIndex = endIndex < params.length ? endIndex + 1 : params.length;
if (params.length >= startIndex) {
return new StringType(Stream.of(Arrays.copyOfRange(params, startIndex, toIndex))
.filter(p -> p.trim().length() > 0).map(p -> p.trim()).collect(Collectors.joining(", ", "", "")));
}
return StringType.EMPTY;
}
}
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, 2));
updateState(CHANNEL_AUDIO_OUT_INFO, OnkyoParserHelper.infoBuilder(data.getValue(), 3, 5));
break;
case VIDEOINFO:
updateState(CHANNEL_VIDEO_IN_INFO, OnkyoParserHelper.infoBuilder(data.getValue(), 0, 3));
updateState(CHANNEL_VIDEO_OUT_INFO, OnkyoParserHelper.infoBuilder(data.getValue(), 4, 7));
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 @@ -94,6 +94,7 @@ thing-type.config.onkyo.config.volumeScale.option.0.5 = 0-50

# channel group types

channel-group-type.onkyo.information.label = Audio & Video Info
channel-group-type.onkyo.netMenuControls.label = Net/USB Menu
channel-group-type.onkyo.netMenuControls.channel.item0.label = Menu Item 0
channel-group-type.onkyo.netMenuControls.channel.item0.description = Net/USB menu item at position 0
Expand Down Expand Up @@ -130,6 +131,10 @@ channel-type.onkyo.albumArtUrl.label = Album Art Url
channel-type.onkyo.albumArtUrl.description = Url to the image of cover art of the current song
channel-type.onkyo.artist.label = Artist
channel-type.onkyo.artist.description = Artist name of the current song
channel-type.onkyo.audioIn.label = Audio Input Info
channel-type.onkyo.audioIn.description = Audio Input Stream Information
channel-type.onkyo.audioOut.label = Audio Output Info
channel-type.onkyo.audioOut.description = Audio Output Stream Information
channel-type.onkyo.audioinfo.label = Audio Info
channel-type.onkyo.audioinfo.description = Detailed audio info
channel-type.onkyo.control.label = Control
Expand Down Expand Up @@ -226,5 +231,9 @@ channel-type.onkyo.power.label = Power
channel-type.onkyo.power.description = Power on/off your device
channel-type.onkyo.title.label = Title
channel-type.onkyo.title.description = Title of the current song
channel-type.onkyo.videoIn.label = Video Input Info
channel-type.onkyo.videoIn.description = Video Input Stream Information
channel-type.onkyo.videoOut.label = Video Output Info
channel-type.onkyo.videoOut.description = Video Output Stream Information
channel-type.onkyo.volume.label = Volume
channel-type.onkyo.volume.description = Volume of your device
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" pattern="%s"></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" pattern="%s"></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
Loading