Skip to content

Commit

Permalink
[hdpowerview] Remove unnecessary init checks and fix Thing status det…
Browse files Browse the repository at this point in the history
…ail (#12331)

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

Signed-off-by: Fabian Wolter <[email protected]>
  • Loading branch information
fwolter authored Feb 28, 2022
1 parent dd68743 commit d35e96a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private synchronized void poll() {
// 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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,9 @@ public HDPowerViewRepeaterHandler(Thing thing) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,13 @@ public void initialize() {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d35e96a

Please sign in to comment.