2 * Copyright (c) 2010-2024 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.govee.internal.command.hygrometer;
15 import java.util.concurrent.CompletableFuture;
17 import javax.measure.quantity.Dimensionless;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.core.library.types.QuantityType;
22 import org.openhab.core.library.unit.Units;
25 * @author Connor Petty - Initial Contribution
29 public class GetBatteryCommand extends GetCommand {
31 private CompletableFuture<@Nullable QuantityType<Dimensionless>> resultHandler;
33 public GetBatteryCommand(CompletableFuture<@Nullable QuantityType<Dimensionless>> resultHandler) {
34 this.resultHandler = resultHandler;
38 public byte getCommandCode() {
43 public void handleResponse(byte @Nullable [] data, @Nullable Throwable th) {
45 resultHandler.completeExceptionally(th);
48 int value = data[0] & 0xFF;
49 resultHandler.complete(new QuantityType<Dimensionless>(value, Units.PERCENT));
51 resultHandler.complete(null);