]> git.basschouten.com Git - openhab-addons.git/commitdiff
[PJLinkDevice] audio/video mute (#16504)
authorNils Schnabel <nils@users.noreply.github.com>
Tue, 21 May 2024 09:45:26 +0000 (11:45 +0200)
committerGitHub <noreply@github.com>
Tue, 21 May 2024 09:45:26 +0000 (11:45 +0200)
* audio/video mute

Signed-off-by: Nils Schnabel <github@to.nilsschnabel.de>
Co-authored-by: Leo Siepel <leosiepel@gmail.com>
bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/PJLinkDeviceBindingConstants.java
bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/PJLinkDeviceHandler.java
bundles/org.openhab.binding.pjlinkdevice/src/main/java/org/openhab/binding/pjlinkdevice/internal/device/command/mute/MuteQueryResponse.java
bundles/org.openhab.binding.pjlinkdevice/src/main/resources/OH-INF/i18n/pjLinkDevice.properties
bundles/org.openhab.binding.pjlinkdevice/src/main/resources/OH-INF/thing/thing-types.xml
bundles/org.openhab.binding.pjlinkdevice/src/main/resources/OH-INF/update/instructions.xml [new file with mode: 0644]

index 4895fa0bcf349e65d71016468f6f44acd7ad1437..33eb0b91fb657b2b082c7f7e137d01851a60b884 100644 (file)
@@ -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";
 
index 76f45dafd16a1fb38003a907c7bd55d0f303bf43..2fd759cf1cc6b8ff36955372177eec2090002454 100644 (file)
@@ -181,9 +181,12 @@ public class PJLinkDeviceHandler extends BaseThingHandler {
                     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();
@@ -191,6 +194,8 @@ public class PJLinkDeviceHandler extends BaseThingHandler {
                                     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);
@@ -202,6 +207,11 @@ public class PJLinkDeviceHandler extends BaseThingHandler {
                                 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, muteOn);
+                            }
                         }
                     } else {
                         logger.debug("Received unknown audio/video mute command {}", command);
index 50bf5ef8c776c0c9600734b8cc9b520eb6a6ae80..b56625247ee409e6b9a500b60cb5b26ee6fdd3ac 100644 (file)
@@ -29,21 +29,24 @@ import org.openhab.binding.pjlinkdevice.internal.device.command.ResponseExceptio
 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", true, true, 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() {
@@ -67,6 +70,10 @@ public class MuteQueryResponse extends PrefixedResponse<MuteQueryResponse.MuteQu
         public boolean isVideoMuted() {
             return this.videoMuted;
         }
+
+        public boolean isAudioAndVideoMuted() {
+            return this.audioAndVideoMuted;
+        }
     }
 
     private static final HashSet<ErrorCode> SPECIFIED_ERRORCODES = new HashSet<>(
index 407416c4658f06a79f88ef3e4e7d199ba7dbdc0f..4dc05cfda9145f263e5b31f7fa9214bf86022f52 100644 (file)
@@ -34,6 +34,8 @@ thing-type.config.pjLinkDevice.pjLinkDevice.tcpPort.description = The TCP port o
 
 # channel types
 
+channel-type.pjLinkDevice.audioAndVideoMute.label = Audio and Video Mute
+channel-type.pjLinkDevice.audioAndVideoMute.description = Select the audio and video mute status
 channel-type.pjLinkDevice.audioMute.label = Audio Mute
 channel-type.pjLinkDevice.audioMute.description = Select the audio mute status
 channel-type.pjLinkDevice.input.label = Input
index b70918c9a992535bd9073fee1ad011514831b3d6..9e20e7a1a47b33080e5073bdabbf0e6e8dea0012 100644 (file)
                        <channel id="input" typeId="input"/>
                        <channel id="audioMute" typeId="audioMute"/>
                        <channel id="videoMute" typeId="videoMute"/>
+                       <channel id="audioAndVideoMute" typeId="audioAndVideoMute"/>
                        <channel id="lamp1Hours" typeId="lampHours"/>
                        <channel id="lamp1Active" typeId="lampActive"/>
                </channels>
 
+               <properties>
+                       <property name="thingTypeVersion">1</property>
+               </properties>
+
                <config-description>
                        <parameter-group name="basic">
                                <context>basic</context>
                <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>
diff --git a/bundles/org.openhab.binding.pjlinkdevice/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.pjlinkdevice/src/main/resources/OH-INF/update/instructions.xml
new file mode 100644 (file)
index 0000000..82f5100
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
+       xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
+       <thing-type uid="pjLinkDevice:pjLinkDevice">
+               <instruction-set targetVersion="1">
+                       <add-channel id="audioAndVideoMute">
+                               <type>pjLinkDevice:audioAndVideoMute</type>
+                       </add-channel>
+               </instruction-set>
+       </thing-type>
+
+</update:update-descriptions>