]> git.basschouten.com Git - openhab-addons.git/blob
3fec489850e5c7238fafe5b3da722f1f219f78a4
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.mqtt.generic;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * Interface to keep track of the availability of device using an availability topic or messages received
20  *
21  * @author Jochen Klein - Initial contribution
22  */
23 @NonNullByDefault
24 public interface AvailabilityTracker {
25
26     /**
27      * Adds an availability topic to determine the availability of a device.
28      * <p>
29      * Availability topics are usually set by the device as LWT.
30      *
31      * @param availability_topic
32      * @param payload_available
33      * @param payload_not_available
34      */
35     public void addAvailabilityTopic(String availability_topic, String payload_available, String payload_not_available);
36
37     /**
38      * Adds an availability topic to determine the availability of a device.
39      * <p>
40      * Availability topics are usually set by the device as LWT.
41      *
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).
49      */
50     public void addAvailabilityTopic(String availability_topic, String payload_available, String payload_not_available,
51             @Nullable String transformation_pattern,
52             @Nullable TransformationServiceProvider transformationServiceProvider);
53
54     public void removeAvailabilityTopic(String availability_topic);
55
56     public void clearAllAvailabilityTopics();
57
58     /**
59      * resets the indicator, if messages have been received.
60      * <p>
61      * This is used to time out the availability of the device after some time without receiving a message.
62      */
63     public void resetMessageReceived();
64 }