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.shelly.internal.handler;
15 import java.util.List;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.eclipse.jetty.client.HttpClient;
21 import org.openhab.binding.shelly.internal.api.ShellyApiException;
22 import org.openhab.binding.shelly.internal.api.ShellyApiInterface;
23 import org.openhab.binding.shelly.internal.api.ShellyDeviceProfile;
24 import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellySettingsStatus;
25 import org.openhab.binding.shelly.internal.config.ShellyThingConfiguration;
26 import org.openhab.core.thing.Channel;
27 import org.openhab.core.thing.Thing;
28 import org.openhab.core.thing.ThingStatus;
29 import org.openhab.core.thing.ThingStatusDetail;
30 import org.openhab.core.thing.type.ChannelTypeUID;
31 import org.openhab.core.types.State;
32 import org.openhab.core.types.StateOption;
35 * The {@link ShellyThingInterface} implements the interface for Shelly Manager to access the thing handler
37 * @author Markus Michels - Initial contribution
40 public interface ShellyThingInterface {
42 ShellyDeviceProfile getProfile(boolean forceRefresh) throws ShellyApiException;
45 List<StateOption> getStateOptions(ChannelTypeUID uid);
47 double getChannelDouble(String group, String channel);
49 boolean updateChannel(String group, String channel, State value);
51 boolean updateChannel(String channelId, State value, boolean force);
53 void setThingOnline();
55 void setThingOffline(ThingStatusDetail detail, String messageKey, Object... arguments);
57 String getThingType();
59 ThingStatus getThingStatus();
61 ThingStatusDetail getThingStatusDetail();
63 boolean isThingOnline();
65 boolean requestUpdates(int requestCount, boolean refreshSettings);
67 void triggerUpdateFromCoap();
69 void reinitializeThing();
71 void restartWatchdog();
73 void publishState(String channelId, State value);
75 boolean areChannelsCreated();
77 State getChannelValue(String group, String channel);
79 boolean updateInputs(ShellySettingsStatus status);
81 void updateChannelDefinitions(Map<String, Channel> dynChannels);
83 void postEvent(String event, boolean force);
85 void triggerChannel(String group, String channelID, String event);
87 void triggerButton(String group, int idx, String value);
89 ShellyDeviceStats getStats();
95 String getThingName();
97 ShellyThingConfiguration getThingConfig();
99 HttpClient getHttpClient();
101 String getProperty(String key);
103 void updateProperties(String key, String value);
105 boolean updateWakeupReason(@Nullable List<Object> valueArray);
107 ShellyApiInterface getApi();
109 ShellyDeviceProfile getProfile();
111 long getScheduledUpdates();
113 void fillDeviceStatus(ShellySettingsStatus status, boolean updated);
115 boolean checkRepresentation(String key);
117 void incProtMessages();
119 void incProtErrors();