https://github.com/przybandrzej/yeelight-java-sdk
SDK for Java apps to search and communicate with Yeelight devices within local network.
https://github.com/przybandrzej/yeelight-java-sdk
iot java library sdk smart-home smartbulb yeelight
Last synced: 6 months ago
JSON representation
SDK for Java apps to search and communicate with Yeelight devices within local network.
- Host: GitHub
- URL: https://github.com/przybandrzej/yeelight-java-sdk
- Owner: przybandrzej
- License: apache-2.0
- Created: 2021-09-21T15:46:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-24T10:43:57.000Z (almost 5 years ago)
- Last Synced: 2023-07-04T09:26:39.989Z (almost 3 years ago)
- Topics: iot, java, library, sdk, smart-home, smartbulb, yeelight
- Language: Java
- Homepage:
- Size: 104 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Yeelight Java SDK
SDK for Java apps to communicate with Yeelight devices.
## Installing
### Gradle
`implementation 'io.github.przybandrzej:yeelight-java-sdk:0.1.2'`
### Maven
```xml
io.github.przybandrzej
yeelight-java-sdk
0.1.2
```
## Usage
### Search for devices
```java
Discover discover = new Discover("192.168.2.109", 12345);
discover.sendSearch();
boolean searching = true;
while(searching) {
try {
Device device = discover.receiveSearchPacket(5000);
} catch(SearchTimeoutException e) {
searching = false;
}
}
```
The first parameter of the constructor is your machine's IP in local network, the second is a port of your choice - make sure it's not used by other services.
Then you can send a search packet and receive search response. The response will be from only one device. If you want to search all devices within your network, make sure to call the method until the timeout.
### Control a device
```java
DeviceControl ctrl = new DeviceControl(device);
ctrl.onDeviceStateChange(() -> {
System.out.println("Callback for when a device has received an update.");
});
ctrl.setPower(true, false);
ctrl.setColorTemperature(1800, false);
ctrl.adjustBrightness(-50, false);
ctrl.close();
```
## Author
**Andrzej Przybysz**
**Email:** andrzej.przybysz01@gmail.com
**Github:** [przybandrzej](https://github.com/przybandrzej)
**LinkedIn:** [Andrzej Przybysz](https://www.linkedin.com/in/andrzej-przybysz/)