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.io.homekit.internal.accessories;
15 import static org.openhab.io.homekit.internal.HomekitCharacteristicType.FILTER_CHANGE_INDICATION;
17 import java.util.List;
18 import java.util.concurrent.CompletableFuture;
20 import org.openhab.io.homekit.internal.HomekitAccessoryUpdater;
21 import org.openhab.io.homekit.internal.HomekitSettings;
22 import org.openhab.io.homekit.internal.HomekitTaggedItem;
24 import io.github.hapjava.accessories.FilterMaintenanceAccessory;
25 import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
26 import io.github.hapjava.characteristics.impl.filtermaintenance.FilterChangeIndicationEnum;
27 import io.github.hapjava.services.impl.FilterMaintenanceService;
30 * Implements filter maintenance indicator
32 * @author Eugen Freiter - Initial contribution
34 public class HomekitFilterMaintenanceImpl extends AbstractHomekitAccessoryImpl implements FilterMaintenanceAccessory {
35 private BooleanItemReader filterChangeIndication;
37 public HomekitFilterMaintenanceImpl(HomekitTaggedItem taggedItem, List<HomekitTaggedItem> mandatoryCharacteristics,
38 HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException {
39 super(taggedItem, mandatoryCharacteristics, updater, settings);
40 filterChangeIndication = createBooleanReader(FILTER_CHANGE_INDICATION);
41 getServices().add(new FilterMaintenanceService(this));
45 public CompletableFuture<FilterChangeIndicationEnum> getFilterChangeIndication() {
46 return CompletableFuture
47 .completedFuture(filterChangeIndication.getValue() ? FilterChangeIndicationEnum.CHANGE_NEEDED
48 : FilterChangeIndicationEnum.NO_CHANGE_NEEDED);
52 public void subscribeFilterChangeIndication(final HomekitCharacteristicChangeCallback callback) {
53 subscribe(FILTER_CHANGE_INDICATION, callback);
57 public void unsubscribeFilterChangeIndication() {
58 unsubscribe(FILTER_CHANGE_INDICATION);