Skip to content

Commit 367f8c4

Browse files
nilslsiepel
andauthored
[PJLinkDevice] audio/video mute (openhab#16504)
* audio/video mute Signed-off-by: Nils Schnabel <[email protected]> Co-authored-by: Leo Siepel <[email protected]>
1 parent 330c776 commit 367f8c4

File tree

6 files changed

+50
-6
lines changed

6 files changed

+50
-6
lines changed

bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/PJLinkDeviceBindingConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class PJLinkDeviceBindingConstants {
3636
public static final String CHANNEL_TYPE_INPUT = "input";
3737
public static final String CHANNEL_TYPE_AUDIO_MUTE = "audioMute";
3838
public static final String CHANNEL_TYPE_VIDEO_MUTE = "videoMute";
39+
public static final String CHANNEL_TYPE_AUDIO_AND_VIDEO_MUTE = "audioAndVideoMute";
3940
public static final String CHANNEL_TYPE_LAMP_HOURS = "lampHours";
4041
public static final String CHANNEL_TYPE_LAMP_ACTIVE = "lampActive";
4142

bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/PJLinkDeviceHandler.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,21 @@ public void handleCommand(ChannelUID channelUID, Command command) {
181181
break;
182182
case CHANNEL_TYPE_AUDIO_MUTE:
183183
case CHANNEL_TYPE_VIDEO_MUTE:
184+
case CHANNEL_TYPE_AUDIO_AND_VIDEO_MUTE:
184185
boolean isAudioMute = channelTypeId.equals(PJLinkDeviceBindingConstants.CHANNEL_TYPE_AUDIO_MUTE);
185186
boolean isVideoMute = channelTypeId.equals(PJLinkDeviceBindingConstants.CHANNEL_TYPE_VIDEO_MUTE);
186-
if (isVideoMute || isAudioMute) {
187+
boolean isAudioAndVideoMute = channelTypeId
188+
.equals(PJLinkDeviceBindingConstants.CHANNEL_TYPE_AUDIO_AND_VIDEO_MUTE);
189+
if (isVideoMute || isAudioMute || isAudioAndVideoMute) {
187190
if (command == RefreshType.REFRESH) {
188191
// refresh both video and audio mute, as it's one request
189192
MuteQueryResponseValue muteStatus = device.getMuteStatus();
190193
updateState(PJLinkDeviceBindingConstants.CHANNEL_AUDIO_MUTE,
191194
OnOffType.from(muteStatus.isAudioMuted()));
192195
updateState(PJLinkDeviceBindingConstants.CHANNEL_VIDEO_MUTE,
193196
OnOffType.from(muteStatus.isVideoMuted()));
197+
updateState(PJLinkDeviceBindingConstants.CHANNEL_TYPE_AUDIO_AND_VIDEO_MUTE,
198+
OnOffType.from(muteStatus.isAudioAndVideoMuted()));
194199
} else {
195200
if (isAudioMute) {
196201
logger.trace("Received audio mute command {}", command);
@@ -202,6 +207,11 @@ public void handleCommand(ChannelUID channelUID, Command command) {
202207
boolean muteOn = command == OnOffType.ON;
203208
device.setMute(MuteInstructionChannel.VIDEO, muteOn);
204209
}
210+
if (isAudioAndVideoMute) {
211+
logger.trace("Received video mute command {}", command);
212+
boolean muteOn = command == OnOffType.ON;
213+
device.setMute(MuteInstructionChannel.AUDIO_AND_VIDEO, muteOn);
214+
}
205215
}
206216
} else {
207217
logger.debug("Received unknown audio/video mute command {}", command);

bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/device/command/mute/MuteQueryResponse.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,24 @@
2929
public class MuteQueryResponse extends PrefixedResponse<MuteQueryResponse.MuteQueryResponseValue> {
3030

3131
public enum MuteQueryResponseValue {
32-
OFF("Mute off", "30", false, false),
33-
VIDEO_MUTE_ON("Video muted", "11", false, true),
34-
AUDIO_MUTE_ON("Audio muted", "21", true, false),
35-
AUDIO_AND_VIDEO_MUTE_ON("Audio and video muted", "31", true, true);
32+
OFF("Mute off", "30", false, false, false),
33+
VIDEO_MUTE_ON("Video muted", "11", false, true, false),
34+
AUDIO_MUTE_ON("Audio muted", "21", true, false, false),
35+
AUDIO_AND_VIDEO_MUTE_ON("Audio and video muted", "31", true, true, true);
3636

3737
private String text;
3838
private String code;
3939
private boolean audioMuted;
4040
private boolean videoMuted;
41+
private boolean audioAndVideoMuted;
4142

42-
private MuteQueryResponseValue(String text, String code, boolean audioMuted, boolean videoMuted) {
43+
private MuteQueryResponseValue(String text, String code, boolean audioMuted, boolean videoMuted,
44+
boolean audioAndVideoMuted) {
4345
this.text = text;
4446
this.code = code;
4547
this.audioMuted = audioMuted;
4648
this.videoMuted = videoMuted;
49+
this.audioAndVideoMuted = audioAndVideoMuted;
4750
}
4851

4952
public String getText() {
@@ -67,6 +70,10 @@ public boolean isAudioMuted() {
6770
public boolean isVideoMuted() {
6871
return this.videoMuted;
6972
}
73+
74+
public boolean isAudioAndVideoMuted() {
75+
return this.audioAndVideoMuted;
76+
}
7077
}
7178

7279
private static final HashSet<ErrorCode> SPECIFIED_ERRORCODES = new HashSet<>(

bundles/org.openhab.binding.pjlinkdevice/src/main/resources/OH-INF/i18n/pjLinkDevice.properties

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ thing-type.config.pjLinkDevice.pjLinkDevice.tcpPort.description = The TCP port o
3434

3535
# channel types
3636

37+
channel-type.pjLinkDevice.audioAndVideoMute.label = Audio and Video Mute
38+
channel-type.pjLinkDevice.audioAndVideoMute.description = Select the audio and video mute status
3739
channel-type.pjLinkDevice.audioMute.label = Audio Mute
3840
channel-type.pjLinkDevice.audioMute.description = Select the audio mute status
3941
channel-type.pjLinkDevice.input.label = Input

bundles/org.openhab.binding.pjlinkdevice/src/main/resources/OH-INF/thing/thing-types.xml

+11
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
<channel id="input" typeId="input"/>
1414
<channel id="audioMute" typeId="audioMute"/>
1515
<channel id="videoMute" typeId="videoMute"/>
16+
<channel id="audioAndVideoMute" typeId="audioAndVideoMute"/>
1617
<channel id="lamp1Hours" typeId="lampHours"/>
1718
<channel id="lamp1Active" typeId="lampActive"/>
1819
</channels>
1920

21+
<properties>
22+
<property name="thingTypeVersion">1</property>
23+
</properties>
24+
2025
<config-description>
2126
<parameter-group name="basic">
2227
<context>basic</context>
@@ -103,6 +108,12 @@
103108
<description>Select the video mute status</description>
104109
</channel-type>
105110

111+
<channel-type id="audioAndVideoMute">
112+
<item-type>Switch</item-type>
113+
<label>Audio and Video Mute</label>
114+
<description>Select the audio and video mute status</description>
115+
</channel-type>
116+
106117
<channel-type id="lampHours">
107118
<item-type>Number</item-type>
108119
<label>Lamp Hours</label>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2+
<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
4+
xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
5+
<thing-type uid="pjLinkDevice:pjLinkDevice">
6+
<instruction-set targetVersion="1">
7+
<add-channel id="audioAndVideoMute">
8+
<type>pjLinkDevice:audioAndVideoMute</type>
9+
</add-channel>
10+
</instruction-set>
11+
</thing-type>
12+
13+
</update:update-descriptions>

0 commit comments

Comments
 (0)