All Projects → stoman → MilightAPI

stoman / MilightAPI

Licence: MIT license
A java API for MiLight light bulbs. Other brands of light bulbs are also compatible, for instance EasyBulb, LimitlessLED, etc.

Programming Languages

java
68154 projects - #9 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to MilightAPI

python-limitlessled
No description or website provided.
Stars: ✭ 32 (+14.29%)
Mutual labels:  milight, limitlessled
j4ts
Core Java APIs for TypeScript / JavaScript / JSweet
Stars: ✭ 92 (+228.57%)
Mutual labels:  java-api
tiff-java
Tagged Image File Format Java Library
Stars: ✭ 65 (+132.14%)
Mutual labels:  java-api
Useful Java Links
A list of useful Java frameworks, libraries, software and hello worlds examples
Stars: ✭ 5,126 (+18207.14%)
Mutual labels:  java-api
Simple-YAML
A Java API that provides an easy-to-use way to store data using the YAML format.
Stars: ✭ 68 (+142.86%)
Mutual labels:  java-api
testlink-java-api
TestLink Java API
Stars: ✭ 62 (+121.43%)
Mutual labels:  java-api
radiobrowser4j
RadioBrowser Java API library
Stars: ✭ 30 (+7.14%)
Mutual labels:  java-api
travels-java-api
An API for travel management. It is built with Java, Spring Boot, and Spring Framework. A toy-project to serve as a theoretical basis for the Medium series of articles I wrote about Java+Spring.
Stars: ✭ 139 (+396.43%)
Mutual labels:  java-api
active-persistence
Active Persistence is a implementation of Active Record Query Interface for JPA that makes it easy and fun.
Stars: ✭ 14 (-50%)
Mutual labels:  java-api
wbp4j
Simple Java Api for 微博图床,使用简单的api即可完成上传图片
Stars: ✭ 48 (+71.43%)
Mutual labels:  java-api
compare-utils
Compares of Java Collections and Objects (of different classes) made easy
Stars: ✭ 15 (-46.43%)
Mutual labels:  java-api
japi
Used to generate a beautiful API Java document
Stars: ✭ 103 (+267.86%)
Mutual labels:  java-api
JavaTelegramBot-API
Java Telegram Bot API
Stars: ✭ 34 (+21.43%)
Mutual labels:  java-api
google-search-results-java
Google Search Results JAVA API via SerpApi
Stars: ✭ 18 (-35.71%)
Mutual labels:  java-api
backblaze-b2-java-api
Java API for the fabulous backblaze B2 API
Stars: ✭ 13 (-53.57%)
Mutual labels:  java-api
yahoo-weather-java-api
A Java API for the yahoo weather service
Stars: ✭ 26 (-7.14%)
Mutual labels:  java-api
python-ledcontroller
Controller library for limitlessled/easybulb/milight Wi-Fi LEDs
Stars: ✭ 35 (+25%)
Mutual labels:  milight

MiLight API

This is an API for MiLight light bulbs written in Java. Other brands of light bulbs are also compatible, for instance EasyBulb, LimitlessLED, etc. With this API it is easy to switch lights on and off, change color and brightness and other settings. Additionally, tools like an ambient light effect, fading animations and music visualizations are included. Only a WiFi box and some light bulbs are needed to run this API.

Pull requests as well as notifications about usages of this API are always appreciated. Documentation of all classes is available at GitHub Pages.

Basic Usage

Connect your WiFi box to the lights as described in the manual. Find the local IP address of your box in the local network. This information can be found at the interface of your router, for instance. Now you can run the API on a machine connected to the same network.

To connect to your WiFi box create a WiFiBox object in your Java application:

String ip = "192.168.1.42"; //add your custom IP here
WiFiBox box = new WiFiBox(ip);

Additional constructors with custom ports or other types of addresses are also available. Individual groups of lights can be created like this:

Lights groupA = box.getLights(1);
Lights groupB = new Lights(ip, 2);

All commands available on a remote control or an app connected to this box are now available, for example:

//switch all lights on
box.on();
//switch group 4 of
box.off(4);
//switch group 2 to disco mode
box.discoMode(2);
//make the disco mode faster
box.discoModeFaster(2);
//switch the color of group 3 to blue
box.color(3, new MilightColor(Color.BLUE));
//dim group 1
box.brightness(1, MilightColor.MIN_BRIGHTNESS);

Many more commands are available, check the docs to read more. To display colors the lights change their brightness and hue as well switch between white and color mode to resemble the chosen color as close as possible.

Ambient Light and Music Visualizer

Lights can be used to create an ambient light effect. This means the lights will resemble the colors of the screen of your PC. Use this to lighten your room fitting to a movie you are watching or similar. AmbientLight can be used like this:

AmbientLight ambient = new AmbientLight(groupA);//or some other Lights object
ambient.start();

The effect can be stopped with

ambient.stop();

More configuration is available and described in the documentation.

Similarly, a visualization of the music played on your machine can be created. The source to read the music from needs to be available as a TargetDataLine. The function MusicVisualizer.getDefaultLine() is available to find the most common data lines. The visualizer can be started like this using the default line:

MusicVisualizer vis = new MusicVisualizer(groupB);
vis.start();

The effect can be stopped with

vis.stop();

Timer

There is a timer available to fade from one color or brightness to another or switch the lights off after a certain amount of time. Timers can be used like this:

Timer timer = new Timer(
	groupA, //the lights to control,
	10000, //animation time in milliseconds
	new MilightColor(Color.BLUE), //start color or brightness
	new MilightColor(Color.BLACK), //target color or brightness
	true //switch the lights off after the animation	
);
timer.start();

Watching Events

All commands sent out by the API are available as events to make it possible to react to commands sent out. Add a LightListener like this:

groupA.addLightListener(new LightListener() {
	public void lightsChanged(LightEvent e) {
		//work with the event
	}
});

The following events are available:

Similarly, there is a TimerListener available to catch the event that the timer has finished its animation.

There is no way to read the current state of a light from the WiFi box. However, we can track all commands sent by the API to compute the current state. To automatically track the state of a light use the LightState class. Note, that changes made by another remote control or app are not noticed by this class.

Author

This library is written by Stefan Toman and available under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].