Skip to content

Commit

Permalink
audio/video mute
Browse files Browse the repository at this point in the history
Signed-off-by: Nils Schnabel <github@to.nilsschnabel.de>
  • Loading branch information
nils committed Mar 9, 2024
1 parent 05725de commit 7c428ea
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class PJLinkDeviceBindingConstants {
public static final String CHANNEL_TYPE_INPUT = "input";
public static final String CHANNEL_TYPE_AUDIO_MUTE = "audioMute";
public static final String CHANNEL_TYPE_VIDEO_MUTE = "videoMute";
public static final String CHANNEL_TYPE_AUDIO_AND_VIDEO_MUTE = "audioAndVideoMute";
public static final String CHANNEL_TYPE_LAMP_HOURS = "lampHours";
public static final String CHANNEL_TYPE_LAMP_ACTIVE = "lampActive";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,21 @@ public void handleCommand(ChannelUID channelUID, Command command) {
break;
case CHANNEL_TYPE_AUDIO_MUTE:
case CHANNEL_TYPE_VIDEO_MUTE:
case CHANNEL_TYPE_AUDIO_AND_VIDEO_MUTE:
boolean isAudioMute = channelTypeId.equals(PJLinkDeviceBindingConstants.CHANNEL_TYPE_AUDIO_MUTE);
boolean isVideoMute = channelTypeId.equals(PJLinkDeviceBindingConstants.CHANNEL_TYPE_VIDEO_MUTE);
if (isVideoMute || isAudioMute) {
boolean isAudioAndVideoMute = channelTypeId
.equals(PJLinkDeviceBindingConstants.CHANNEL_TYPE_AUDIO_AND_VIDEO_MUTE);
if (isVideoMute || isAudioMute || isAudioAndVideoMute) {
if (command == RefreshType.REFRESH) {
// refresh both video and audio mute, as it's one request
MuteQueryResponseValue muteStatus = device.getMuteStatus();
updateState(PJLinkDeviceBindingConstants.CHANNEL_AUDIO_MUTE,
OnOffType.from(muteStatus.isAudioMuted()));
updateState(PJLinkDeviceBindingConstants.CHANNEL_VIDEO_MUTE,
OnOffType.from(muteStatus.isVideoMuted()));
updateState(PJLinkDeviceBindingConstants.CHANNEL_TYPE_AUDIO_AND_VIDEO_MUTE,
OnOffType.from(muteStatus.isAudioAndVideoMuted()));
} else {
if (isAudioMute) {
logger.trace("Received audio mute command {}", command);
Expand All @@ -202,6 +207,11 @@ public void handleCommand(ChannelUID channelUID, Command command) {
boolean muteOn = command == OnOffType.ON;
device.setMute(MuteInstructionChannel.VIDEO, muteOn);
}
if (isAudioAndVideoMute) {
logger.trace("Received video mute command {}", command);
boolean muteOn = command == OnOffType.ON;
device.setMute(MuteInstructionChannel.AUDIO_AND_VIDEO_MUTE, muteOn);

Check failure on line 213 in bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/PJLinkDeviceHandler.java

View workflow job for this annotation

GitHub Actions / Build (Java 17, ubuntu-22.04)

AUDIO_AND_VIDEO_MUTE cannot be resolved or is not a field
}
}
} else {
logger.debug("Received unknown audio/video mute command {}", command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,24 @@
public class MuteQueryResponse extends PrefixedResponse<MuteQueryResponse.MuteQueryResponseValue> {

public enum MuteQueryResponseValue {
OFF("Mute off", "30", false, false),
VIDEO_MUTE_ON("Video muted", "11", false, true),
AUDIO_MUTE_ON("Audio muted", "21", true, false),
AUDIO_AND_VIDEO_MUTE_ON("Audio and video muted", "31", true, true);
OFF("Mute off", "30", false, false, false),
VIDEO_MUTE_ON("Video muted", "11", false, true, false),
AUDIO_MUTE_ON("Audio muted", "21", true, false, false),
AUDIO_AND_VIDEO_MUTE_ON("Audio and video muted", "31", false, false, true);

private String text;
private String code;
private boolean audioMuted;
private boolean videoMuted;
private boolean audioAndVideoMuted;

private MuteQueryResponseValue(String text, String code, boolean audioMuted, boolean videoMuted) {
private MuteQueryResponseValue(String text, String code, boolean audioMuted, boolean videoMuted,
boolean audioAndVideoMuted) {
this.text = text;
this.code = code;
this.audioMuted = audioMuted;
this.videoMuted = videoMuted;
this.audioAndVideoMuted = audioAndVideoMuted;
}

public String getText() {
Expand All @@ -67,6 +70,10 @@ public boolean isAudioMuted() {
public boolean isVideoMuted() {
return this.videoMuted;
}

public boolean isAudioAndVideoMuted() {
return this.audioAndVideoMuted;
}
}

private static final HashSet<ErrorCode> SPECIFIED_ERRORCODES = new HashSet<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
<description>Select the video mute status</description>
</channel-type>

<channel-type id="audioAndVideoMute">
<item-type>Switch</item-type>
<label>Audio and Video Mute</label>
<description>Select the audio and video mute status</description>
</channel-type>

<channel-type id="lampHours">
<item-type>Number</item-type>
<label>Lamp Hours</label>
Expand Down

0 comments on commit 7c428ea

Please sign in to comment.