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.bluetooth.daikinmadoka.internal.model.commands;
15 import java.util.concurrent.Executor;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaMessage;
19 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaProperties.OperationMode;
20 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaValue;
21 import org.openhab.core.util.HexUtils;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * This command is in charge of changing the current operation mode
28 * @author Benjamin Lafois - Initial contribution
32 public class SetOperationmodeCommand extends BRC1HCommand {
34 private final Logger logger = LoggerFactory.getLogger(SetOperationmodeCommand.class);
36 private OperationMode operationMode;
38 public SetOperationmodeCommand(OperationMode operationMode) {
39 this.operationMode = operationMode;
43 public byte[][] getRequest() {
44 MadokaValue mv = new MadokaValue(0x20, 1, new byte[] { (byte) this.operationMode.value() });
45 return MadokaMessage.createRequest(this, mv);
49 public void handleResponse(Executor executor, ResponseListener listener, MadokaMessage mm) {
50 byte[] msg = mm.getRawMessage();
51 if (logger.isDebugEnabled() && msg != null) {
52 logger.debug("Got response for {} : {}", this.getClass().getSimpleName(), HexUtils.bytesToHex(msg));
55 setState(State.SUCCEEDED);
56 executor.execute(() -> listener.receivedResponse(this));
60 public int getCommandId() {
64 public OperationMode getOperationMode() {