Apply suggestions from code review

Co-authored-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: David Pace <dev@davidpace.de>
This commit is contained in:
David Pace 2025-01-06 21:01:16 +01:00 committed by GitHub
parent 1b8696ef34
commit 9aa64a2972
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -89,7 +89,7 @@ public abstract class BoschSHCDeviceHandler extends BoschSHCHandler {
protected boolean processDeviceInfo(Device deviceInfo) { protected boolean processDeviceInfo(Device deviceInfo) {
try { try {
updateLocationPropertiesIfApplicable(deviceInfo); updateLocationPropertiesIfApplicable(deviceInfo);
} catch (Exception e) { } catch (BoschSHCException e) {
logger.warn("Error while updating location properties for thing {}.", getThing().getUID(), e); logger.warn("Error while updating location properties for thing {}.", getThing().getUID(), e);
} }
// do not cancel thing initialization if location properties cannot be updated // do not cancel thing initialization if location properties cannot be updated
@ -104,12 +104,10 @@ public abstract class BoschSHCDeviceHandler extends BoschSHCHandler {
private void updateLocationPropertyIfApplicable(Map<String, String> thingProperties, Device deviceInfo) private void updateLocationPropertyIfApplicable(Map<String, String> thingProperties, Device deviceInfo)
throws BoschSHCException { throws BoschSHCException {
@Nullable
String roomName = getBridgeHandler().resolveRoomId(deviceInfo.roomId); String roomName = getBridgeHandler().resolveRoomId(deviceInfo.roomId);
if (roomName != null) { if (roomName != null) {
@Nullable
String currentLocation = thingProperties.get(PROPERTY_LOCATION); String currentLocation = thingProperties.get(PROPERTY_LOCATION);
if (currentLocation == null || !currentLocation.equals(roomName)) { if (!roomName.equals(currentLocation)) {
logger.debug("Updating property '{}' of thing {} to '{}'.", PROPERTY_LOCATION, getThing().getUID(), logger.debug("Updating property '{}' of thing {} to '{}'.", PROPERTY_LOCATION, getThing().getUID(),
roomName); roomName);
updateProperty(PROPERTY_LOCATION, roomName); updateProperty(PROPERTY_LOCATION, roomName);