2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.pjlinkdevice.internal.device.command.mute;
15 import java.util.Arrays;
16 import java.util.HashSet;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.pjlinkdevice.internal.device.command.ErrorCode;
20 import org.openhab.binding.pjlinkdevice.internal.device.command.PrefixedResponse;
21 import org.openhab.binding.pjlinkdevice.internal.device.command.ResponseException;
24 * The response part of {@link MuteQueryCommand}
26 * @author Nils Schnabel - Initial contribution
29 public class MuteQueryResponse extends PrefixedResponse<MuteQueryResponse.MuteQueryResponseValue> {
31 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);
39 private boolean audioMuted;
40 private boolean videoMuted;
42 private MuteQueryResponseValue(String text, String code, boolean audioMuted, boolean videoMuted) {
45 this.audioMuted = audioMuted;
46 this.videoMuted = videoMuted;
49 public String getText() {
53 public static MuteQueryResponseValue parseString(String code) throws ResponseException {
54 for (MuteQueryResponseValue result : MuteQueryResponseValue.values()) {
55 if (result.code.equals(code)) {
60 throw new ResponseException("Cannot understand mute status: " + code);
63 public boolean isAudioMuted() {
64 return this.audioMuted;
67 public boolean isVideoMuted() {
68 return this.videoMuted;
72 private static final HashSet<ErrorCode> SPECIFIED_ERRORCODES = new HashSet<>(
73 Arrays.asList(ErrorCode.UNAVAILABLE_TIME, ErrorCode.DEVICE_FAILURE));
75 public MuteQueryResponse(String response) throws ResponseException {
76 super("AVMT=", SPECIFIED_ERRORCODES, response);
80 protected MuteQueryResponseValue parseResponseWithoutPrefix(String responseWithoutPrefix) throws ResponseException {
81 return MuteQueryResponseValue.parseString(responseWithoutPrefix);