[somfytahoma] Fixed bug causing Gateway and Actiongroups get never ONLINE (#10355)

Signed-off-by: Ondrej Pecta <opecta@gmail.com>
This commit is contained in:
Ondrej Pecta
2021-03-28 18:52:33 +02:00
committed by GitHub
parent d2edd69f36
commit 89ae8afa49
3 changed files with 30 additions and 7 deletions

View File

@@ -15,9 +15,12 @@ package org.openhab.binding.somfytahoma.internal.handler;
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;
/**
@@ -34,8 +37,16 @@ public class SomfyTahomaActionGroupHandler extends SomfyTahomaBaseThingHandler {
}
@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

View File

@@ -146,10 +146,6 @@ public abstract class SomfyTahomaBaseThingHandler extends BaseThingHandler {
return logger;
}
protected boolean isAlwaysOnline() {
return false;
}
protected @Nullable SomfyTahomaBridgeHandler getBridgeHandler() {
Bridge localBridge = this.getBridge();
return localBridge != null ? (SomfyTahomaBridgeHandler) localBridge.getHandler() : null;
@@ -167,7 +163,7 @@ public abstract class SomfyTahomaBaseThingHandler extends BaseThingHandler {
}
private void setUnavailable() {
if (ThingStatus.OFFLINE != thing.getStatus() && !isAlwaysOnline()) {
if (ThingStatus.OFFLINE != thing.getStatus()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, UNAVAILABLE);
}
}

View File

@@ -12,14 +12,17 @@
*/
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,
@@ -34,6 +37,19 @@ public class SomfyTahomaGatewayHandler extends SomfyTahomaBaseThingHandler {
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();