Skip to content

Commit

Permalink
[upnpcontrol] Prepare dynamic channels and status messages for transl…
Browse files Browse the repository at this point in the history
…ation (openhab#13364)

* prepare dynamic channels and status messages for translation

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
  • Loading branch information
mherwege authored and andan67 committed Nov 5, 2022
1 parent a8ac2f3 commit fbcb9c0
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,78 +33,106 @@
public enum UpnpChannelName {

// Volume channels
LF_VOLUME("LFvolume", "Left Front Volume", "Left front volume, will be left volume with stereo sound",
LF_VOLUME("LFvolume", "@text/channel.upnpcontrol.lfvolume.label", "@text/channel.upnpcontrol.lfvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
RF_VOLUME("RFvolume", "Right Front Volume", "Right front volume, will be left volume with stereo sound",
RF_VOLUME("RFvolume", "@text/channel.upnpcontrol.rfvolume.label", "@text/channel.upnpcontrol.rfvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
CF_VOLUME("CFvolume", "Center Front Volume", "Center front volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
LFE_VOLUME("LFEvolume", "Frequency Enhancement Volume", "Low frequency enhancement volume (subwoofer)",
CF_VOLUME("CFvolume", "@text/channel.upnpcontrol.cfvolume.label", "@text/channel.upnpcontrol.cfvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
LFE_VOLUME("LFEvolume", "@text/channel.upnpcontrol.lfevolume.label",
"@text/channel.upnpcontrol.lfevolume.description", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
LS_VOLUME("LSvolume", "@text/channel.upnpcontrol.lsvolume.label", "@text/channel.upnpcontrol.lsvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
RS_VOLUME("RSvolume", "@text/channel.upnpcontrol.rsvolume.label", "@text/channel.upnpcontrol.rsvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
LFC_VOLUME("LFCvolume", "@text/channel.upnpcontrol.lfcvolume.label",
"@text/channel.upnpcontrol.lfcvolume.description", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
RFC_VOLUME("RFCvolume", "@text/channel.upnpcontrol.rfcvolume.label",
"@text/channel.upnpcontrol.rfcvolume.description", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
SD_VOLUME("SDvolume", "@text/channel.upnpcontrol.sdvolume.label", "@text/channel.upnpcontrol.sdvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
SL_VOLUME("SLvolume", "@text/channel.upnpcontrol.slvolume.label", "@text/channel.upnpcontrol.slvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
SR_VOLUME("SRvolume", "@text/channel.upnpcontrol.srvolume.label", "@text/channel.upnpcontrol.srvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
T_VOLUME("Tvolume", "@text/channel.upnpcontrol.tvolume.label", "@text/channel.upnpcontrol.tvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
B_VOLUME("Bvolume", "@text/channel.upnpcontrol.bvolume.label", "@text/channel.upnpcontrol.bvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
BC_VOLUME("BCvolume", "@text/channel.upnpcontrol.bcvolume.label", "@text/channel.upnpcontrol.bcvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
BL_VOLUME("BLvolume", "@text/channel.upnpcontrol.blvolume.label", "@text/channel.upnpcontrol.blvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
BR_VOLUME("BRvolume", "@text/channel.upnpcontrol.brvolume.label", "@text/channel.upnpcontrol.brvolume.description",
ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
LS_VOLUME("LSvolume", "Left Surround Volume", "Left surround volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
RS_VOLUME("RSvolume", "Right Surround Volume", "Right surround volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
LFC_VOLUME("LFCvolume", "Left of Center Volume", "Left of center (in front) volume", ITEM_TYPE_VOLUME,
CHANNEL_TYPE_VOLUME),
RFC_VOLUME("RFCvolume", "Right of Center Volume", "Right of center (in front) volume", ITEM_TYPE_VOLUME,
CHANNEL_TYPE_VOLUME),
SD_VOLUME("SDvolume", "Surround Volume", "Surround (rear) volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
SL_VOLUME("SLvolume", "Side Left Volume", "Side left (left wall) volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
SR_VOLUME("SRvolume", "Side Right Volume", "Side right (right wall) volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
T_VOLUME("Tvolume", "Top Volume", "Top (overhead) volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
B_VOLUME("Bvolume", "Bottom Volume", "Bottom volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
BC_VOLUME("BCvolume", "Back Center Volume", "Back center volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
BL_VOLUME("BLvolume", "Back Left Volume", "Back Left Volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),
BR_VOLUME("BRvolume", "Back Right Volume", "Back right volume", ITEM_TYPE_VOLUME, CHANNEL_TYPE_VOLUME),

// Mute channels
LF_MUTE("LFmute", "Left Front Mute", "Left front mute, will be left mute with stereo sound", ITEM_TYPE_MUTE,
CHANNEL_TYPE_MUTE),
RF_MUTE("RFmute", "Right Front Mute", "Right front mute, will be left mute with stereo sound", ITEM_TYPE_MUTE,
CHANNEL_TYPE_MUTE),
CF_MUTE("CFmute", "Center Front Mute", "Center front mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
LFE_MUTE("LFEmute", "Frequency Enhancement Mute", "Low frequency enhancement mute (subwoofer)", ITEM_TYPE_MUTE,
CHANNEL_TYPE_MUTE),
LS_MUTE("LSmute", "Left Surround Mute", "Left surround mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
RS_MUTE("RSmute", "Right Surround Mute", "Right surround mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
LFC_MUTE("LFCmute", "Left of Center Mute", "Left of center (in front) mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
RFC_MUTE("RFCmute", "Right of Center Mute", "Right of center (in front) mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
SD_MUTE("SDmute", "Surround Mute", "Surround (rear) mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
SL_MUTE("SLmute", "Side Left Mute", "Side left (left wall) mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
SR_MUTE("SRmute", "Side Right Mute", "Side right (right wall) mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
T_MUTE("Tmute", "Top Mute", "Top (overhead) mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
B_MUTE("Bmute", "Bottom Mute", "Bottom mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
BC_MUTE("BCmute", "Back Center Mute", "Back center mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
BL_MUTE("BLmute", "Back Left Mute", "Back Left Mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
BR_MUTE("BRmute", "Back Right Mute", "Back right mute", ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
LF_MUTE("LFmute", "@text/channel.upnpcontrol.lfmute.label", "@text/channel.upnpcontrol.lfmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
RF_MUTE("RFmute", "@text/channel.upnpcontrol.rfmute.label", "@text/channel.upnpcontrol.rfmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
CF_MUTE("CFmute", "@text/channel.upnpcontrol.cfmute.label", "@text/channel.upnpcontrol.cfmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
LFE_MUTE("LFEmute", "@text/channel.upnpcontrol.lfemute.label", "@text/channel.upnpcontrol.lfemute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
LS_MUTE("LSmute", "@text/channel.upnpcontrol.lsmute.label", "@text/channel.upnpcontrol.lsmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
RS_MUTE("RSmute", "@text/channel.upnpcontrol.rsmute.label", "@text/channel.upnpcontrol.rsmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
LFC_MUTE("LFCmute", "@text/channel.upnpcontrol.lfcmute.label", "@text/channel.upnpcontrol.lfcmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
RFC_MUTE("RFCmute", "@text/channel.upnpcontrol.rfcmute.label", "@text/channel.upnpcontrol.rfcmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
SD_MUTE("SDmute", "@text/channel.upnpcontrol.sdmute.label", "@text/channel.upnpcontrol.sdmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
SL_MUTE("SLmute", "@text/channel.upnpcontrol.slmute.label", "@text/channel.upnpcontrol.slmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
SR_MUTE("SRmute", "@text/channel.upnpcontrol.srmute.label", "@text/channel.upnpcontrol.srmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
T_MUTE("Tmute", "@text/channel.upnpcontrol.tmute.label", "@text/channel.upnpcontrol.tmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
B_MUTE("Bmute", "@text/channel.upnpcontrol.bmute.label", "@text/channel.upnpcontrol.bmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
BC_MUTE("BCmute", "@text/channel.upnpcontrol.bcmute.label", "@text/channel.upnpcontrol.bcmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
BL_MUTE("BLmute", "@text/channel.upnpcontrol.blmute.label", "@text/channel.upnpcontrol.blmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),
BR_MUTE("BRmute", "@text/channel.upnpcontrol.brmute.label", "@text/channel.upnpcontrol.brmute.description",
ITEM_TYPE_MUTE, CHANNEL_TYPE_MUTE),

// Loudness channels
LOUDNESS("loudness", "Loudness", "Master loudness", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
LF_LOUDNESS("LFloudness", "Left Front Loudness", "Left front loudness", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
RF_LOUDNESS("RFloudness", "Right Front Loudness", "Right front loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
CF_LOUDNESS("CFloudness", "Center Front Loudness", "Center front loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
LFE_LOUDNESS("LFEloudness", "Frequency Enhancement Loudness", "Low frequency enhancement loudness (subwoofer)",
ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
LS_LOUDNESS("LSloudness", "Left Surround Loudness", "Left surround loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
RS_LOUDNESS("RSloudness", "Right Surround Loudness", "Right surround loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
LFC_LOUDNESS("LFCloudness", "Left of Center Loudness", "Left of center (in front) loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
RFC_LOUDNESS("RFCloudness", "Right of Center Loudness", "Right of center (in front) loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
SD_LOUDNESS("SDloudness", "Surround Loudness", "Surround (rear) loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
SL_LOUDNESS("SLloudness", "Side Left Loudness", "Side left (left wall) loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
SR_LOUDNESS("SRloudness", "Side Right Loudness", "Side right (right wall) loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
T_LOUDNESS("Tloudness", "Top Loudness", "Top (overhead) loudness", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
B_LOUDNESS("Bloudness", "Bottom Loudness", "Bottom loudness", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
BC_LOUDNESS("BCloudness", "Back Center Loudness", "Back center loudness", ITEM_TYPE_LOUDNESS,
CHANNEL_TYPE_LOUDNESS),
BL_LOUDNESS("BLloudness", "Back Left Loudness", "Back Left Loudness", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
BR_LOUDNESS("BRloudness", "Back Right Loudness", "Back right loudness", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS);
LF_LOUDNESS("LFloudness", "@text/channel.upnpcontrol.lfloudness.label",
"@text/channel.upnpcontrol.lfloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
RF_LOUDNESS("RFloudness", "@text/channel.upnpcontrol.rfloudness.label",
"@text/channel.upnpcontrol.rfloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
CF_LOUDNESS("CFloudness", "@text/channel.upnpcontrol.cfloudness.label",
"@text/channel.upnpcontrol.cfloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
LFE_LOUDNESS("LFEloudness", "@text/channel.upnpcontrol.lfeloudness.label",
"@text/channel.upnpcontrol.lfeloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
LS_LOUDNESS("LSloudness", "@text/channel.upnpcontrol.lsloudness.label",
"@text/channel.upnpcontrol.lsloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
RS_LOUDNESS("RSloudness", "@text/channel.upnpcontrol.rsloudness.label",
"@text/channel.upnpcontrol.rsloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
LFC_LOUDNESS("LFCloudness", "@text/channel.upnpcontrol.lfcloudness.label",
"@text/channel.upnpcontrol.lfcloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
RFC_LOUDNESS("RFCloudness", "@text/channel.upnpcontrol.rfcloudness.label",
"@text/channel.upnpcontrol.rfcloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
SD_LOUDNESS("SDloudness", "@text/channel.upnpcontrol.sdloudness.label",
"@text/channel.upnpcontrol.sdloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
SL_LOUDNESS("SLloudness", "@text/channel.upnpcontrol.slloudness.label",
"@text/channel.upnpcontrol.slloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
SR_LOUDNESS("SRloudness", "@text/channel.upnpcontrol.srloudness.label",
"@text/channel.upnpcontrol.srloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
T_LOUDNESS("Tloudness", "@text/channel.upnpcontrol.tloudness.label",
"@text/channel.upnpcontrol.tloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
B_LOUDNESS("Bloudness", "@text/channel.upnpcontrol.bloudness.label",
"@text/channel.upnpcontrol.bloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
BC_LOUDNESS("BCloudness", "@text/channel.upnpcontrol.bcloudness.label",
"@text/channel.upnpcontrol.bcloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
BL_LOUDNESS("BLloudness", "@text/channel.upnpcontrol.blloudness.label",
"@text/channel.upnpcontrol.blloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS),
BR_LOUDNESS("BRloudness", "@text/channel.upnpcontrol.brloudness.label",
"@text/channel.upnpcontrol.brloudness.description", ITEM_TYPE_LOUDNESS, CHANNEL_TYPE_LOUDNESS);

private static final Map<String, UpnpChannelName> UPNP_CHANNEL_NAME_MAP = Stream.of(UpnpChannelName.values())
.collect(Collectors.toMap(UpnpChannelName::getChannelId, Function.identity()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ protected void initDevice() {
pollingJob = upnpScheduler.scheduleWithFixedDelay(this::initJob, 0, config.refresh, TimeUnit.SECONDS);
}
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"No UDN configured for " + thing.getLabel());
String msg = String.format("@text/offline.no-udn [ \"%s\" ]", thing.getLabel());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, msg);
}
}

Expand Down Expand Up @@ -398,8 +398,9 @@ public void onServiceSubscribed(@Nullable String service, boolean succeeded) {
service);
if (!succeeded) {
upnpSubscribed = false;
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Could not subscribe to service " + service + "for" + thing.getLabel());
String msg = String.format("@text/offline.subscription-failed [ \"%1$s\", \"%2$s\" ]", service,
thing.getLabel());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, msg);
}
}

Expand All @@ -409,8 +410,8 @@ public void onStatusChanged(boolean status) {
if (status) {
initJob();
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Communication lost with " + thing.getLabel());
String msg = String.format("@text/offline.communication-lost [ \"%s\" ]", thing.getLabel());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, msg);
}
}

Expand Down
Loading

0 comments on commit fbcb9c0

Please sign in to comment.