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.mqtt.generic;
15 import java.util.List;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
20 * Interface to keep track of the availability of device using an availability topic or messages received
22 * @author Jochen Klein - Initial contribution
23 * @author Cody Cutrer - Support all/any/latest
26 public interface AvailabilityTracker {
28 * controls the conditions needed to set the entity to available
30 enum AvailabilityMode {
32 * payload_available must be received on all configured availability topics before the entity is marked as
38 * payload_available must be received on at least one configured availability topic before the entity is marked
44 * the last payload_available or payload_not_available received on any configured availability topic controls
51 * Sets how multiple availability topics are treated
53 void setAvailabilityMode(AvailabilityMode mode);
56 * Adds an availability topic to determine the availability of a device.
58 * Availability topics are usually set by the device as LWT.
60 * @param availability_topic
61 * @param payload_available
62 * @param payload_not_available
64 void addAvailabilityTopic(String availability_topic, String payload_available, String payload_not_available);
67 * Adds an availability topic to determine the availability of a device.
69 * Availability topics are usually set by the device as LWT.
71 * @param availability_topic The MQTT topic where availability is published to.
72 * @param payload_available The value for the topic to indicate the device is online.
73 * @param payload_not_available The value for the topic to indicate the device is offline.
74 * @param transformation_pattern A transformation pattern to process the value before comparing to
75 * payload_available/payload_not_available.
77 void addAvailabilityTopic(String availability_topic, String payload_available, String payload_not_available,
78 List<String> transformation_pattern);
80 void removeAvailabilityTopic(String availability_topic);
82 void clearAllAvailabilityTopics();
85 * resets the indicator, if messages have been received.
87 * This is used to time out the availability of the device after some time without receiving a message.
89 void resetMessageReceived();