studioimaginaire / phue

A Python library for the Philips Hue system
Other
1.52k stars 267 forks source link

Added the ability to use the remote API #133

Closed CerebralXor closed 4 years ago

CerebralXor commented 6 years ago

This pull request adds the ability to use the Hue API remotely. I've kept in mind some of the goals of this project (single file, 2 and 3 compatibility and no module dependencies). The README is updated to include documentation on the remote API.

A user will be required to provide their own credentials from the Philips Hue developer's portal.

Some small changes were required to the existing Bridge class to enable a new RemoteBridge to subclass it. The main change was changing the base of the API URL from a string literal /api/ to an instance variable, since the URL base is /bridge/ for the remote API. The other was the ability to add authentication headers to the request() method.

Another change was required to facilitate simple authorisation and token generation from a terminal.

The rest of the new code is creating a Token class to handle the authentication tokens, and a RemoteBridge subclass of the Bridge class.