Skip to content

Commit

Permalink
[lgwebos] Console command to show the access key (openhab#7801)
Browse files Browse the repository at this point in the history
* [lgwebos] Console command to show the access key

Access key no more logged
* Fix in README

Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: CSchlipp <[email protected]>
  • Loading branch information
lolodomo authored and CSchlipp committed Jul 26, 2020
1 parent 47009ea commit 1b1dcb0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion bundles/org.openhab.binding.lgwebos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,19 @@ A sample HABPanel remote control widget can be found [in this github repository.

## Console Commands

The binding provides two specific commands you can use in the console.
The binding provides a few commands you can use in the console.
Enter the command `lgwebos` to get the usage.

```
openhab> lgwebos
Usage: smarthome:lgwebos <thingUID> applications - list applications
Usage: smarthome:lgwebos <thingUID> channels - list channels
Usage: smarthome:lgwebos <thingUID> accesskey - show the access key
```

The command `applications` reports in the console the list of all applications with their id and name.
The command `channels` reports in the console the list of all channels with their id, number and name.
The command `accesskey` reports in the console the access key used to connect to your TV.

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class LGWebOSCommandExtension extends AbstractConsoleCommandExtension {

private static final String APPLICATIONS = "applications";
private static final String CHANNELS = "channels";
private static final String ACCESS_KEY = "accesskey";

private final ThingRegistry thingRegistry;

Expand Down Expand Up @@ -72,6 +73,9 @@ public void execute(String[] args, Console console) {
case CHANNELS:
handler.reportChannels().forEach(console::println);
break;
case ACCESS_KEY:
console.println("Your access key is " + handler.getKey());
break;
default:
printUsage(console);
break;
Expand All @@ -85,6 +89,7 @@ public void execute(String[] args, Console console) {
@Override
public List<String> getUsages() {
return Arrays.asList(new String[] { buildCommandUsage("<thingUID> " + APPLICATIONS, "list applications"),
buildCommandUsage("<thingUID> " + CHANNELS, "list channels") });
buildCommandUsage("<thingUID> " + CHANNELS, "list channels"),
buildCommandUsage("<thingUID> " + ACCESS_KEY, "show the access key") });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public String getKey() {
@Override
public void storeKey(@Nullable String key) {
if (!getKey().equals(key)) {
logger.info("Store {} as access Key in the thing configuration", key);
logger.debug("Store new access Key in the thing configuration");
// store it current configuration and avoiding complete re-initialization via handleConfigurationUpdate
getLGWebOSConfig().key = key;

Expand Down

0 comments on commit 1b1dcb0

Please sign in to comment.