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.anthem.internal.handler;
15 import static org.openhab.binding.anthem.internal.AnthemBindingConstants.COMMAND_TERMINATION_CHAR;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
20 * The {@link AnthemCommand} is responsible for creating commands to be sent to the
23 * @author Mark Hilbush - Initial contribution
26 public class AnthemCommand {
27 private static final String COMMAND_TERMINATOR = String.valueOf(COMMAND_TERMINATION_CHAR);
29 private String command = "";
31 public AnthemCommand(String command) {
32 this.command = command;
35 public static AnthemCommand powerOn(Zone zone) {
36 return new AnthemCommand(String.format("Z%sPOW1", zone.getValue()));
39 public static AnthemCommand powerOff(Zone zone) {
40 return new AnthemCommand(String.format("Z%sPOW0", zone.getValue()));
43 public static AnthemCommand volumeUp(Zone zone, int amount) {
44 return new AnthemCommand(String.format("Z%sVUP%02d", zone.getValue(), amount));
47 public static AnthemCommand volumeDown(Zone zone, int amount) {
48 return new AnthemCommand(String.format("Z%sVDN%02d", zone.getValue(), amount));
51 public static AnthemCommand volume(Zone zone, int level) {
52 return new AnthemCommand(String.format("Z%sVOL%02d", zone.getValue(), level));
55 public static AnthemCommand muteOn(Zone zone) {
56 return new AnthemCommand(String.format("Z%sMUT1", zone.getValue()));
59 public static AnthemCommand muteOff(Zone zone) {
60 return new AnthemCommand(String.format("Z%sMUT0", zone.getValue()));
63 public static AnthemCommand activeInput(Zone zone, int input) {
64 return new AnthemCommand(String.format("Z%sINP%02d", zone.getValue(), input));
67 public static AnthemCommand queryPower(Zone zone) {
68 return new AnthemCommand(String.format("Z%sPOW?", zone.getValue()));
71 public static AnthemCommand queryVolume(Zone zone) {
72 return new AnthemCommand(String.format("Z%sVOL?", zone.getValue()));
75 public static AnthemCommand queryMute(Zone zone) {
76 return new AnthemCommand(String.format("Z%sMUT?", zone.getValue()));
79 public static AnthemCommand queryActiveInput(Zone zone) {
80 return new AnthemCommand(String.format("Z%sINP?", zone.getValue()));
83 public static AnthemCommand queryNumAvailableInputs() {
84 return new AnthemCommand(String.format("ICN?"));
87 public static AnthemCommand queryInputShortName(int input) {
88 return new AnthemCommand(String.format("ISN%02d?", input));
91 public static AnthemCommand queryInputLongName(int input) {
92 return new AnthemCommand(String.format("ILN%02d?", input));
95 public static AnthemCommand queryModel() {
96 return new AnthemCommand("IDM?");
99 public static AnthemCommand queryRegion() {
100 return new AnthemCommand("IDR?");
103 public static AnthemCommand querySoftwareVersion() {
104 return new AnthemCommand("IDS?");
107 public static AnthemCommand querySoftwareBuildDate() {
108 return new AnthemCommand("IDB?");
111 public static AnthemCommand queryHardwareVersion() {
112 return new AnthemCommand("IDH?");
115 public static AnthemCommand queryMacAddress() {
116 return new AnthemCommand("IDN?");
119 public static AnthemCommand customCommand(String customCommand) {
120 return new AnthemCommand(customCommand);
123 public String getCommand() {
124 return command + COMMAND_TERMINATOR;
128 public String toString() {