]> git.basschouten.com Git - openhab-addons.git/blob
f4ad2e2d47666f5c6a6fafd3b13c4bee5bbf0d0c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
14
15 import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
16 import org.openhab.binding.lgtvserial.internal.protocol.serial.responses.OnOffResponse;
17 import org.openhab.core.library.types.OnOffType;
18
19 /**
20  * This command is the base command for the On/Off type command which translates to 00/01 on the wire.
21  *
22  * @author Richard Lavoie - Initial contribution
23  *
24  */
25 public abstract class BaseOnOffCommand extends BaseLGSerialCommand {
26
27     protected BaseOnOffCommand(char command1, char command2, int setId) {
28         super(command1, command2, setId, true);
29     }
30
31     @Override
32     protected String computeSerialDataFrom(Object data) {
33         return data == OnOffType.ON ? "01" : "00";
34     }
35
36     @Override
37     protected LGSerialResponse createResponse(int set, boolean success, String data) {
38         return new OnOffResponse(set, success, data);
39     }
40 }