Skip to content

Commit

Permalink
openhab#47 Fixed code analysis warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Oeing <[email protected]>
Signed-off-by: Gerd Zanker <[email protected]>
  • Loading branch information
coeing authored and GerdZanker committed Jan 7, 2021
1 parent 3c4e1bb commit ca62d36
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 23 deletions.
1 change: 1 addition & 0 deletions bundles/org.openhab.binding.boschshc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ A keystore file with a self signed certificate is created automatically. This ce
Bosch IDs for found devices are displayed in the openHAB log on bootup (`OPENHAB_FOLDER/userdata/logs/openhab.log`)

Example:

```
2020-08-11 12:42:49.490 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=Heizung id=hdm:HomeMaticIP:3014F711A000XXXXXXXXXXXX
2020-08-11 12:42:49.495 [INFO ] [chshc.internal.BoschSHCBridgeHandler] - Found device: name=-RoomClimateControl- id=roomClimateControl_hz_1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* A virtual device which controls up to six Bosch Smart Home radiator thermostats in a room.
*
* @author Christian Oeing ([email protected])
* @author Christian Oeing - Initial contribution
*/
@NonNullByDefault
public final class ClimateControlHandler extends BoschSHCHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.*;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.library.types.PercentType;
Expand All @@ -31,28 +30,27 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonSyntaxException;

/**
* Utility functions to convert data between Bosch things and openHAB items
*
* @author Christian Oeing - Initial contribution
*/
final class DataConversion {
public static int levelToOpenPercentage(double level) {
return (int) Math.round((1 - level) * 100);
}

public static double openPercentageToLevel(double openPercentage) {
return (100 - openPercentage) / 100.0;
}
}

/**
* Handler for a shutter control device
*
* @author Christian Oeing - Initial contribution
*/
@NonNullByDefault
public class ShutterControlHandler extends BoschSHCHandler {
/**
* Utility functions to convert data between Bosch things and openHAB items
*
* @author Christian Oeing - Initial contribution
*/
static final class DataConversion {
public static int levelToOpenPercentage(double level) {
return (int) Math.round((1 - level) * 100);
}

public static double openPercentageToLevel(double openPercentage) {
return (100 - openPercentage) / 100.0;
}
}

final String ShutterControlServiceName = "ShutterControl";

Expand Down Expand Up @@ -96,7 +94,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}

@Override
public void processUpdate(String id, @NonNull JsonElement state) {
public void processUpdate(String id, JsonElement state) {
try {
Gson gson = new Gson();
updateState(gson.fromJson(state, ShutterControlState.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

import com.google.gson.annotations.SerializedName;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* State for a shutter control device
*
* @author Christian Oeing - Initial contribution
*/
@NonNullByDefault
public class ShutterControlState {
@SerializedName("@type")
public String type = "shutterControlState";
Expand All @@ -35,9 +38,11 @@ public class ShutterControlState {

public ShutterControlState() {
this.level = 0.0;
this.operationState = OperationState.STOPPED;
}

public ShutterControlState(double level) {
this.level = level;
this.operationState = OperationState.STOPPED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

import com.google.gson.annotations.SerializedName;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* Base Bosch Smart Home Controller service state.
*
* @author Christian Oeing - Initial contribution
*/
@NonNullByDefault
public class BoschSHCServiceState {
@SerializedName("@type")
private final String type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@
*/
package org.openhab.binding.boschshc.internal.services;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* Generic error response of the Bosch REST API.
*
* @author Christian Oeing ([email protected])
* @author Christian Oeing - Initial contribution
*/
@NonNullByDefault
public class JsonRestExceptionResponse extends BoschSHCServiceState {
public JsonRestExceptionResponse() {
super("JsonRestExceptionResponseEntity");
this.errorCode = "";
this.statusCode = 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
*/
package org.openhab.binding.boschshc.internal.services.roomclimatecontrol;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.boschshc.internal.services.BoschSHCService;

/**
* Service of a virtual device which controls the radiator thermostats in a room.
*
* @author Christian Oeing ([email protected])
* @author Christian Oeing - Initial contribution
*/
@NonNullByDefault
public class RoomClimateControlService extends BoschSHCService<@NonNull RoomClimateControlServiceState> {
public class RoomClimateControlService extends BoschSHCService<RoomClimateControlServiceState> {
/**
* Constructor.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* State for {@link RoomClimateControlService} to get and set the desired temperature of a room.
*
* @author Christian Oeing ([email protected])
* @author Christian Oeing - Initial contribution
*/
@NonNullByDefault
public class RoomClimateControlServiceState extends BoschSHCServiceState {
Expand Down

0 comments on commit ca62d36

Please sign in to comment.