diff --git a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoCommand.java b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoCommand.java index 002ca93b008..a11e2cddb9c 100644 --- a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoCommand.java +++ b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoCommand.java @@ -68,14 +68,10 @@ public enum OppoCommand { private final String value; - public static final Set INITIAL_COMMANDS = new HashSet<>( - Arrays.asList(QUERY_POWER_STATUS, QUERY_FIRMWARE_VERSION, QUERY_VOLUME, QUERY_HDMI_RESOLUTION, - QUERY_HDR_SETTING, QUERY_PLAYBACK_STATUS, QUERY_DISC_TYPE, QUERY_AUDIO_TYPE, QUERY_SUBTITLE_SHIFT, - QUERY_OSD_POSITION, QUERY_REPEAT_MODE, QUERY_ZOOM_MODE, QUERY_INPUT_SOURCE)); - public static final Set QUERY_COMMANDS = new HashSet<>( - Arrays.asList(QUERY_VOLUME, QUERY_HDMI_RESOLUTION, QUERY_PLAYBACK_STATUS, QUERY_DISC_TYPE, QUERY_AUDIO_TYPE, - QUERY_SUBTITLE_SHIFT, QUERY_OSD_POSITION, QUERY_REPEAT_MODE, QUERY_ZOOM_MODE, QUERY_INPUT_SOURCE)); + Arrays.asList(QUERY_VOLUME, QUERY_HDMI_RESOLUTION, QUERY_HDR_SETTING, QUERY_PLAYBACK_STATUS, + QUERY_DISC_TYPE, QUERY_AUDIO_TYPE, QUERY_SUBTITLE_SHIFT, QUERY_OSD_POSITION, QUERY_REPEAT_MODE, + QUERY_ZOOM_MODE, QUERY_INPUT_SOURCE, QUERY_FIRMWARE_VERSION)); OppoCommand(String value) { this.value = value; diff --git a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/handler/OppoHandler.java b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/handler/OppoHandler.java index fd100f13480..be9023b48f0 100644 --- a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/handler/OppoHandler.java +++ b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/handler/OppoHandler.java @@ -13,6 +13,7 @@ package org.openhab.binding.oppo.internal.handler; import static org.openhab.binding.oppo.internal.OppoBindingConstants.*; +import static org.openhab.core.thing.Thing.*; import java.math.BigDecimal; import java.util.ArrayList; @@ -88,7 +89,6 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis private List hdmiModeOptions = new ArrayList<>(); private long lastEventReceived = System.currentTimeMillis(); - private String versionString = BLANK; private String verboseMode = VERBOSE_2; private String currentChapter = BLANK; private String currentTimeMode = T; @@ -97,6 +97,8 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis private boolean isPowerOn = false; private boolean isUDP20X = false; private boolean isBdpIP = false; + private boolean isVbModeSet = false; + private boolean isInitialQuery = false; private Object sequenceLock = new Object(); /** @@ -243,7 +245,12 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis if (command instanceof OnOffType) { connector.sendCommand( command == OnOffType.ON ? OppoCommand.POWER_ON : OppoCommand.POWER_OFF); - isPowerOn = (command == OnOffType.ON ? true : false); + + // set the power flag to false only, will be set true by QPW or UPW messages + if (command == OnOffType.OFF) { + isPowerOn = false; + isInitialQuery = false; + } } break; case CHANNEL_VOLUME: @@ -369,7 +376,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis String key = evt.getKey(); String updateData = evt.getValue().trim(); if (this.getThing().getStatus() == ThingStatus.OFFLINE) { - updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE, this.versionString); + updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE); } synchronized (sequenceLock) { @@ -410,7 +417,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis updateChannelState(CHANNEL_TIME_DISPLAY, updateData); break; case QVR: - this.versionString = updateData; + thing.setProperty(PROPERTY_FIRMWARE_VERSION, updateData); break; case QPW: updateChannelState(CHANNEL_POWER, updateData); @@ -426,6 +433,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis if (ZERO.equals(updateData)) { currentPlayMode = BLANK; isPowerOn = false; + isInitialQuery = false; } else { isPowerOn = true; } @@ -578,11 +586,11 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis try { long prevUpdateTime = lastEventReceived; - connector.sendCommand(OppoCommand.SET_VERBOSE_MODE, this.verboseMode); + connector.sendCommand(OppoCommand.QUERY_POWER_STATUS); Thread.sleep(SLEEP_BETWEEN_CMD_MS); // if the player is off most of these won't really do much... - OppoCommand.INITIAL_COMMANDS.forEach(cmd -> { + OppoCommand.QUERY_COMMANDS.forEach(cmd -> { try { connector.sendCommand(cmd); Thread.sleep(SLEEP_BETWEEN_CMD_MS); @@ -606,7 +614,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, error); closeConnection(); } else { - updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE, this.versionString); + updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE); } } } @@ -639,11 +647,20 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis synchronized (sequenceLock) { try { - // if using direct IP connection on the 83/9x/10x, no unsolicited updates are sent + // the verbose mode must be set while the player is on + if (isPowerOn && !isVbModeSet && !isBdpIP) { + connector.sendCommand(OppoCommand.SET_VERBOSE_MODE, this.verboseMode); + isVbModeSet = true; + Thread.sleep(SLEEP_BETWEEN_CMD_MS); + } + + // If using direct serial connection, the query is done once after the player is turned on + // - OR - if using direct IP connection on the 83/9x/10x, no unsolicited updates are sent // so we must query everything to know what changed. - if (isBdpIP) { + if ((isPowerOn && !isInitialQuery) || isBdpIP) { connector.sendCommand(OppoCommand.QUERY_POWER_STATUS); if (isPowerOn) { + isInitialQuery = true; OppoCommand.QUERY_COMMANDS.forEach(cmd -> { try { connector.sendCommand(cmd); diff --git a/bundles/org.openhab.binding.oppo/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.oppo/src/main/resources/OH-INF/thing/channels.xml index d7018bb332c..1c9e6c8dd5e 100644 --- a/bundles/org.openhab.binding.oppo/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.oppo/src/main/resources/OH-INF/thing/channels.xml @@ -6,9 +6,9 @@ - + - An Oppo Blu-ray Disc Player + Controls an Oppo Blu-ray Disc Player