2 * Copyright (c) 2010-2021 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.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaMessage;
20 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaParsingException;
21 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaProperties.OperationMode;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * This command returns the current AC operation mode
28 * @author Benjamin Lafois - Initial contribution
32 public class GetOperationmodeCommand extends BRC1HCommand {
34 private final Logger logger = LoggerFactory.getLogger(GetOperationmodeCommand.class);
36 private @Nullable OperationMode operationMode;
39 public byte[][] getRequest() {
40 return MadokaMessage.createRequest(this);
44 public void handleResponse(Executor executor, ResponseListener listener, MadokaMessage mm)
45 throws MadokaParsingException {
46 byte[] bOperationMode = mm.getValues().get(0x20).getRawValue();
47 if (bOperationMode == null) {
48 setState(State.FAILED);
49 throw new MadokaParsingException("Incorrect operation mode");
52 operationMode = OperationMode.valueOf(bOperationMode[0]);
54 logger.debug("operationMode: {}", operationMode);
56 setState(State.SUCCEEDED);
57 executor.execute(() -> listener.receivedResponse(this));
61 public int getCommandId() {
65 public @Nullable OperationMode getOperationMode() {