[somfytahoma] Fixed bug causing Gateway and Actiongroups get never ONLINE (#10355)
Signed-off-by: Ondrej Pecta <opecta@gmail.com>
This commit is contained in:
@@ -15,9 +15,12 @@ package org.openhab.binding.somfytahoma.internal.handler;
|
|||||||
import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.EXECUTE_ACTION;
|
import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.EXECUTE_ACTION;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
import org.openhab.core.thing.ThingStatus;
|
||||||
|
import org.openhab.core.thing.ThingStatusDetail;
|
||||||
import org.openhab.core.types.Command;
|
import org.openhab.core.types.Command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,8 +37,16 @@ public class SomfyTahomaActionGroupHandler extends SomfyTahomaBaseThingHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isAlwaysOnline() {
|
public void initializeThing(@Nullable ThingStatus bridgeStatus) {
|
||||||
return true;
|
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
|
@Override
|
||||||
|
|||||||
@@ -146,10 +146,6 @@ public abstract class SomfyTahomaBaseThingHandler extends BaseThingHandler {
|
|||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAlwaysOnline() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected @Nullable SomfyTahomaBridgeHandler getBridgeHandler() {
|
protected @Nullable SomfyTahomaBridgeHandler getBridgeHandler() {
|
||||||
Bridge localBridge = this.getBridge();
|
Bridge localBridge = this.getBridge();
|
||||||
return localBridge != null ? (SomfyTahomaBridgeHandler) localBridge.getHandler() : null;
|
return localBridge != null ? (SomfyTahomaBridgeHandler) localBridge.getHandler() : null;
|
||||||
@@ -167,7 +163,7 @@ public abstract class SomfyTahomaBaseThingHandler extends BaseThingHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setUnavailable() {
|
private void setUnavailable() {
|
||||||
if (ThingStatus.OFFLINE != thing.getStatus() && !isAlwaysOnline()) {
|
if (ThingStatus.OFFLINE != thing.getStatus()) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, UNAVAILABLE);
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, UNAVAILABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.somfytahoma.internal.handler;
|
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 static org.openhab.core.thing.Thing.PROPERTY_FIRMWARE_VERSION;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.somfytahoma.internal.model.SomfyTahomaStatus;
|
import org.openhab.binding.somfytahoma.internal.model.SomfyTahomaStatus;
|
||||||
import org.openhab.core.library.types.StringType;
|
import org.openhab.core.library.types.StringType;
|
||||||
import org.openhab.core.thing.Channel;
|
import org.openhab.core.thing.Channel;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
import org.openhab.core.thing.ThingStatus;
|
import org.openhab.core.thing.ThingStatus;
|
||||||
|
import org.openhab.core.thing.ThingStatusDetail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link SomfyTahomaGatewayHandler} is responsible for handling commands,
|
* The {@link SomfyTahomaGatewayHandler} is responsible for handling commands,
|
||||||
@@ -34,6 +37,19 @@ public class SomfyTahomaGatewayHandler extends SomfyTahomaBaseThingHandler {
|
|||||||
super(thing);
|
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
|
@Override
|
||||||
public void refresh(String channel) {
|
public void refresh(String channel) {
|
||||||
String id = getGateWayId();
|
String id = getGateWayId();
|
||||||
|
|||||||
Reference in New Issue
Block a user