import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.EXECUTE_ACTION;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
+import org.openhab.core.thing.ThingStatus;
+import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.types.Command;
/**
}
@Override
- protected boolean isAlwaysOnline() {
- return true;
+ public void initializeThing(@Nullable ThingStatus bridgeStatus) {
+ if (bridgeStatus != null) {
+ if (bridgeStatus == ThingStatus.ONLINE) {
+ updateStatus(ThingStatus.ONLINE);
+ } else {
+ updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
+ }
+ } else {
+ updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
+ }
}
@Override
return logger;
}
- protected boolean isAlwaysOnline() {
- return false;
- }
-
protected @Nullable SomfyTahomaBridgeHandler getBridgeHandler() {
Bridge localBridge = this.getBridge();
return localBridge != null ? (SomfyTahomaBridgeHandler) localBridge.getHandler() : null;
}
private void setUnavailable() {
- if (ThingStatus.OFFLINE != thing.getStatus() && !isAlwaysOnline()) {
+ if (ThingStatus.OFFLINE != thing.getStatus()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, UNAVAILABLE);
}
}
*/
package org.openhab.binding.somfytahoma.internal.handler;
+import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.STATUS;
import static org.openhab.core.thing.Thing.PROPERTY_FIRMWARE_VERSION;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.somfytahoma.internal.model.SomfyTahomaStatus;
import org.openhab.core.library.types.StringType;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
+import org.openhab.core.thing.ThingStatusDetail;
/**
* The {@link SomfyTahomaGatewayHandler} is responsible for handling commands,
super(thing);
}
+ @Override
+ public void initializeThing(@Nullable ThingStatus bridgeStatus) {
+ if (bridgeStatus != null) {
+ if (bridgeStatus == ThingStatus.ONLINE) {
+ refresh(STATUS);
+ } else {
+ updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
+ }
+ } else {
+ updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
+ }
+ }
+
@Override
public void refresh(String channel) {
String id = getGateWayId();