Fix initialization of shade handler. (#11707)

Fixes #11702

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
jlaur 2021-12-05 17:48:37 +01:00 committed by GitHub
parent 112d2653a7
commit b28a3f3765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 6 deletions

View File

@ -135,7 +135,7 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler {
if (host == null || host.isEmpty()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.conf-error-no-host-address");
"@text/offline.conf-error.no-host-address");
return;
}

View File

@ -39,6 +39,7 @@ import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StopMoveType;
import org.openhab.core.library.types.UpDownType;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -80,14 +81,25 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
getShadeId();
} catch (NumberFormatException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Configuration 'id' not a valid integer");
"@text/offline.conf-error.invalid-id");
return;
}
if (getBridgeHandler() == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Hub not configured");
Bridge bridge = getBridge();
if (bridge == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
return;
}
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
if (!(bridge.getHandler() instanceof HDPowerViewHubHandler)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"@text/offline.conf-error.invalid-bridge-handler");
return;
}
ThingStatus bridgeStatus = bridge.getStatus();
if (bridgeStatus == ThingStatus.ONLINE) {
updateStatus(ThingStatus.ONLINE);
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
}
}
@Override

View File

@ -36,7 +36,9 @@ channel-type.hdpowerview.shade-vane.description = The opening of the slats in th
# thing status descriptions
offline.conf-error-no-host-address = Host address must be set
offline.conf-error.no-host-address = Host address must be set
offline.conf-error.invalid-id = Configuration 'id' not a valid integer
offline.conf-error.invalid-bridge-handler = Invalid bridge handler
# dynamic channels