Ignore NuvoNet events for sources not managed by openHAB (#13535)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
parent
6103c30830
commit
51054fe51b
|
@ -224,6 +224,13 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
|
|||
return;
|
||||
}
|
||||
|
||||
nuvoNetSrcMap.put("1", config.nuvoNetSrc1);
|
||||
nuvoNetSrcMap.put("2", config.nuvoNetSrc2);
|
||||
nuvoNetSrcMap.put("3", config.nuvoNetSrc3);
|
||||
nuvoNetSrcMap.put("4", config.nuvoNetSrc4);
|
||||
nuvoNetSrcMap.put("5", config.nuvoNetSrc5);
|
||||
nuvoNetSrcMap.put("6", config.nuvoNetSrc6);
|
||||
|
||||
if (this.isMps4) {
|
||||
logger.debug("Port set to {} configuring binding for MPS4 compatability", MPS4_PORT);
|
||||
|
||||
|
@ -234,13 +241,6 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
|
|||
logger.debug("At least one source is configured as an openHAB NuvoNet source");
|
||||
loadMenuConfiguration(config);
|
||||
|
||||
nuvoNetSrcMap.put("1", config.nuvoNetSrc1);
|
||||
nuvoNetSrcMap.put("2", config.nuvoNetSrc2);
|
||||
nuvoNetSrcMap.put("3", config.nuvoNetSrc3);
|
||||
nuvoNetSrcMap.put("4", config.nuvoNetSrc4);
|
||||
nuvoNetSrcMap.put("5", config.nuvoNetSrc5);
|
||||
nuvoNetSrcMap.put("6", config.nuvoNetSrc6);
|
||||
|
||||
favoriteMap.put("1",
|
||||
!config.favoritesSrc1.isEmpty() ? config.favoritesSrc1.split(COMMA) : new String[0]);
|
||||
favoriteMap.put("2",
|
||||
|
@ -762,6 +762,8 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
|
|||
}
|
||||
break;
|
||||
case TYPE_MENU_ITEM_SELECTED:
|
||||
// ignore this update unless openHAB is handling this source
|
||||
if (nuvoNetSrcMap.get(key).equals(2)) {
|
||||
String[] updateDataSplit = updateData.split(COMMA);
|
||||
String zoneSource = updateDataSplit[0];
|
||||
String menuId = updateDataSplit[1];
|
||||
|
@ -815,10 +817,14 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
|
|||
logger.debug("Error sending exit menu command for {}", zoneSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TYPE_ZONE_MENUREQ:
|
||||
// ignore this update unless openHAB is handling this source
|
||||
if (nuvoNetSrcMap.get(key).equals(2)) {
|
||||
logger.debug("Menu Request: Source: {} - Value: {}", key, updateData);
|
||||
// For now we only support one level deep menus. If third field is '1', indicates go back to main menu.
|
||||
// For now we only support one level deep menus. If third field is '1', indicates go back to main
|
||||
// menu.
|
||||
String[] menuDataSplit = updateData.split(",");
|
||||
if (menuDataSplit.length > 3 && ONE.equals(menuDataSplit[2])) {
|
||||
try {
|
||||
|
@ -827,7 +833,7 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
|
|||
logger.debug("Error sending main menu command for {}", menuDataSplit[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case TYPE_ZONE_CONFIG:
|
||||
logger.debug("Zone Configuration: Zone: {} - Value: {}", key, updateData);
|
||||
|
@ -845,6 +851,8 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
|
|||
}
|
||||
break;
|
||||
case TYPE_ALBUM_ART_REQ:
|
||||
// ignore this update unless openHAB is handling this source
|
||||
if (nuvoNetSrcMap.get(key).equals(2)) {
|
||||
logger.debug("Album Art Request for Source: {} - Data: {}", key, updateData);
|
||||
// 0x620FD879,80,80,2,0x00C0C0C0,0,0,0,0,1
|
||||
String[] albumArtReq = updateData.split(COMMA);
|
||||
|
@ -860,8 +868,11 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
|
|||
} catch (NuvoException e) {
|
||||
logger.debug("Error sending ALBUMARTAVAILABLE command for source: {}", key);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TYPE_ALBUM_ART_FRAG_REQ:
|
||||
// ignore this update unless openHAB is handling this source
|
||||
if (nuvoNetSrcMap.get(key).equals(2)) {
|
||||
logger.debug("Album Art Fragment Request for Source: {} - Data: {}", key, updateData);
|
||||
// 0x620FD879,0,750 (id, requested offset from start of image, byte length requested)
|
||||
String[] albumArtFragReq = updateData.split(COMMA);
|
||||
|
@ -877,16 +888,19 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
|
|||
System.arraycopy(albumArtBytes, offset, chunk, 0, length);
|
||||
final String frag = Base64.getEncoder().encodeToString(chunk);
|
||||
try {
|
||||
connector.sendCommand(SRC_KEY + key + ALBUM_ART_FRAG + requestedId + COMMA + offset + COMMA
|
||||
+ frag.length() + COMMA + frag);
|
||||
connector.sendCommand(SRC_KEY + key + ALBUM_ART_FRAG + requestedId + COMMA + offset
|
||||
+ COMMA + frag.length() + COMMA + frag);
|
||||
} catch (NuvoException e) {
|
||||
logger.debug("Error sending ALBUMARTFRAG command for source: {}, artId: {}", key,
|
||||
requestedId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TYPE_FAVORITE_REQ:
|
||||
// ignore this update unless openHAB is handling this source
|
||||
if (nuvoNetSrcMap.get(key).equals(2)) {
|
||||
logger.debug("Favorite request for source: {} - favoriteId: {}", key, updateData);
|
||||
try {
|
||||
int playlistIdx = Integer.parseInt(updateData, 16) - 1000;
|
||||
|
@ -895,6 +909,7 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
|
|||
} catch (NumberFormatException nfe) {
|
||||
logger.debug("Unable to parse favoriteId: {}", updateData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
logger.debug("onNewMessageEvent: unhandled key {}", key);
|
||||
|
|
Loading…
Reference in New Issue