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.boschshc.internal.services.batterylevel;
15 import java.util.concurrent.ExecutionException;
16 import java.util.concurrent.TimeoutException;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.boschshc.internal.devices.bridge.BridgeHandler;
21 import org.openhab.binding.boschshc.internal.devices.bridge.dto.DeviceServiceData;
22 import org.openhab.binding.boschshc.internal.exceptions.BoschSHCException;
23 import org.openhab.binding.boschshc.internal.services.BoschSHCService;
26 * Service to retrieve battery levels.
28 * @author David Pace - Initial contribution
32 public class BatteryLevelService extends BoschSHCService<DeviceServiceData> {
34 public BatteryLevelService() {
35 super("BatteryLevel", DeviceServiceData.class);
39 public @Nullable DeviceServiceData getState()
40 throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
41 String deviceId = getDeviceId();
42 if (deviceId == null) {
45 BridgeHandler bridgeHandler = getBridgeHandler();
46 if (bridgeHandler == null) {
49 return bridgeHandler.getServiceData(deviceId, getServiceName());