[hdpowerview] Remove unnecessary init checks and fix Thing status detail (#12331)

* [hdpowerview] Remove unnecessary init checks and fix Thing status detail

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
This commit is contained in:
Fabian Wolter 2022-02-28 22:53:33 +01:00 committed by GitHub
parent dd687435ec
commit d35e96ab3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 22 deletions

View File

@ -311,7 +311,7 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler {
// exceptions are logged in HDPowerViewWebTargets
} catch (HubException e) {
logger.warn("Error connecting to bridge: {}", e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
}
}

View File

@ -67,18 +67,9 @@ public class HDPowerViewRepeaterHandler extends AbstractHubbedThingHandler {
public void initialize() {
repeaterId = getConfigAs(HDPowerViewRepeaterConfiguration.class).id;
logger.debug("Initializing repeater handler for repeater {}", repeaterId);
if (repeaterId <= 0) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.conf-error.invalid-id");
return;
}
Bridge bridge = getBridge();
if (bridge == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
return;
}
if (!(bridge.getHandler() instanceof HDPowerViewHubHandler)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.conf-error.invalid-bridge-handler");
return;
}

View File

@ -94,21 +94,13 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
isDisposing = false;
shadeId = getConfigAs(HDPowerViewShadeConfiguration.class).id;
logger.debug("Initializing shade handler for shade {}", shadeId);
if (shadeId <= 0) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.conf-error.invalid-id");
return;
}
Bridge bridge = getBridge();
if (bridge == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED);
return;
}
if (!(bridge.getHandler() instanceof HDPowerViewHubHandler)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/offline.conf-error.invalid-bridge-handler");
return;
}
updateStatus(ThingStatus.UNKNOWN);
}

View File

@ -52,7 +52,6 @@ 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.invalid-id = Configuration 'id' not a valid integer
offline.conf-error.invalid-bridge-handler = Invalid bridge handler
offline.gone.shade-unknown-to-hub = Shade is unknown to Hub