mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
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:
parent
1b8696ef34
commit
9aa64a2972
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user