Giter Site home page Giter Site logo

joplin's Introduction

Joplin

A Java client for the Philips Hue Entertainment API, named after Scott Joplin, composer of The Entertainer.

Using

Supported Java versions

Java 11+ is required to use the client.

Installation

The client is available on Maven Central and can be pulled in as a dependency by adding the usual block to your Maven POM:

<dependencies>
    <dependency>
        <groupId>io.github.c0urante</groupId>
        <artifactId>joplin</artifactId>
        <version>${joplin.version}</version>
    </dependency>
</dependencies>

Or to your Gradle build file:

dependencies {
    "io.github.c0urante:joplin:$joplinVersion"
}

Bridge Setup

Follow the steps in the Hue Entertainment API getting started guide to find the IP address for your bridge, set up credentials, and create an entertainment area.

Once you've done all that, proceed to the next section to see how to put it all to use.

Creating and initializing a client

import io.github.c0urante.joplin.HueEntertainmentClient;

public class Demo {

  public HueEntertainmentClient createClient() throws IOException, InterruptedException {
    // Instantiate the client
    HueEntertainmentClient client = HueEntertainmentClient.builder()
        .host("192.168.1.1")
        .username("9HihcZzDENE6OAtYHllimwehffPVSA6sucfawIki ")
        .clientKey("D88D89ABBE97E97465D8735A8986BD32")
        .entertainmentArea("acvvdn41-e5tz-s737-oq7s-8snimm9ttk8n")
        .build();

    // Use the bridge REST API to turn on streaming
    // This method must be called before light colors can be set
    client.initializeStream();

    return client;
  }
}

Setting light colors

import io.github.c0urante.joplin.HueEntertainmentClient;
import io.github.c0urante.joplin.Light;

import java.awt.Color;
import java.io.IOException;

public class Demo {

  public void setLights() throws IOException, InterruptedException {
    HueEntertainmentClient client = createClient();
    HueColor color1 = new Rgb(Color.GREEN);
    HueColor color2 = new Rgb(Color.RED);

    // Merry Christmas!
    client.sendColors(color1, color2);

    // Alternatively, if you just want to set N lights to a single fixed color
    HueColor color3 = new Rgb(Color.BLUE);
    client.sendColors(8, color3);

    // Or, if you want to set specific lights to specific colors
    Light light1 = new Light(0, color1);
    Light light3 = new Light(2, color2);
    Light light5 = new Light(4, color3);
    client.sendLights(light1, light3, light5);

    // Don't forget to clean up once you're finished
    client.close();
  }
}

Building

# Build the library, skip tests, and install to your local Maven repository
mvn clean install -DskipTests

Testing

All tests are currently integration tests. In order to run tests, you need a working bridge with at least two lights, and all of the information outlined in Bridge Setup.

Once you have all that, populate the lights.properties file with the IP address, credentials, etc. for your setup:

bridge.host = 192.168.1.1
# Should always be 2100 but just in case Philips allows the port to change in the future
# bridge.port =
username = 9HihcZzDENE6OAtYHllimwehffPVSA6sucfawIki
client.key = D88D89ABBE97E97465D8735A8986BD32
entertainment.area.id = acvvdn41-e5tz-s737-oq7s-8snimm9ttk8n

If you'd like to ensure that no changes to this file are ever committed, you can instruct git to ignore it:

git update-index --skip-worktree src/test/resources/lights.properties

And finally, you can run tests with:

mvn test

Contributing

PRs and GitHub issues welcome!

joplin's People

Contributors

bowbahdoe avatar c0urante avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bowbahdoe

joplin's Issues

Tests broken with Java 11

With #2, tests are failing in some environments that use Java 11 because of a cipher suite mismatch when trying to contact the bridge's REST API. This does not appear to be indicative of a bug in the project and is only a minor nuisance, but would be nice to address at some point since we do aim to support Java 11+.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.