Skip to content

Commit

Permalink
Update documentation, now that a new version was released
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroOne3010 committed Feb 16, 2020
1 parent a5ae542 commit d846ad0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/),
and this project adheres to [Semantic Versioning](https://semver.org/).

Unreleased
v1.3.0 (2020-02-16)
----------

### Added
Expand Down
52 changes: 31 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,35 @@ import io.github.zeroone3010.yahueapi.discovery.*;

### Initializing the API with a connection to the Bridge

#### Bridge discovery

If you do not know the IP address of the Bridge, you can use the automatic Bridge discovery functionality.
The `discoverBridges` method of the `HueBridgeDiscoveryService` class accepts a `Consumer`
that is called whenever a new Bridge is found. You may either hook into that or you can supply a no-op consumer
and just use the `Future<List<HueBridge>>` that is returned. Please do note, however, that it may take
approximately five seconds for the discovery process to complete. The `HueBridge` objects hold an IP address
that may be then used to initiate a connection with the Bridge.

Without any parameters besides the consumer the `discoverBridges` method uses all available discovery
methods simultaneously, namely N-UPnP and UPnP. If you wish to change that, the method accepts a varargs
list of discovery method enum values.

[//]: # (throws-InterruptedException|java.util.concurrent.ExecutionException)
[//]: # (import java.util.List;)
[//]: # (import java.util.concurrent.Future;)
```java
Future<List<HueBridge>> bridgesFuture = new HueBridgeDiscoveryService()
.discoverBridges(bridge -> System.out.println("Bridge found: " + bridge));
final List<HueBridge> bridges = bridgesFuture.get();
if( !bridges.isEmpty() ) {
final String bridgeIp = bridges.get(0).getIp();
System.out.println("Bridge found at " + bridgeIp);
// Then follow the code snippets below under the "Once you have a Bridge IP address" header
}
```

#### Once you have a Bridge IP address

If you already have an API key for your Bridge:

[//]: # (init)
Expand All @@ -42,25 +71,6 @@ System.out.println("Store this API key for future use: " + key);
final Hue hue = new Hue(bridgeIp, key);
```

#### Bridge discovery (upcoming!)

If you do not know the IP address of the Bridge, in a future version of this library
you will be able to use an automatic Bridge discovery method, like this (subject to change):

[//]: # (throws-InterruptedException|java.util.concurrent.ExecutionException)
[//]: # (import java.util.List;)
[//]: # (import java.util.concurrent.Future;)
```java
Future<List<HueBridge>> bridgesFuture = new HueBridgeDiscoveryService()
.discoverBridges(bridge -> System.out.println("Bridge found: " + bridge));
final List<HueBridge> bridges = bridgesFuture.get();
if( !bridges.isEmpty() ) {
final String bridgeIp = bridges.get(0).getIp();
System.out.println("Bridge found at " + bridgeIp);
// Then follow the code snippets above
}
```

### Using the rooms, lights, and scenes

[//]: # (requires-init)
Expand All @@ -83,7 +93,7 @@ room.getLightByName("Corner").get().turnOff();
final Optional<Light> light = room.getLightByName("Ceiling 1");
light.ifPresent(l -> l.setState(State.builder().color(java.awt.Color.GREEN).keepCurrentState()));

// Activate a scene (upcoming!):
// Activate a scene:
room.getSceneByName("Tropical twilight").ifPresent(Scene::activate);
```

Expand All @@ -108,7 +118,7 @@ Add the following dependency to your pom.xml file:
<dependency>
<groupId>io.github.zeroone3010</groupId>
<artifactId>yetanotherhueapi</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
</dependency>
```

Expand Down

0 comments on commit d846ad0

Please sign in to comment.