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.mqtt.generic;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
19 * Interface to keep track of the availability of device using an availability topic or messages received
21 * @author Jochen Klein - Initial contribution
24 public interface AvailabilityTracker {
27 * Adds an availability topic to determine the availability of a device.
29 * Availability topics are usually set by the device as LWT.
31 * @param availability_topic
32 * @param payload_available
33 * @param payload_not_available
35 public void addAvailabilityTopic(String availability_topic, String payload_available, String payload_not_available);
38 * Adds an availability topic to determine the availability of a device.
40 * Availability topics are usually set by the device as LWT.
42 * @param availability_topic The MQTT topic where availability is published to.
43 * @param payload_available The value for the topic to indicate the device is online.
44 * @param payload_not_available The value for the topic to indicate the device is offline.
45 * @param transformation_pattern A transformation pattern to process the value before comparing to
46 * payload_available/payload_not_available.
47 * @param transformationServiceProvider The service provider to obtain the transformation service (required only if
48 * transformation_pattern is not null).
50 public void addAvailabilityTopic(String availability_topic, String payload_available, String payload_not_available,
51 @Nullable String transformation_pattern,
52 @Nullable TransformationServiceProvider transformationServiceProvider);
54 public void removeAvailabilityTopic(String availability_topic);
56 public void clearAllAvailabilityTopics();
59 * resets the indicator, if messages have been received.
61 * This is used to time out the availability of the device after some time without receiving a message.
63 public void resetMessageReceived();