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.lgtvserial.internal.protocol.serial.commands;
15 import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
16 import org.openhab.binding.lgtvserial.internal.protocol.serial.responses.StringResponse;
19 * This command is the base command for the On/Off type command which translates to 00/01 on the wire.
21 * @author Richard Lavoie - Initial contribution
24 public abstract class BaseStringCommand extends BaseLGSerialCommand {
26 protected BaseStringCommand(char command1, char command2, int setId) {
27 super(command1, command2, setId, true);
30 public BaseStringCommand(char command1, char command2, int setId, boolean updatable) {
31 super(command1, command2, setId, updatable);
35 public LGSerialResponse parseResponse(String response) {
36 int set = Integer.parseInt(response.substring(2, 4), 16);
37 boolean success = 'O' == response.charAt(5) && 'K' == response.charAt(6);
39 return new StringResponse(set, success, response.substring(7));
43 protected String computeSerialDataFrom(Object data) {
44 return data.toString();
48 protected LGSerialResponse createResponse(int set, boolean success, String data) {
49 return new StringResponse(set, success, data);