Skip to content

gilbertotcc/lifx-client

Repository files navigation

LIFX Client

Java client to consume LIFX HTTP API.

Coverage Status Download

Usage

Library artifactory is published on Bintray. In order to use it, add the lifx Bintray repository to your build .settings Gradle file and include the lifx-client dependency as shown below.

repositories {
  maven {
    url  "https://dl.bintray.com/gilbertotcc/lifx"
  }
}

dependencies {
  compile 'com.github.gilbertotcc.lifx:lifx-client:<VERSION>'
}

Sample application

Following code provides a brief example that show how LIFX Client can be used to turn on all the lights in red color.

To generate the access token, visit LIFX Cloud Settings page.

import static com.github.gilbertotcc.lifx.models.Selectors.All;

import com.github.gilbertotcc.lifx.models.Power;
import com.github.gilbertotcc.lifx.models.State;

public class RedLightOnSwitcher {

  public static void main(String[] args) {

    LifxClient client = LifxClient.newLifxClientFor("<YOUR_ACCESS_TOKEN>");

    var state = State.builder()
      .power(Power.ON)
      .color("red")
      .brightness(1.0)
      .build();
    var input = new LightsStateInput(all(), state);

    client.setLightsState(input);
  }
}

In src/test directory can be found more examples that show how LIFX client can be used for the more advanced operations that LIFX HTTP API provides.

About

Java client to consume LIFX HTTP API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published