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.globalcache.internal.command;
15 import java.util.concurrent.LinkedBlockingQueue;
17 import org.openhab.binding.globalcache.internal.GlobalCacheBindingConstants.CommandType;
18 import org.openhab.core.thing.Thing;
19 import org.openhab.core.types.Command;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * The {@link CommandSendir} class implements the GlobalCache sendir command, which sends
25 * an infrared command to the device.
27 * @author Mark Hilbush - Initial contribution
29 public class CommandSendir extends AbstractCommand {
31 private final Logger logger = LoggerFactory.getLogger(CommandSendir.class);
33 private String rcvCounter;
36 public CommandSendir(Thing thing, Command command, LinkedBlockingQueue<RequestMessage> queue, String mod,
37 String con, String code, int sendCounter) {
38 super(thing, queue, "sendir", CommandType.COMMAND);
40 this.command = command;
41 deviceCommand = "sendir," + mod + ":" + con + "," + sendCounter + "," + code;
45 public void parseSuccessfulReply() {
46 if (deviceReply == null) {
50 // decode response of form completeir,1:1,<ID>
51 if (deviceReply.startsWith("completeir")) {
52 setModule(deviceReply.substring(11, 12));
53 setConnector(deviceReply.substring(13, 14));
54 setRcvCounter(deviceReply.substring(15));
58 private void setRcvCounter(String c) {
62 public String getRcvCounter() {
67 public void logSuccess() {
68 logger.debug("Execute '{}' succeeded for command {} on thing {} at {}", commandName, command.toString(),
69 thing.getUID().getId(), ipAddress);
73 public void logFailure() {
74 logger.error("Execute '{}' failed on thing {} at {}: errorCode={}, errorMessage={}", commandName,
75 thing.getUID().getId(), ipAddress, errorCode, errorMessage);