mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[oppo] Add missing input option and enable translations (#17783)
* Add missing input option and enable translations Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
parent
38b04943cc
commit
511fab73c0
@ -19,6 +19,8 @@ import java.util.Set;
|
|||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.oppo.internal.handler.OppoHandler;
|
import org.openhab.binding.oppo.internal.handler.OppoHandler;
|
||||||
|
import org.openhab.core.i18n.LocaleProvider;
|
||||||
|
import org.openhab.core.i18n.TranslationProvider;
|
||||||
import org.openhab.core.io.transport.serial.SerialPortManager;
|
import org.openhab.core.io.transport.serial.SerialPortManager;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
import org.openhab.core.thing.ThingTypeUID;
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
@ -41,14 +43,19 @@ public class OppoHandlerFactory extends BaseThingHandlerFactory {
|
|||||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_PLAYER);
|
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_PLAYER);
|
||||||
|
|
||||||
private final SerialPortManager serialPortManager;
|
private final SerialPortManager serialPortManager;
|
||||||
|
private final TranslationProvider translationProvider;
|
||||||
|
private final LocaleProvider localeProvider;
|
||||||
|
|
||||||
private final OppoStateDescriptionOptionProvider stateDescriptionProvider;
|
private final OppoStateDescriptionOptionProvider stateDescriptionProvider;
|
||||||
|
|
||||||
@Activate
|
@Activate
|
||||||
public OppoHandlerFactory(final @Reference OppoStateDescriptionOptionProvider provider,
|
public OppoHandlerFactory(final @Reference OppoStateDescriptionOptionProvider provider,
|
||||||
final @Reference SerialPortManager serialPortManager) {
|
final @Reference SerialPortManager serialPortManager, @Reference TranslationProvider translationProvider,
|
||||||
|
@Reference LocaleProvider localeProvider) {
|
||||||
this.stateDescriptionProvider = provider;
|
this.stateDescriptionProvider = provider;
|
||||||
this.serialPortManager = serialPortManager;
|
this.serialPortManager = serialPortManager;
|
||||||
|
this.translationProvider = translationProvider;
|
||||||
|
this.localeProvider = localeProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,7 +68,8 @@ public class OppoHandlerFactory extends BaseThingHandlerFactory {
|
|||||||
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
|
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
|
||||||
|
|
||||||
if (SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
|
if (SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
|
||||||
return new OppoHandler(thing, stateDescriptionProvider, serialPortManager);
|
return new OppoHandler(thing, stateDescriptionProvider, serialPortManager, translationProvider,
|
||||||
|
localeProvider);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,8 @@ import org.openhab.binding.oppo.internal.communication.OppoMessageEventListener;
|
|||||||
import org.openhab.binding.oppo.internal.communication.OppoSerialConnector;
|
import org.openhab.binding.oppo.internal.communication.OppoSerialConnector;
|
||||||
import org.openhab.binding.oppo.internal.communication.OppoStatusCodes;
|
import org.openhab.binding.oppo.internal.communication.OppoStatusCodes;
|
||||||
import org.openhab.binding.oppo.internal.configuration.OppoThingConfiguration;
|
import org.openhab.binding.oppo.internal.configuration.OppoThingConfiguration;
|
||||||
|
import org.openhab.core.i18n.LocaleProvider;
|
||||||
|
import org.openhab.core.i18n.TranslationProvider;
|
||||||
import org.openhab.core.io.transport.serial.SerialPortManager;
|
import org.openhab.core.io.transport.serial.SerialPortManager;
|
||||||
import org.openhab.core.library.types.DecimalType;
|
import org.openhab.core.library.types.DecimalType;
|
||||||
import org.openhab.core.library.types.NextPreviousType;
|
import org.openhab.core.library.types.NextPreviousType;
|
||||||
@ -56,6 +58,8 @@ import org.openhab.core.types.Command;
|
|||||||
import org.openhab.core.types.State;
|
import org.openhab.core.types.State;
|
||||||
import org.openhab.core.types.StateOption;
|
import org.openhab.core.types.StateOption;
|
||||||
import org.openhab.core.types.UnDefType;
|
import org.openhab.core.types.UnDefType;
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
|
import org.osgi.framework.FrameworkUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -85,6 +89,10 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
|||||||
private SerialPortManager serialPortManager;
|
private SerialPortManager serialPortManager;
|
||||||
private OppoConnector connector = new OppoDefaultConnector();
|
private OppoConnector connector = new OppoDefaultConnector();
|
||||||
|
|
||||||
|
private final TranslationProvider translationProvider;
|
||||||
|
private final LocaleProvider localeProvider;
|
||||||
|
private final @Nullable Bundle bundle;
|
||||||
|
|
||||||
private List<StateOption> inputSourceOptions = new ArrayList<>();
|
private List<StateOption> inputSourceOptions = new ArrayList<>();
|
||||||
private List<StateOption> hdmiModeOptions = new ArrayList<>();
|
private List<StateOption> hdmiModeOptions = new ArrayList<>();
|
||||||
|
|
||||||
@ -105,10 +113,14 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
|||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public OppoHandler(Thing thing, OppoStateDescriptionOptionProvider stateDescriptionProvider,
|
public OppoHandler(Thing thing, OppoStateDescriptionOptionProvider stateDescriptionProvider,
|
||||||
SerialPortManager serialPortManager) {
|
SerialPortManager serialPortManager, TranslationProvider translationProvider,
|
||||||
|
LocaleProvider localeProvider) {
|
||||||
super(thing);
|
super(thing);
|
||||||
this.stateDescriptionProvider = stateDescriptionProvider;
|
this.stateDescriptionProvider = stateDescriptionProvider;
|
||||||
this.serialPortManager = serialPortManager;
|
this.serialPortManager = serialPortManager;
|
||||||
|
this.translationProvider = translationProvider;
|
||||||
|
this.localeProvider = localeProvider;
|
||||||
|
this.bundle = FrameworkUtil.getBundle(OppoHandler.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -842,9 +854,12 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buildOptionDropdowns(int model) {
|
private void buildOptionDropdowns(int model) {
|
||||||
|
hdmiModeOptions.clear();
|
||||||
|
inputSourceOptions.clear();
|
||||||
|
|
||||||
if (model == MODEL83 || model == MODEL103 || model == MODEL105) {
|
if (model == MODEL83 || model == MODEL103 || model == MODEL105) {
|
||||||
hdmiModeOptions.add(new StateOption("AUTO", "Auto"));
|
hdmiModeOptions.add(new StateOption("AUTO", getString("auto", "Auto")));
|
||||||
hdmiModeOptions.add(new StateOption("SRC", "Source Direct"));
|
hdmiModeOptions.add(new StateOption("SRC", getString("direct", "Source Direct")));
|
||||||
if (model != MODEL83) {
|
if (model != MODEL83) {
|
||||||
hdmiModeOptions.add(new StateOption("4K2K", "4K*2K"));
|
hdmiModeOptions.add(new StateOption("4K2K", "4K*2K"));
|
||||||
}
|
}
|
||||||
@ -856,26 +871,27 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (model == MODEL103 || model == MODEL105) {
|
if (model == MODEL103 || model == MODEL105) {
|
||||||
inputSourceOptions.add(new StateOption("0", "Blu-Ray Player"));
|
inputSourceOptions.add(new StateOption("0", getString("blu_ray", "Blu-ray Player")));
|
||||||
inputSourceOptions.add(new StateOption("1", "HDMI/MHL IN-Front"));
|
inputSourceOptions.add(new StateOption("1", getString("hdmi_in_front", "HDMI/MHL In-Front")));
|
||||||
inputSourceOptions.add(new StateOption("2", "HDMI IN-Back"));
|
inputSourceOptions.add(new StateOption("2", getString("hdmi_in_back", "HDMI In-Back")));
|
||||||
inputSourceOptions.add(new StateOption("3", "ARC"));
|
inputSourceOptions.add(new StateOption("3", getString("arc1", "ARC 1")));
|
||||||
|
inputSourceOptions.add(new StateOption("4", getString("arc2", "ARC 2")));
|
||||||
|
|
||||||
if (model == MODEL105) {
|
if (model == MODEL105) {
|
||||||
inputSourceOptions.add(new StateOption("4", "Optical In"));
|
inputSourceOptions.add(new StateOption("5", getString("optical", "Optical In")));
|
||||||
inputSourceOptions.add(new StateOption("5", "Coaxial In"));
|
inputSourceOptions.add(new StateOption("6", getString("coaxial", "Coaxial In")));
|
||||||
inputSourceOptions.add(new StateOption("6", "USB Audio In"));
|
inputSourceOptions.add(new StateOption("7", getString("usb", "USB Audio In")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model == MODEL203 || model == MODEL205) {
|
if (model == MODEL203 || model == MODEL205) {
|
||||||
hdmiModeOptions.add(new StateOption("AUTO", "Auto"));
|
hdmiModeOptions.add(new StateOption("AUTO", getString("auto", "Auto")));
|
||||||
hdmiModeOptions.add(new StateOption("SRC", "Source Direct"));
|
hdmiModeOptions.add(new StateOption("SRC", getString("direct", "Source Direct")));
|
||||||
hdmiModeOptions.add(new StateOption("UHD_AUTO", "UHD Auto"));
|
hdmiModeOptions.add(new StateOption("UHD_AUTO", getString("auto_uhd", "UHD Auto")));
|
||||||
hdmiModeOptions.add(new StateOption("UHD24", "UHD24"));
|
hdmiModeOptions.add(new StateOption("UHD24", "UHD24"));
|
||||||
hdmiModeOptions.add(new StateOption("UHD50", "UHD50"));
|
hdmiModeOptions.add(new StateOption("UHD50", "UHD50"));
|
||||||
hdmiModeOptions.add(new StateOption("UHD60", "UHD60"));
|
hdmiModeOptions.add(new StateOption("UHD60", "UHD60"));
|
||||||
hdmiModeOptions.add(new StateOption("1080P_AUTO", "1080P Auto"));
|
hdmiModeOptions.add(new StateOption("1080P_AUTO", getString("auto_1080p", "1080P Auto")));
|
||||||
hdmiModeOptions.add(new StateOption("1080P24", "1080P24"));
|
hdmiModeOptions.add(new StateOption("1080P24", "1080P24"));
|
||||||
hdmiModeOptions.add(new StateOption("1080P50", "1080P50"));
|
hdmiModeOptions.add(new StateOption("1080P50", "1080P50"));
|
||||||
hdmiModeOptions.add(new StateOption("1080P60", "1080P60"));
|
hdmiModeOptions.add(new StateOption("1080P60", "1080P60"));
|
||||||
@ -888,18 +904,22 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
|||||||
hdmiModeOptions.add(new StateOption("480P", "480P"));
|
hdmiModeOptions.add(new StateOption("480P", "480P"));
|
||||||
hdmiModeOptions.add(new StateOption("480I", "480I"));
|
hdmiModeOptions.add(new StateOption("480I", "480I"));
|
||||||
|
|
||||||
inputSourceOptions.add(new StateOption("0", "Blu-Ray Player"));
|
inputSourceOptions.add(new StateOption("0", getString("blu_ray", "Blu-ray Player")));
|
||||||
inputSourceOptions.add(new StateOption("1", "HDMI IN"));
|
inputSourceOptions.add(new StateOption("1", getString("hdmi_in", "HDMI In")));
|
||||||
inputSourceOptions.add(new StateOption("2", "ARC"));
|
inputSourceOptions.add(new StateOption("2", getString("arc", "ARC")));
|
||||||
|
|
||||||
if (model == MODEL205) {
|
if (model == MODEL205) {
|
||||||
inputSourceOptions.add(new StateOption("3", "Optical In"));
|
inputSourceOptions.add(new StateOption("3", getString("optical", "Optical In")));
|
||||||
inputSourceOptions.add(new StateOption("4", "Coaxial In"));
|
inputSourceOptions.add(new StateOption("4", getString("coaxial", "Coaxial In")));
|
||||||
inputSourceOptions.add(new StateOption("5", "USB Audio In"));
|
inputSourceOptions.add(new StateOption("5", getString("usb", "USB Audio In")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private @Nullable String getString(String i18nKey, String defaultStr) {
|
||||||
|
return translationProvider.getText(bundle, "option." + i18nKey, defaultStr, localeProvider.getLocale());
|
||||||
|
}
|
||||||
|
|
||||||
private void handleHdmiModeUpdate(String updateData) {
|
private void handleHdmiModeUpdate(String updateData) {
|
||||||
// ugly... a couple of the query hdmi mode response codes on the earlier models don't match the code to set it
|
// ugly... a couple of the query hdmi mode response codes on the earlier models don't match the code to set it
|
||||||
// some of this protocol is weird like that...
|
// some of this protocol is weird like that...
|
||||||
|
@ -163,3 +163,20 @@ channel-type.oppo.zoom_mode.state.option.09 = 4x
|
|||||||
channel-type.oppo.zoom_mode.state.option.10 = 1/2
|
channel-type.oppo.zoom_mode.state.option.10 = 1/2
|
||||||
channel-type.oppo.zoom_mode.state.option.11 = 1/3
|
channel-type.oppo.zoom_mode.state.option.11 = 1/3
|
||||||
channel-type.oppo.zoom_mode.state.option.12 = 1/4
|
channel-type.oppo.zoom_mode.state.option.12 = 1/4
|
||||||
|
|
||||||
|
# selectable player option descriptions
|
||||||
|
|
||||||
|
option.arc = ARC
|
||||||
|
option.arc1 = ARC 1
|
||||||
|
option.arc2 = ARC 2
|
||||||
|
option.auto = Auto
|
||||||
|
option.auto_1080p = 1080P Auto
|
||||||
|
option.auto_uhd = UHD Auto
|
||||||
|
option.blu_ray = Blu-ray Player
|
||||||
|
option.coaxial = Coaxial In
|
||||||
|
option.direct = Source Direct
|
||||||
|
option.hdmi_in = HDMI In
|
||||||
|
option.hdmi_in_back = HDMI In-Back
|
||||||
|
option.hdmi_in_front = HDMI/MHL In-Front
|
||||||
|
option.optical = Optical In
|
||||||
|
option.usb = USB Audio In
|
||||||
|
Loading…
Reference in New Issue
Block a user