Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Friese <af944580@googlemail.com>
  • Loading branch information
alexf2015 committed Nov 8, 2024
1 parent 21381d9 commit dfa6c09
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public class MyUplinkBindingConstants {
public static final String STATUS_NO_VALID_DATA = "@text/status.no.valid.data";
public static final String STATUS_NO_CONNECTION = "@text/status.no.connection";
public static final String STATUS_DEVICE_NOT_FOUND = "@text/status.device.not.found";
public static final String STATUS_CONFIG_ERROR_NO_CLIENT_ID = "@text/status.config.error.no.client.id";
public static final String STATUS_CONFIG_ERROR_NO_CLIENT_SECRET = "@text/status.config.error.no.client.secret";

// other
public static final long POLLING_INITIAL_DELAY = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,16 @@ public void initialize() {
logger.debug("myUplink Account initialized with configuration: {}", config.toString());

updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, STATUS_WAITING_FOR_LOGIN);
webInterface.start();
startPolling();

if (config.getClientId().isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, STATUS_CONFIG_ERROR_NO_CLIENT_ID);
} else if (config.getClientSecret().isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
STATUS_CONFIG_ERROR_NO_CLIENT_SECRET);
} else {
webInterface.start();
startPolling();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ public void enqueueCommand(MyUplinkCommand command) {
private @Nullable MyUplinkBridgeHandler getBridgeHandler() {
Bridge bridge = getBridge();
return bridge != null && bridge.getHandler() instanceof MyUplinkBridgeHandler handler ? handler : null;
}

@Override
public MyUplinkConfiguration getBridgeConfiguration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ thing-type.config.myuplink.account.group.authentication.label = Authentication
thing-type.config.myuplink.account.group.authentication.description = Authentication settings.
thing-type.config.myuplink.account.group.connection.label = Connection
thing-type.config.myuplink.account.group.connection.description = Connection settings.
thing-type.config.myuplink.account.group.customChannels.label = Custom Channels
thing-type.config.myuplink.account.group.customChannels.description = Custom Channel configuration
thing-type.config.myuplink.account.group.general.label = General
thing-type.config.myuplink.account.group.general.description = General settings.
thing-type.config.myuplink.generic-device.deviceId.label = Device Id
thing-type.config.myuplink.generic-device.deviceId.description = The Id to identify the device.
thing-type.config.myuplink.generic-device.systemId.label = System Id
Expand Down Expand Up @@ -63,3 +59,22 @@ channel-type.myuplink.type-percent.label = Generic Percentage
channel-type.myuplink.type-pressure.label = Generic Pressure
channel-type.myuplink.type-temperature.label = Generic Temperature
channel-type.myuplink.type-time.label = Generic Time

# thing types config

thing-type.config.myuplink.account.group.customChannels.label = Custom Channels
thing-type.config.myuplink.account.group.customChannels.description = Custom Channel configuration
thing-type.config.myuplink.account.group.general.label = General
thing-type.config.myuplink.account.group.general.description = General settings.


# status translations

status.token.validated = "Access token validated"
status.waiting.for.bridge = "Waiting for bridge to go online"
status.waiting.for.login = "Waiting for web api login"
status.no.valid.data = "No valid data received. This is most likely a configuration error"
status.no.connection = "No connection could be established"
status.device.not.found = "Device could not be found. Most likely a configuration error"
status.config.error.no.client.id = "No/Empty client id. Please fix the configuration."
status.config.error.no.client.secret = "No/Empty client secret. Please fix the configuration."

0 comments on commit dfa6c09

Please sign in to comment.