Skip to content

Commit

Permalink
GitHub #46 - Updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sqmk committed Mar 30, 2013
1 parent 8169c74 commit 12a9a9e
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions README.md
Expand Up @@ -74,7 +74,7 @@ try {

All commands can be issued in a similar manner as the previous two examples.

Once you have determined you can make requests to the bridge, you can test if the username you provided is authenticated.
Once you have determined you can make requests to the bridge, you can test if the username you provided is available.

```php
$isAuthenticated = $client->sendCommand(
Expand All @@ -86,22 +86,22 @@ echo $isAuthenticated
: 'You are not authenticated!';
```

If the username provided is not authenticated, you can use the convenience script to authenticate, which is documented later in this README. Or, you can use the Authenticate command to do it yourself.
If the username provided is not created, you can use the convenience script to authenticate, which is documented later in this README. Or, you can use the CreateUser command to do it yourself.

```php
// Push the bridge's link button prior to running this
try {
$client->sendCommand(
new \Phue\Command\Authenticate
new \Phue\Command\CreateUser($client->getUsername())
);

echo "{$client->getUsername()} is now authenticated";
echo "You are now authenticated";
} catch (\Phue\Transport\Exception\LinkButtonException $e) {
echo 'The link button was not pressed!';
}
```

After the user is authenticated, you won't have to authenticate again unless you reset the bridge!
After the user is created, you won't have to create it again unless you reset the bridge!

### Managing lights

Expand Down Expand Up @@ -463,56 +463,47 @@ The internal IP address(es) listed in the results is what you need for the Phue

If the script provided doesn't find your bridge, or if you don't have internet connection on your network, I have created a wiki page that describes a few other convenient ways of finding it: [Finding Philips Hue bridge on network](/sqmk/Phue/wiki/Finding-Philips-Hue-bridge-on-network).

### Authentication
### Authentication / Creating a User

To test connectivity and authenticate with the bridge, you can use ```bin/phue-authenticate```. The script uses the Phue library to make requests and receive responses from the Philips Hue bridge.
To test connectivity and authenticate with the bridge, you can use ```bin/phue-create-user```. The script uses the Phue library to make requests and receive responses from the Philips Hue bridge.

At this point, you should be ready to authenticate with the bridge. The bridge expects a 32 character hash as a username to authenticate with, but you can feed in any string into the client and it will automatically hash for you. This is much easier to remember than the hash!
At this point, you should be ready to authenticate with the bridge. The bridge expects a username between 10 and 40 characters with alphanumeric characters to authenticate with.

Here's how to run the script for authenticating:
Here's how to run the script for authenticating/creating a user:

```
$ ./bin/phue-authenticate 10.0.1.31 your.username
$ ./bin/phue-create-user 10.0.1.31 your.username
```

If the connection is ok, you will get a response similar to this:

```
! - Username your.username doesn't appear to be 32 character hash (A-F, 0-9)
! - Using this for username instead: af8caecf12655838d10fa92d86d09e82
Testing connection to bridge at 10.0.1.31
Response appears OK!
Attempting to authenticate (af8caecf12655838d10fa92d86d09e82):
Attempting to create user:
Press the Bridge's button!
Waiting.....
Waiting.........
```

The ```phue-authenticate``` script will attempt to authenticate with the bridge once every second. The bridge's connection button (the big round lit up one) needs to be pressed while the script runs. If the button is pressed during execution of the script, you should get a response like this:
The ```phue-create-user``` script will attempt to create a user on the bridge once every second. The bridge's connection button (the big round lit up one) needs to be pressed while the script runs. If the button is pressed during execution of the script, you should get a response like this:

```
! - Username your.username doesn't appear to be 32 character hash (A-F, 0-9)
! - Using this for username instead: af8caecf12655838d10fa92d86d09e82
Testing connection to bridge at 10.0.1.31
Response appears OK!
Attempting to authenticate (af8caecf12655838d10fa92d86d09e82):
Attempting to create user:
Press the Bridge's button!
Waiting......
Authentication for user your.username was successful!
Waiting..........
Successfully created new user: whateverok
```

From then on, you should be able to use the final username for interacting with the Philips Hue bridge!
From then on, you should be able to use the username you just created for interacting with the Philips Hue bridge!

### Scanning / registering new lights

Now that you have tested connection and authentication to the bridge, you can now register your lights using the Phue client.

Another convenience script has been created to demonstrate how to use Phue to get the bridge to start scanning for and retrieving new lights. This script is ```phue-light-finder```, and it is also located in the ```bin``` directory.

You can pass the same arguments for ```phue-light-finder``` as you did with ```phue-authenticate```. Here's how to use the script:
You can pass the same arguments for ```phue-light-finder``` as you did with ```phue-create-user```. Here's how to use the script:

```
$ ./bin/phue-light-finder 10.0.1.31 your.username
Expand Down

0 comments on commit 12a9a9e

Please sign in to comment.