Skip to content

loefberg/lifx-sdk-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The lifx firmware update 2.0 seems to break a few things, we are waiting for the LIFX team to update LIFXKit. In the meantime please try the old 1.0.1 release if you are having problems.

lifx-sdk-java aims to be a feature complete implementation of the LIFX protocol for Java. It supports turning lights on/off, colors, labels, groups and alarms (persisted in the bulb).

If you run into a bug please don't hesitate to create an issue, so that we can try and make this library as stable as possible!

Examples

Print all lights:

LFXClient client = new LFXClient();        
client.open(true);
try {
    for(LFXLight light: client.getLights()) {
        System.out.format("Light: %n");
        System.out.format("\tid=%s%n", light.getID());
        System.out.format("\tlabel=%s%n", light.getLabel());
        System.out.format("\tpower=%s%n", light.isPower());
        System.out.format("\ttime=%s%n", light.getTime());
        System.out.format("\tcolor=%s%n", light.getColor());                
    }
} finally {
    client.close();
}

Setting an alarm on a light. The alarm is saved in the light and does not require the program to be running for the alarm to go off. In the current firmware only two alarms per light is allowed:

LFXClient client = new LFXClient();
client.open(true);
try {            
    LFXLight light = client.getLights().getLightByLabel("my light");
    Date time = new Date(System.currentTimeMillis() + 30 * 1000);
    LFXAlarmCollection alarms = light.getAlarms();                        
    alarms.set(0, new LFXAlarm(time, new LFXHSBKColor(Color.BLUE), 7 * 1000));
} finally {
    client.close();
}

For more examples see the example package.

Documentation

Maven

Version 2.0

Javadoc for 2.0

<dependency>
  <groupId>com.github.besherman</groupId>
  <artifactId>lifx-sdk-java</artifactId>
  <version>2.0</version>
</dependency>

Version 1.0

For the old lifx-sdk-android compatible release see the release-1.0 branch

<dependency>
  <groupId>com.github.besherman</groupId>
  <artifactId>lifx-sdk-java</artifactId>
  <version>1.0.1</version>
</dependency>

History

Version 1.0 of lifx-sdk-java was a simple port of lifx-sdk-android and tried to keep as close to the original as possible. But as time has passed lifx-sdk-android has not seen much activity or updates and an official Java implementation does not seem likely. So the upcoming version 2.0 of lifx-sdk-java has been largely rewritten for a simpler codebase and many new features has been implemented. The old version 1.0 branch is still avaliable.

About

A port of "LIFX Android SDK" to Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages