GithubHelp home page GithubHelp logo

yeelight-api's Introduction

YeeLight Java API

Overview

This library is a Java implementation of YeeLight's Third Party Protocol. In order to enable your lights to use this library, you must enable LAN Mode via the official app. This library was built on the specification published by YeeLight.

Usage

Building the API

        // All values in this example are the defaults
        YeeApiBuilder builder = new YeeApiBuilder();
                
        // When calling .build(), if this is true. api.discoverLights with a timeout of 1000ms
        // will be called automatically, set to false if you want to handle this yourself
        builder.autoDiscovery(true);
        
        // Finalises the build and starts the UDP discovery thread
        YeeApi api = builder.build();

Changing the colour of the lights

        YeeApi api = new YeeApiBuilder()
                .build();

        // getLights() returns an immutable collection of all lights currently known to the library..
        // The objects in this collection are a snapshot of the current state of the lights and will not be updated as
        // state changes.
        api.getLights().forEach(yeeLight -> {
            
            // To change the colour of the light you would use the setRgb method
            api.setRgb(id, red, green, blue, duration);
            
            // This would change the lights to red over 3 seconds
            api.setRgb(yeeLight.getId(), 255, 0, 0, YeeDuration.seconds(3));

            // This would change the lights to light blue/cyan instantly
            api.setRgb(yeeLight.getId(), 0, 255, 255, YeeDuration.instant());
        });

YeeApi contains almost all methods supported under the third party protocol. Scenes are not supported.

yeelight-api's People

Contributors

dependabot[bot] avatar moppletop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

venryx ideade

yeelight-api's Issues

Problem compiling the project

Screenshot 2023-03-11 at 21 09 00

Hello, nice project.

But I'm having several problems to compile the project. Example above. Seems to be associated to lombok annotation.

I think I'm missing a step. Could you help me ?

Thanks

Some problems with discover

JDK: BellSoft Liberica JDK 17.0.7 (build 17.0.7+7-LTS)
OS: Manjaro 23.0.1

Hi, I'm writing an application to control light bulbs from PC.
I encountered this problem: In com.moppletop.yeelight.api.discovery.DiscoveryUDPListener on line 105 there is a socket connection creation, and there is a method InetAddress.getLocalHost() which, according to your comment should return the address of the current device in the local network. In my case this method returns the address 127.0.1.1, so socket.receive() on line 80 does not get any information about the current available devices. Perhaps we should put the address passed to the constructor into the parameters (YeeConfiguration class)? In my case, passing null as the address works, but the method is private and the class is buried deep in the code, so I don't see any way to change this behavior

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.