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.webthing.internal.client;
15 import java.util.function.BiConsumer;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.webthing.internal.client.dto.WebThingDescription;
21 * A WebThing represents the client-side proxy of a remote devices implementing the Web Thing API according to
22 * https://iot.mozilla.org/wot/
23 * The API design is oriented on https://www.w3.org/TR/wot-scripting-api/#the-consumedthing-interface
25 * @author Gregor Roth - Initial contribution
28 public interface ConsumedThing {
31 * @return the description (meta data) of the WebThing
33 WebThingDescription getThingDescription();
36 * Makes a request for Property value change notifications
38 * @param propertyName the property to be observed
39 * @param listener the listener to call on changes
41 void observeProperty(String propertyName, BiConsumer<String, Object> listener);
44 * Writes a single Property.
46 * @param propertyName the propertyName
47 * @return the current propertyValue
48 * @throws PropertyAccessException if the property can not be read
50 Object readProperty(String propertyName) throws PropertyAccessException;
53 * Writes a single Property.
55 * @param propertyName the propertyName
56 * @param newValue the new propertyValue
57 * @throws PropertyAccessException if the property can not be written
59 void writeProperty(String propertyName, Object newValue) throws PropertyAccessException;
62 * @return true, if connection is alive
67 * closes the connection